BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
belfem::opt::Optimizer Class Reference

driver that optimizes an Objective using a chosen Algorithm. More...

#include <cl_Optimizer.hpp>

Public Member Functions

 Optimizer (Objective &aObjective, const Algorithm aAlgorithm)
 ~Optimizer ()=default
void set_bounds (const Vector< real > &aLowerBounds, const Vector< real > &aUpperBounds)
 set the lower and upper bounds of the design variables.
Status optimize (Vector< real > &aX, real &aValue)
 run the optimization, starting from and writing back into aX.
const stringerrmsg () const
 detailed diagnostic from the solver for the most recent optimize() call ( e.g.
realftol_rel ()
 relative tolerance on the objective value ( ftol_rel )
realxtol_rel ()
 relative tolerance on the design vector ( xtol_rel )
uintmax_eval ()
 maximum number of objective evaluations; 0 means unlimited
bool & maximize ()
 flag selecting maximization ( true ) over minimization ( false )
const Algorithmalgorithm () const
 the algorithm used by this optimizer

Detailed Description

driver that optimizes an Objective using a chosen Algorithm.

This is the counterpart of ode::Integrator: it owns the numerical bookkeeping (bounds, tolerances, evaluation budget) while remaining agnostic of what is being optimized. The concrete solver library (nlopt) is a private implementation detail of cl_Optimizer.cpp.

The Objective is borrowed by reference (non-owning) and must outlive every call to optimize(), just as ode::Integrator borrows its ODE.

Constructor & Destructor Documentation

◆ Optimizer()

belfem::opt::Optimizer::Optimizer ( Objective & aObjective,
const Algorithm aAlgorithm )

◆ ~Optimizer()

belfem::opt::Optimizer::~Optimizer ( )
default

Member Function Documentation

◆ algorithm()

const Algorithm & belfem::opt::Optimizer::algorithm ( ) const
inline

the algorithm used by this optimizer

◆ errmsg()

const string & belfem::opt::Optimizer::errmsg ( ) const
inline

detailed diagnostic from the solver for the most recent optimize() call ( e.g.

which bound fails lb <= ub ); empty when no detail was reported. Complements the generic error_message( status ).

◆ ftol_rel()

real & belfem::opt::Optimizer::ftol_rel ( )
inline

relative tolerance on the objective value ( ftol_rel )

◆ max_eval()

uint & belfem::opt::Optimizer::max_eval ( )
inline

maximum number of objective evaluations; 0 means unlimited

◆ maximize()

bool & belfem::opt::Optimizer::maximize ( )
inline

flag selecting maximization ( true ) over minimization ( false )

◆ optimize()

Status belfem::opt::Optimizer::optimize ( Vector< real > & aX,
real & aValue )

run the optimization, starting from and writing back into aX.

Parameters
aXon entry the initial guess, on exit the optimum
aValueon exit the objective value at aX
Returns
the termination status

aX and aValue are only meaningful when is_usable( status ) is true; on failure they must not be trusted. When the solver reports a detailed diagnostic, it is available via errmsg().

◆ set_bounds()

void belfem::opt::Optimizer::set_bounds ( const Vector< real > & aLowerBounds,
const Vector< real > & aUpperBounds )

set the lower and upper bounds of the design variables.

Each vector must have length objective.dimension().

Setting aLowerBounds( i ) == aUpperBounds( i ) fixes design variable i: nlopt eliminates that dimension internally, so parameters can be pinned without changing the Objective.

◆ xtol_rel()

real & belfem::opt::Optimizer::xtol_rel ( )
inline

relative tolerance on the design vector ( xtol_rel )


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