Instance

public abstract class Instance<T extends Entity<?>>

Represent an instance of a modelling entity

Parameters:
  • <T> – Type of the father entity

Fields

entity

protected T entity

hasData

protected boolean hasData

key

protected Object key

Constructors

Instance

Instance(T entity, Object key)

Default constructor

Throws:
  • NullPointerException – if entity is null

Methods

checkValidity

protected void checkValidity()

To be executed when accessing properties, throws IllegalStateException if the instance has been deleted

copyFrom

abstract void copyFrom(Instance<?> from)

entity

public T entity()
Returns:Get the algebraic entity this instance is part of

getDoubleSuffix

protected double getDoubleSuffix(String suffix)

getIntegerIndex

int getIntegerIndex()

If this entity is indexed over an integer index, returns the index number of the entity

Throws:
Returns:

The indexing number

getIntegerIndex

static int getIntegerIndex(Object index)

getIntegerIndices

int[] getIntegerIndices()

If this entity is indexed over a set of integer indices, returns the index number of the entity

Throws:
Returns:

The indexing numbers

getIntegerIndices

static int[] getIntegerIndices(Object index)

getStringSuffix

protected String getStringSuffix(String suffix)

hasData

boolean hasData()
Returns:True if the instance has data initialised

invalidate

void invalidate()

isValid

boolean isValid()

Flag that specifies if the instance has been deleted or not

name

static String name(Entity<?> entity, Object key)

name

public String name()
Returns:The instance’s name

setHasData

protected void setHasData(boolean hasData)

toString

public String toString()

Returns a string representation of the instance.

For constraints and objective instances it is equivalent to the AMPL statement:

expand instanceName;

For set and variable instances see the documentation for the specific class.