0

I am studying time scheduling problem solving with linear programming. I am reading paragraph 2.5 from this book (pages 32-35) and I am trying to solve it with Java and javailp-lp_solve.

long story short, I have a binary variable v(s,c,h) which takes value 1 if subject s is taught in classroom c in time slot h and 0 otherwise.

I have a question about a type of constraint that I cannot completely understand. For example, every instructor teaches at most one subject every hour (time slot)

enter image description here

where

enter image description here

There are two teachers teaching the subjects below:

enter image description here

I would like to ask: How do I develop this double summation, having 3 elements?

If I understood well, I've got to implement something like this

enter image description here

But what about h? What is its role, since there is no reference for it in summation? Having a variable with 3 elements, how should I implement it? I am completely lost here and I cannot even create the code. I would appreciate of you could explain to me what is going on here. Thank you in advance.

Vassilis De
  • 363
  • 1
  • 3
  • 21
  • 1
    The special sign befor the "h" means "for all". So you need to expand the calculation so that you iterate over all hours as well. So in principle you just have 3 for-loops to calculate the sum. The you return true in the sum is <= 1 and false otherwise. – Support Ukraine Mar 05 '15 at 12:10
  • And what's the difference between this and constraint a (page 33), which has for the same purpose a triple summation? – Vassilis De Mar 05 '15 at 12:14
  • Sorry - don't have the book... – Support Ukraine Mar 05 '15 at 12:16
  • I have a link for the book in my question – Vassilis De Mar 05 '15 at 12:17
  • The link doesn't work. I just get a stop sign and some letters (greek maybe) I don't understand. – Support Ukraine Mar 05 '15 at 12:18
  • It has a triple summation like ΣΣΣv(s,c,h) <= 1 (first Σ for s, second for c and third for h). s is from 1 to 8, c from 1 to 3 and h from 1 to 5 – Vassilis De Mar 05 '15 at 12:25
  • This seems more a Math question than programming. Anyway, the only difference I see is that s has limited range in your original post. In Math you can typically express the same thing in several ways. Using the "for all" notation is just an alternative to the Σ sign taking all values. If c can only take the values 1..3 then your original constrain could have been written with a single Σ sign for s and then both c and h after the "for all" sign. – Support Ukraine Mar 05 '15 at 12:34

1 Answers1

0

In equation above upside down A is a mathematical symbol for foreach or forall. In other words this has to be true foreach h. For coding this you need a top level loop of h values. So you will get a value of h in each loop and then inside that you need to create two loops: first for s (to retrieve subset of subjects) and then for c [this is pretty much aligned with your understanding].

Say if h={1,2} then there will be four constraints for cases:

  1. h=1 ohm=ohm1
  2. h=1 ohm=ohm2
  3. h=2 ohm=ohm1
  4. h=2 ohm=ohm2
abhiieor
  • 3,132
  • 4
  • 30
  • 47