-
Notifications
You must be signed in to change notification settings - Fork 0
239 lines (203 loc) · 7.64 KB
/
profile_default_cbds_newuoa_big.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
name: Profile default cbds and newuoa using optiprofiler, big
on:
# Trigger the workflow on # push or pull request
# push:
# Trigger the workflow manually
# schedule:
# - cron: '0 0 */3 * *'
workflow_dispatch:
jobs:
test:
name: Profile default cbds and newuoa using optiprofiler, big
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
matlab: [latest]
dim: [big]
with_optim_toolbox: [yes]
solver: [cbds-original]
competitor: [newuoa]
run_plain: [false]
feature: [plain, perturbed_x0, perturbed_x0_1, perturbed_x0_10, noisy_1e-1, noisy_1e-2, noisy_1e-3, noisy_1e-4, truncated_1, truncated_2, truncated_3, truncated_4, permuted, linearly_transformed, random_nan_5, random_nan_10, random_nan_20, quantized, rotation_noisy_1e-1, rotation_noisy_1e-2, rotation_noisy_1e-3, rotation_noisy_1e-4]
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Checkout OptiProfiler
uses: actions/checkout@v4
with:
repository: optiprofiler/optiprofiler
ref: matlab
path: optiprofiler
- name: Checkout BDS
uses: actions/checkout@v4
with:
repository: blockwise-direct-search/bds
ref: main
path: bds
- name: Install Texlive
run: sudo apt-get update && sudo apt-get install texlive
- name: Check whether LaTeX is installed
run: pdflatex --version
- name: Cache MATLAB
id: cache-matlab
uses: actions/cache@v4.0.1
with:
path: ${{ runner.tool_cache }}/MATLAB
key: ${{ matrix.os }}-${{ matrix.matlab }}-${{ matrix.with_optim_toolbox }}
- name: Set up MATLAB with optimization toolbox
if: ${{ matrix.with_optim_toolbox == 'yes' }}
uses: matlab-actions/setup-matlab@v2.1.2
with:
release: ${{ matrix.matlab }}
products: Optimization_Toolbox
- name: Run test
uses: matlab-actions/run-command@v2.1.1
with:
command: |
root_dir = pwd()
ls
% Setup optiprofiler
cd(fullfile(root_dir, 'optiprofiler'));
setup
cd(root_dir);
% Setup bds
cd(fullfile(root_dir, 'bds'));
setup
cd(fullfile(root_dir, 'bds', 'tests', 'competitors'));
addpath(pwd);
% profile
cd(fullfile(root_dir, 'bds', 'tests'));
options = struct();
options.feature_name = '${{ matrix.feature }}';
options.solver_names = {'${{ matrix.solver }}', '${{ matrix.competitor }}'};
options.dim = '${{ matrix.dim }}';
options.run_plain = ${{ matrix.run_plain }};
profile_optiprofiler(options);
cd(root_dir);
cd(fullfile(root_dir, 'bds', 'tests', 'out'));
ls -R
cd(root_dir);
- name: Change the summary file name
run: |
cd ./bds/tests/out
ls -R
find . -type f -name 'summary*.pdf' | while read -r file; do
# Obtain the parent directory and name
parent_dir=$(dirname "$file")
parent_name=$(basename "$parent_dir")
# Obtain the new name(Why the fifth underline? Because the last five parts are the time stamp)
new_name=$(echo "$parent_name" | awk -F'_' '{if(NF>=5) {for(i=1;i<=NF-5;i++) printf "%s%s", $i, (i<NF-5?"_":"")} else print $0}')
# Print the new name
echo "New name: $new_name"
# Obtain the directory name
dir_name=$(dirname "$file")
# Rename the file
mv "$file" "$dir_name/summary_$new_name.pdf"
echo "Renamed $file to $dir_name/summary_$new_name.pdf"
done
- name: Upload artifact
uses: actions/upload-artifact@v3.1.2
with:
name: profile_optiprofiler_${{ matrix.solver }}_${{ matrix.competitor }}_${{ matrix.dim }}_${{ matrix.feature }}_${{ matrix.run_plain }}
path: ./bds/tests/out/**
merge_artifacts:
name: Merge Artifacts
runs-on: ubuntu-latest
needs: test
permissions:
actions: read
contents: read
steps:
- name: Install PDF tools
run: sudo apt-get update && sudo apt-get install -y poppler-utils
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: downloaded_artifacts
- name: List downloaded files
run: |
echo "Downloaded files:"
ls -R downloaded_artifacts/
- name: Merge PDF files
run: |
cd downloaded_artifacts
ls -R
mkdir summary
find . -type f -name 'summary*.pdf' -exec cp {} summary/ \;
cd summary
# Define keywords to search for PDF files
keywords=(
"plain"
"noisy_1_no_rotation"
"noisy_2_no_rotation"
"noisy_3_no_rotation"
"noisy_4_no_rotation"
"rotation_noisy_1"
"rotation_noisy_2"
"rotation_noisy_3"
"rotation_noisy_4"
"permuted"
"linearly_transformed"
"quantized"
"perturbed_x0"
"random_nan_5"
"random_nan_10"
"random_nan_20"
"truncated_1"
"truncated_2"
"truncated_3"
"truncated_4"
)
output_file="merged.pdf"
declare -a pdf_files # Use an array to store PDF files
# Obtain all PDF files starting with 'summary'
all_pdf_files=(summary*.pdf)
# Print the array content for debugging
echo "Found these PDF files:"
for file in "${all_pdf_files[@]}"; do
echo " $file"
done
# Create an associative array to store keyword to file mapping
declare -A keyword_to_file
# Search for PDF files with keywords
for keyword in "${keywords[@]}"; do
echo "Searching for keyword: $keyword"
for file in "${all_pdf_files[@]}"; do
if [[ $file == *"$keyword"* ]]; then
echo " Found file for keyword '$keyword': $file"
keyword_to_file[$keyword]=$file
break # Every keyword should have only one file
fi
done
done
# Clear array to store PDF files in order of keywords
pdf_files=()
# Add PDF files to the array in order of keywords
for keyword in "${keywords[@]}"; do
if [[ -n "${keyword_to_file[$keyword]}" ]]; then
pdf_files+=("${keyword_to_file[$keyword]}")
fi
done
# Print the array content for debugging
echo -e "\nFiles in order of keywords:"
printf '%s\n' "${pdf_files[@]}"
# Print total number of files found
echo -e "\nTotal files found: ${#pdf_files[@]}"
# Merge PDF files
if [[ ${#pdf_files[@]} -gt 0 ]]; then
pdfunite "${pdf_files[@]}" "$output_file"
echo "Merge successfully: $output_file"
else
echo "There are no PDF files to merge."
echo -e "\nAll PDF files in current directory:"
ls summary*.pdf
fi
- name: Upload merged artifact
uses: actions/upload-artifact@v3
with:
name: merged_profiles
path: downloaded_artifacts