Different optimization results between Yalmip and Mathematica
Answeredtbk=13.9;
C=166/9*6;
ucmax=461.1.
clc
clear
Pbkmax=1497400;
tbk=13.9;
C=166/9*6;
ucmax=461.1;
uc0=sdpvar(1);
i=sdpvar(1);
x=sdpvar(1);
y=sdpvar(1);
z=sdpvar(1);
p=sdpvar(1);
q=sdpvar(1);
S=0.5*(-Pbkmax^2*C*tbk+C^2*Pbkmax*x+2*C*Pbkmax*tbk*q)*z+0.5*Pbkmax*tbk-0.5*C*x;
F=[];
F=F+[[0<=i<=(ucmax-uc0)*C/tbk]:'constraint1'];
e=10^(-5);
F=F+[[ucmax-Pbkmax*tbk/(4*C*ucmax)+e<=uc0<=ucmax]:'constraint2'];
% F=F+[[380<=uc0<=ucmax]:'constraint2']; %change lower limit of uc0
% F=F+[[ucmax-Pbkmax*tbk/(4*C*ucmax)+e<=uc0<=440]:'constraint2']; % change upper limit of uc0
F=F+[[x==uc0^2]:'constraint3'];
F=F+[[y==i^2]:'constraint4'];
F=F+[[p==x*y]:'constraint5'];
F=F+[[q==uc0*i]:'constraint6'];
F=F+[[z*(tbk*y+C*Pbkmax)==1]:'constraint7'];
options=sdpsettings('solver','gurobi');
options.savesolveroutput=1;
output=optimize(F,-S,options);
Uc0=value(uc0)
I=value(i)
Ulin=ucmax-Pbkmax*tbk/(4*C*ucmax)
Ilin=(ucmax-Uc0)*C/tbk
-
Could you please share a model file? Please refer to How do I write an MPS model file from a third-party API? for all information about how to generate a model file out of Yalmip.
Note that uploading files in the Community Forum is not possible but we discuss an alternative in Posting to the Community Forum.
Best regards,
Jaromił0 -
NAME matlab
ROWS
N OBJ
L R0
L R1
L R2
L R3
E qc0
E qc1
E qc2
E qc3
E qc4
COLUMNS
C0 R1 7.9616306954436444e+00
C0 R2 -1
C0 R3 1
C1 R0 -1
C1 R1 1
C2 OBJ 5.5333333333333329e+01
C2 qc0 1
C3 OBJ 0
C3 qc1 1
C4 OBJ 1.7245559593413333e+15
C4 qc4 1.6571226666666666e+08
C5 OBJ 0
C5 qc2 1
C6 OBJ 0
C6 qc3 1
RHS
RHS1 OBJ 10406930
RHS1 R1 3.6711079136690646e+03
RHS1 R2 -3.5912806888485625e+02
RHS1 R3 461.1
RHS1 qc4 1
BOUNDS
FR BND1 C0
FR BND1 C1
FR BND1 C2
FR BND1 C3
FR BND1 C4
FR BND1 C5
FR BND1 C6
QUADOBJ
C2 C4 -9.1694120888888874e+09
C4 C6 -2.3034005066666665e+09
QCMATRIX qc0
C0 C0 -1
QCMATRIX qc1
C1 C1 -1
QCMATRIX qc2
C2 C3 -0.5
C3 C2 -0.5
QCMATRIX qc3
C0 C1 -0.5
C1 C0 -0.5
QCMATRIX qc4
C3 C4 6.95
C4 C3 6.95
ENDATA0 -
Thank you for sharing the model.
The issue are the huge coefficients and infinite bounds for variables used in the optimization model. When you only plot a function, you just have to evaluate some function values to get a well scaled plot even for very big coefficients and variable values. This does not apply to optimization algorithms. Optimization algorithms are sensitive to bad scaling, i.e., huge/tiny coefficient values and unbounded variables in nonlinear terms.
In order to properly solve your model, you have to re-scale it. In particular, you have to reduce the coefficient values and provide tight finite bounds for every variable participating in a bilinear term. Please refer to our Guidelines for Numerical Issues for more information.
Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
3 comments