Re: piecewise linear function

"Heinrich Schuchardt" <[email protected]>
Newsgroups gmane.comp.gnu.glpk
Message-ID <trinity-9b36de6f-2a3a-446c-9821-2f8f22ff0e2f-1518726080234@msvc-mesg-gmx023>
Hello Giovanni,

please, read doc/gmpl.pdf which comes with the GLPK source.

The <<>> syntax may exist in AMPL but it does not exist in GMPL.

Depending on your piecewise linear function being concave or convex you can replace it with some linear constraints or you will have to introduce extra binary variables.

Best regards

Heinrich

Am 15.02.18, 21:10, Giovanni Di Stasi <[email protected]> schrieb:

I am trying to use such functions but I get a syntax error.
In particular, this is my program, taken by the following book chapter:

https://ampl.com/BOOK/CHAPTERS/20-piecewise.pdf

set ORIG; # origins

set DEST; # destinations

param supply {ORIG} >= 0; # amounts available at origins

param demand {DEST} >= 0; # amounts required at destinations

check: sum {i in ORIG} supply[i] = sum {j in DEST} demand[j];

param rate1 {i in ORIG, j in DEST} >= 0;

param rate2 {i in ORIG, j in DEST} >= rate1[i,j];

param rate3 {i in ORIG, j in DEST} >= rate2[i,j];

param limit1 {i in ORIG, j in DEST} > 0;

param limit2 {i in ORIG, j in DEST} > limit1[i,j];

var Trans {ORIG,DEST} >= 0; # units to be shipped

minimize Total_Cost: sum {i in ORIG, j in DEST}

<<limit1[i,j], limit2[i,j];

rate1[i,j], rate2[i,j], rate3[i,j]>> Trans[i,j];

subject to Supply {i in ORIG}:

sum {j in DEST} Trans[i,j] = supply[i];

subject to Demand {j in DEST}:

sum {i in ORIG} Trans[i,j] = demand[j];

When I try to make glpk parse it, I get the following error:

glpsol --model glpk/Test --data /tmp/DATAg5ZQ0L -w /tmp/OUTXlm0ST

GLPSOL: GLPK LP/MIP Solver, v4.61

Parameter(s) specified in the command line:

--model glpk/Test --data /tmp/DATAg5ZQ0L -w /tmp/OUTXlm0ST

Reading model section from glpk/Test...

glpk/Test:14: syntax error in expression

Context: ...>= 0 ; minimize Total_Cost : sum { i in ORIG , j in DEST } <

MathProg model processing error

I really have no clue as of now.

Thanks

_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk

_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.