help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] sparse variables?


From: Andrew Makhorin
Subject: Re: [Help-glpk] sparse variables?
Date: Mon, 25 Feb 2008 09:30:53 +0300

> Is it possible to specify sparse variables in GMPL?
> Such as:
> var shipmWtoD {p in product, w in warehouse, d in demandpt, 1..T:
> MilageWhsDpt[w,d]>0} >=0, default 0.0;

Yes, it is possible. All model objects in mathprog are sparse by
definition, because symbolic subscripts are allowed.

> which generates the syntax error:
> <PRE>
> Reading model section from Model.mod...
> Model.mod:75: syntax error in variable statement
> Context: ...demandpt , 1 .. T : MilageWhsDpt [ w , d ] > 0 } >= 0 ,
> default
> Model processing error
> </PRE>

The 'default' keyword cannot be used in the variable statement.

> Here, MilageWhsDpt[w,d] is a sparse parameter denoting the distance
> between relevant nodes. defined as
> <PRE>
> param MilageWhsDpt default 0.0    :=
> [WhsA,DptB]    1
> [WhsA,DptC]    1
> [WhsB,DptE]    1;
> </PRE>

> I think,  #39;default #39; keyword cannot be used with variables
> but then removing the default keyword makes glpsol look for some
> shipmWtoD variables which depend on some MilageWhsDpt values which is
> 0.0 due to the sparse nature of that data.

> Error:
> Model.mod:127: shipmWtoD[Prod1,WhsA,DptE,1] out of domain
> Model processing error

You should not refer to members of a variable which are not in its
domain. To avoid such references you need to add corresponding
conditions everywhere you refer to the variable. For example:

s.t. foo{i in I}: sum{j in J, k in K}
     (if (i,j,k) in DOMAIN then x[i,j,k] else 0) = ... ;

('else 0' is used by default, so it can be omitted).

> What I would prefer is that GMPL does not create those variables at
> all. Is this possible?

The mathprog translator does exactly that that you say, i.e. it creates
only those elemental variables, which are actually referenced from other
model statements. For example, if you specify

var x{i in 1..1000};

and then use x in the constraint:

s.t. foo: sum{i in 11..15} x[i] = 1;

only five elemental variables x[11], ..., x[15] will be actually
created and added to the problem object on passing it to the solver.






reply via email to

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