re. constrained optimization
Posted: Fri Sep 18, 2015 7:51 am
Hi,
I am trying to run a constrained forward optimization. I tried to includethe constraint function in the optimization class, but I feel that both the objective function and constraint function are running independent of each other.
My doubt: Do I need to repeat the same steps inside constrained function, similar to the objective function. or is it possible to pass the parameters obtained from objective function directly to the constraint function?
hope someone could find the error and kindly correct me.
thanks
Nithin
I am trying to run a constrained forward optimization. I tried to includethe constraint function in the optimization class, but I feel that both the objective function and constraint function are running independent of each other.
My doubt: Do I need to repeat the same steps inside constrained function, similar to the objective function. or is it possible to pass the parameters obtained from objective function directly to the constraint function?
hope someone could find the error and kindly correct me.
thanks
Nithin
Code: Select all
// Example:
class ProblemSystem : public OptimizerSystem {
public:
int objectiveFunc( const Vector & newControllerParameters, bool new_coefficients, Real& f ) const {
// 1 . Updating newControllerParameters for muscle
// 2. Adding an analysis
// 3. integrating states
// 4. From states ( from analysis) formulate the f (objective function), and get x to minimise
f = [x] ;
return( 0 );
}
int constraintFunc( const Vector &newControllerParameters, bool new_coefficients, Vector &constraints) const{
// 1 . Updating newControllerParameters for muscle
// 2. Adding an analysis
// 3. integrating states
// 4. From analysis, states formulate the f (objective function), and get x
constraints[0] = x[0] - 25.0;
return(0);
}
ProblemSystem( const int numParams, const int numEqualityConstraints) :
OptimizerSystem( numParams )
{
setNumEqualityConstraints( numEqualityConstraints );
}
};