[Top][All Lists]

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

Re: [Help-glpk] Strange Error with if/then/else

From: Leandro Barcelos
Subject: Re: [Help-glpk] Strange Error with if/then/else
Date: Sat, 5 Apr 2008 14:15:29 -0300


You can't put the variable in the test sentence of the if-then-else.

On Sat, Apr 5, 2008 at 2:13 PM, Leandro Barcelos <address@hidden> wrote:

maximize Anzahl : sum{i in PEOPLE} x[i];

That's the same.

The problem with your equation is that you can't put if-then-else in a linear equation


On Sat, Apr 5, 2008 at 10:36 AM, Jonathan Klein <address@hidden> wrote:

i havbe a very simple Problem like this:

var x{i in PEOPLE} binary;
maximize Anzahl : sum{i in PEOPLE} (if x[i]==1 then 1 else 0);
set LEUTE:=Hans Joachen Peter Klaus;

And i get the Error: operator preceding == has invalid type

I know, that this problem doesn't make sense, but i have i somewhat more complex problem in wich i get the same error:

# Berufsinformationstag

set STUDENT;#i
set CHOICE;#j
set COURSE;#k
set GROUP;#l

param Student_Choice {i in STUDENT, j in CHOICE} symbolic in COURSE;# Welcher Schüler welche Wünsche hat
#param Course_Minimum {k in COURSE};#Wie viele Schüler eine Veranstaltung minimal braucht
#param Course_Maximum {k in COURSE};#Wie viele Schüler eine Veranstaltung haben darf
param Satisfaction {j in CHOICE};#für jeden wunsch die Menge, wie glücklich er ist

var TimeTable{k in COURSE, l in GROUP}, binary;
var StudentDistribution {i in STUDENT, k in COURSE, l in GROUP} binary ;

# wenn sich der schüler die aktuelle veranstaltung wünscht und in der veranstaltung in dieser gruppe ist
maximize z: sum{i in STUDENT, l in GROUP, k in COURSE, j in CHOICE}
                       (if 1==StudentDistribution[i,k,l]
                       and k==Student_Choice[i, j]
                       then Satisfaction[k] else 0);

So i have Students that are in different Courses, in 1 Course per Group. They coose 6 Courses and will be in 4 (1 in each group). If they are in a grout that the have choosen, they are happy.
So i have to check for every Choice of every Student in every Course in every Group if the student is in this course in this group and if he had choosen it. If so, he gets as much happiness as his choice had importance.

At the end i need to know form every Student in which courses he ist an which courses in which group have to take place, so i have choosen the binary variables.

I dont konw why the types should not match, because StudentDistribution ist binary, so i can only be 0 or 1 an Student_Choice has to be a COURSE.

I studiet the language reference manual for a long time and looked at many examples with if/then/else but i still have no idea what i'm doing wrong.

PS: I use C++ for 5 years now, but im relativly new to GNU MathProg :(

I would be very gald for every help.


Help-glpk mailing list

Leandro B. Barcelos

Leandro B. Barcelos
reply via email to

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