Otawa
0.10
|
This class provides a convenient way to handle ILP systems in OTAWA. More...
#include <otawa/ilp/AbstractSystem.h>
Classes | |
class | AbstractVar |
class | ConstIter |
class | VarIter |
Public Member Functions | |
AbstractSystem (void) | |
virtual | ~AbstractSystem (void) |
virtual Constraint * | newConstraint (Constraint::comparator_t comp, double constant) |
Build a new constraint that may be initialized by the user. More... | |
virtual Constraint * | newConstraint (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 Var * | newVar (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 Var * | newVar (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 ILPPlugin * | plugin (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 |
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.
otawa::ilp::AbstractSystem::AbstractSystem | ( | void | ) |
|
virtual |
Add a factor to the object function.
coef | Coefficient of the factor. |
var | Variable of the factor. |
Implements otawa::ilp::System.
References otawa::ilp::Expression::add(), and obj.
|
virtual |
Implements otawa::ilp::System.
|
virtual |
Count the number of constraints in the system.
Implements otawa::ilp::System.
References conss.
|
virtual |
Count the number of variables in the system.
Implements otawa::ilp::System.
References vars.
|
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.
out | Used output. |
References otawa::ilp::System::dumpSolution(), and otawa::ilp::System::dumpSystem().
Referenced by exportLP(), and otawa::ilp::Output::processWorkSpace().
|
inherited |
Dump the system to the given output and format.
out | Used output. |
fmt | Used format |
References otawa::ilp::CPLEX, otawa::ilp::DEFAULT, otawa::ilp::System::dumpCPlex(), otawa::ilp::System::dumpLPSolve(), otawa::ilp::System::dumpMOSEK(), otawa::ilp::System::dumpSystem(), otawa::ilp::LP_SOLVE, and otawa::ilp::MOSEK.
|
inherited |
Dump system in CPlex format.
_out | Output stream to use. |
References _, otawa::ilp::Constraint::EQ, otawa::ilp::Constraint::GE, elm::genstruct::HashTable< K, T, H >::get(), otawa::ilp::Constraint::GT, elm::genstruct::HashTable< K, T, H >::hasKey(), otawa::ilp::Constraint::LE, otawa::ilp::Constraint::LT, out, elm::genstruct::HashTable< K, T, H >::put(), and otawa::sign().
Referenced by otawa::ilp::System::dump().
|
inherited |
Dump in LPSolve format.
_out | Output stream. |
References elm::avl::Set< T, C >::add(), otawa::ilp::Var::BIN, otawa::ilp::Constraint::comparator(), otawa::ilp::Constraint::constant(), otawa::ilp::System::constraints(), cout, otawa::ilp::Var::FLOAT, otawa::ilp::Var::INT, otawa::ilp::Constraint::label(), otawa::sem::neg(), out, and otawa::ilp::Constraint::terms().
Referenced by otawa::ilp::System::dump().
|
inherited |
Dump in MOSEK format.
_out | Output stream. |
References _, otawa::ilp::Constraint::EQ, otawa::ilp::Constraint::GE, elm::genstruct::HashTable< K, T, H >::get(), otawa::ilp::Constraint::GT, elm::genstruct::HashTable< K, T, H >::hasKey(), otawa::ilp::Constraint::LE, otawa::ilp::Constraint::LT, out, elm::genstruct::HashTable< K, T, H >::put(), and otawa::sign().
Referenced by otawa::ilp::System::dump().
|
virtual |
Dump the solution textually to the given output.
out | Stream to output to (default to cout). |
Implements otawa::ilp::System.
References otawa::ilp::System::valueOf(), and vars.
|
virtualinherited |
Dump the system in text format (as a default, call exportLP).
out | Stream to dump to (default to cout). |
References otawa::ilp::System::exportLP().
Referenced by otawa::ilp::System::dump().
|
virtual |
Export the system to the given output using the LP format (lp_solve).
out | Stream to export to (default to cout). |
Implements otawa::ilp::System.
References otawa::ilp::CPLEX, and otawa::ilp::System::dump().
|
inherited |
Tests if it is possible to dump in the given format.
fmt | Used format |
References otawa::ilp::CPLEX, otawa::ilp::DEFAULT, otawa::ilp::LP_SOLVE, and otawa::ilp::MOSEK.
|
protected |
Get index (in the system storage table) of the variable.
This method is useful to associate AbstractSystem variables with the underlying ILP system.
var | Variable to get index for. |
|
virtualinherited |
Get the message of the last error.
Referenced by otawa::ipet::WCETComputation::processWorkSpace().
|
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.
comp | Comparator used (one of Constraint::LT, LE, EQ, GT, GE). |
constant | Constant value. |
Implements otawa::ilp::System.
|
virtual |
Implements otawa::ilp::System.
References otawa::ilp::AbstractConstraint::_idx, otawa::ilp::AbstractConstraint::_sys, AbstractConstraint, and conss.
Implements otawa::ilp::System.
References otawa::ilp::Var::INT.
|
virtual |
Build a new variable with the given type.
type | Type of the variable. |
name | Variable name. |
Implements otawa::ilp::System.
References otawa::ilp::AbstractSystem::AbstractVar::_idx, otawa::ilp::AbstractSystem::AbstractVar::_sys, AbstractVar, and vars.
|
virtual |
Implements otawa::ilp::System.
References obj.
|
virtualinherited |
Return the owner plugin.
As a default, return null.
Referenced by otawa::ipet::WCETComputation::processWorkSpace().
|
private |
Remove a constraint from the system.
cons | Removed constraint. |
References otawa::ilp::AbstractConstraint::_idx, cleaning, and conss.
Referenced by otawa::ilp::AbstractConstraint::~AbstractConstraint().
|
private |
Remove a variable from the system.
var | Variable to remove. |
References otawa::ilp::AbstractSystem::AbstractVar::_idx, cleaning, and vars.
|
pure virtualinherited |
Solve the ILP system.
ws | If passed (default to null), the given workspace is used to test if the computation is cancelled in order to stop the solver. |
Referenced by otawa::ipet::WCETComputation::processWorkSpace(), and otawa::ilp::System::solve().
|
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.
ws | Current workspace. |
mon | Monitor to use. |
References otawa::ilp::System::solve().
|
pure virtualinherited |
Return the value of the optimized object function.
Referenced by otawa::ipet::WCETComputation::processWorkSpace().
|
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.
var | Variable whose value is looked for. |
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().
|
friend |
Referenced by newConstraint().
|
friend |
Referenced by newVar().
|
private |
Referenced by remove(), and ~AbstractSystem().
|
private |
Referenced by countConstraints(), newConstraint(), remove(), and ~AbstractSystem().
|
private |
Referenced by addObjectFunction(), and objTerms().
|
private |
Referenced by countVars(), dumpSolution(), newVar(), remove(), and ~AbstractSystem().