Originally posted by: KeerthivasanC
I have the following data for a scheduling problem:
df_project
|
Project
|
Teams Needed
|
|
A
|
6
|
|
B
|
4
|
|
C
|
5
|
|
D
|
2
|
|
E
|
1
|
df_timeperiod
|
Time Period
|
Max. Teams Allowed
|
|
TP1
|
2
|
|
TP2
|
4
|
|
TP3
|
6
|
|
TP4
|
8
|
Here is what I have coded so far:
project = []
project = list(df_project['Project'])
TP1 = m.integer_var_dict(name = "TP1",keys=project)
TP2 = m.integer_var_dict(name = "TP2",keys=project)
TP3 = m.integer_var_dict(name = "TP3",keys=project)
TP4 = m.integer_var_dict(name = "TP4",keys=project)
m.add_constraint(TP1['A'] + TP2['A'] + TP3['A'] + TP4['A'] == 6)
m.add_constraint(TP1['B'] + TP2['B'] + TP3['B'] + TP4['B'] == 4)
m.add_constraint(TP1['C'] + TP2['C'] + TP3['C'] + TP4['C'] == 5)
m.add_constraint(TP1['D'] + TP2['D'] + TP3['D'] + TP4['D'] == 2)
m.add_constraint(TP1['E'] + TP2['E'] + TP3['E'] + TP4['E'] == 6)
m.add_constraint(TP1['A'] + TP1['B'] + TP1['C'] + TP1['D'] + TP1['E'] == 2)
m.add_constraint(TP2['A'] + TP2['B'] + TP2['C'] + TP2['D'] + TP2['E'] == 4)
m.add_constraint(TP3['A'] + TP3['B'] + TP3['C'] + TP3['D'] + TP3['E'] == 6)
m.add_constraint(TP4['A'] + TP4['B'] + TP4['C'] + TP4['D'] + TP4['E'] <= 8)
I also want to make sure that [TP1[i] for i in project] takes values from this list - [0,0.5,1,1.5,2] given TP1 can't have more than 2 teams assigned to it. set_domain is only possible for integer variables as I understand. So, is there a way to do this?
Coming to my main question, how I can generate a large number of feasible solutions to this problem? I would appreciate a code snippet which uses solution pool to do this.
Thanks.
#CPLEXOptimizers#DecisionOptimization