help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] [Fwd: GLPK Mathprog model]


From: Xypron
Subject: Re: [Help-glpk] [Fwd: GLPK Mathprog model]
Date: Thu, 27 Jan 2011 20:14:38 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20101123 SeaMonkey/2.0.11

Hello Alan,

please, register for the help list to have your mail directly received, see
http://lists.gnu.org/mailman/listinfo/help-glpk

> var f{k in 1..K} = sum{i in 1..I, j in 1..J} x[i,j,k]*w[i] ;

In AMPL this is called a defined variable. The statement does not declare a structural variable but works like kind of a macro. Each occurance of f[k] will be replaced by sum{i in 1..I, j in 1..J} x[i,j,k]*w[i] (see Robert Fourer, David M.Gay, Brian W. Kerninghan, "AMPL - A modeling Language for Mathematical Programming", 2nd ed, p. 131).

This is not possible in GMPL.

You could use a structural variable

var f{k in 1..K};

and a constraint

s.t. c1{k in 1..K} :
  f[k] = sum{i in 1..I, j in 1..J} x[i,j,k]*w[i];

But this may render your problem harder to solve.

Best regards

Xypron


-------- Forwarded Message --------
From: Alan Zinober<address@hidden>
To: address@hidden
Subject: GLPK Mathprog model
Date: Thu, 27 Jan 2011 09:27:21 +0000


The model below (only relevant parts included) is taken from a working
AMPL model program
that is solved running in AMPL.

I am trying to run the same problem using GLPK (Mathprog) but there is
an error reported on the last line below.

According to the guidance manual the text below seems fine. Any advice
will be most welcome.

GLPK "report":

Reading model section from G-case7-a26Suli.txt...
G-case7-a26Suli.txt:47: expression following = has invalid type
Context: ...um { i in 1 .. I , j in 1 .. J } x [ i , j , k ] * w [ i ] ;
MathProg model processing error

     Alan

#---------------------------------------PARAMETERS
param I;
param J;
param K;

param w{1..I};             # wt per type i pack

#---------------------------------------VARIABLES

var x{1..I, 1..J, 1..K}, binary;

var f{k in 1..K} = sum{i in 1..I, j in 1..J}  x[i,j,k]*w[i] ;





_______________________________________________
Help-glpk mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-glpk





reply via email to

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