.. java:import:: java.util Iterator Objective ========= .. java:package:: com.ampl :noindex: .. java:type:: public class Objective extends BasicEntity 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 :java:ref:`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 :java:ref:`UnsupportedOperationException` if called for a non scalar objective. Otherwise, use the method :java:ref:`Objective.get` to obtain the objects of type :java:ref:`ObjectiveInstance`, from which to access all properties (see section :ref:`secAccessInstancesAndValues` 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 :java:ref:`Entity.getValues` and the :java:ref:`DataFrame` class. Constructors ------------ Objective ^^^^^^^^^ .. java:constructor:: public Objective(Entity entity) :outertype: Objective Constructor Objective ^^^^^^^^^ .. java:constructor:: Objective(ObjectiveBase impl) :outertype: Objective Methods ------- astatus ^^^^^^^ .. java:method:: public String astatus() :outertype: Objective Return the AMPL status :throws UnsupportedOperationException: if the objective is not scalar drop ^^^^ .. java:method:: public void drop() :outertype: Objective Drop all instances of this objective, corresponding to the AMPL code: .. parsed-literal:: drop objectiveName; exitcode ^^^^^^^^ .. java:method:: public int exitcode() :outertype: Objective Exit code returned by solver after most recent solve with this objective :throws UnsupportedOperationException: if the objective is not scalar :return: Exit code get ^^^ .. java:method:: @Override public ObjectiveInstance get() :outertype: Objective Get the objective instance (valid for scalar objectives only). :throws IllegalStateException: if the entity has been deleted in the underlying AMPL interpreter :throws UnsupportedOperationException: if the objective is not scalar. get ^^^ .. java:method:: @Override public ObjectiveInstance get(Object... key) :outertype: Objective Get the objective corresponding to the specified key. See :ref:`secAccessInstancesAndValues` for further information on how the key can be specified. :param key: Key of the instance to be found. :throws IllegalStateException: if the entity has been deleted in the underlying AMPL interpreter :throws IllegalArgumentException: if trying to access an instance with the wrong number of keys (see :java:ref:`Entity.indexarity`) :return: The objective instance corresponding to the specified key. Returns ``null`` if the specified key is not present. get ^^^ .. java:method:: public ObjectiveInstance get(Tuple key) :outertype: Objective Get the objective instance corresponding to the specified key, expressed as a Tuple. See :ref:`secAccessInstancesAndValues` for further information on how the key can be specified. :param key: The indexing Tuple of the instance to be found :throws IllegalStateException: if the entity has been deleted in the underlying AMPL interpreter :throws IllegalArgumentException: if trying to access an instance with the wrong indexarity (see :java:ref:`Entity.indexarity`) :return: The objective instance corresponding to the specified key. Returns ``null`` if the specified key is not present. impl ^^^^ .. java:method:: ObjectiveBase impl() :outertype: Objective iterator ^^^^^^^^ .. java:method:: @Override public Iterator iterator() :outertype: Objective message ^^^^^^^ .. java:method:: public String message() :outertype: Objective Result message returned by solver after most recent solve with this objective :throws UnsupportedOperationException: if the objective is not scalar minimization ^^^^^^^^^^^^ .. java:method:: public boolean minimization() :outertype: Objective Return true if the objective is minimization, false otherwise restore ^^^^^^^ .. java:method:: public void restore() :outertype: Objective Restore all instances of this objective, corresponding to the AMPL code: .. parsed-literal:: restore objectiveName; result ^^^^^^ .. java:method:: public String result() :outertype: Objective Result string returned by solver after most recent solve with this objective :throws UnsupportedOperationException: if the objective is not scalar sstatus ^^^^^^^ .. java:method:: public String sstatus() :outertype: Objective Return the solver status :throws UnsupportedOperationException: if the objective is not scalar value ^^^^^ .. java:method:: public double value() :outertype: Objective If the entity has only one objective (usually the case), get the corresponding value :throws UnsupportedOperationException: if the objective is not scalar :return: Value of the objective