Solver Class Reference

Abstract base class for solving an optimization problem. More...

#include <opt.h>

Inheritance diagram for Solver:
Inheritance graph
[legend]
Collaboration diagram for Solver:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Solver (int n, Pointer< ostream > out_solver_p_=out_out_p, Pointer< ostream > out_solver_log_p_=out_log_p)
 Constructor for the dimension.
virtual ~Solver ()
 Virtual Destructor.
int dim () const
 Gives the dimension.
double opt_val ()
 Gives the optimal value.
double time ()
 Gives the time, needed to solve the problem.
int iter ()
 Gives the number of iterations, needed to solve the problem.
virtual int solve ()=0
 Solves the problem.
virtual int solve (dvector &x)
 Solves the problem for a starting point.
virtual void print (ostream &out) const
 Print's some information about the problem.

Public Attributes

Pointer< ostream > out_solver_p
 A Pointer to an ostream to print solver-relevant information to.
Pointer< ostream > out_solver_log_p
 A Pointer to an ostream to print solver-relevant logging-information to.
double tol
 A tolerance value.
int iter_max
 The maximal number of iterations.
dvector sol_point
 The solution point.

Protected Attributes

int dim_
 The number of variables.
double time_
 The time, needed to find the solution.
double opt_val_
 The optimal value.
int iter_
 The number of iterations.

Friends

ostream & operator<< (ostream &out, const Solver &a)
 Output-Operator.

Detailed Description

Abstract base class for solving an optimization problem.

You need to implement the following method:

Definition at line 20 of file opt.h.


Constructor & Destructor Documentation

Solver::Solver ( int  n,
Pointer< ostream >  out_solver_p_ = out_out_p,
Pointer< ostream >  out_solver_log_p_ = out_log_p 
) [inline]

Constructor for the dimension.

Sets sol_point to zero, time_ and tol to -1, iter_max to INF, optimal and no_sol to false.

Parameters:
n The dimension of the problem.
out_solver_p_ A Pointer to an ostream, to print solver-output to, default is out_out_p.
out_solver_log_p_ A Pointer to an ostream, to print solver-related logging-output to, default is out_log_p.

Definition at line 92 of file opt.h.

virtual Solver::~Solver (  )  [inline, virtual]

Virtual Destructor.

Definition at line 99 of file opt.h.


Member Function Documentation

int Solver::dim (  )  const [inline]

Gives the dimension.

Returns:
The dimension of the problem.

Definition at line 104 of file opt.h.

double Solver::opt_val (  )  [inline]

Gives the optimal value.

Returns:
The optimal value.

Definition at line 109 of file opt.h.

double Solver::time (  )  [inline]

Gives the time, needed to solve the problem.

Reimplemented in LocOpt.

Definition at line 113 of file opt.h.

int Solver::iter (  )  [inline]

Gives the number of iterations, needed to solve the problem.

Definition at line 117 of file opt.h.

virtual int Solver::solve (  )  [pure virtual]

Solves the problem.

Abstract.

Returns:
A status code: 0, if all went right.
See also:
solve(dvector&)

Implemented in MinlpBCP, gamsLocOpt, IpOpt, LagHeu, LinearRelaxSolver, MinlpOpt, LPSolver, BoxLocOpt, SimpleEquationSolver, SubGradOpt, and Random.

virtual int Solver::solve ( dvector x  )  [inline, virtual]

Solves the problem for a starting point.

Sets sol_point to x. Calls solve().

Parameters:
x The dvector to start the solver with.
See also:
solve()

Reimplemented in MinlpBCP, gamsLocOpt, IpOpt, LPSolver, BoxLocOpt, SimpleEquationSolver, SubGradOpt, and Random.

Definition at line 132 of file opt.h.

virtual void Solver::print ( ostream &  out  )  const [inline, virtual]

Print's some information about the problem.

Print's the dimension, the tolerance, the solution time, the number of iterations and if an optimal solution was found.

Parameters:
out The ostream to print to.

Definition at line 138 of file opt.h.


Friends And Related Function Documentation

ostream& operator<< ( ostream &  out,
const Solver a 
) [friend]

Output-Operator.

Calls a.print(out).

Parameters:
out The ostream to print to.
a The Solver to print.
Returns:
The ostream.

Definition at line 27 of file opt.h.


Member Data Documentation

int Solver::dim_ [protected]

The number of variables.

See also:
dim()

Definition at line 28 of file opt.h.

double Solver::time_ [protected]

The time, needed to find the solution.

See also:
time()

Definition at line 39 of file opt.h.

double Solver::opt_val_ [protected]

The optimal value.

See also:
opt_val()

Definition at line 44 of file opt.h.

int Solver::iter_ [protected]

The number of iterations.

See also:
iter()

Definition at line 49 of file opt.h.

A Pointer to an ostream to print solver-relevant information to.

See also:
out_solver

Definition at line 54 of file opt.h.

A Pointer to an ostream to print solver-relevant logging-information to.

See also:
out_solver_log

Definition at line 58 of file opt.h.

double Solver::tol

A tolerance value.

See also:
set_tol(double)

Definition at line 75 of file opt.h.

The maximal number of iterations.

See also:
set_itermax(int)

Definition at line 80 of file opt.h.

The solution point.

Definition at line 84 of file opt.h.


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

Generated on 10 Mar 2013 for LaGO by  doxygen 1.6.1