Objective¶
-
public class
Objective
extends BasicEntity<ObjectiveInstance>¶ Represents an AMPL objective. Note that, in case of a scalar objective, all the properties (corresponding to AMPL suffixes) of the objective instance can be accessed through methods like
Objective.value
. The methods have the same name of the corresponding AMPL suffixes. See http://www.ampl.com/NEW/suffbuiltin.html for a list of the available suffixes.All these methods throw an
UnsupportedOperationException
if called for a non scalar objective.Otherwise, use the method
Objective.get
to obtain the objects of typeObjectiveInstance
, from which to access all properties (see section Access to instances and values for further information on how to access instances).To gain access to all the values in an entity (for all instances and all suffixes for that entities), see
Entity.getValues
and theDataFrame
class.
Constructors¶
Methods¶
astatus¶
-
public String
astatus
()¶ Return the AMPL status
Throws: - UnsupportedOperationException – if the objective is not scalar
drop¶
-
public void
drop
()¶ Drop all instances of this objective, corresponding to the AMPL code:
drop objectiveName;
exitcode¶
-
public int
exitcode
()¶ Exit code returned by solver after most recent solve with this objective
Throws: - UnsupportedOperationException – if the objective is not scalar
Returns: Exit code
get¶
-
public ObjectiveInstance
get
()¶ Get the objective instance (valid for scalar objectives only).
Throws: - UnsupportedOperationException – if the objective is not scalar.
- IllegalStateException – if the entity has been deleted in the underlying AMPL interpreter
get¶
-
public ObjectiveInstance
get
(Object... key)¶ Get the objective corresponding to the specified key. See Access to instances and values for further information on how the key can be specified.
Parameters: - key – Key of the instance to be found.
Throws: - IllegalArgumentException – if trying to access an instance with the wrong number of keys (see
Entity.indexarity
) - IllegalStateException – if the entity has been deleted in the underlying AMPL interpreter
Returns: The objective instance corresponding to the specified key. Returns
null
if the specified key is not present.
get¶
-
public ObjectiveInstance
get
(Tuple key)¶ Get the objective instance corresponding to the specified key, expressed as a Tuple. See Access to instances and values for further information on how the key can be specified.
Parameters: - key – The indexing Tuple of the instance to be found
Throws: - IllegalArgumentException – if trying to access an instance with the wrong indexarity (see
Entity.indexarity
) - IllegalStateException – if the entity has been deleted in the underlying AMPL interpreter
Returns: The objective instance corresponding to the specified key. Returns
null
if the specified key is not present.
iterator¶
-
public Iterator<ObjectiveInstance>
iterator
()¶
message¶
-
public String
message
()¶ Result message returned by solver after most recent solve with this objective
Throws: - UnsupportedOperationException – if the objective is not scalar
minimization¶
-
public boolean
minimization
()¶ Return true if the objective is minimization, false otherwise
restore¶
-
public void
restore
()¶ Restore all instances of this objective, corresponding to the AMPL code:
restore objectiveName;
result¶
-
public String
result
()¶ Result string returned by solver after most recent solve with this objective
Throws: - UnsupportedOperationException – if the objective is not scalar
sstatus¶
-
public String
sstatus
()¶ Return the solver status
Throws: - UnsupportedOperationException – if the objective is not scalar
value¶
-
public double
value
()¶ If the entity has only one objective (usually the case), get the corresponding value
Throws: - UnsupportedOperationException – if the objective is not scalar
Returns: Value of the objective