Jive reference manual
List of all members | Public Member Functions | Protected Member Functions
jive::solver::ConstrainedSolver Class Reference

Bundles a solver and a constraints handler into a single object. More...

Inheritance diagram for jive::solver::ConstrainedSolver:
Inheritance graph

Public Member Functions

 ConstrainedSolver (const jem::Ref< Solver > &solver, const jem::Ref< Constrainer > &constrainer)
 Constructs a constrained solver given another solver and a constraints handler. More...
 
virtual void solve (const Vector &lhs, const Vector &rhs)
 Computes the solution of a linear system of equations subjected to a set of linear constraints. More...
 
- Public Member Functions inherited from jive::solver::Solver
virtual void configure (const Properties &conf, const Properties &props)
 Configures this solver given a set of properties. More...
 
virtual jem::ClassgetClass () const
 Returns the Class instance representing the runtime class of this object. More...
 
- Public Member Functions inherited from jem::Object
virtual String toString () const
 Returns a short textual description of this object. More...
 
virtual long hashValue () const
 Returns a hash value for this object. More...
 
virtual bool equals (const Ref< Object > &obj) const
 Tests whether two objects are equal. More...
 
Ref< Objectclone () const
 Returns a copy of this object. More...
 

Protected Member Functions

virtual ~ConstrainedSolver ()
 
- Protected Member Functions inherited from jive::solver::Solver
virtual ~Solver ()
 
- Protected Member Functions inherited from jem::Collectable
 Collectable ()
 Creates an empty Collectable. More...
 
 ~Collectable ()
 Frees resources. More...
 

Additional Inherited Members

- Public Types inherited from jive::solver::Solver
typedef jem::util::Properties Properties
 A type representing a set of properties. More...
 
typedef util::Vector Vector
 A type that represents a vector. More...
 
- Static Public Member Functions inherited from jive::solver::Solver
static jem::ClassgetType ()
 
- Static Public Member Functions inherited from jem::Object
static ClassgetType ()
 Returns the Class instance representing the Object class. More...
 

Detailed Description

#include <jive/solver/ConstrainedSolver.h>

A ConstrainedSolver object bundles a Solver object and a Constrainer object. When the member function solve() is invoked on a ConstrainedSolver object, it will automatically apply the constraints encapsulated by its Constrainer object.

Constructor & Destructor Documentation

jive::solver::ConstrainedSolver::ConstrainedSolver ( const jem::Ref< Solver > &  solver,
const jem::Ref< Constrainer > &  constrainer 
)

Constructs a new ConstrainedSolver that encapsulates the Solver object solver and the Constrainer object constrainer. It is your responsibility to make sure that the solver object solver has a reference to the constrained coefficient matrix constrainer->getOutputMatrix().

Parameters
solver- a Solver object.
constrainer- a Constrainer object.
Precondition
solver != NIL &&
constrainer != NIL
virtual jive::solver::ConstrainedSolver::~ConstrainedSolver ( )
protectedvirtual

Member Function Documentation

virtual void jive::solver::ConstrainedSolver::solve ( const Vector lhs,
const Vector rhs 
)
virtual

Computes the solution of a linear system of equations subjected to a set of linear constraints. If solver and constrainer denote the solver and constraints handler, respectively, that were passed to the constructor, then this function executes the following code:

constrainer->apply ();
Constrainer::Shape sh = constrainer_->outputMatrixShape ();
Vector x ( sh[1] );
Vector b ( sh[0] );
constrainer->getRhs ( b, rhs );
solver->solve ( x, b );
constrainer->getSolution ( lhs, x );

Note that the function apply may update the shape of the output matrix. It is therefore called before the solution vector and right-hand side vector are created.

Implements jive::solver::Solver.