help-glpk
[Top][All Lists]

## Re: [Help-glpk] Error: expression following = has invalid type

 From: Andrew Makhorin Subject: Re: [Help-glpk] Error: expression following = has invalid type Date: Thu, 28 Jul 2011 02:58:49 +0400

```> I am having a similar issue, but my original setup was using
>  parameters.  I can not get the solver to use my primary variable with
>  a numeric function (mod and abs in my case).  Here is a subset of my
>  model:
> param Def_SPk integer default 1;
> set R;
> set I;
> set T;
> param S{i in I} > 0 default Def_SPk;
> var p{i in I, r in R, t in T} integer >=0;
> s.t. StdPack{i in I} :
>        s[i] = sum{r in R, t in T}(p[i,r,t] mod S[i]) ;
> I do not see an issue with using variable p this way – what am
>  I missing?  Thanks,

You cannot use a variable as an argument to the mod function, because this
leads to a non-linear constraint, that is not allowed in glpk.

One way to model the constraint StdPack is the following:

var q{i in I, r in R, t in T}, integer, >= 0;
/* quotient: q[i,r,t] = p[i,r,t] div S[i] */

var r{i in I, r in R, t in T}, >= 0, <= S[i]-1;
/* remainder: r[i,r,t] = p[i,r,t] mod S[i] */

s.t. foo{i in I, r, in R, t in T}:
p[i,r,t] = S[i] * q[i,r,t] + r[i,r,t];

s.t. StdPack{i in I} :
s[i] = sum{r in R, t in T}r[i,r,t] ;

```