piecewise linear for minimizing concave

492 views
Skip to first unread message

renan

unread,
Dec 10, 2010, 7:07:20 PM12/10/10
to AMPL Modeling Language
hi Robert,

one of my constraint deals with discounts so i plan to apply the
piecewise but i cant see any data and model examples in the book
dealing with minimizing a concave... do you have some reference there
about this?

im confused about the syntax of the piecewise when its already as a
constraint and not as an objective?

need your help badly,

thanks very much Rob,

Renan

Paul

unread,
Dec 10, 2010, 10:32:38 PM12/10/10
to AMPL Modeling Language
Minimizing a concave piecewise linear function can be done using
binary variables. Perhaps the second half of
http://orinanobworld.blogspot.com/2010/10/piecewise-linear-functions-in-math.html
(dealing with economies of scale) will shed some light. If your
piecewise linear function is discontinuous, see
http://orinanobworld.blogspot.com/2010/12/modeling-all-units-discount.html.

/Paul

Robert Fourer

unread,
Dec 11, 2010, 12:52:29 AM12/11/10
to am...@googlegroups.com, renan
You can use a piecewise-linear function in any AMPL objective or constraint.
There have to be no variables in the lists of slopes and breakpoints that
come between << and >>, however. And any other terms in the objective and
constraint have to be linear in the variables. Except in a few special
cases (such as minimizing a convex function) AMPL will automatically convert
the piecewise-linear terms to linear terms involving supplementary integer
variables, which CPLEX will handle appropriately.

Putting a variable following "if" in an if-then-else expression will also
create a nonlinear constraint that will be rejected by CPLEX.

Bob Fourer
4...@ampl.com

> -----Original Message-----
> From: renan [mailto:renan...@yahoo.com]
> Sent: Friday, December 10, 2010 1:55 PM
> To: Robert Fourer
> Subject: Re: about discounting
>
> how can i linearize this constraint because CPLEX said that my model
> contains nonquadratic non-linear constraint
> this is the part of the model
>
> var TOTCOST{c in CAMPAIGN}=sum{(i,j,k) in ROUTES}
> cost[i,j,k]*insertion[i,j,k,c];
> var COUNT{c in CAMPAIGN}=sum{(i,j,k) in ROUTES}insertion[i,j,k,c];
>
> var DISQTY1{c in CAMPAIGN}=if COUNT[c]>=limit1 then TOTCOST[c]*disc1;
> var DISQTY2{c in CAMPAIGN}=if COUNT[c]>=limit2 then TOTCOST[c]*disc2
> else DISQTY1[c];
>
> subject to BUDGET{c in CAMPAIGN}:
> TOTCOST[c]-(DISQTY1[c]+DISQTY2[c])
> <=budget[c];
>
> thanks
> renan
>

renan

unread,
Dec 13, 2010, 9:12:36 PM12/13/10
to AMPL Modeling Language
hi there paul,

i read the material you gave me... what's seemed wrong with my ampl?
can you please check

my decision variable is insertion[i,j,k,u]

can you please check if this is consistent with the formulas explained
in your material...

set QTYBREAK;
var break {a in QTYBREAK}>=0, binary;
param limit{a in QTYBREAK};
ADDCONST1:sum {a in QTYBREAK} break[a]=1;
ADDCONST2{a in QTYBREAK): limit[a]*break[a]<= sum{(i,j,k) in ROUTES,c
in CAMPAIGN}insertion[i,j,k,c]
<=limit[a+1]*break[a]+upper[a](1-break[a]);
ADDCONST3{a in QTYBREAK): rate[a] >=sum{(i,j,k) in ROUTES,c in
CAMPAIGN}slope[a]*insertion[i,j,k,c]-limit[a]*(1-break[a]);

ampl said that there are syntax errors in first line of ADDCONST2 and
in ADDCONST3...

please help me with this paul... i just need to finish this within
this week...

thanks you paul;


On Dec 10, 7:32 pm, Paul <paul_ru...@att.net> wrote:
> Minimizing a concave piecewise linear function can be done using
> binary variables.  Perhaps the second half ofhttp://orinanobworld.blogspot.com/2010/10/piecewise-linear-functions-...
> (dealing with economies of scale) will shed some light.  If your
> piecewise linear function is discontinuous, seehttp://orinanobworld.blogspot.com/2010/12/modeling-all-units-discount....
>
> /Paul

Paul

unread,
Dec 19, 2010, 5:29:36 PM12/19/10
to AMPL Modeling Language
On Dec 13, 9:12 pm, renan <renanblu...@yahoo.com> wrote:

> ADDCONST2{a in QTYBREAK):  limit[a]*break[a]<= sum{(i,j,k) in ROUTES,c
> in CAMPAIGN}insertion[i,j,k,c]
>                         <=limit[a+1]*break[a]+upper[a](1-break[a]);
> ADDCONST3{a in QTYBREAK):       rate[a] >=sum{(i,j,k) in ROUTES,c in
> CAMPAIGN}slope[a]*insertion[i,j,k,c]-limit[a]*(1-break[a]);
>
> ampl said that there are syntax errors in first line of ADDCONST2 and
> in ADDCONST3...
>

AMPL only understands double constraints (A <= B <= C) in one line if
A and C are constants or parameters. The simple solution is to split
ADDCONST2 into two constraints ADDCONST2a and ADDCONST2b, and the same
for ADDCONST3.

/Paul
Reply all
Reply to author
Forward
0 new messages