help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] piecewise linear function


From: Heinrich Schuchardt
Subject: Re: [Help-glpk] piecewise linear function
Date: Thu, 15 Feb 2018 21:21:20 +0100

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 <address@hidden> 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 address@hidden https://lists.gnu.org/mailman/listinfo/help-glpk

reply via email to

[Prev in Thread] Current Thread [Next in Thread]