Skip to content

Commit bd996cc

Browse files
committed
260509.220120.CST [skip ci] introduce test_classical in testprima to control whether the classical mode is tested
1 parent c222c26 commit bd996cc

7 files changed

Lines changed: 30 additions & 29 deletions

File tree

.github/workflows/test_matlab.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,14 @@ jobs:
170170
uses: matlab-actions/run-command@v3.1.0
171171
with:
172172
command: |
173-
cd matlab/tests; testprima_ex();
173+
cd matlab/tests;
174+
testprima_ex(false); % false: do not test the classical mode.
174175
175176
- name: Conduct the test; treat timeout as SUCCESS (exit 0). Only for macOS on Intel.
176177
if: ${{ runner.os == 'macOS' && runner.arch == 'X64' }}
177178
uses: equipez/run-matlab-command@v2
178179
with:
179180
timelimit: 320m
180181
command: |
181-
cd matlab/tests; testprima_ex();
182+
cd matlab/tests;
183+
testprima_ex(false); % false: do not test the classical mode.

.github/workflows/test_matlab_linux.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,5 @@ jobs:
136136
uses: matlab-actions/run-command@v3.1.0
137137
with:
138138
command: |
139-
cd matlab/tests; testprima_ex();
139+
cd matlab/tests;
140+
testprima_ex(true); % true: test the classical mode.

.github/workflows/test_matlab_mac.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ jobs:
6868
# cat cobylb.f
6969

7070
- name: Conduct the test # We do not use matlab-actions/run-command, which is not supported on macOS ARM64 as of 20240119
71-
run: ${{ env.MATLAB }} -nojvm -batch "cd matlab/tests; testprima_ex();"
72-
71+
# true: test the classical mode.
72+
run: ${{ env.MATLAB }} -nojvm -batch "cd matlab/tests; testprima_ex(true);"

.github/workflows/test_matlab_mac_intel.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,5 @@ jobs:
100100
with:
101101
timelimit: 320m
102102
command: |
103-
cd matlab/tests; testprima_ex();
103+
cd matlab/tests;
104+
testprima_ex(true); % true: test the classical mode.

.github/workflows/test_matlab_windows.yml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,7 @@ jobs:
122122
end
123123
root_dir = pwd();
124124
cd(fullfile(root_dir, 'matlab/tests'));
125-
try
126-
parfor i = 1:1
127-
testprima_ex();
128-
end
129-
catch exception
130-
% Copy the crash dump files to root_dir if exceptions occur.
131-
copy_crash_dump_files(root_dir, true)
132-
dir(root_dir)
133-
rethrow(exception);
134-
end
135-
136-
- name: Store artifacts
137-
uses: actions/upload-artifact@v7
138-
if: always() # Always run even if the workflow is canceled manually or due to overtime.
139-
with:
140-
name: ${{ matrix.solver }}
141-
path: |
142-
matlab_crash_dump*
125+
% With MinGW, we do not test the classical mode, which may encounter memory errors with
126+
% the message "ERROR: MATLAB error Exit Status: 0xc0000409".
127+
test_classical = ~strcmpi('${{ matrix.compiler }}', 'mingw');
128+
testprima_ex(test_classical);

matlab/tests/testprima.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
function testprima(release, precision, nrun)
1+
function testprima(release, precision, nrun, test_classical)
22
%TESTPRIMA tests prima on a few VERY simple problems.
3+
% release is a boolean that controls whether to test prima in release mode (true) or not (false).
4+
% In release mode, the testing precision is relaxed and the testing results are not printed.
5+
% precision is a positive scalar that specifies the required precision.
6+
% nrun is a positive integer that specifies the number of runs with randomly perturbed x0. The
7+
% default value is 1, meaning that no perturbation will be added to x0. If nrun > 1, a tiny
8+
% quasi-random perturbation will be added to x0 in each run.
9+
% test_classical is a boolean that controls whether to test the classical version of prima.
310
%
411
% Note: Do NOT follow the syntax here when you use prima. This file is
512
% written for testing purpose, and it uses quite atypical syntax. See
@@ -40,6 +47,9 @@ function testprima(release, precision, nrun)
4047
else
4148
perturb = eps;
4249
end
50+
if nargin < 4
51+
test_classical = false;
52+
end
4353

4454
options.debug = true;
4555
options.chkfunval = true;
@@ -80,7 +90,7 @@ function testprima(release, precision, nrun)
8090
% 2. Himmelblau's function (hmlb) has multiple minima when
8191
% unconstrained. They are [3; 2], [-2.805118; 3.131312], [-3.779310; -3.283186], [3.584428; -1.848126]
8292

83-
if release
93+
if release || ~test_classical
8494
clflag_list = {false}; % clflag: call the solvers in classical mode (true) or not (false)
8595
else
8696
clflag_list = {true, false}; % clflag: call the solvers in classical mode (true) or not (false)

matlab/tests/testprima_ex.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
function testprima_ex()
1+
function testprima_ex(test_classical)
22
%TESTPRIMA tests prima extensively on a few VERY simple problems, combining testprima and pdv.
3+
% test_classical is a boolean that controls whether to test the classical version of prima.
34

45
ver;
56

@@ -10,11 +11,11 @@ function testprima_ex()
1011
options.verbose = true;
1112
setup(options);
1213
prima('info')
13-
testprima(true, 1.0e-10, 100);
14+
testprima(false, 1.0e-10, 100, test_classical);
1415
setup
1516
setup path
1617
prima('info')
17-
testprima(true, 1.0e-10, 100);
18+
testprima(false, 1.0e-10, 100, test_classical);
1819
setup cobyla
1920
setup uobyqa
2021
setup newuoa

0 commit comments

Comments
 (0)