How can I use 'OR' constraints with fmincon / linprog: { x=0 } or { 0.6 <= x <= 1 }
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello!
I have a matlab script that optimize the electricity production from a heating plant based on the current electricity price and available boilers. Its very close to: http://www.mathworks.se/products/optimization/description6.html
However, the boilers can only run between 60-100 % or be completely turned off. So the constraints should be like:
x=0
or
0.6 <= x =< 1
for every boiler, and I have 10 of them.
How can I put this into linprog or fmincon? I want to have a script that tells me when to turn the boilers on and off and also at what rate every boiler should go.
Thank you very much
댓글 수: 0
채택된 답변
Matt J
2013년 11월 18일
편집: Matt J
2013년 11월 18일
The only robust way is to loop over all 2^10 on/off combinations of the boilers. In each pass through the loop, i.e., for each combination, use fmincon/linprog to solve for the optimal output of the on-boilers. Shouldn't be too bad with only 10 unknowns max. per problem.
댓글 수: 3
Matt J
2013년 11월 18일
편집: Matt J
2013년 11월 18일
The technique there only has a chance of working if the constrained region is connected which, in your case, it is not. And this still ignores the risks of the non-smoothness of c(x), mentioned at the link.
You could reformulate your problem in terms of expressions b(i)*x(i) where x(i) is boiler output and b(i) is a binary variable describing the state of the i-th boiler, (1=on, 0=off). If you have the Global Optimization Toolbox, you could then try applying GA to the reformulated problem. However, it's hard say whether this will do any better for you than exhaustive search.
추가 답변 (2개)
Matt J
2013년 11월 18일
편집: Matt J
2013년 11월 18일
If your objective is linear, another idea might be to discretize x(i) and use bintprog(). For example, using binary variables y(i,j), the following
x(i)=0.6*y(i,1)+0.1*(y(i,2)+y(i,3)+y(i,4)+y(i,5));
s.t. 4*y(i,1)>=y(i,2)+y(i,3)+y(i,4)+y(i,5),
allows x(i) to take on values [0,.6,.7,.8,.9,1.0]. You could use a bintprog solution to this approximate problem to first decide which boilers should be off/on. Once you know which biolers are on/off, you can then solve for the on-boiler x(i) more precisely and in continuous space using linprog.
jar
2013년 11월 22일
편집: Matt J
2013년 11월 22일
댓글 수: 1
Matt J
2013년 11월 22일
편집: Matt J
2013년 11월 22일
Hi jar,
It can't reliably work unfortunately. The issue was never about how to express the constraints you want in the syntax fmincon desires. The problem is that feasible sets consisting of disjoint, unconnected regions simply cannot be handled for theoretical reasons. fmincon has no way of jumping back and forth between the disjoint regions x(1)=0 and 0.4<=x(1)<=1 as it performs its search. Once fmincon lands in one of these regions, it will likely just stay bounded there and search for a local minimum.
Incidentally, you don't need three additional variables x(3), x(4), x(5) to do what you were attempting. You only need x(3) and the single additional constraint
x(1)*(x(3)-x(1))=0
which is satisfied only when x(1) is equal either to 0 or to 0.4<=x(3)<=1.
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!