how to do piecewise linear approximation

176 views
Skip to first unread message

lily ye

unread,
Apr 26, 2018, 8:15:37 AM4/26/18
to YALMIP
If cost of a generation is  :
 cost(t)=a*p(t)^2+b*p(t)
we can approximate it by a set of piecewise blocks,only if we know the cost of p_min&p_max.BUT  I'm confused  how to figure out the number of the blocks i need to replace the p(t),if there are 3 piecewise blocks totally ? can i use"implies"
i don't know how to code it..

Johan Löfberg

unread,
Apr 26, 2018, 8:33:13 AM4/26/18
to YALMIP

Johan Löfberg

unread,
Apr 26, 2018, 8:34:54 AM4/26/18
to YALMIP
but why are you using a pwa approximation of a convex quadratic cost? As long as you simply have that as an additive term in the objective, you will have a convex QP objective

lily ye

unread,
Apr 26, 2018, 9:26:03 PM4/26/18
to YALMIP
 "have that as an additive term in the objective" .  "That" means approximation or Quadratic cost? I've just learned  Yalmip less than  a month
Message has been deleted

lily ye

unread,
Apr 26, 2018, 11:34:34 PM4/26/18
to YALMIP
Thanks for your reply!
I see,So in my objective,I could type:
x=1:3:10; % 3 blocks in total
y=ax^2+bx;
sdpvar Cost P %P is the power of one generation at time k;
Cost=interp1(x,y,'linear',P);
is that rihgt?

Johan Löfberg

unread,
Apr 27, 2018, 2:35:53 AM4/27/18
to YALMIP
if your objective is ...+x^2+..., you can just as well keep that quadratic term in the objective, as it is convex and solvers such as cplex/gurobi/mosek are MIQP solvers and thus have no problems with convex quadratic expressions

Johan Löfberg

unread,
Apr 27, 2018, 2:38:08 AM4/27/18
to YALMIP
If you absolutely want to use a linear approximation of the quadratic cost, yes. My guess is the cost is convex though (a>=0) hence there is no reason to at least try to solve it as a MIQP before approximating it as a MILP

lily ye

unread,
Apr 27, 2018, 3:36:48 AM4/27/18
to YALMIP
If my objective is ax^2+bx+c,there is no need to transfer it?
If my constraints not only contain quadratic cost,but there is also standard SOCP,must I use a linear approximation?
MIQP+SOCP what kind solver can I use? How about MILP+SOCP?

Johan Löfberg

unread,
Apr 27, 2018, 3:47:44 AM4/27/18
to YALMIP
if a>=0, that is a convex quadratic and thus most integer solvers can deal with that

The second question makes no sense as you talk about cost in the constraint.

Mosek/Gurobi/CPLEX can all solve mixed-integer SOCP, which covers linear/convex quadratic/socp-representable constraints and costs
Reply all
Reply to author
Forward
0 new messages