NO FRAMES

Class IloEnv

Definition file: ilconcert/iloenv.h
The class of environments for models or algorithms in Concert Technology.

An instance of this class is an environment, managing memory and identifiers for modeling objects. Every Concert Technology object, such as an extractable object, a model, or an algorithm, must belong to an environment. In C++ terms, when you construct a model (an instance of IloModel) or an algorithm (an instance of IloCplex, IloCP, or IloSolver, for example), then you must pass one instance of IloEnv as an argument of that constructor.

Environment and Memory Management

An environment (an instance of IloEnv) efficiently manages memory allocations for the objects constructed with that environment as an argument. For example, when Concert Technology objects in your model are extracted by an algorithm, those extracted objects are handled as efficiently as possible with respect to memory management; there is no unnecessary copying that might cause memory explosions in your application on the part of Concert Technology.

When your application deletes an instance of IloEnv, Concert Technology will automatically delete all models and algorithms depending on that environment as well. You delete an environment by calling the member function env.end.

The memory allocated for Concert Technology arrays, expressions, sets, and columns is not freed until all references to these objects have terminated and the objects themselves have been deleted.

Certain classes documented in this manual, such as IloFastMutex, are known as system classes. They do not belong to a Concert Technology environment; in other words, an instance of IloEnv is not an argument in their constructors. As a consequence, a Concert Technology environment does not attempt to manage their memory allocation and de-allocation; a call of IloEnv:end will not delete an instance of a system class. These system classes are clearly designated in this documentation, and the appropriate constructors and destructors for them are documented in this manual as well.

Environment and Initialization

An instance of IloEnv in your application initializes certain data structures and modeling facilities for Concert Technology. For example, IloEnv initializes the symbolic constant IloInfinity.

The environment also specifies the current assumptions about normalization or the reduction of terms in linear expressions. For an explanation of this concept, see the concept Normalization: Reducing Linear Terms

Environment and Communication Streams

An instance of IloEnv in your application initializes the default output streams for general information, for error messages, and for warnings.

Environment and Extractable Objects

Every extractable object in your problem must belong to an instance of IloEnv. In C++ terms, in the constructor of certain extractable objects that you create, such as a constrained variable, you must pass an instance of IloEnv as an argument to specify which environment the extractable object belongs to. An extractable object (that is, an instance of IloExtractable or one of its derived subclasses) is tied throughout its lifetime to the environment where it is created. It can be used only with extractable objects belonging to the same environment. It can be extracted only for an algorithm attached to the same environment.

Two different environments cannot share the same extractable object.

You can extract objects from only one environment into a given algorithm. In other words, algorithms do not extract objects from two or more different environments.

Most member functions in this class contain assert statements. For an explanation of the macro NDEBUG (a way to turn on or turn off these assert statements), see the concept Assert and NDEBUG.

See Also:

Constructor Summary
public IloEnv()
public IloEnv(IloEnvI * impl)
Method Summary
public voidend()
public ostream &error() const
public IloExtractableI *getExtractable(IloInt id)
public IloEnvI *getImpl() const
public IloIntgetMaxId() const
public IloIntgetMemoryUsage() const
public ostream &getNullStream() const
public IloRandomgetRandom() const
public IloNumgetTime() const
public IloIntgetTotalMemoryUsage() const
public const char *getVersion() const
public IloBoolisValidId(IloInt id) const
public ostream &out() const
public voidprintTime() const
public voidsetDeleter(IloDeleterMode mode) const
public voidsetError(ostream & s)
public voidsetNormalizer(IloBool val) const
public voidsetOut(ostream & s)
public voidsetWarning(ostream & s)
public voidunsetDeleter() const
public ostream &warning() const
Constructor Detail

IloEnv

public IloEnv()

This constructor creates an environment to manage the extractable objects in Concert Technology.


IloEnv

public IloEnv(IloEnvI * impl)

This constructor creates an environment (a handle) from its implementation object.


Method Detail

end

public void end()

When you call this member function, it cleans up the invoking environment. In other words, it deletes all the extractable objects (instances of IloExtractable and its subclasses) created in that environment and frees the memory allocated for them. It also deletes all algorithms (instances of IloAlgorithm and its subclasses) created in that environment and frees memory allocated for them as well, including the representations of extractable objects extracted for those algorithms.

The memory allocated for Concert Technology arrays, expressions, sets, and columns is not freed until all references to these objects have terminated and the objects themselves have been deleted.


error

public ostream & error() const

This member function returns a reference to the output stream currently used for error messages from the invoking environment. It is initialized as cerr.


getExtractable

public IloExtractableI * getExtractable(IloInt id)

This member function returns the extractable associated with the specified identifier id.


getImpl

public IloEnvI * getImpl() const

This member function returns the implementation object of the invoking environment.


getMaxId

public IloInt getMaxId() const

This member function returns the highest id of all extractables int the current IloEnv


getMemoryUsage

public IloInt getMemoryUsage() const

This member function returns a value in bytes specifying how full the heap is.


getNullStream

public ostream & getNullStream() const

This member function calls the null stream of the environment. This member function can be used with IloAlgorithm::setOut() to suppress screen output by redirecting it to the null stream.


getRandom

public IloRandom getRandom() const

Each instance of IloEnv contains a random number generator, an instance of the class IloRandom. This member function returns that IloRandom instance.


getTime

public IloNum getTime() const

This member function returns the amount of time elapsed in seconds since the construction of the invoking environment. (The member function IloEnv::printTime directs this information to the output stream of the invoking environment.)


getTotalMemoryUsage

public IloInt getTotalMemoryUsage() const

This member function returns a value in bytes specifying how large the heap is.


getVersion

public const char * getVersion() const

This member function returns a string specifying the version of ILOG Concert Technology.


isValidId

public IloBool isValidId(IloInt id) const

This methods tells you if the current id is associated with a live extractable.


out

public ostream & out() const

This member function returns a reference to the output stream currently used for logging. General output from the invoking environment is accessible through this member function. By default, the logging output stream is defined by an instance of IloEnv as cout.


printTime

public void printTime() const

This member function directs the output of the member function IloEnv::getTime to the output stream of the invoking environment. (The member function IloEnv::getTime accesses the elapsed time in seconds since the creation of the invoking environment.)


setDeleter

public void setDeleter(IloDeleterMode mode) const

This member function sets the mode for the deletion of extractables, as described in the concept Deletion of Extractable Objects. The mode can be IloLinearDeleterMode or IloSafeDeleterMode.


setError

public void setError(ostream & s)

This member function sets the stream for errors generated by the invoking environment. By default, the stream is defined by an instance of IloEnv as cerr.


setNormalizer

public void setNormalizer(IloBool val) const

This member function turns on or off the facilities in Concert Technology for normalizing linear expressions. Normalizing linear expressions is also known as reducing the terms of a linear expression. In this context, a linear expression that does not contain multiple terms with the same variable is said to be normalized. The concept in this manual offers examples of this idea.

When val is IloTrue, (the default), then Concert Technology analyzes linear expressions to determine whether any variable appears more than once in a given linear expression. It then combines terms in the linear expression to eliminate any duplication of variables. This mode may require more time during preliminary computation, but it avoids the possibility of an assertion failing in the case of duplicated variables in the terms of a linear expression.

When val is IloFalse, then Concert Technology assumes that all linear expressions in the invoking environment have already been processed to reduce them to their most efficient form. In other words, Concert Technology assumes that linear expressions have been normalized. This mode may save time during computation, but it entails the risk that a linear expression may contain one or more variables, each of which appears in one or more terms. This situation will cause certain assert statements in Concert Technology to fail if you do not compile with the flag -DNDEBUG.


setOut

public void setOut(ostream & s)

This member function redirects the out() stream with the stream given as an argument.

This member function can be used with IloEnv::getNullStream to suppress screen output by redirecting it to the null stream.


setWarning

public void setWarning(ostream & s)

This member function sets the stream for warnings from the invoking environment. By default, the stream is defined by an instance of IloEnv as cout.


unsetDeleter

public void unsetDeleter() const

This member function unsets the mode for the deletion of extractables, as described in the concept Deletion of Extractable Objects.


warning

public ostream & warning() const

This member function returns a reference to the output stream currently used for warnings from the invoking environment. By default, the warning output stream is defined by an instance of IloEnv as cout.