Objective

public class Objective extends Entity<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 type ObjectiveInstance, 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 the DataFrame class.

Constructors

Objective

Objective(ObjectiveBase impl)

Methods

astatus

public String astatus()

Return the AMPL status

Throws:

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:
Returns:

Exit code

get

public ObjectiveInstance get()

Get the objective instance (valid for scalar objectives only).

Throws:

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:
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:
Returns:

The objective instance corresponding to the specified key. Returns null if the specified key is not present.

impl

ObjectiveBase impl()

iterator

public Iterator<ObjectiveInstance> iterator()

message

public String message()

Result message returned by solver after most recent solve with this objective

Throws:

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:

sstatus

public String sstatus()

Return the solver status

Throws:

toString

public String toString()

String representation of the objective. Equivalent to the AMPL statement

show objectiveName;

value

public double value()

If the entity has only one objective (usually the case), get the corresponding value

Throws:
Returns:

Value of the objective