MINLP: Model not available in objective at level 1

245 views
Skip to first unread message

Quinten

unread,
Apr 6, 2021, 10:35:16 AM4/6/21
to YALMIP
Hello Prof. Löfberg,

I am getting the error 'Model creation failed (Model not available in objective at level 1)' when I want to solve an MINLP problem with either the Mosek or BNB solver. The same problem runs well with the Optimization toolbox ga solver. I can not find any information online about this issue and don't know how to go further from here.


%% MINLP assignment problem
C = jobmeans(:,choice);   % cost matrix
v = jobvars(:,choice);

% For vector input
Aeq7 = kron(eye(n(w)),ones(1,n(w)));        
beq7 = [ones(length(C),1)];                 

Aeq6 = zeros(length(C),length(C)*length(C));
for i = 1:length(C)
    for j = 1:length(C)
Aeq6(i,n(w)*(j-1)+1+i-1) = 1;               
    end
end
beq6 = [ones(length(C),1)];                

Aeq = [Aeq7;Aeq6];
beq = [beq7;beq6];

A = [Aeq;-Aeq];         % Rewriting Ax=b as Ax<=b, -Ax,<=-b
b = [beq;-beq];        % since ga solver does not accept eq constraints


% Optimization variable for Yalmip solver
x_y = binvar(5.^2,1);

% Objective function for Yalmip solver Equation 5 BRSP paper 
obj = (-(T-C'*(vecnplus1*x_y)))/sqrt(v'*(vecnplus1.^2*x_y));     
ops = sdpsettings('solver','bnb','bnb.solver','fmincon');
optimize([A*x_y <= b, x_y],obj,ops)

What could I have done wrong here?

Regards,
Quinten

Johan Löfberg

unread,
Apr 6, 2021, 10:52:45 AM4/6/21
to YALMIP
sqrt is a convexity-aware operator implemented with socp cones, and yalmip cannot see that you model satisfies conditions for that to be possible. If you really want to go full nonlinear, you use sqrtm. However, it looks like you have a model where you can do better

Your objective appears to be
(a + b'*x)/sqrt(c'*x)

If you know that it is non-negative, you can just as well minimize  (a+b'*x)^2/(c'*x) which is quadratic over affine which is SOCP-representable (already available in quad_over_affine)

it also looks like you are complicating model construction massively by manually setting up A/Aeq/b/beq for someting that looks like a simple model. Also, converting equalities to inequalities is a bad idea. And my guess is hat you original decision variable is a matrix, but you have manually written it using a vector. IT smells like you have something trivial like sum(X,2)==1 for a matrix X

Quinten

unread,
Apr 6, 2021, 11:31:59 AM4/6/21
to YALMIP
Thank you for your swift response.

My solver now successfully solves after modifying sqrt to sqrtm. 

Your guess is correct. I am modeling an assignment problem where the entries of each row and column separately are constrained to sum up to 1. 

I have rewritten the equality constraint into inequality constraints as the ga solver of the Optimization toolbox does not accept equality constraints.

If I use the equality constraints for my case it seems that I receive a warning

Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =  4.854638e-17. 
> In backsolveSys
  In solveAugSystem
  In projConjGrad
  In projConjGrad
  In tangentialStep
  In computeTrialStep
  In barrier
  In fmincon (line 834)
  In callfmincon (line 95)
  In bnb_solvelower (line 246)
  In bnb>branch_and_bound (line 526)
  In bnb (line 223)
  In solvesdp (line 371)
  In optimize (line 31)
  In BRSP (line 183)

Also, the function value seems to be better for my specific case when I'm using inequality constraints. I will pay attention for different root seeds.

Regards

Johan Löfberg

unread,
Apr 6, 2021, 11:48:51 AM4/6/21
to YALMIP
If you are using YALMIP, you should model the problem properly, and not use a sub-standard model just because some other poor solver isn't capable of handling that.

Post a reproducible model. I suspect this is a problem you easily can solve as a MILP or at least MISOCP. Solving it as a general nonlinear mixed-integer problem (using bnb which asumes convexity) is a bad idea

Johan Löfberg

unread,
Apr 6, 2021, 12:47:46 PM4/6/21
to YALMIP
My guess is you are solving something like this (robust beta-scheduling)

n = 25;
M = rand(n);
S = rand(n);
T = 1;
X = binvar(n,n,'full');
Model = [sum(X,1)==1,sum(X,2) == 1];
% Objective = minimize (sum (M.*X) - T)./(sum sqrt(S.*X)) which we square to get SOCP-representable
sdpvar e % Avoid low-rank quadratic so use intermediate for sum
Model = [Model, e == sum(sum(M.*X))-T];
Objective = quadratic_over_affine(e^2,sum(sum(S.*X)));
optimize(Model,Objective)

Solved in fractions of a second using a MISOCP solver (cplex/gurobi/mosek). Even bnb+sedumi solves it in a second or so

tisdag 6 april 2021 kl. 17:31:59 UTC+2 skrev Quinten:

Quinten

unread,
Apr 6, 2021, 3:35:32 PM4/6/21
to YALMIP
Once again thanks for the effort Prof. Löfberg.

I can not seem to reproduce your results. The following code leads to the error given in red.

x_y = binvar(n(w),n(w),'full');
M = rand(n(w));
S = rand(n(w));
eqconstraint = [sum(x_y,1)==1,sum(x_y,2)==1];
ops = sdpsettings('solver','gurobi');
sdpvar e
eqconstraint = [eqconstraint, e==sum(sum(M.*x_y))-T];
obj = quadratic_over_affine(e^2,sum(sum(S.*x_y)));
optimize(eqconstraint,obj,ops)

Reference to non-existent field 'replace'.

Error in compileinterfacedata (line 126)
        if ~isempty(operators{i}.properties.replace)

Error in solvesdp (line 249)
[interfacedata,recoverdata,solver,diagnostic,F,Fremoved,ForiginalQuadratics] =
compileinterfacedata(F,[],logdetStruct,h,options,0,solving_parametric);

Error in optimize (line 31)
[varargout{1:nargout}] = solvesdp(varargin{:});

Error in BRSP (line 192)
optimize(eqconstraint,obj,ops)

Unfortunately I can not make sense of this error.

Johan Löfberg

unread,
Apr 6, 2021, 3:39:01 PM4/6/21
to YALMIP
old version of yalmip perhaps?

Quinten

unread,
Apr 6, 2021, 3:48:57 PM4/6/21
to YALMIP
I have downloaded the new version and now I'm encountering the following issue (which did not occur before)

Check for missing argument or incorrect argument data type in call to function 'sdpvar'.

Error in BRSP (line 176)
x_y = sdpvar(n(w),n(w),'full');

I'm not familiar with any changes in the updated version. Do you know what is going wrong here?

Johan Löfberg

unread,
Apr 6, 2021, 3:53:57 PM4/6/21
to YALMIP
Now the sdpvar function appears to point at something very strange

which sdpvar  -all

I would start by restarting MATAB as something appears very broken. 

Quinten

unread,
Apr 6, 2021, 4:55:23 PM4/6/21
to YALMIP
Unfortunately this has not solved the issue. I will try an older version of Yalmip tomorrow morning.

Johan Löfberg

unread,
Apr 6, 2021, 5:21:07 PM4/6/21
to YALMIP
you should use the latest version

the error message is a standard error message from matlab when you reference classes that don't exist in path, or there are multiple versions in path, or the class has been redefined i.e. updated without restarting.

in other words, you either have multiple versions of yalmip on path or you have some broken installation such as copying over new version without deleting old directory first thus getting some weird mixture of files, or some other weird issue with path

Quinten

unread,
Apr 7, 2021, 3:42:36 AM4/7/21
to YALMIP
I have removed the previous Yalmip folder and created a new one under a new name and restarted Matlab.

I have tried to add the paths as for different locations

addpath(genpath('C:\Users\x\YALMIP-pack\extras'))
addpath(genpath('C:\Users\x\YALMIP-pack\solvers'))
addpath(genpath('C:\Users\x\YALMIP-pack\modules'))
addpath(genpath('C:\Users\x\YALMIP-pack\modules\parametric'))
addpath(genpath('C:\Users\x\YALMIP-pack\modules\global'))
addpath(genpath('C:\Users\x\YALMIP-pack\modules\sos'))
addpath(genpath('C:\Users\x\YALMIP-pack\operators'))

However this error seems to occur regardless for the folder directory

Check for missing argument or incorrect argument data type in call to function 'sdpvar'.

Error in binvar (line 25)
    sys = sdpvar(varargin{:});

Error in BRSP (line 179)
x_y = binvar(n(w),n(w),'full');

Johan Löfberg

unread,
Apr 7, 2021, 3:48:03 AM4/7/21
to YALMIP
check

which sdpvar -all

to see if you have multiple copies or some crap like that

Quinten

unread,
Apr 7, 2021, 3:51:20 AM4/7/21
to YALMIP
>> which sdpvar -all
C:\Users\x\extras\@blkvar\sdpvar.m      % blkvar method
C:\Users\x\extras\@constraint\sdpvar.m  % constraint method
C:\Users\x\extras\@lmi\sdpvar.m         % lmi method
C:\Users\x\extras\@ndsdpvar\sdpvar.m    % ndsdpvar method

This is its output!

Johan Löfberg

unread,
Apr 7, 2021, 3:54:13 AM4/7/21
to YALMIP
It's missing the class definition of sdpvar, meaning you don't have whole YALMIP in your path (i.. top directory yalmip  is missing)

Johan Löfberg

unread,
Apr 7, 2021, 3:54:49 AM4/7/21
to YALMIP

Quinten

unread,
Apr 7, 2021, 4:04:37 AM4/7/21
to YALMIP
I did not include it in the last time I ran my script but had done so before. Now when I run the command yalmiptest I see that some solvers (Gurobi and Mosek) are not installed. Do I have to register on their webpage to have my academic license issued before use?

>> yalmiptest
+++++++++++++++++++++++++++++++++++++++++++++++
|       Searching for installed solvers       |
+++++++++++++++++++++++++++++++++++++++++++++++
|        Solver|   Version/module|      Status|
+++++++++++++++++++++++++++++++++++++++++++++++
|         BARON|                 |   not found|
|      BINTPROG|                 |   not found|
|     BISECTION|                 |       found|
|        BMIBNB|                 |       found|
|           BNB|                 |       found|
|        BONMIN|                 |       found|
|         BPMPD|                 |   not found|
|           CBC|                 |       found|
|          CDCS|                 |   not found|
|           CDD|           CDDMEX|   not found|
|           CLP|             OPTI|       found|
|           CLP|        CLPMEX-LP|   not found|
|           CLP|        CLPMEX-QP|   not found|
|      CONEPROG|                 |   not found|
|         CPLEX|      IBM 12.10.0|   not found|
|         CPLEX|      IBM 12.10.0|   not found|
|         CPLEX|       IBM 12.9.0|   not found|
|         CPLEX|       IBM 12.9.0|   not found|
|         CPLEX|       IBM 12.8.0|   not found|
|         CPLEX|       IBM 12.8.0|   not found|
|         CPLEX|       IBM 12.7.1|   not found|
|         CPLEX|       IBM 12.7.1|   not found|
|         CPLEX|       IBM 12.7.0|   not found|
|         CPLEX|       IBM 12.7.0|   not found|
|         CPLEX|       IBM 12.6.3|   not found|
|         CPLEX|       IBM 12.6.3|   not found|
|         CPLEX|       IBM 12.6.2|   not found|
|         CPLEX|       IBM 12.6.2|   not found|
|         CPLEX|       IBM 12.6.1|   not found|
|         CPLEX|       IBM 12.6.1|   not found|
|         CPLEX|       IBM 12.6.0|   not found|
|         CPLEX|       IBM 12.6.0|   not found|
|         CPLEX|       IBM 12.5.1|   not found|
|         CPLEX|         IBM 12.5|   not found|
|         CPLEX|         IBM 12.4|   not found|
|         CPLEX|         IBM 12.3|   not found|
|         CPLEX|         IBM 12.2|   not found|
|         CPLEX|         IBM 12.1|   not found|
|         CPLEX|         IBM 12.0|   not found|
|         CPLEX|         CPLEXMEX|   not found|
|          CSDP|             opti|       found|
|          CSDP|                 |   not found|
|        CUTSDP|                 |       found|
|        CUTSDP|                 |       found|
|          DSDP|             OPTI|       found|
|          DSDP|                4|       found|
|          DSDP|                5|   not found|
|          ECOS|                 |   not found|
|      FILTERSD|            dense|       found|
|      FILTERSD|           sparse|       found|
|       FMINCON|        geometric|       found|
|       FMINCON|         standard|       found|
|    FMINSEARCH|                 |       found|
|         FRLIB|                 |   not found|
|          GLPK|       GLPKMEX-CC|   not found|
|          GLPK|          GLPKMEX|   not found|
|          GLPK|          GLPKMEX|   not found|
|        GPPOSY|                 |   not found|
|        GUROBI|           GUROBI|   not found|
|        GUROBI|              MEX|   not found|
|        GUROBI|        NONCONVEX|   not found|
|    INTLINPROG|                 |       found|
|         IPOPT|         standard|       found|
|         IPOPT|        geometric|       found|
|         KKTQP|                 |       found|
|        KNITRO|                 |   not found|
|          KYPD|                 |   not found|
|         LINDO|             MIQP|   not found|
|         LINDO|              NLP|   not found|
|       LINPROG|                 |       found|
|        LMILAB|                 |   not found|
|       LMIRANK|                 |   not found|
|     LOGDETPPA|              0.1|   not found|
|       LPSOLVE|        MXLPSOLVE|       found|
|        LSQLIN|                 |       found|
|     LSQNONNEG|                 |       found|
|        MAXDET|                 |   not found|
|         MOSEK|            LP/QP|   not found|
|         MOSEK|             SOCP|   not found|
|         MOSEK|              SDP|   not found|
|         MOSEK|        GEOMETRIC|   not found|
|         MPLCP|                 |   not found|
|           MPT|                3|   not found|
|           MPT|                2|   not found|
|           NAG|           e04mbf|   not found|
|           NAG|           e04naf|   not found|
|         NOMAD|                 |       found|
|          NONE|                 |       found|
|          OOQP|                 |       found|
|          OOQP|                 |       found|
|           OSL|          OSLPROG|   not found|
|          OSQP|                 |   not found|
|        PENBMI|           PENOPT|   not found|
|        PENBMI|           TOMLAB|   not found|
|        PENLAB|                 |   not found|
|        PENNON|         standard|   not found|
|        PENSDP|           PENOPT|   not found|
|        PENSDP|           TOMLAB|   not found|
|           POP|                 |   not found|
|   POWERSOLVER|                 |   not found|
|          QPAS|                 |   not found|
|          QPIP|                 |   not found|
|       QPOASES|                 |   not found|
|         QSOPT|             OPTI|   not found|
|         QSOPT|         MEXQSOPT|   not found|
|      QUADPROG|                 |       found|
|    QUADPROGBB|                 |   not found|
|       REFINER|              1.1|       found|
|          SCIP|           linear|       found|
|          SCIP|               nl|       found|
|           SCS|           direct|   not found|
|           SCS|         indirect|   not found|
|          SDPA|                M|   not found|
|         SDPLR|                 |   not found|
|        SDPNAL|              0.5|   not found|
|        SDPNAL|                 |   not found|
|         SDPT3|                4|   not found|
|         SDPT3|              3.1|   not found|
|         SDPT3|             3.02|   not found|
|         SDPT3|              3.0|   not found|
|        SEDUMI|              1.1|   not found|
|        SEDUMI|              1.3|   not found|
|        SEDUMI|             1.05|   not found|
|        SEDUMI|             1.03|   not found|
|         SNOPT|        geometric|   not found|
|         SNOPT|         standard|   not found|
|         SNOPT|             cmex|   not found|
|    SPARSECOLO|                0|   not found|
|     SPARSEPOP|                 |   not found|
|         STRUL|                1|   not found|
|          VSDP|              0.1|   not found|
|        XPRESS|     MEXPRESS 1.1|   not found|
|        XPRESS|     MEXPRESS 1.0|   not found|
|        XPRESS|             FICO|   not found|
+++++++++++++++++++++++++++++++++++++++++++++++

Johan Löfberg

unread,
Apr 7, 2021, 4:07:40 AM4/7/21
to YALMIP
If you haven't installed them, you have to install them

If you have installed them, you must set their path in MATLAB so YALMIP can see them

and you have to have licenses correctly activated for them to run

Quinten

unread,
Apr 7, 2021, 5:31:44 AM4/7/21
to YALMIP
Dear Prof Löfberg,

My solver is functioning correctly now. Thank you for your extensive help.

Regards 

Quinten

unread,
Apr 20, 2021, 4:50:00 AM4/20/21
to YALMIP
Dear Prof. Löfberg,

I found that with the modified objective function (quadratic over affine function),

Model = [sum(X,1)==1,sum(X,2) == 1];
% Objective = minimize (sum (M.*X) - T)./(sum sqrt(S.*X)) which we square to get SOCP-representable
sdpvar e % Avoid low-rank quadratic so use intermediate for sum
Model = [Model, e == sum(sum(M.*X))-T];
obj = quadratic_over_affine(e^2,sum(sum(S.*X)));
optimize(Model,obj)
X = value(X);
fval_solve = value(obj);

fval = (T-sum(sum((M.*X)')))/sqrt(sum(sum((S.*X)')));   % plugging back into true objective function

 my solver grants me a solution which is optimal for the squared objective function, not the true objective function. The solver finds objective value fval_solve to be lower than for a different schedule because the objective value is the squared value of the true objective value (fval_solve is fval^2). 

fval_solve = (-0.0080)^2 = 6.476e-05

So if I plug the solution back into the true objective function (not squared) then fval is significantly worse than the objective value for other solutions.
fval = -0.0080

Plugging a random feasible X into fval grants both higher and lower values than the "optimal" fval.

Is there a different approach to defining the objective function, or am I verifying my results incorrectly?

Quinten

unread,
Apr 20, 2021, 5:00:29 AM4/20/21
to YALMIP
To avoid confusion, below is how I defined my objective function. I did copy your code, which I cited in the above message

T = 290;        % low mean, medium variance


% Optimization variable for Yalmip solver
x_y = binvar(n(w),n(w),'full');

eqconstraint = [sum(x_y,1)==1,sum(x_y,2)==1];

M = C*(n(w)+1-[1:n(w)]);
S = v*(n(w)+1-[1:n(w)]).^2;
ops = sdpsettings('solver','mosek'); % State-of-the-art: short solvertime
sdpvar e
eqconstraint = [eqconstraint, e==sum(sum((M.*x_y)'))-T];
obj = quadratic_over_affine(e^2,sum(sum((S.*x_y)')));  
optimize(eqconstraint,obj,ops)     % Solving for superior model

Johan Löfberg

unread,
Apr 20, 2021, 5:02:10 AM4/20/21
to YALMIP
the reformulation assumes the numerator is nonnegative, otherwise it is not a convex function

Johan Löfberg

unread,
Apr 20, 2021, 5:12:43 AM4/20/21
to YALMIP
but s far as I can tell, you want maximize (T-sum(sum((M.*X)')))/sqrt(sum(sum((S.*X)'))); and you say that you have a solution where that is negative, that means that solution yields a  positive value of the numerator in the minimization form, thus squaring the objective should not be a problem. Hence, if you claim there exist a better solution, you would have to supply a reducible example to support that claim

tisdag 20 april 2021 kl. 10:50:00 UTC+2 skrev Quinten:

Quinten

unread,
Apr 20, 2021, 6:01:03 AM4/20/21
to YALMIP
Thank you for your response. 


As for your question:

In the following code I create a set of (5! -1) = 119 additional feasible schedules for the 5 job one-machine problem. Plugging some of these schedules into the true objective function grant a higher (and lower) fval than if I plug in my Yalmip found solution into the true objective function.  Value fval_solve seems to be lower than min(fvalr.^2) but to my understanding this does not make sense as I am not comparing the true objective values.


T = 290;        % low mean, medium variance
n = 5;   % 5 jobs

M = C*(n(w)+1-[1:n(w)]);
S = v*(n(w)+1-[1:n(w)]).^2;

% Optimization variable for Yalmip solver
x_y = binvar(n(w),n(w),'full');

eqconstraint = [sum(x_y,1)==1,sum(x_y,2)==1];

% Setting solver. gurobi,mosek > BNB
ops = sdpsettings('solver','gurobi');  % State-of-the-art: short solvertime
% ops = sdpsettings('solver','mosek'); % State-of-the-art: short solvertime
% ops = sdpsettings('solver','bnb','bnb.solver','fmincon'); % Sub-optimal, but supports non-convex numerator
ops = sdpsettings(ops,'verbose',0);

 sdpvar e
eqconstraint = [eqconstraint, e==sum(sum((M.*x_y)'))-T];   
obj = quadratic_over_affine(e^2,sum(sum((S.*x_y)')));      % Gurobi/Mosek

% obj = (sum(sum((M.*x_y)'))-T)/sqrtm(sum(sum((S.*x_y)')));    % BNB model

optimize(eqconstraint,obj,ops)     % Yalmip solving 
x_y = value(x_y);
fval_solve = value(obj);           % Optimizer objective value
fval = (T-sum(sum((M.*x_y)')))/sqrt(sum(sum((S.*x_y)'))); % True objective value


s = zeros(n(w),1);          % optimal path found by Yalmip 
 for i = 1:n(w)
 [nn,In] = find(x_y(:,i) == 1);
s(i,1) = nn;
 end
     

%% Sensitivity analysis

% Regular criterion
Phis = fval;       % Optimal/ dominant path and only path in set 

%% Finding all feasible solutions to one-machine problem
%  For larger problems (n>5) use allcomb function
 elements = repmat({1:n(w)},1,n(w));
 combinations = cell(1, numel(elements)); %set up the varargout result
 [combinations{:}] = ndgrid(elements{:});
 combinations = cellfun(@(x) x(:), combinations,'uniformoutput',false); 
 result = [combinations{:}]; % NumberOfCombinations by N matrix. Each row is unique.
 
 rowremoval = [];
 for i = 1:length(result)
     for j = 1:n(w)
 [nn,In] = find(result(i,:) == j);
 if ne(sum(nn),1) == 1          % Selecting schedules with duplicate jobs (infeasible)
 rowremoval = [rowremoval;i];
 break
 end
     end
 end
 result(rowremoval,:) = [];  % Removing infeasible schedules from set

 for i = 1:length(result)
 if result(i,:) == s'           % selecting optimal schedule from set
 optremoval = i;
 end
 end
 result(optremoval,:) = [];  % Removing optimal schedule from set 
 
 x_yr = zeros(n(w),n(w),length(result));
 fvalr = zeros(length(result),1);
 for i = 1:length(result)
     for r = 1:n(w)
         for c = 1:n(w)
 if result(i,c) == r             
 x_yr(r,c,i) = 1;               % creating remaining feasible schedules set
 end
         end
     end
fvalr(i,1) = (T-sum(sum((M.*x_yr(:,:,i))')))/sqrt(sum(sum((S.*x_yr(:,:,i))'))); % Set of objective values of remaining feasible schedules
 end

 % Regular criterion
Phik = fvalr;        % value of objective function semi-active functions
Phi_opt = min(Phik);    % best semiactive function value of set (1.8)

if Phis <= Phi_opt
    disp('Semi-active schedule x_y is the optimal schedule')
end




Johan Löfberg

unread,
Apr 20, 2021, 6:21:38 AM4/20/21
to YALMIP
Unrecognized function or variable 'C'.

Quinten

unread,
Apr 20, 2021, 7:04:44 AM4/20/21
to YALMIP
The missing two vectors are C (job duration mean) and v (job duration variance)

C = [16.4253 28.0081 10.0029 17.5583 13.6689]';
v = [53.1229 16.2347 3.8418 13.5912 11.1858]';

Johan Löfberg

unread,
Apr 20, 2021, 7:09:59 AM4/20/21
to YALMIP
Unrecognized function or variable 'w'.

Quinten

unread,
Apr 20, 2021, 7:15:36 AM4/20/21
to YALMIP
Excuse me for providing you with incomplete pieces of code.


Originally I ran the script for three different values of n = [5 10 15] (later I modified it to n=5 only) , so therefore I created the loop

%%
n = 5;
for w = 1:length(n)

Code here

end

Johan Löfberg

unread,
Apr 20, 2021, 8:03:56 AM4/20/21
to YALMIP
The optimal objective (for the minimization) is negative, hence it cannot be squared, and the convexifying trick is not possile

bmibnb easily solves it though
obj = (sum(sum((M.*x_y)'))-T)/sqrtm(sum(sum((S.*x_y)')));    % BNB model
optimize(eqconstraint,obj,sdpsettings('solver','bmibnb'))
* Starting YALMIP global branch & bound.
* Upper solver     : fmincon
* Lower solver     : GUROBI
* LP solver        : GUROBI
* -Extracting bounds from model
* -Perfoming root-node bound propagation
* -Calling upper solver (no solution found)
* -Branch-variables : 26
* -More root-node bound-propagation
* -Performing LP-based bound-propagation 
* -And some more root-node bound-propagation
* Starting the b&b process
 Node       Upper       Gap(%)       Lower     Open   Time
    1 :  -2.86861E+00     4.15   -3.03255E+00    2     0s  Improved solution found by heuristics  
    2 :  -2.86861E+00     4.15   -3.03255E+00    1     0s  Poor lower bound  
    3 :  -2.86861E+00     1.58   -2.93041E+00    2     0s    
    4 :  -2.86861E+00     1.58   -2.93041E+00    1     1s  Poor lower bound  
    5 :  -2.86861E+00     0.29   -2.87982E+00    2     1s    
* Finished.  Cost: -2.8686 (lower bound: -2.8798, relative gap 0.28934%)
* Termination with relative gap satisfied 


Quinten

unread,
Apr 20, 2021, 8:29:38 AM4/20/21
to YALMIP
Dear Prof. Löfberg,

Thank you for your help. It is well appreciated.

Regards

Johan Löfberg

unread,
Apr 20, 2021, 8:30:33 AM4/20/21
to YALMIP
lots of alternatives though as you only have binaries

maxmizing f/sqrt(g) with positive optimal f can be written as maximize t s.t f/sqrt(g) >= sqrt(t) which is f^2 >= g*t, which is nasty nonconvex in general, but since all your variables are binary, it is only binary*binary nd binary*continuous, hence it is MILP-representable. Some solver will convert automatically, YALMIP can also convert, but best is probably to derive MILP model manually as the permutation constraints probably reduce the model significantly and removes many monomials

% Let YALMIP derive MILP
s = (sum(sum((M.*x_y)'))-T)^2 - sum(sum((S.*x_y)'))*t
[q,Cuts] = binmodel(s,[100 >= t >= 0]);
optimize([eqconstraint, q>=0, Cuts],-t)

basically solved in the root node by gurobi after some cutting

Since gurobi supports nonconvex quadratics, one can also simply send that model. Now it takes some iterations, but still solved easily
optimize([eqconstraint, s >= 0],-t)







Reply all
Reply to author
Forward
0 new messages