[Top][All Lists]

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

[Help-glpk] logic conditions in MathProg

From: Dedalus
Subject: [Help-glpk] logic conditions in MathProg
Date: Thu, 5 Feb 2004 05:41:55 -0500

I am a beginner in the field of LP, so please bear with me.

I read that in MathProg you can use the IF..THEN..ELSE condition.

More than that, I could see it used in several example programs.

However, when I try to use it, I have no success, so that I started 
thinking there must be something personal with it: why the IF condition 
works ok with everybody and not with me ? :)

I want to do a very simple thing: I want to sum the hours of a time 
slot only when a given employee is assigned to it.

this won't work:

WorkedHrs[e]= sum {s in Slots: Assignments[s]=e} Hours[e];

this won't work, too:

WorkedHrs[e]= sum {s in Slots} 0+ (if Assignments[s]=e then Hours[s] );

I get the error message

Reading model section from bernardi.mod...
bernardi.mod:44: operand preceding = has invalid type
Context: ...} : WorkedHrs [ e ] = sum { s in Slots : Assignments [ s ] =
Model processing error

The message disappears if I write

      WorkedHrs[e]= sum {s in Slots} Hours[s];

but naturally this is not what I want.

Declarations are given below.

Any help ?

Thank you

Duilio Foschi

PS I am aware that the model I wrote is not the classic one. I am 
trying to spare variables.

param LastDay > 0 integer; # Number of days in schedule
param LastEmployee > 0 integer; # Number of avaiable employees
param LastSlot > 0 integer; # Number of slots to fill

set Employees := 1..LastEmployee;
set Days := 1..LastDay;   # days of assignment
set Slots := 1..LastSlot;   

var Assignments {Slots} integer >=1;

param Hours {Slots} > 0; 
param Shifts {Slots} > 0; 

var WorkedHrs {e in Employees} >=0;

Free POP3/Web Email, File Manager, Calendar and Address Book

reply via email to

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