Originally posted by: **ClaraD**

Thank you Alex,

I had already looked at this example that you provided. I've combined this example with another one you wrote about tuples:https://www.ibm.com/developerworks/community/forums/html/topic?id=9748cb9c-fa58-471a-8f9b-fba546df609b&ps=25

I am now trying to adapt my code to see if by saving the data in tuples I can find a solution. I am confident that this is the good way to go, thanks for pointing me in this direction.

Regards,

Clara

PS: Just in case it's useful to someone I'm gonna leave the code about the stochastic buses with tuples here:

int nbKids=300;

{int} nbKidsScenarii={nbKids+i*10 | i in -10..2};

float proba[nbKidsScenarii]=[ 1, 1, 2, 2, 2 ,3 ,3 ,4, 5 ,10 ,50 ,10, 7];

assert sum(s in nbKidsScenarii) proba[s]==100; // total probability is 100

tuple bus{

key int nbSeats;

float cost;}

// This is a tuple set

{bus} buses={<40,500>,<30,400>};

// asserts help make sure data is fine

assert forall(b in buses) b.nbSeats>0;

assert forall(b in buses) b.cost>0;

float costIncreaseIfLastMinute=1.1;

// number of buses booked in advance

// decision variable array

dvar int+ nbBus[buses];

// number of buses booked at the last minute which is far more expensive

// we call those recourse decision

dvar int+ nbBusonTop[buses][nbKidsScenarii] ;

minimize

sum(b in buses) b.cost*nbBus[b]

+

1/100*costIncreaseIfLastMinute*

sum(a in nbKidsScenarii,b in buses) proba[a]*b.cost*(nbBusonTop[b][a]);

subject to

{

forall(a in nbKidsScenarii)

(sum(b in buses) b.nbSeats*(nbBus[b]+nbBusonTop[b][a]))>=a;

}

Results:

nbBus = [6

0];

nbBusonTop = [[0 0 0 0 0 0 0 0 1 0 0 1 2]

[0 0 0 0 0 1 1 1 0 2 2 1 0]];

#DecisionOptimization#OPLusingCPLEXOptimizer