MULTIBODY SIMULATION SOFTWARE - API documentation

chrono::ChOptimizer Class Reference

#include <CHsolvmin.h>

Inheritance diagram for chrono::ChOptimizer:

Inheritance graph
[legend]
Collaboration diagram for chrono::ChOptimizer:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ChOptimizer ()
virtual void Copy (ChOptimizer *source)
virtual void SetObjective (char *mformula)
char * GetObjective ()
void SetDatabase (void *newdb)
void * GetDatabase ()
virtual void AddOptVar (CHoptVar *newvar)
virtual void RemoveOptVar (CHoptVar *newvar)
virtual CHoptVarGetVarList ()
virtual void SetVarList (CHoptVar *mv)
virtual int CompileOptVar ()
virtual int GetNumOfVars ()
virtual void SetNumOfVars (int mv)
virtual void SetObjective (double(*m_func)(double p[], void *my_data))
virtual void SetDObjective (void(*m_dfunc)(double p[], double dp[], void *my_data))
double * GetXv ()
double * GetXv_sup ()
double * GetXv_inf ()
void SetXv (double *mx)
void SetXv_sup (double *mx)
void SetXv_inf (double *mx)
void * GetMyData ()
void SetMyData (void *mmy_data)
int Vars_to_System (double x[])
int Vars_to_System (ChMatrix<> *x)
int System_to_Vars (double x[])
int System_to_Vars (ChMatrix<> *x)
double Eval_fx (double x[])
double Eval_fx (ChMatrix<> *x)
void Eval_grad (double x[], double gr[])
void Eval_grad (ChMatrix<> *x, ChMatrix<> *gr)
virtual int PreOptimize ()
virtual int DoOptimize ()
virtual int PostOptimize ()
virtual int Optimize ()
void DoBreakCheck ()

Public Attributes

bool minimize
double grad_step
double opt_fx
char err_message [200]
int error_code
long fx_evaluations
long grad_evaluations
int(* break_funct )()
int break_cycles
int user_break
int break_cyclecounter

Protected Attributes

char function [300]
CHoptVaroptvarlist
void * database
int C_vars
double(* func )(double p[], void *my_data)
void(* dfunc )(double p[], double dp[], void *my_data)
void * my_data
double * xv
double * xv_sup
double * xv_inf
JSScript * fx_script


Detailed Description

Base class for multi-variable optimization.

Constructor & Destructor Documentation

chrono::ChOptimizer::ChOptimizer (  ) 

Ch_optimizer Base optimization engine member functions


Member Function Documentation

void chrono::ChOptimizer::SetObjective ( char *  mformula  )  [virtual]

Sets the objective function to maximize, as ASCII interpreted formula Such fourmula will be interpreted by the "database" object.

Reimplemented in chrono::ChOptimizerHybrid.

void chrono::ChOptimizer::SetDatabase ( void *  newdb  ) 

Sets the database which will be accessed by interpreted formulas [obsolete].

Reimplemented in chrono::ChOptimizerHybrid.

void chrono::ChOptimizer::AddOptVar ( CHoptVar newvar  )  [virtual]

Sets the optimization variables.

Reimplemented in chrono::ChOptimizerHybrid.

int chrono::ChOptimizer::GetNumOfVars (  )  [virtual]

returns the number of optimization variables set.

virtual void chrono::ChOptimizer::SetNumOfVars ( int  mv  )  [virtual]

Set the number of optimization variables. note: if you use the CHoptVar "ascii" variables, this is not needed -the count is automatic- but you MUST set it > 0 if you want to use the "C" evaluation of *funct()!!!

Reimplemented in chrono::ChOptimizerHybrid.

virtual void chrono::ChOptimizer::SetObjective ( double(*)(double p[], void *my_data)  m_func  )  [virtual]

Set the C function which will be used for fx evaluation instead of parsing of "ascii" objective formula.

Reimplemented in chrono::ChOptimizerHybrid.

void* chrono::ChOptimizer::GetMyData (  ) 

Function optional argument: the "my_data" generic pointer..

int chrono::ChOptimizer::Vars_to_System ( double  x[]  ) 

The multibody system "database" gets the current state of variables. Ret. null if can't set values

int chrono::ChOptimizer::System_to_Vars ( double  x[]  ) 

The variables gets their corresponding values in multibody system. Return null if can't get values

double chrono::ChOptimizer::Eval_fx ( double  x[]  ) 

Returns the value of the functional, for given state of variables and with the given "database" multibody system. Here evaluates the string "function".

void chrono::ChOptimizer::Eval_grad ( double  x[],
double  gr[] 
)

Computes the gradient of objective function, for given state of variables. The gradient is stored into gr vector.

int chrono::ChOptimizer::PreOptimize (  )  [virtual]

Performs the optimization of the ChSystem pointed by "database" (or whatever object which can evaluate the string "function" and the "optvarlist") using the current parameters. Returns false if some error occured.

int chrono::ChOptimizer::Optimize (  )  [virtual]

Does the three steps in sequence PreOptimize, DoOptimize, PostOptimize. The derived classes shouldn't need the definition of this method, because they just have to implement the DoOptimize.

void chrono::ChOptimizer::DoBreakCheck (  ) 

Each break_cycles number of times this fx is called, the function break_funct() is evaluated (if any) and if positive, the variable user_break becomes true.


Member Data Documentation

double(* chrono::ChOptimizer::func)(double p[], void *my_data) [protected]

The user can provide the evaluation fx also in form of a generic C function of N parameters (passed as a vector double[] p), which will be used if C_vars >0 and by providing the function "*funct", otherwise NULL for parsing of the ASCII formula "function".

void(* chrono::ChOptimizer::dfunc)(double p[], double dp[], void *my_data) [protected]

Same as above, but to compute gradient. If NULL (as default), the gradient is obtained numerically by differentiation.

bool chrono::ChOptimizer::minimize

default = false; just maximize

double chrono::ChOptimizer::grad_step

default = 1.e-12; step size for evaluation of gradient

double chrono::ChOptimizer::opt_fx

best resulting value of objective function

char chrono::ChOptimizer::err_message[200]

the ok/warning/error messages are written here

long chrono::ChOptimizer::fx_evaluations

number of function evaluations

long chrono::ChOptimizer::grad_evaluations

number of gradient evaluations

int(* chrono::ChOptimizer::break_funct)()

if not null, this function is called each 'break_cycles' evaluations

int chrono::ChOptimizer::break_cycles

how many fx evaluations per check

int chrono::ChOptimizer::user_break

if break_funct() reported TRUE, this flag is ON, and optimizers should exit all cycles

int chrono::ChOptimizer::break_cyclecounter

internal


CHRONO::ENGINE
C++ library for multibody simulation, (C) Alessandro Tasora
This API documentation has been generated on 17 Jul 2009 by Doxygen