Skip to main content
FRAMES NO FRAMES

Class IloOplModel

Definition file: ilopl/ilooplmodel.h
Map of IloOplModelIloOplModelIloOplModel
Instance of an OPL model.

Instances of this class represent an OPL model. This class associates a model definition with data sources and an optimization engine.

You find a whole variety of services useful when using OPL models with Concert in this class. Refer also to the Interfaces User's Manual.

See Also:

Method Summary
public voidaddDataSource(IloOplDataSource source)
public voidaddSettings(IloOplSettings settings)
public voidapplyOpsSettings(const char * baseDir, const char * opsFile)
public voidconvertAllIntVars()
public voidend()
public voidgenerate()
public IloOplConflictIteratorgetConflictIterator() const
public IloCPgetCP() const
public IloCplexgetCplex() const
public IloOplElementgetElement(const char * name)
public IloOplModelDefinitiongetModelDefinition() const
public const char *getName() const
public IloObjectivegetObjective()
public IloOplRelaxationIteratorgetRelaxationIterator() const
public IloOplSettingsgetSettings() const
public const char *getSourceName() const
public IloBoolhasCP() const
public IloBoolhasCplex() const
public IloOplModel(IloOplModelDefinition definition, IloCplex cplex)
public IloOplModel(IloEnv env, IloOplModelDefinition definition, IloCplex cplex)
public IloOplModel(IloOplSettings settings, IloOplModelDefinition definition, IloCplex cplex)
public IloOplModel(IloEnv env, IloOplSettings settings, IloOplModelDefinition definition, IloCplex cplex)
public IloOplModel(IloOplModelDefinition definition, IloCP cp)
public IloOplModel(IloEnv env, IloOplModelDefinition definition, IloCP cp)
public IloOplModel(IloOplSettings settings, IloOplModelDefinition definition, IloCP cp)
public IloOplModel(IloEnv env, IloOplSettings settings, IloOplModelDefinition definition, IloCP cp)
public IloBoolisUsingCP() const
public IloBoolisUsingCplex() const
public IloIntmain()
public IloOplDataElementsmakeDataElements() const
public IloOplElementIteratormakeElementIterator(IloBool ownElements)
public IloOplElementIteratormakeElementIterator()
public voidpostProcess()
public IloIntprintConflict(std::ostream & os) const
public voidprintExternalData(std::ostream & os, const char * title)
public voidprintExternalData(std::ostream & os)
public voidprintInternalData(std::ostream & os, const char * title)
public voidprintInternalData(std::ostream & os)
public IloIntprintRelaxation(std::ostream & os) const
public voidprintSolution(std::ostream & os)
public const char *resolvePath(const char * name) const
public std::istream *resolveStream(const char * name) const
public IloBoolsetPoolSolution(IloInt solId)
public voidsetSettings(IloOplSettings settings)
public voidunconvertAllIntVars()
Method Detail

IloOplModel

public IloOplModel(IloOplModelDefinition definition, IloCplex cplex)

Constructs a model instance based on a definition. Refer also to the Interfaces User's Manual.

Parameters:

definition
The model definition for this OPL model instance.
cplex
The CPLEX optimization engine associated with this OPL model instance.

IloOplModel

public IloOplModel(IloEnv env, IloOplModelDefinition definition, IloCplex cplex)

Constructs a model instance based on an environment and a definition. Refer also to the Interfaces User's Manual.

Parameters:

env
The environment to allocate memory.
definition
The model definition for this OPL model instance.
cplex
The CPLEX optimization engine associated with this OPL model instance.

IloOplModel

public IloOplModel(IloOplSettings settings, IloOplModelDefinition definition, IloCplex cplex)

Constructs a model instance based on a definition, with shared settings. Refer also to the Interfaces User's Manual.

Parameters:

settings
The settings to use.
definition
The model definition for this OPL model instance.
cplex
The CPLEX optimization engine associated with this OPL model instance.

IloOplModel

public IloOplModel(IloEnv env, IloOplSettings settings, IloOplModelDefinition definition, IloCplex cplex)

Constructs a model instance based on an environment and a definition, with shared settings. Refer also to the Interfaces User's Manual.

Parameters:

env
The environment to allocate memory.
settings
The settings to use.
definition
The model definition for this OPL model instance.
cplex
The CPLEX optimization engine associated with this OPL model instance.

IloOplModel

public IloOplModel(IloOplModelDefinition definition, IloCP cp)

Constructs a model instance based on a definition. Refer also to the Interfaces User's Manual.

Parameters:

definition
The model definition for this OPL model instance.
cp
The CP optimization engine associated with this OPL model instance.

IloOplModel

public IloOplModel(IloEnv env, IloOplModelDefinition definition, IloCP cp)

Constructs a model instance based on an environment and a definition. Refer also to the Interfaces User's Manual.

Parameters:

env
The environment to allocate memory.
definition
The model definition for this OPL model instance.
cp
The CP optimization engine associated with this OPL model instance.

IloOplModel

public IloOplModel(IloOplSettings settings, IloOplModelDefinition definition, IloCP cp)

Constructs a model instance based on a definition with shared settings. Refer also to the Interfaces User's Manual.

Parameters:

settings
The settings to use.
definition
The model definition for this OPL model instance.
cp
The CP optimization engine associated with this OPL model instance.

IloOplModel

public IloOplModel(IloEnv env, IloOplSettings settings, IloOplModelDefinition definition, IloCP cp)

Constructs a model instance based on an environment and a definition with shared settings. Refer also to the Interfaces User's Manual.

Parameters:

env
The environment to allocate memory.
settings
The settings to use.
definition
The model definition for this OPL model instance.
cp
The CP optimization engine associated with this OPL model instance.

addDataSource

public void addDataSource(IloOplDataSource source)

Adds a data source to this OPL model.

Parameters:

source
The data source object to be added to the model.

addSettings

public void addSettings(IloOplSettings settings)

Adds a settings configuration to this OPL model.

Parameters:

settings
The settings to be added to the model.

applyOpsSettings

public void applyOpsSettings(const char * baseDir, const char * opsFile)

Apply the settings to OPL and the needed engine.

For example: oplModel.applyOpsSettings(0, "c:/temp/mytrans.ops");

Or: oplModel.applyOpsSettings("c:/temp/", "mytrans.ops");

0param opsFile OPS file name of OPS full path

Parameters:

baseDir
Base directory or null 0param opsFile OPS file name of OPS full path

convertAllIntVars

public void convertAllIntVars()

Relaxes all integer decision variables.

This method adds an IloConversion object for each IloIntVar in the model.


end

public void end()

Clears the memory used by this object


generate

public void generate()

Generates the problem and uses the optimization engine to extract it.

This is the main purpose of an OPL model instance. It reads data, performs preprocessing, and creates the Concert IloModel object to represent the resulting problem. The problem is then extracted using the associated engine.


getConflictIterator

public IloOplConflictIterator getConflictIterator() const

Returns the default conflict iterator.

The invoking model is handling the creation/deletion of this iterator, you must not end it.

Returns:

An IloOplConflictIterator for the default conflict iterator.

getCP

public IloCP getCP() const

Returns the CP optimization engine associated with this OPL model instance.

Returns:

An IloCP for CP engine associated this OPL model.

getCplex

public IloCplex getCplex() const

Returns the CPLEX optimization engine associated with this OPL model instance.

Returns:

An IloCplex for CPLEX engine associated this OPL model.

getElement

public IloOplElement getElement(const char * name)

Returns a named model element.

Parameters:

name
The name of the element to return.

Returns:

An IloOplElement for the named model element.

getModelDefinition

public IloOplModelDefinition getModelDefinition() const

Returns the model definition.

Returns:

The IloModelDefinition for this OPL model instance.

getName

public const char * getName() const

Returns the name of an OPL model.

Returns:

The name of this OPL model.

getObjective

public IloObjective getObjective()

Returns a Concert objective for the objective.

If the model has no objective, an empty handle will be returned.

Returns:

An IloObjective for the objective of the implementation object.

getRelaxationIterator

public IloOplRelaxationIterator getRelaxationIterator() const

Returns the default relaxation iterator.

The invoking model is handling the creation/deletion of this iterator, you must not end it.

Returns:

An IloOplRelaxationIterator for the default conflict iterator.

getSettings

public IloOplSettings getSettings() const

Returns the settings object.

Returns:

The IloOplSettings used by this OPL model instance.

getSourceName

public const char * getSourceName() const

Returns the name of a model definition's source.

Returns:

The source name of this OPL model.

hasCP

public IloBool hasCP() const

Returns IloTrue, if this model has a CP engine associated.


hasCplex

public IloBool hasCplex() const

Returns IloTrue, if this model has a CPLEX engine associated.


isUsingCP

public IloBool isUsingCP() const

This member function tells you whether this model requires a CP engine.

Returns:

IloTrue if a CP engine is required.

isUsingCplex

public IloBool isUsingCplex() const

This member function tells you whether this model requires a CPLEX engine.

Returns:

IloTrue if a CPLEX engine is required.

main

public IloInt main()

Executes flow control scripting defined in the model.

Returns:

The integer value of the last expression in the main block. If that last expression does not evaluate to an integer, 0 is returned. If scripting errors occur, a negative value is returned.

makeDataElements

public IloOplDataElements makeDataElements() const

This service routine returns all elements used in this OPL model instance. The returned object can be used as a data source for other OPL model instances.

Returns:

An IloOplDataElements for the model elements.

makeElementIterator

public IloOplElementIterator makeElementIterator(IloBool ownElements)

Returns a new iterator for the elements in this model. The caller is responsible for ending the iterator.

If the element iterator owns its elements, only the current element is valid, previous ones cannot be used.

If the element iterator does not own its elements, previously iterated elements can be used. The caller is responsible for ending those elements.

Parameters:

ownElements
If this parameter is set to IloFalse, the iterator does not own the elements it iterates.

Returns:

An IloOplElementIterator for the model elements.

makeElementIterator

public IloOplElementIterator makeElementIterator()

Returns a new iterator for the elements in this model. The caller is responsible for ending the iterator.

This element iterator owns all the elements on which it iterates. Only the current element is valid, previous ones cannot be used.

Returns:

An IloOplElementIterator for the model elements.

postProcess

public void postProcess()

Used to perform postprocessing.

After a solution is found, the postprocessing part of the model can be executed.

The solving is controlled outside OPL, therefore this service routine has to be invoked manually whenever a new solution is available.


printConflict

public IloInt printConflict(std::ostream & os) const

Reports conflicting constraints on the given stream and returns the number of conflicts found.

Parameters:

os
The name of the stream that contains the model.

Returns:

An integer value indicating the number of conflicts.

printExternalData

public void printExternalData(std::ostream & os, const char * title)

This service routine serializes external data elements taken from data sources. Adds a title and time stamp header.


printExternalData

public void printExternalData(std::ostream & os)

This service routine serializes external data elements taken from data sources.


printInternalData

public void printInternalData(std::ostream & os, const char * title)

This service routine serializes internal data elements. Adds a title and time stamp header.


printInternalData

public void printInternalData(std::ostream & os)

This service routine serializes internal data elements.


printRelaxation

public IloInt printRelaxation(std::ostream & os) const

Reports the relaxations needed to obtain a feasible model on the given stream, returns the number of relaxations found, and changes the state of the invoking object to relaxation mode.

Parameters:

os
The name of the stream that contains the model.

Returns:

An integer value indicating the number of relaxations.

printSolution

public void printSolution(std::ostream & os)

This service routine serializes the current solution.


resolvePath

public const char * resolvePath(const char * name) const

Resolves a resource name as file path.

Relative paths are resolved relative to this OPL model. Refer also to the Interfaces User's Manual.

Parameters:

name
The name of the resource for which you want a file path.

Returns:

The absolute file path for the named object.

resolveStream

public std::istream * resolveStream(const char * name) const

Resolves a resource name as stream.

Relative paths are resolved relative to this OPL model.

The caller takes ownership of the result.

Parameters:

name
The name of the resource that you want to resolve as a stream.

Returns:

A stream for the named object.

setPoolSolution

public IloBool setPoolSolution(IloInt solId)

Sets the invoking model in the state of the solution indexed by solId.

This method works only if the embedded algorithm had been collecting a pool of solutions. If the id is higher than then available number of solution in the pool, the method will do nothing and return IloFalse if the id is negative, the model is returned to the default solution state.

Parameters:

solId
the id of the solution to be used, or -1 to return to original default state.

Returns:

Whether the state of the invoking model has been changed

setSettings

public void setSettings(IloOplSettings settings)

Replaces the settings object.


unconvertAllIntVars

public void unconvertAllIntVars()

Undoes the effects of convertAllIntVars().