Trees | Indices | Help |
|
---|
|
Methods for adding, querying, and modifying multiple objectives.
The methods in this interface can be used to add, query, and modify objectives in a specified problem. These objectives are used when multi-objective optimization is initiated.
For more details see the section on multi-objective optimization in the CPLEX User's Manual.
Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from |
Class Variables | |
sense = <cplex._internal._subinterfaces.ObjSense object at 0x7ff53e959510>
|
Properties | |
Inherited from |
Method Details |
Creates a new MultiObjInterface. The Multi-Objective interface is exposed by the top-level Cplex class as Cplex.multiobj. This constructor is not meant to be used externally.
|
Returns the absolute tolerance of an objective function. objidx must be an objective name or index. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(obj=[1.0 for i in range(3)]) >>> c.multiobj.get_abstol(0) 0.0 |
Returns the definition of an objective. Returns an objective definitions, where the definition is a list containing the following components: obj (a list containing the linear objective coefficients), offset, weight, priority, abstol, reltol (see set_definition). objidx is the name or index of the objective to be accessed. The optional begin and end arguments must be variable indices or names. Together, begin and end specify the range of objective function coefficients to be returned. By default, the linear objective coefficients of all variables from the problem will be returned (i.e., begin will default to the first variable index and end will default to the last variable index). See CPXmultiobjgetobj in the Callable Library Reference Manual for more detail. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> varind = list(c.variables.add(obj=[1.0, 2.0])) >>> c.multiobj.get_definition(0) [[1.0, 2.0], 0.0, 1.0, 0, 0.0, 0.0] |
Returns the linear coefficients of a set of variables. Can be called by four forms each of which requires an objidx argument. objidx must be an objective name or index.
Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add( ... obj=[1.5 * i for i in range(10)], ... names=[str(i) for i in range(10)]) >>> c.variables.get_num() 10 >>> c.multiobj.get_linear(0, 8) 12.0 >>> c.multiobj.get_linear(0, '1', 3) [1.5, 3.0, 4.5] >>> c.multiobj.get_linear(0, [2, '0', 5]) [3.0, 0.0, 7.5] >>> c.multiobj.get_linear(0) [0.0, 1.5, 3.0, 4.5, 6.0, 7.5, 9.0, 10.5, 12.0, 13.5] |
Returns the names of a set of objectives. There are four forms by which multiobj.get_names may be called.
See CPXmultiobjgetnames in the Callable Library Reference Manual for more detail. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> c.multiobj.set_definition(0, name='mo1') >>> c.multiobj.get_names(0) 'mo1' |
Returns the number of objectives in the problem. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> c.multiobj.get_num() 1 >>> indices = c.multiobj.set_num(2) >>> c.multiobj.get_num() 2 |
Returns the constant offset of an objective function. objidx must be an objective name or index. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(obj=[1.0 for i in range(3)]) >>> c.multiobj.get_offset(0) 0.0 |
Returns the priority of an objective function. objidx must be an objective name or index. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(obj=[1.0 for i in range(3)]) >>> c.multiobj.get_priority(0) 0 |
Returns the relative tolerance of an objective function. objidx must be an objective name or index. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(obj=[1.0 for i in range(3)]) >>> c.multiobj.get_reltol(0) 0.0 |
Returns the sense of all objective functions. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> c.multiobj.sense[c.multiobj.get_sense()] 'minimize' >>> c.multiobj.set_sense(c.multiobj.sense.maximize) >>> c.multiobj.sense[c.multiobj.get_sense()] 'maximize' >>> c.multiobj.set_sense(c.multiobj.sense.minimize) >>> c.multiobj.sense[c.multiobj.get_sense()] 'minimize' |
Returns the weight of an objective function. objidx must be an objective name or index. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(obj=[1.0 for i in range(3)]) >>> c.multiobj.get_weight(0) 1.0 |
Sets the absolute tolerance of an objective function. objidx must be an objective name or index. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(obj=[1.0 for i in range(3)]) >>> c.multiobj.set_abstol(0, 1e-6) >>> c.multiobj.get_abstol(0) 1e-06 |
Sets the definition of an objective. multiobj.set_definition accepts the keyword arguments objidx, obj, offset, weight, priority, abstol, reltol, and name. objidx is the name or index of the objective to be set. The objective index must be in the interval [0, Cplex.multiobj.get_num() - 1]. obj can be either a SparsePair or a list of two lists specifying the linear component of the objective. If not specified, the coefficients of every variable are set to 0.0.
offset is the offset of the objective to be set. If not specififed, the offset is set to 0.0. weight is the weight of the objective to be set. For the definition of the weight see the description of blended objective in the multi-objective optimization section of the CPLEX User's Manual. If not specified, the weight is set to 1.0. priority is the priority of the objective to be set. It must be a nonnegative integer. For the definition of the priority see the description of lexicographic objective in the multi-objective optimization section of the CPLEX User's Manual. If not specified, the priority is set to 0. abstol is the absolute tolerance of the objective to be set. If not specified, the absolute tolerance is set to 0.0. reltol is the relative tolerance of the objective to be set. If not specified, the relative tolerance is set to 0.0. name is a string representing the name of the objective to be set. If not specified, the objective name will default to None. See CPXmultiobjsetobj in the Callable Library Reference Manual for more detail. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> varind = list(c.variables.add(names=['x1', 'x2'])) >>> c.multiobj.set_definition( ... objidx=0, ... obj=cplex.SparsePair(ind=varind, val=[1.0, 2.0]), ... offset=0.0, ... weight=1.0, ... priority=0, ... abstol=1e-06, ... reltol=1e-04, ... name='obj1') >>> c.multiobj.get_definition('obj1') [[1.0, 2.0], 0.0, 1.0, 0, 1e-06, 0.0001] >>> c.multiobj.get_names(0) 'obj1' |
Changes the linear part of an objective function. Can be called by two forms each of which requires an objidx argument. objidx must be an objective name or index.
Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(names=[str(i) for i in range(4)]) >>> c.multiobj.get_linear(0) [0.0, 0.0, 0.0, 0.0] >>> c.multiobj.set_linear(0, 0, 1.0) >>> c.multiobj.get_linear(0) [1.0, 0.0, 0.0, 0.0] >>> c.multiobj.set_linear(0, '3', -1.0) >>> c.multiobj.get_linear(0) [1.0, 0.0, 0.0, -1.0] >>> c.multiobj.set_linear(0, [('2', 2.0), (1, 0.5)]) >>> c.multiobj.get_linear(0) [1.0, 0.5, 2.0, -1.0] |
Sets the name of an objective function. objidx must be an objective name or index. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> c.multiobj.set_num(3) >>> for i in range(3): ... c.multiobj.set_name(i, str(i)) >>> c.multiobj.get_names() ['0', '1', '2'] |
Sets the number of objectives in the problem instance. There is always at least one objective in the problem instance (indexed 0) thus numobj must be at least 1. If before calling this function there were more objectives in the instance than the specified numobj then the objectives whose index is >= numobj are removed from the instance. If before calling this function the number of objectives was <= numobj then new objectives are created, all with all-zero coefficients and default settings (like priority, weight, etc). Example usage: >>> import cplex >>> c = cplex.Cplex() >>> c.multiobj.set_num(2) >>> c.multiobj.get_num() 2 |
Sets the constant offset of an objective function. objidx must be an objective name or index. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(obj=[1.0 for i in range(3)]) >>> c.objective.set_offset(3.14) >>> c.objective.get_offset() 3.14 |
Sets the priority of an objective function. objidx must be an objective name or index. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(obj=[1.0 for i in range(3)]) >>> c.multiobj.set_priority(0, 2) >>> c.multiobj.get_priority(0) 2 |
Sets the relative tolerance of an objective function. objidx must be an objective name or index. Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(obj=[1.0 for i in range(3)]) >>> c.multiobj.set_reltol(0, 1e-4) >>> c.multiobj.get_reltol(0) 0.0001 |
Sets the sense of all objective functions.
The argument to this method must be either multiobj.sense.minimize or multiobj.sense.maximize. >>> import cplex >>> c = cplex.Cplex() >>> c.multiobj.sense[c.multiobj.get_sense()] 'minimize' >>> c.multiobj.set_sense(c.multiobj.sense.maximize) >>> c.multiobj.sense[c.multiobj.get_sense()] 'maximize' >>> c.multiobj.set_sense(c.multiobj.sense.minimize) >>> c.multiobj.sense[c.multiobj.get_sense()] 'minimize' |
Sets the weight of an objective function. objidx must be an objective name or index.
Example usage: >>> import cplex >>> c = cplex.Cplex() >>> indices = c.variables.add(obj=[1.0 for i in range(3)]) >>> c.multiobj.set_weight(0, -2.0) >>> c.multiobj.get_weight(0) -2.0 |
Trees | Indices | Help |
|
---|