Linprog to maximise a function
이전 댓글 표시
I have a function as following and try to maximise the value of V. Logic: if sn coefficient is positively largest, take max qn. if sn coefficient is negative, take min qn. if sn coefficient is between positively largest and zero, qn varies proportionally.
My code below is working but the outputs of x are equal to either DQMax or DQMi, no value is between them. How can I modify the code to derive q will vary proportionally?
V(q)=s1*q1+s2*q2+....sn*qn
where qn subject to these constraints 1) every DQMin<q<DQMax 2) ADMin<sum (q1,q2,...qn)<ADMax
f=-s(1:365);
a1=ones(1,365);
a2=-ones(1,365);
A=[a1;a2];
b=[AQMax;-AQMin];
lb=DQMin.*ones(365,1);
ub=DQMax.*ones(365,1);
[x,fval,exitflag,output,lambda] = linprog(f,A,b,[],[],lb,ub);
답변 (1개)
Alan Weiss
2013년 1월 23일
0 개 추천
I'm sorry, I do not understand why you are dissatisfied with the result. If the result satisfies all the constraints, then what else do you want? The only case where the outputs would not be equal to the bounds is when the linear inequality constraints are active, so I suppose your linear constraints are far enough apart that they do not matter.
You can test what I mean by setting ADMin and ADMax very close to each other.
Alan Weiss
MATLAB mathematical toolbox documentation
댓글 수: 2
Ella
2013년 2월 15일
Alan Weiss
2013년 2월 15일
I still do not understand why you are dissatisfied with the result that linprog gives you when DQMax and DQMin are set to their normal values. What makes you think that the answer is erroneous?
One other thing. linprog tries to minimize the objective function. If you want to maximize, enter -f as the objective function vector, and take the negative of the resulting objective. See the documentation.
Alan Weiss
MATLAB mathematical toolbox documentation
카테고리
도움말 센터 및 File Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!