On Jun 15, 2017, at 2:06 PM, Nitesh Sood <nites...@gmail.com> wrote:
Can anybody help me with the following constraint:
scenarios = [1, 2, 3, 4, 5] this is "I"
scenarios_2 = len(scenarios) + 1 this is "I + 1"
#Currently the decision variables looks like this for the x
x_decisions = {}x_matrix = []for i in range(scenarios_2):i_column = []for j in range(scenarios_2):if i != j:x_decisions[i] = model.addVar(vtype = GRB.BINARY, name = str(i))x_column.append(x_decisions[i])
else:
x_decisions[i] = 0
x_column.append(x_decisions[i])x_matrix.append(y_column)
#Currently the first constraint looks like this:
for j in range(scenarios_2):for i in range(scenarios_2):if j != i:model.addConstr(quicksum(y_matrix[j][i] for s in range(scenarios)) == 1, name = ("first_constraint")I have difficulties to understand how to implement the above mentioned constraint.--
---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+unsubscribe@googlegroups.com.
Hello,Thank you for the help.I'd like to ask does this work?
for i in range(scenarios_2):model.addConstr(quicksum(x_decisions_variables[i][j] for j in range(scenarios_2) if i != j ) == 1)I mean that i != j thing in the end?
torstai 15. kesäkuuta 2017 23.04.35 UTC+3 Edgar Alan Avila Gomez kirjoitti:
For i in....M.addconstr(quicksum([x[I,j] For j in ... If i != j]) == 1)For j in...................
El jun. 15, 2017 1:52 PM, "Nitesh Sood" <nites...@gmail.com> escribió:
--Decision variable matrix should look like the picture above. Other option is not to add zeros, thus then matrix would be I*(I+1), right? Would that work? I am really confused how to implement the decisions variables and constraints in this case. This is the last step in my model.
---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Where and why do I need [] symbol? Apparently gurobi accepts the constraints when I loaded them into model (didn't give any error but I might have errors when I run the model)I have actually additional questionHow do I implement following objective function:
--
---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
y = {} for r in S+1: for s in S+1: if r != s: y[r,s] = m.addVars(vtype = GRB.BINARY)
for r in S: m.addConstr(quicksum([y[r,s] for s in S+1 if r != s]) == 1) for s in S: m.addConstr(quicksum([y[r,s] for r in S if r != s]) == 1)
for r in range(1,S+1): for s in range(1,S+1): if r != s: m.addConstr((v_Var[r] - v_Var[s] + (S+1) * y[r,s]) <= S)
Link to my whole code:https://github.com/NiteshNSood/SSD_efficient/blob/master/SSD-testi.py
And I have difficulties to understand constraint #15, why I need [r+1][s+1] according to my instructor?I get same results with and without +1 (coincidence?). But since I am analyzing a lot of data and for looping 70-80 rounds (approximately this will take over 24 hours, about one to 30minutes for each round) and I will do this to different portfolio sets (5/10/12) I'd like to be sure that my model is flawless.# Longarela article, constraint (15)for r in scenarios:for s in scenarios:if r != s:model.addConstr(v_decision[r] - v_decision[s] + (S + 1) * y_decision[r+1][s+1]<= S, name = "constraint (15)")Link to article:See, (13) - (17).
perjantai 23. kesäkuuta 2017 10.41.47 UTC+3 Nitesh Sood kirjoitti:Hi,Whoah, it indeed resembles TSP model (I looked it up) (constraint 13, 14 Longarela's article).We did some test and the model gave expected values. But there is one thing where I am confused.If you can please (I am not sure am I allowed to copy article here), see the Longarela's article "A characterization of the SSD-Efficient Frontier of Portfolio Weights by Means of a Set of Mixed-Integer Linear Constraints"And my code looks like this:y_decision:y_decision = []for r in scenarios_2:#Creating empty list for the rowy_decision.append([])for s in scenarios_2:if r != s:y_decision[r].append(model.addVar(vtype = GRB.BINARY))else:y_decision[r].append(0)# Longarela article, constraint(13)for r in scenarios_2:model.addConstr(quicksum(y_decision[r][s] for s in scenarios_2 if r != s) == 1,name = "constraint (13)")# Longarela article, constraint(14)for s in scenarios_2:model.addConstr(quicksum(y_decision[r][s] for r in scenarios_2 if s != r) == 1,name = "constraint (14)")# Longarela article, constraint (15)for r in scenarios:for s in scenarios:if r != s:model.addConstr(v_decision[r] - v_decision[s] + (S + 1) * y_decision[r+1][s+1]<= S, name = "constraint (15)")I have one question regarding to that red text. My instructor asked me to put +1. But I don't understand why.I also can upload the whole code if it is needed.
sunnuntai 18. kesäkuuta 2017 21.00.52 UTC+3 Edgar Alan Avila Gomez kirjoitti:
The traditional way to do this is to use penalties on the i = j, then it simply iterates over all.9999 x xx 9999 xx x 9999Everything depends on how the problem is formulated, the best would be a literal interpretation.I do not know the model and what restrictions it has, however the last constraints and objective corresponds to the TSP model ... if I previously made decoding variables for i = j equal to zero, I should actually let them take any value, and everything will depend Of the penalties.
2017-06-17 3:12 GMT-06:00 Nitesh Sood <nites...@gmail.com>:
--
---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+un...@googlegroups.com.
--MII. Edgar Alan Ávila Gómez6671678109
--
---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.