Non lineal not solving
Hi,
I want to model the following problem:
There are n+1 workers in an office. Find a nonlinear model to find the squared office with the smallest perimeter. Each worker needs to keep a minimun distance of 2 meters from others workers.
The program is not working. Is the modeling wrong or am I missing something in the code? How can I improve it?
Thank you.
-
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 Alfredo,
Could you elaborate on what you mean as "not working"?
I was able to successfully run the code with Gurobi 9.0.2 and Python 3.7.6 using Spyder. I can see that you are using Python 3.8.2.Are you using conda? There is currently no conda package for Python 3.8 for Gurobi 9.0.2. Keep in mind that when installing Anaconda, Python 3.7 is still the default Python version. Apart from that, you can install Gurobi in Python 3.8 via python setup.py install executed from the Gurobi home directory to be able to use Python 3.8.
Regarding the code:
You don't have to create a separate list for your variables \(x,y\).
You can just directly add the variables to the model and still be able to access them when you usex = model.addVars(n,lb=0,ub=100,vtype=GRB.CONTINUOUS,name='X')
y = model.addVars(n,lb=0,ub=100,vtype=GRB.CONTINUOUS,name='Y')Note that I added upper bounds for the variables, as it is recommended to add finite lower and upper bounds when solving quadratic optimization models.
Additionally, you don't need the model.update() line as this is done by
model.update()
and you currently don't want to retrieve data/attributes from the model before optimizing.Best regards,
Jaromił0
Post is closed for comments.
Comments
2 comments