Skip to main content

Non lineal not solving

Comments

2 comments

  • Official comment
    Simranjit Kaur
    Gurobi Staff Gurobi Staff
    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?.
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    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 use

    x = 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.