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 15:07:14 +0300

>> 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) = ... ;

> ( #39;else 0 #39; is used by default, so it can be omitted).

> Thank you for the answer.

> I see your point but could not figure out how to implement it when
> there are several links between random source nodes and random
> destination nodes. Please note that, each element in a subset of
> sources is not connected to each element in the subset of
> destinations, either. 
> (if it was like that I could do: 
> set ssubset within source;
> set dsubset within destination;
> set link within (ssubset cross dsubset); and it could be easy to
> check the DOMAIN then but this is not the situation)

> So, do I understand right that I have to keep a list of all the
> links in a set somehow and check if the variable is referencing to
> those or referencing to something else?

If you are able to specify a "sparse" variable that requires
specifying its domain, you should be able to specify its domain as
a separate set. Right?

For example (from your previous message):

var shipmWtoD {p in product, w in warehouse, d in demandpt, 1..T:
       MilageWhsDpt[w,d]>0} >=0, default 0.0;

You could specify the domain of shipmWtoD as follows:

set DDD := setof{p in product, w in warehouse, d in demandpt,
              t in 1..T: MilageWhsDpt[w,d]>0} (p,w,d,t);

and then use it to specify the variable itself:

var shipmWtoD{(p,w,d,t) in DDD}, >= 0;

DDD then would allow you checking if some member of shipmWtoD is
not defined to avoid referencing it:

s.t. foo: sum{...} (if (p,w,d,t) in DDD then shipmWtoD[p,w,d,t]
                    else 0) >= 0;

However, I would like to repeat that the mathprog translator creates
only those elemental variables, which are actually referenced from other
model statements. So there is not much sense to have "sparse" vars.


Andrew Makhorin





reply via email to

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