Skip to content

Profile cbds and newuoa using optiprofiler, big #1

Profile cbds and newuoa using optiprofiler, big

Profile cbds and newuoa using optiprofiler, big #1

name: Profile 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 CBDS and NEWUOA, big
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
matlab: [latest]
dim: [big]
with_optim_toolbox: [yes]
solver: [cbds]
competitor: [newuoa]
run_plain: [false]
summarize_log_ratio_profiles: [false]
feature: [plain, perturbed_x0_0.001, perturbed_x0_1, perturbed_x0_10, perturbed_x0_100, 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_1, quantized_2, quantized_3, quantized_4, 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: 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
setup
cd(fullfile(root_dir, 'tests', 'competitors'));
addpath(pwd);
% profile
cd(fullfile(root_dir, '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 }};
options.summarize_log_ratio_profiles = ${{ matrix.summarize_log_ratio_profiles }};
profile_optiprofiler(options);
cd(root_dir);
cd(fullfile(root_dir, 'tests', 'out'));
ls -R
cd(root_dir);
- name: Change the summary file name
run: |
cd ./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")
# Establish the new file name
new_file="$dir_name/summary_$new_name.pdf"
# Check if the source and destination are the same
if [ "$file" != "$new_file" ]; then
mv "$file" "$new_file"
echo "Renamed $file to $new_file"
else
echo "Source and destination are the same, skipping: $file"
fi
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: ./tests/out/**
merge_artifacts:
name: Merge Artifacts
runs-on: ubuntu-latest
needs: test
permissions:
actions: read
contents: read
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: recursive
- 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: tests/testdata/downloaded_artifacts
- name: List all files
run: |
cd tests/testdata/downloaded_artifacts
ls -R
- name: Merge PDF files
run: |
cp tests/tools/merge_pdf.sh tests/testdata/downloaded_artifacts
cd tests/testdata/downloaded_artifacts/
ARTIFACT_NAME=$(ls | grep "profile_optiprofiler" | head -n 1)
BASE_INFO=$(echo $ARTIFACT_NAME | sed -n 's/.*optiprofiler_\([^_]*_[^_]*_\(small\|big\)\).*/\1/p')
echo "Base info extracted: ${BASE_INFO}"
echo "BASE_INFO=${BASE_INFO}" >> $GITHUB_ENV
# Merge PDF files
mkdir summary
for f in $(find . -maxdepth 3 -type f -name 'summary*.pdf'); do
if [ ! -f "summary/$(basename $f)" ]; then
cp "$f" summary/
fi
done
cd summary
ls
bash ../merge_pdf.sh
mv merged.pdf "summary_${BASE_INFO}.pdf"
cd ..
if [ -d "summary" ]; then
mv summary "summary_${BASE_INFO}"
fi
- name: Upload merged artifact
uses: actions/upload-artifact@v3
env:
BASE_INFO: ${{ env.BASE_INFO }}
with:
name: merged_profiles_${{ env.BASE_INFO }}
path: tests/testdata/downloaded_artifacts/**
- name: Upload summary files
uses: actions/upload-artifact@v3
env:
BASE_INFO: ${{ env.BASE_INFO }}
with:
name: summary_files_${{ env.BASE_INFO }}
path: tests/testdata/downloaded_artifacts/summary_${{ env.BASE_INFO }}/**