-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If statement with constraint #49
Comments
Hi Gabriele,
An 'if' statement in python requires a Boolean value. If x and y are
variables, then 'x < y' is an expression (i.e., a variable true if and only
the constraint x < y is satisfied).
You can express an implication using the fact that variables with Boolean
domains are treated as 0/1 so
x <= z
enforce z to be true if x is true, and does nothing otherwise, which I
believe is what you mean to do:
model += (time_table[y,a] > time_table[e,a]) <= (time_table[e,a] >=
time_table[e,a] + exams_duration[e])
Cheers,
…On Mon, Jan 30, 2017 at 10:02 AM, barloccia ***@***.***> wrote:
Hi,
I'have a problem with a particularly constraint on my CSP problem.
My decision variable is a matrix, and i apply some constraints. One of
this is:
for e in range(exams):
for a in range(columns):
for y in range(exams):
if y != e:
if time_table[y,a] > time_table[e,a]: #time_table -> decision matrix
model += time_table[e,a] >= time_table[e,a] + exams_duration[e];
It doesn't work. I saw that the problem is within the IF statement. I
would like to know what i'm doing wrong. My problem is "scheduling exams in
a period with a number of rooms (moreover exams_duration, rooms_capacity
and so on)". I have to force that an exams scheduled in a particularly
time, start after the duration of the previous exams, if it exists.
thanks for the help,
Regards
Gabriele
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#49>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAVBC9qeIMa9vfCulXcr1TTc0mw3IuYiks5rXac8gaJpZM4LxKpm>
.
--
-Emmanuel
|
It works! thank you very much for the quick answer, very nice. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I'have a problem with a particularly constraint on my CSP problem.
My decision variable is a matrix, and i apply some constraints. One of this is:
for e in range(exams):
for a in range(columns):
for y in range(exams):
if y != e:
if time_table[y,a] > time_table[e,a]: #time_table -> decision matrix
model += time_table[e,a] >= time_table[e,a] + exams_duration[e];
It doesn't work. I saw that the problem is within the IF statement. I would like to know what i'm doing wrong. My problem is "scheduling exams in a period with a number of rooms (moreover exams_duration, rooms_capacity and so on)". I have to force that an exams scheduled in a particularly time, start after the duration of the previous exams, if it exists.
thanks for the help,
Regards
Gabriele
The text was updated successfully, but these errors were encountered: