set new constraint but got NotImplementedError
AnsweredHi,I have two question now
1.I had a problem implementing real world data in my model, seems like my model refuse to build second launch station but I didn't set a constraint for it. This is my code.
The data I use in this model are three kinds of places where people living, and candidate point of two different places.
I set my E (which is fly range) to 25 and I want to go less, but it's not working, it only works when I set my E to 40 or higher, and I noticed that seems like the model just restrict my sum of
y[i]
variable to 1, I said that because I've read the data, the model should be fine if it just build more launch station, the objective value will be bigger, but there's going to get a solution.
but it just refuse to do it, but I might be wrong.
And here comes the second question, after all that, I decided to add a constraint,
"there should be at least one or more launch station "
m.addConstr((sum(y[i] for i in facility2)>=1),name="at least one")
but the outcome remains the same, so I modified a bit, just to test
m.addConstr((sum(y[i] for i in facility2)>1),name="at least one")
and now the outcome is
NotImplementedError
I don't know if it's my model or code goes wrong, or maybe my data? I can put my data here if anyone needed.
Thanks.
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi,
Mathematical solvers like Gurobi do not support strict inequality constraints. A workaround would be to introduce a small tolerance, i.e., set the constraint to something like \(\text{term} \geq 1 + 10^{-4}\).
Best regards,
Jaromił1 -
Hi,
Please see this article about why Gurobi does not allow strict inequality constraints. This is why you are seeing this error message.
To verify whether your model actually corresponds to the mathematical formulation, we recommend writing out the LP file. You can do this via model.write("mymodel.lp").
I hope that helps.
Cheers,
Matthias0 -
I tried
m.write("project_412.lp")
it only showed
Warning: Q constraint 0 doesn't have a name
Warning: linear constraint 1 and linear constraint 2 have the same name "onlyone"what is Q constraint?
All of my constraints has different names, what does the second warning try to tell me?
0 -
The term Q constraint refers to a quadratic constraint. The second warning states that two linear constraints have the same name. It seems like you are using non-ascii charactesr to name your constraints. This may cause trouble. Please try using standard ascii characters without whitespaces when naming your variables and constraints.
0
Post is closed for comments.
Comments
5 comments