Objective ========= .. java:package:: com.ampl :noindex: .. java:type:: public class Objective extends Entity 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:: Objective() :outertype: Objective Objective ^^^^^^^^^ .. java:constructor:: Objective(AMPL ampl, Engine engine, String name) :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 UnsupportedOperationException: if the objective is not scalar. :throws IllegalStateException: if the entity has been deleted in the underlying AMPL interpreter 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 IllegalArgumentException: if trying to access an instance with the wrong number of keys (see :java:ref:`Entity.indexarity`) :throws IllegalStateException: if the entity has been deleted in the underlying AMPL interpreter :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 IllegalArgumentException: if trying to access an instance with the wrong indexarity (see :java:ref:`Entity.indexarity`) :throws IllegalStateException: if the entity has been deleted in the underlying AMPL interpreter :return: The objective instance corresponding to the specified key. Returns ``null`` if the specified key is not present. 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 refreshInstances ^^^^^^^^^^^^^^^^ .. java:method:: @Override void refreshInstances() :outertype: Objective 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 setDeclaration ^^^^^^^^^^^^^^ .. java:method:: @Override void setDeclaration(String declaration) :outertype: Objective sstatus ^^^^^^^ .. java:method:: public String sstatus() :outertype: Objective Return the solver status :throws UnsupportedOperationException: if the objective is not scalar toString ^^^^^^^^ .. java:method:: @Override public String toString() :outertype: Objective String representation of the objective. Equivalent to the AMPL statement .. parsed-literal:: show objectiveName; 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