[Top][All Lists]

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

Re: [Help-glpk] MathProg error

From: Brady Hunsaker
Subject: Re: [Help-glpk] MathProg error
Date: 05 Feb 2004 09:55:00 -0500

On Wed, 2004-02-04 at 20:06, Duilio Foschi wrote:
> the aim of the following code should be clear
>       WorkedHrs[n]= sum {s in Slots: Assignments[s]=n} Hours[s];
> The relative declarations are enclosed below.
> Unfortunately, the compiler gives a weird error message


I believe the problem is that you are using variables in the conditional
statement.  The conditional statement is evaluated when the instance (by
which I mean a specific set of variables and constraints) is
constructed--not when the instance is solved.  That is, your model is
trying to use information about the solution to decide how to write the
constraints.  This is not possible; the instance must be created before
any attempt is made to solve it.

I would recommend using 0,1 variables instead of your current integer
Assignments variables.  For example, something like 

var Assign { Slots, Nurses } binary;
var WorkedHrs { Nurses };

subject to CountHours {n in Nurses} := 
    WorkedHrs[n] = sum {s in Slots} Assign[s,n] * Hours[s];

This may not be exactly what you want and I haven't tested to even see
if my syntax is correct, but this is one approach you could try.


Brady Hunsaker
Assistant Professor
Industrial Engineering
University of Pittsburgh

reply via email to

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