How can I use 'OR' constraints with fmincon / linprog: { x=0 } or { 0.6 <= x <= 1 }
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (2)
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.
1 comentario
jar
el 19 de Nov. de 2013
1 comentario
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.
Categorías
Más información sobre Solver Outputs and Iterative Display en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!