how can I do linear programming with a piecewise objective function?
显示 更早的评论
hello
I have done a linear programming code.And now the objective function of the problem will become a piece-wise function, but still linear in every part of the function.Also, all the constrains are linear as well.
which order can I use to solve the optimizing problem? still the linprog? if yes, how to write the objective function,AKA f. If not, which order can I turn to?
I have tried the fmincon order, but the example in help seems wrong, because I errors happened when I was trying to run it. Is also seems that the description of 'medium-scale programming' in help of linprog suits my requirements, but I cannot figure out how to right the objective function.
thanks
zech
回答(2 个)
Alan Weiss
2013-2-22
0 个投票
Optimization Toolbox solvers generally assume that objective functions are smooth, meaning twice differentiable. They can have difficulty with nonsmooth functions.
That said, there should be no errors even with nonsmooth objectives. If you show us some code we might be able to help diagnose what is going on with your objective or constraint functions.
linprog is unsuitable because it does not handle piecewise-defined objectives and constraints.
It is possible that patternsearch, in Global Optimization Toolbox, is most suitable, because it does not care about smoothness.
Alan Weiss
MATLAB mathematical toolbox documentation
7 个评论
xinyu
2013-2-23
xinyu
2013-2-24
Alan Weiss
2013-2-25
If fminimax works for you locally, then you should probably use it to search globally. Simply set different start points and see if you obtain different results. See, for example, this section of the documentation.
In particular, since you have bounds on all your components, you can try the following as random start points:
x0 = lb + rand(size(lb)).*(ub - lb);
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
xinyu
2013-2-27
Alan Weiss
2013-2-27
Sorry, you found a typo in the documentation. I'll fix that. The syntax is supposed to be
x = fminimax(fun,x0,A,b,Aeq,beq,lb,ub)
Alan Weiss
MATLAB mathematical toolbox documentation
Matt J
2013-2-27
0 个投票
If your problem size isn't too large (you say it's "medium scale"), you could try a brute force approach. Since your feasible set consists of polygonal pieces, you could find try to find the vertices of all the polygons using
The piecewise linear objective has to be optimized at one of the vertices, so you could just search the values at all vertices to find the optimum.
类别
在 帮助中心 和 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!