Skip to content

Commit a4c4655

Browse files
committed
260510.110728.CST [skip ci] introduce verbose to control the printing behavior of the solvers in testprima, as the crash MATLAB error Exit Status: 0xc0000409 seems to te due to the printing
1 parent 2e78085 commit a4c4655

7 files changed

Lines changed: 31 additions & 16 deletions

File tree

.github/workflows/test_matlab.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ jobs:
171171
with:
172172
command: |
173173
cd matlab/tests;
174-
testprima_ex(false); % false: do not test the classical mode.
174+
test_classical = true;
175+
verbose = true;
176+
testprima_ex(test_classical, verbose);
175177
176178
- name: Conduct the test; treat timeout as SUCCESS (exit 0). Only for macOS on Intel.
177179
if: ${{ runner.os == 'macOS' && runner.arch == 'X64' }}
@@ -180,4 +182,6 @@ jobs:
180182
timelimit: 320m
181183
command: |
182184
cd matlab/tests;
183-
testprima_ex(false); % false: do not test the classical mode.
185+
test_classical = true;
186+
verbose = true;
187+
testprima_ex(test_classical, verbose);

.github/workflows/test_matlab_linux.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,6 @@ jobs:
137137
with:
138138
command: |
139139
cd matlab/tests;
140-
testprima_ex(true); % true: test the classical mode.
140+
test_classical = true;
141+
verbose = true;
142+
testprima_ex(test_classical, verbose);

.github/workflows/test_matlab_mac.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@ jobs:
6969

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

.github/workflows/test_matlab_mac_intel.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,6 @@ jobs:
101101
timelimit: 320m
102102
command: |
103103
cd matlab/tests;
104-
testprima_ex(true); % true: test the classical mode.
104+
test_classical = true;
105+
verbose = true;
106+
testprima_ex(test_classical, verbose);

.github/workflows/test_matlab_windows.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ jobs:
122122
end
123123
root_dir = pwd();
124124
cd(fullfile(root_dir, 'matlab/tests'));
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(true);
125+
test_classical = true;
126+
% With MinGW, if we set verbose to true, MATLAB will crash with the message "ERROR: MATLAB error Exit Status: 0xc0000409".
127+
% To be investigated whether this is a bug of MATLAB or MinGW. Setting verbose to false is a workaround.
128+
verbose = ~strcmpi('${{ matrix.compiler }}', 'mingw');
129+
testprima_ex(test_classical, verbose);

matlab/tests/testprima.m

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function testprima(release, precision, nrun, test_classical)
1+
function testprima(release, precision, nrun, test_classical, verbose)
22
%TESTPRIMA tests prima on a few VERY simple problems.
33
% release is a boolean that controls whether to test prima in release mode (true) or not (false).
44
% In release mode, the testing precision is relaxed and the testing results are not printed.
@@ -7,6 +7,8 @@ function testprima(release, precision, nrun, test_classical)
77
% default value is 1, meaning that no perturbation will be added to x0. If nrun > 1, a tiny
88
% quasi-random perturbation will be added to x0 in each run.
99
% test_classical is a boolean that controls whether to test the classical version of prima.
10+
% verbose is a boolean that controls whether the solvers print messages. In release mode, it will
11+
% be ignored and the solvers will not print messages.
1012
%
1113
% Note: Do NOT follow the syntax here when you use prima. This file is
1214
% written for testing purpose, and it uses quite atypical syntax. See
@@ -50,6 +52,10 @@ function testprima(release, precision, nrun, test_classical)
5052
if nargin < 4
5153
test_classical = false;
5254
end
55+
if nargin < 5
56+
verbose = false;
57+
end
58+
verbose = verbose && ~release; % In release mode, the solvers will not print messages regardless of the value of `verbose`.
5359

5460
options.debug = true;
5561
options.chkfunval = true;
@@ -129,9 +135,8 @@ function testprima(release, precision, nrun, test_classical)
129135
problem.x0 = x0;
130136
options.solver = solver;
131137
options.classical = clflag;
138+
options.iprint = round(4*(2*rand() - 1)) * verbose;
132139
problem.options = options;
133-
%problem.options.iprint = round(4*(2*rand() - 1)) * (1 - release);
134-
problem.options.iprint = 0;
135140

136141
switch type
137142
case 'unconstrained'
@@ -163,7 +168,7 @@ function testprima(release, precision, nrun, test_classical)
163168

164169
xs = prima(problem);
165170

166-
% Remove the *_output.txt files produced when iprint < 0.
171+
% Remove the *_output.txt files produced when options.iprint < 0.
167172
if ~isempty(dir('*_output.txt'))
168173
delete('*_output.txt');
169174
end

matlab/tests/testprima_ex.m

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

56
ver;
67

@@ -11,11 +12,11 @@ function testprima_ex(test_classical)
1112
options.verbose = true;
1213
setup(options);
1314
prima('info')
14-
testprima(false, 1.0e-10, 100, test_classical);
15+
testprima(false, 1.0e-10, 100, test_classical, verbose);
1516
setup
1617
setup path
1718
prima('info')
18-
testprima(false, 1.0e-10, 100, test_classical);
19+
testprima(false, 1.0e-10, 100, test_classical, verbose);
1920
setup cobyla
2021
setup uobyqa
2122
setup newuoa

0 commit comments

Comments
 (0)