The return value of the objective callback function must be a real double scalar.
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear friends,
I am trying to do a Mixed Integer Nonlinear Program (MINLP) Optimization problem by using a "BONMIN" toolbox. I have got an error and couldn't find the problem.
This is my code:
clc,clear
a = 1000;
b = 0.05;
h = 1;
c = 8;
i = 0.02;
r = 0.08;
T_0 = 0.06;
m = 0.5;
O = 200;
syms v x t T p k
%theta
theta = 1/(1+m-v);
inner1 = int(theta, 0, x);
outer1 = int(exp(inner1), 0, T);
inner2 = int(theta, t, x);
outer2 = int(int(exp(inner2), t, T), 0, T);
outer3 = int(outer1,0,T)
%Objective function
TP = (a*exp(-b*p)/T)*((p-c*(1+i*k)*(1+r*(T-(k+1)*T_0/2)))*outer1-(h+r*h*p)*outer2+r*p*outer3)-O/T
f = -TP
x = sym('x', [3, 1])
tn= ['fun_1','.m'];
fun_1 = matlabFunction(subs(f, [k, p, T], [x(1),x(2),x(3)]),'file',tn)
fun = @(x) fun_1(x(1),x(2),x(3))
nlcon = @(x) x(3)-T_0*x(1);
cl = 0;
cu = Inf;
lb = [1;c;T_0];
ub = [floor(m/T_0);Inf;m];
x0 = [2 12 0.2]';
opts = optimset('display','iter');
xtype = 'ICC';
Opt = opti('fun',fun,'nl',nlcon,cl,cu,'bounds',lb,ub,'xtype',xtype,'x0',x0,'options',opts)%½¨Á¢¶ÔÏó:×¢Òâ°Ñº¯Êý¡¢Ô¼ÊøÌõ¼þ¡¢±ß½ç¡¢±äÁ¿ÀàÐÍ¡¢³õÖµµÈ¶¼°üº¬½øÀ´
[x,fval,exitflag,info] = solve(Opt)% Çó½â
The following is the error obtained :
*** Error using Bonmin Matlab interface: ***
The first return value of the objective callback function must be a real double scalar.
Exception of type: IpoptException in file "Unknown File" at line -1:
Exception message: Unknown Exception caught in Ipopt
NLP0012I
Num Status Obj It time Location
NLP0014I 1 FAILED 0 0 0
*** Error using Bonmin Matlab interface: ***
The first return value of the objective callback function must be a real double scalar.
Exception of type: IpoptException in file "Unknown File" at line -1:
Exception message: Unknown Exception caught in Ipopt
NLP0014I 1 FAILED 0 0 0 resolve robustness
*** Error using Bonmin Matlab interface: ***
The first return value of the objective callback function must be a real double scalar.
Exception of type: IpoptException in file "Unknown File" at line -1:
Exception message: Unknown Exception caught in Ipopt
NLP0014I 3 FAILED 0 0 0
Cbc0006I The LP relaxation is infeasible or too expensive
0 Kommentare
Siehe auch
Kategorien
Mehr zu Nonlinear Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


