help-glpk
[Top][All Lists]
Advanced

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

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


From: glpk xypron
Subject: Re: [Help-glpk] Error: expression following = has invalid type
Date: Wed, 14 Jul 2010 22:39:33 +0200

Hello Diego,

> var sp{s in S, p in P} = sum{c in C} (sc[s,c] * sum{r in R} x[c,p,r]);

variables cannot be set in the declaration. Instead you can create
a constraint, e.g.

var sp{s in S, p in P};

maximize my_objective : 
  sum{s in S, p in P} sp[s,p];

s.t. my_constraint{s in S, p in P} :
  sp[s,p] = sum{c in C} (sc[s,c] * sum{r in R} x[c,p,r]);

If sp, sc, x are parameters, you can write:
param sp{s in S, p in P} := sum{c in C} (sc[s,c] * sum{r in R} x[c,p,r]);

For details of the syntax and further examples refer to the
documentation in 
doc/gmpl.pdf of the source distribution which is available at
ftp://ftp.gnu.org/gnu/glpk/glpk-4.44.tar.gz

You can find additional information on
http://en.wikibooks.org/wiki/GLPK

Best regards

Xypron



-------- Original-Nachricht --------
> Datum: Wed, 14 Jul 2010 16:54:02 -0300
> Betreff: [Help-glpk] Error: expression following = has invalid type

> Hello,
> 
> I have a variable  "x{c in C, p in P, r in R}, binary"  that holds 1
> if course c is taught in room s at period p and 0 otherwise.
> The param "sc{s in S, c in C}" holds 1 if student s attend the course
> c and 0 otherwise.
> 
> I need to create other variable "sp{s in S, p in P}" that will be a
> function of x. This variable will hold 1 if student s have a course at
> period p and 0 otherwise.
> 
> I wrote this var statement:
> 
> var sp{s in S, p in P} = sum{c in C} (sc[s,c] * sum{r in R} x[c,p,r]);
> 
> but i get this error: expression following = has invalid type.
> 
> how can i correct this?
> 
> Thanks in advance

-- 
GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.  
Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl



reply via email to

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