Otawa  0.10
otawa::ilp::AbstractSystem Class Referenceabstract

This class provides a convenient way to handle ILP systems in OTAWA. More...

#include <otawa/ilp/AbstractSystem.h>

Inheritance diagram for otawa::ilp::AbstractSystem:
otawa::ilp::System

Classes

class  AbstractVar
 
class  ConstIter
 
class  VarIter
 

Public Member Functions

 AbstractSystem (void)
 
virtual ~AbstractSystem (void)
 
virtual ConstraintnewConstraint (Constraint::comparator_t comp, double constant)
 Build a new constraint that may be initialized by the user. More...
 
virtual ConstraintnewConstraint (const string &label, Constraint::comparator_t comp, double constant)
 
virtual void addObjectFunction (double coef, Var *var)
 Add a factor to the object function. More...
 
virtual VarnewVar (const string &name)
 
virtual int countVars (void)
 Count the number of variables in the system. More...
 
virtual int countConstraints (void)
 Count the number of constraints in the system. More...
 
virtual
elm::datastruct::IteratorInst
< ilp::Constraint * > * 
constraints (void)
 
virtual
elm::datastruct::IteratorInst
< ilp::Constraint::Term > * 
objTerms (void)
 
virtual void exportLP (io::Output &out)
 Export the system to the given output using the LP format (lp_solve). More...
 
virtual void dumpSolution (io::Output &out)
 Dump the solution textually to the given output. More...
 
virtual VarnewVar (Var::type_t type, const string &name)
 Build a new variable with the given type. More...
 
virtual bool solve (WorkSpace *ws=0)=0
 Solve the ILP system. More...
 
virtual bool solve (WorkSpace *ws, otawa::Monitor &mon)
 Solve the ILP system in the given workspace using the given monitor to output logs. More...
 
virtual double valueOf (Var *var)=0
 This method can only be called after the resolution of the system and returns the value of a variable. More...
 
virtual double value (void)=0
 Return the value of the optimized object function. More...
 
virtual void dumpSystem (io::Output &out=elm::cout)
 Dump the system in text format (as a default, call exportLP). More...
 
virtual void dump (elm::io::OutStream &out=elm::io::out)
 Dump the system to the given output. More...
 
void dump (format_t fmt, elm::io::OutStream &out=elm::io::out)
 Dump the system to the given output and format. More...
 
virtual string lastErrorMessage (void)
 Get the message of the last error. More...
 
virtual ILPPluginplugin (void)
 Return the owner plugin. More...
 
bool hasDump (format_t fmt)
 Tests if it is possible to dump in the given format. More...
 
void dumpLPSolve (elm::io::OutStream &out=elm::io::out)
 Dump in LPSolve format. More...
 
void dumpCPlex (elm::io::OutStream &out=elm::io::out)
 Dump system in CPlex format. More...
 
void dumpMOSEK (elm::io::OutStream &out=elm::io::out)
 Dump in MOSEK format. More...
 

Protected Member Functions

int index (ilp::Var *var)
 Get index (in the system storage table) of the variable. More...
 

Private Member Functions

void remove (AbstractConstraint *cons)
 Remove a constraint from the system. More...
 
void remove (AbstractVar *var)
 Remove a variable from the system. More...
 

Private Attributes

genstruct::FragTable
< AbstractVar * > 
vars
 
genstruct::FragTable
< AbstractConstraint * > 
conss
 
Expression obj
 
bool cleaning
 

Friends

class AbstractConstraint
 
class AbstractVar
 

Detailed Description

This class provides a convenient way to handle ILP systems in OTAWA.

The ILP system (constraints, variables) are stored in OTAWA the solve() method is called. This method is not provided by AbstractSystem but the implementation is left to a child class for customization: the child class can now visit the system and built the equivalent one in a particular solver.

Constructor & Destructor Documentation

otawa::ilp::AbstractSystem::AbstractSystem ( void  )
otawa::ilp::AbstractSystem::~AbstractSystem ( void  )
virtual

References cleaning, conss, and vars.

Member Function Documentation

void otawa::ilp::AbstractSystem::addObjectFunction ( double  coef,
Var var 
)
virtual

Add a factor to the object function.

Parameters
coefCoefficient of the factor.
varVariable of the factor.

Implements otawa::ilp::System.

References otawa::ilp::Expression::add(), and obj.

elm::datastruct::IteratorInst< Constraint * > * otawa::ilp::AbstractSystem::constraints ( void  )
virtual

Implements otawa::ilp::System.

int otawa::ilp::AbstractSystem::countConstraints ( void  )
virtual

Count the number of constraints in the system.

Returns
Constraint count.

Implements otawa::ilp::System.

References conss.

int otawa::ilp::AbstractSystem::countVars ( void  )
virtual

Count the number of variables in the system.

Returns
Variable count.

Implements otawa::ilp::System.

References vars.

void otawa::ilp::System::dump ( elm::io::OutStream out = elm::io::out)
virtualinherited

Dump the system to the given output.

The dumping format depends upon the actual used ILP engine. Usually, it is compatible with other tools of the ILP engine.

Parameters
outUsed output.
Deprecated:
Use dumpSystem() and dumpSolution() instead.

References otawa::ilp::System::dumpSolution(), and otawa::ilp::System::dumpSystem().

Referenced by exportLP(), and otawa::ilp::Output::processWorkSpace().

void otawa::ilp::System::dump ( format_t  fmt,
elm::io::OutStream out = elm::io::out 
)
inherited
void otawa::ilp::AbstractSystem::dumpSolution ( io::Output out)
virtual

Dump the solution textually to the given output.

Parameters
outStream to output to (default to cout).

Implements otawa::ilp::System.

References otawa::ilp::System::valueOf(), and vars.

void otawa::ilp::System::dumpSystem ( io::Output out = elm::cout)
virtualinherited

Dump the system in text format (as a default, call exportLP).

Parameters
outStream to dump to (default to cout).

References otawa::ilp::System::exportLP().

Referenced by otawa::ilp::System::dump().

void otawa::ilp::AbstractSystem::exportLP ( io::Output out)
virtual

Export the system to the given output using the LP format (lp_solve).

Parameters
outStream to export to (default to cout).

Implements otawa::ilp::System.

References otawa::ilp::CPLEX, and otawa::ilp::System::dump().

bool otawa::ilp::System::hasDump ( format_t  fmt)
inherited

Tests if it is possible to dump in the given format.

Parameters
fmtUsed format
Returns
Boolean

References otawa::ilp::CPLEX, otawa::ilp::DEFAULT, otawa::ilp::LP_SOLVE, and otawa::ilp::MOSEK.

int otawa::ilp::AbstractSystem::index ( ilp::Var var)
protected

Get index (in the system storage table) of the variable.

This method is useful to associate AbstractSystem variables with the underlying ILP system.

Parameters
varVariable to get index for.
Returns
Variable index.
string otawa::ilp::System::lastErrorMessage ( void  )
virtualinherited

Get the message of the last error.

Since
1.2.0 ILP interface.
Returns
Last error message.

Referenced by otawa::ipet::WCETComputation::processWorkSpace().

Constraint * otawa::ilp::AbstractSystem::newConstraint ( Constraint::comparator_t  comp,
double  constant 
)
virtual

Build a new constraint that may be initialized by the user.

As the ILP system manage the memory of the constraint, the constraint must never be deleted by the user.

Parameters
compComparator used (one of Constraint::LT, LE, EQ, GT, GE).
constantConstant value.
Returns
Built constraint.

Implements otawa::ilp::System.

Constraint * otawa::ilp::AbstractSystem::newConstraint ( const string label,
Constraint::comparator_t  comp,
double  constant 
)
virtual
Var * otawa::ilp::AbstractSystem::newVar ( const string name)
virtual

Implements otawa::ilp::System.

References otawa::ilp::Var::INT.

Var * otawa::ilp::AbstractSystem::newVar ( Var::type_t  type,
const string name 
)
virtual

Build a new variable with the given type.

Parameters
typeType of the variable.
nameVariable name.
Returns
Built variable.
Since
ILP 1.2.0

Implements otawa::ilp::System.

References otawa::ilp::AbstractSystem::AbstractVar::_idx, otawa::ilp::AbstractSystem::AbstractVar::_sys, AbstractVar, and vars.

elm::datastruct::IteratorInst< Constraint::Term > * otawa::ilp::AbstractSystem::objTerms ( void  )
virtual

Implements otawa::ilp::System.

References obj.

ILPPlugin * otawa::ilp::System::plugin ( void  )
virtualinherited

Return the owner plugin.

As a default, return null.

Returns
Owner plugin.

Referenced by otawa::ipet::WCETComputation::processWorkSpace().

void otawa::ilp::AbstractSystem::remove ( AbstractConstraint cons)
private

Remove a constraint from the system.

Parameters
consRemoved constraint.

References otawa::ilp::AbstractConstraint::_idx, cleaning, and conss.

Referenced by otawa::ilp::AbstractConstraint::~AbstractConstraint().

void otawa::ilp::AbstractSystem::remove ( AbstractVar var)
private

Remove a variable from the system.

Parameters
varVariable to remove.

References otawa::ilp::AbstractSystem::AbstractVar::_idx, cleaning, and vars.

boolean otawa::ilp::System::solve ( WorkSpace ws = 0)
pure virtualinherited

Solve the ILP system.

Parameters
wsIf passed (default to null), the given workspace is used to test if the computation is cancelled in order to stop the solver.
Returns
True if the resolution is succesful or false else (mainly due to lack of constraint).

Referenced by otawa::ipet::WCETComputation::processWorkSpace(), and otawa::ilp::System::solve().

bool otawa::ilp::System::solve ( WorkSpace ws,
otawa::Monitor mon 
)
virtualinherited

Solve the ILP system in the given workspace using the given monitor to output logs.

The workspace may be used to support cancellation or progression in user interface.

Parameters
wsCurrent workspace.
monMonitor to use.

References otawa::ilp::System::solve().

double otawa::ilp::System::value ( void  )
pure virtualinherited

Return the value of the optimized object function.

Returns
Object function optimum.

Referenced by otawa::ipet::WCETComputation::processWorkSpace().

double otawa::ilp::System::valueOf ( Var var)
pure virtualinherited

This method can only be called after the resolution of the system and returns the value of a variable.

It is an error to pass a variable not involved in the system.

Parameters
varVariable whose value is looked for.
Returns
Value of the variable.

Referenced by otawa::display::ILPSystemDisplayer::displayVar(), dumpSolution(), otawa::ilp::Var::eval(), otawa::ilp::Expression::eval(), otawa::ipet::WCETCountRecorder::processBB(), otawa::BBRatioDisplayer::processBB(), otawa::BBRatioDisplayer::processCFG(), and otawa::display::ILPSystemDisplayer::processWorkSpace().

Friends And Related Function Documentation

friend class AbstractConstraint
friend

Referenced by newConstraint().

friend class AbstractVar
friend

Referenced by newVar().

Member Data Documentation

bool otawa::ilp::AbstractSystem::cleaning
private

Referenced by remove(), and ~AbstractSystem().

genstruct::FragTable<AbstractConstraint *> otawa::ilp::AbstractSystem::conss
private
Expression otawa::ilp::AbstractSystem::obj
private

Referenced by addObjectFunction(), and objTerms().

genstruct::FragTable<AbstractVar *> otawa::ilp::AbstractSystem::vars
private

The documentation for this class was generated from the following files: