Objective#

class ampl.Entities.Objective : ampl.Entities.Entity<K>#

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 corresponding properties on the Objective itself. The properties have the same name of the corresponding AMPL suffixes. See http://www.ampl.com/NEW/suffbuiltin.html for a list of the available suffixes. An ArgumentException is thrown if one of such methods is called for a non-scalar objective. An ArgumentOutOfRangeException is thrown if any property of an entity which has been deleted from the underlying interpreter is accessed. The instances, represented by the class ampl.ObjectiveInstance can be accessed via the indexing operator, via the method ampl.Entities.Objective.Get or via the iterator provided. To gain access to all the values in an entity (for all instances and all suffixes for that entities), see ampl.Entities.Entity.GetValues and the ampl.DataFrame class.

Public Functions

override IEnumerator<ObjectiveInstance> GetEnumerator ()#
new ObjectiveInstance Get (params object[] index)#
override ObjectiveInstance Get (Tuple t = null)
void Drop ()#

Drop this objective.

void Restore ()#

Restore this objective (if it had been dropped, no effect otherwise)

K[] AsArray ()#
override string ToString ()#

Returns a textual representation of this entity.

DataFrame GetValues ()#

Get the principal values of this entity as a DataFrame.

The specific returned value depends on the type of entity. For:

Variables and Objectives it returns the suffix val

Parameters it returns their values

Constraints it returns the suffix dual

Sets it returns all the members of the set, Note that it does not apply to indexed sets. See ampl.SetInstance.GetValues

Return:

A DataFrame containing the values for all instances

DataFrame GetValues (params string[] suffixes)

Get the specified suffixes value for all instances in a DataFrame.

Param suffixes:

Suffixes to get

Return:

A DataFrame containing the specified values

void SetValues (DataFrame data)#

Set the values of this entity to the correponding values of a DataFrame indexed over the same sets(or a subset).

This function assigns the values in the first data column of the passed dataframe to the entity the function is called from. In particular, the statement::

 `x.SetValues(y.GetValues());`

is semantically equivalent to the AMPL statement::

 `let { s in S } x[s] := y[s];`

Param data:

The data to set the entity to

Properties

ObjectiveInstance this[Tuple t] {get;set;}

Get the instance with the specified index.

ObjectiveInstance this[string t] {get;set;}

Get the instance at t.

this[params object[] index { get; set; }#

Get the instance at index.

double Value { get; set; }#

Get the value of this objective.

string Astatus { get; set; }#

Return the AMPL status.

string Sstatus { get; set; }#

Return the solver status.

int ExitCode { get; set; }#

Exit code returned by solver after most recent solve with this objective.

string Message { get; set; }#

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

string Result { get; set; }#

Result string returned by solver after most recent solve with this objective.

bool IsMinimization { get; set; }#

Get the sense of this objective, true if minimization, false if maximization.

string Name { get; set; }#

Get the name of this entity.

int Indexarity { get; set; }#

Get the indexarity of this entity (sum of the dimensions of the indexing sets).

This value indicates the arity of the tuple to be passed to the method ampl.Entities.EntityBase.Get in order to access an instance of this entity. See the following AMPL examples::

  var x;               # indexarity = 0
  var y {1..2};        # indexarity = 1
  var z {1..2,3..4};   # indexarity = 2
  var zz {{ (1, 2)} };   # indexarity = 2

Get the sum of the dimensions of the indexing sets or 0 if the entity is not indexed

bool IsScalar { get; set; }#

Check whether this entity is scalar.

Equivalent to testing whether indexarity is equal to zero, is true if the entity is scalar (not indexed over any set)

int NumInstances { get; set; }#

Get the number of instances in this entity.

string[] IndexingSets { get; set; }#

Get the AMPL string representation of the sets on which this entity is indexed.The obtained vector can be modified without any effect to the entity.

Is equal to the string representation of the indexing sets for this entity or an empty array if the entity is scalar

string[] XRef { get; set; }#

Get the names of all entities which depend on this one.

ObjectiveMap#

class ampl.Entities.ObjectiveMap : ampl.Entities.EntityMap<ENTITY>#

Enables iterable access to the objectives.

Public Functions

ObjectiveMap ()#
override IEnumerator<Objective> GetEnumerator ()#
ENTITY[] AsArray ()#

Properties

new Objective this[string name] {get;set;}
override int Size { get; set; }#