AttributeError: 'gurobipy.Model' object has no attribute 'setObjectiveN'

1,666 views
Skip to first unread message

David Smith

unread,
Feb 26, 2018, 2:45:00 PM2/26/18
to Gurobi Optimization
I'm running Gurobi 7.0.1 on Python and can't get multiobjective optimisation working. Has anyone else had the same problem and knows a way around it? Maybe there's an easy way of defining multiple objectives w/o using the `model.setObjectiveN()` function.


        import gurobipy as GRB

        model = GRB.Model("MultObj")
        set_params(model)
        x = model.addVars(x_dict.keys(),
                          lb=0.0, ub=1.0, vtype="C", name="x")
        y = model.addVars(y_dict.keys(),
                          vtype="B", name="y")
        z = model.addVars(z_dict.keys(),
                          vtype="B", name="z")
        obj1 = x.prod(x_dict) + y.prod(y_dict)
        model.setObjectiveN(obj1, 1, 2)
        model.setObjectiveN(z.sum(), 2, 2)


Where `set_params()` just sets some parameters for the optimisation (from tuning) and the `*_dicts` are just `{(index): obj_coeff}`.

The full error is regarding the `model.setObjectiveN()` function:

    File "model.pxi", line 281, in gurobipy.Model.__getattr__
    (../../src/python/gurobipy.c:49637)
    File "model.pxi", line 1418, in gurobipy.Model.getAttr 
    (../../src/python/gurobipy.c:62715)
    File "model.pxi", line 3724, in gurobipy.Model.__getattrinfo 
    (../../src/python/gurobipy.c:94154)
    AttributeError: 'gurobipy.Model' object has no 'setObjectiveN'


Cheers!

Renan Garcia

unread,
Feb 26, 2018, 2:46:22 PM2/26/18
to gur...@googlegroups.com
Please upgrade to the latest version of Gurobi, which is currently 7.5.2. The Model.setObjectiveN() was introduced in version 7.5.

--

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

Reply all
Reply to author
Forward
0 new messages