Hi,
as I wrote in
stackoverflowall dimensions should be set in an array so
{string} flights={"A1","A2"};
{string} workingstations={"W1","W2"};
tuple tup {
int sd ; //start time of bagage handling
int sh ; // start time of storage depletion
}
{tup} ttt = {};
tuple Starttime {
int elt; //earlist_starttime
int lst; //lastest_starttime
int ed; //end time of baggage handling
tup tt;
}
tup myt1=<3,4>;
tup myt2=<4,5>;
Starttime S[flights]=[<1,2,3,myt1>,<1,2,9,myt2>];
Starttime S2[flights][workingstations]=[[<1,2,3,myt1>,<1,2,9,myt2>],[<1,2,3,myt1>,<1,2,9,myt2>]];
execute PREPROCESSING {
//initialize tup
var t1 = ttt.add(1,11);
var t2 = ttt.add(2,22);
writeln(ttt);
writeln(S);
writeln(S2);
}
//variables
dvar int+ sd ;
dvar int+ sh;
{Starttime} unionS2=union(i in flights,w in workingstations) {S2[i][w]};
dvar boolean x[flights][workingstations][t2 in unionS2];
subject to
{
forall(i in flights,w in workingstations) sum( t2 in unionS2) x[i][w][t2]== 1;
}
works fine
regards
------------------------------
[Alex] [Fleischer]
[EMEA CPLEX Optimization Technical Sales]
[IBM]
------------------------------
Original Message:
Sent: Wed November 25, 2020 07:46 AM
From: Siwar Moumni
Subject: Decision variable indexing by a Set of type Tuple
HELLO Every bodyi am a new in Cplex , so i want to know how to declare a subset included in a set . i have a S_i : the set of flight i's Feasible start time tuples. this solution gives by Sir Alex Fleischer , but i don't know
{string} flights={"A1","A2"};{string} workingstations={"W1","W2"};tuple tup {int sd ; //start time of bagage handling int sh ; // start time of storage depletion}{tup} ttt = {};tuple Starttime { int elt; //earlist_starttime int lst; //lastest_starttime int ed; //end time of baggage handling tup tt; } tup myt1=<3,4>; tup myt2=<4,5>; Starttime S[flights]=[<1,2,3,myt1>,<1,2,9,myt2>];Starttime S2[flights][workingstations]=[[<1,2,3,myt1>,<1,2,9,myt2>],[<1,2,3,myt1>,<1,2,9,myt2>]];execute PREPROCESSING {//initialize tup var t1 = ttt.add(1,11); var t2 = ttt.add(2,22); writeln(ttt); writeln(S); writeln(S2); }//variablesdvar int+ sd ;dvar int+ sh;subject to{ }
------------------------------
Siwar Moumni
------------------------------
#DecisionOptimization