linprog optimization of two functions
1 次查看(过去 30 天)
显示 更早的评论
Hi community,
I am trying to minimize a two stage function in which first value is computed on the bases of X & D and this values is thereafter used in a new minimization function. I think I almost have the correct code, but some errors keep popping up. or should I solve these functions in 2 seperate scripts?Does anyone know how to solve them?
%overall objective function = Min c.'*x+E[Q(x,D)]
%set of parameters
i=1
j=1
c = 3; %s<c
l = 0.25;
q = 6;
s = 1;
A1 = 1;
D= 60;
%d = 65; not used in estimation
x= D.'*A1;
%E[Q(x,D)= (l-q).'*z-s.'
%Q(x,D)=(l-q).'*z(*)-s.'*y(*);
%s.t x=y(*)+A1.'*z(*);
%to find value for E[Q(x,D)]
f2 = [-s.',(l-q).']; %[ Y, Z]
E=sum(f2)%
Aeq = [eye(j),A1.'];
beq = x;
lb = [zeros(1,i+j)];
ub = [inf(1,j), D(1)];
sol = linprog(f2,[],[],Aeq,beq,lb,ub);
y = sol(1);
z = sol(2) ;
%Now objective function is to minimize c.'*x+E
f1= [c.'+E];%or f1=[c.',E] how to define E in the f1 function? outcome of linprog f1 should give a value of x
Aeq = [];%no equality or inequality constraints, only requirement is for x>0, or should constraint of f2 also be added??
beq = [];
lb = [0];%x>0
ub = [Inf];
sol = linprog(f1,[],[],Aeq,beq,lb,ub);
x = sol(1)
I get no solution for x as matlab says the code is unbouded. However, my only constraint for f1 is that x>0, for f2 there is a constraint (x=y+A1.'*z)
hope that anyone knows what I am doing wrong.
Thankyou!
4 个评论
Matt J
2019-4-29
We cannot tell you what the problem should be. Only the solution. There is nothing incorrect about the solution you have obtained, given the problem you've provided.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!