How can I use 'OR' constraints with fmincon / linprog: { x=0 } or { 0.6 <= x <= 1 }
3 次查看(过去 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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!