Hi,
I tested an example of Simmath optimization.
But I think there are some problems in the example written in the user guide.
So after some modifications on the original code written in the user guide, I could get the proper result.
The class ‘OptimizerSystem’ has one default constructor and one overloaded constructor. But the overloaded constructor should take only one parameter value according to SimTKcore 2.0 doxygen documentation. But in the user guide the overloaded constructor of OptimizerSystem class takes two parameters. So at the end of the definition of class ‘ProblemSystem’, some modification may be applied like this:
ProblemSystem( const int numParams, const int numConstraints) :
OptimizerSystem( numParams ) {
setNumInequalityConstraints(numConstraints);
}
And ‘NUMBER_OF_PARAMETERS’ and ‘NUMBER_OF_CONSTRAINTS’ are not predetermined. In this example, these two values should be same as 2 because the parameters are x1 & x2 and the number of constraint equations is 2.
Here, I have an additional question.
When overriding ‘constraintFunc’ virtual function for ProblemSystem class inherited from OptimizerSystem class, users can put both equality constraint equations and inequality constraint equations. When inequality constraint equations are in form of ‘f(x)>=0’, then can I write this inequality constraint equation as ‘constraints[index]=f(x)’ in the constraintFunc function?
Thanks very much for reading this question and please help me get your advice.
Best regards,
Moonki
Question about Simmath example in user guide
- Moon Ki Jung
- Posts: 44
- Joined: Wed Oct 24, 2007 2:56 am
- Jack Middleton
- Posts: 11
- Joined: Thu Mar 31, 2005 11:55 am
RE: Question about Simmath example in user gu
Hi Moonki,
The PDF of the Simmath User's Guide was out of date so I have updated and posted the new version on the SimTKcore documents page. The constructor for ProblemSystem should look like this:
ProblemSystem( const int numParams, const int numEqualityConstraints, const int numInequalityConstraints ) :
OptimizerSystem( numParams )
{
setNumEqualityConstraints( numEqualityConstraints );
setNumInequalityConstraints( numInequalityConstraints );
}
This example is also in the UserGuide.cpp file in the examples/simmath directory of the download.
Regarding you second question, yes you can express equations of the form ‘f(x)>=0’, as ‘constraints[index]=f(x)’ in the constraintFunc() method
Jack
The PDF of the Simmath User's Guide was out of date so I have updated and posted the new version on the SimTKcore documents page. The constructor for ProblemSystem should look like this:
ProblemSystem( const int numParams, const int numEqualityConstraints, const int numInequalityConstraints ) :
OptimizerSystem( numParams )
{
setNumEqualityConstraints( numEqualityConstraints );
setNumInequalityConstraints( numInequalityConstraints );
}
This example is also in the UserGuide.cpp file in the examples/simmath directory of the download.
Regarding you second question, yes you can express equations of the form ‘f(x)>=0’, as ‘constraints[index]=f(x)’ in the constraintFunc() method
Jack
- Moon Ki Jung
- Posts: 44
- Joined: Wed Oct 24, 2007 2:56 am
RE: Question about Simmath example in user gu
Hi Jack,
Thanks very much for your kind help to my question.
Best regards,
Moonki
Thanks very much for your kind help to my question.
Best regards,
Moonki