BARON solve it right internally but YALMIP run into strange error

26 views
Skip to first unread message

JackJack

unread,
Jul 16, 2025, 10:09:37 AMJul 16
to YALMIP
Dear Professor Johan,

Currently I am using BARON (version 25.7.10) with YALMIP (20250626) ,

I am solving the following problem 

YALMIP.png

The exact solution is 

optimal_yalmip.png

BARON can pin point this solution in it log file res.dat 

The best solution found is:

  variable xlo  xbest xup
  x4 0  0.00000000000000000000000e+00 1
  x1 0  0.00000000000000000000000e+00 1e+51
  x2 0  0.00000000000000000000000e+00 1e+51
  x3 0  0.00000000000000000000000e+00 1e+51
  x5 0  0.00000000000000000000000e+00 12
  x6 -1e+51  0.00000000000000000000000e+00 1e+51

The above solution has an objective value of:  7.3263946711074101614258   


However, when I use the following matlab code 

% Define decision variables
t1 = sdpvar(1,1); % Subscript[t,1]
e1 = sdpvar(1,1); % Subscript[e,1]
s1 = sdpvar(1,1); % Subscript[s,1]
y1 = binvar(1,1); % Subscript[y,1] - binary variable (0 or 1)
f1 = sdpvar(1,1); % Subscript[f,1]
% Define the objective function
objective = e1 + t1;
% Define constraints
constraints = [];
% Non-negativity constraints
constraints = [constraints, t1 >= 0];
constraints = [constraints, e1 >= 0];
constraints = [constraints, s1 >= 0];
% Bounds on f1
constraints = [constraints, f1 >= 0];
constraints = [constraints, f1 <= 12];
% Nonlinear constraints
% t1 >= s1 + 100/(f1*y1 + 1/100) - 1
constraints = [constraints, t1 >= s1 + 100/(f1*y1 + 1/100) - 1];
% e1 >= 1 - (s1 + 100/(f1*y1 + 1/100))
constraints = [constraints, e1 >= 1 - (s1 + 100/(f1*y1 + 1/100))];
% Set solver options for BARON
options = sdpsettings('solver', 'baron', 'verbose', 1);
% Solve the optimization problem
sol = optimize(constraints, objective, options);
% Check solution status
if sol.problem == 0
fprintf('Solution found successfully!\n');
fprintf('Optimal objective value: %.6f\n', value(objective));
fprintf('Optimal values:\n');
fprintf('t1 = %.6f\n', value(t1));
fprintf('e1 = %.6f\n', value(e1));
fprintf('s1 = %.6f\n', value(s1));
fprintf('y1 = %.6f\n', value(y1));
fprintf('f1 = %.6f\n', value(f1));
else
fprintf('Optimization failed with error code: %d\n', sol.problem);
fprintf('Error message: %s\n', sol.info);
end My output is very strange

 Preprocessing found feasible solution with value 9999.00
 Doing local search
 Solving bounding LP
 Starting multi-start local search
 Preprocessing found feasible solution with value 7.32639
 Problem solved during preprocessing
 Lower bound is    7.32639
 
                         *** Normal completion ***            
 
 Wall clock time:                     0.05
 Total CPU time used:                 0.02
 
 Total no. of BaR iterations:      -1
 Best solution found at node:      -1
 Max. no. of nodes in memory:       0
 
 All done
===========================================================================
Solution found successfully!
Optimal objective value: 0.000000
Optimal values:
t1 = 0.000000
e1 = 0.000000
s1 = 0.000000
y1 = 0.000000
f1 = 0.000000

Here, all of the objective value and corresponding decision variable seems to be wrong. I will attatch the BARON log file as bar4.zip.

At this point I am not really sure if this is a BARON issue or YALMIP issue. It seems to me that BARON can find the correct solution but when YALMIP read it out. Things just gone awry.

Would you kindly help me with this.


Thank you for your enthusiasm ! 
bar4.zip

Johan Löfberg

unread,
Jul 16, 2025, 1:42:05 PMJul 16
to YALMIP
I suspect there might be an issue with nonlinear expressions inside fractionals although I cannot test it here. Remove this by multiplying all constraints with f1*y1+1/100 (on paper, i.e. the model you implement should be a polynomial model), or introduce a new variable z with constraints z == y1*f1+1/100 and then use z in the model

JackJack

unread,
Jul 17, 2025, 10:48:49 PMJul 17
to YALMIP
Thank you this is a BARON issue and not a YALMIP issue
Reply all
Reply to author
Forward
0 new messages