Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Here's a skeleton of the FlippinFelinesOptimizerSystem class. The two functions that are the most important are the constructor and objectiveFunc(). We focus on these. The definition of an optimization problem consists primarily of (1) parameters/inputs, and (2) the objective function. The constructorparts that deal with the parameters are C.2, C.3, C.4, and C.5

Code Block
languagecpp
titleFlippinFelinesOptimizerSystem.h
 /**
 * Finds a control input history that achieves certain desired features
 * of a cat's flipping maneuver, as determined by the objective function.
 * The control of the system is performed via a PrescribedController that
 * uses a spline for all actuators.
 *
 * Parameters are ordered by actuator, then by spline point index for a
 * given actuator. Parameters are nondimensionalized by the min or max
 * control values for the associated actuator.
 * */
class FlippinFelinesOptimizerSystem : public SimTK::OptimizerSystem {
public:
    /**
     * @param tool
Contains
all input settings.      * */
    FlippinFelinesOptimizerSystem(OpenSim::FlippinFelinesOptimizerTool & tool) :
        _tool(tool),
        _duration(1.0),
        _objectiveCalls(0),
        _objectiveFcnValueBestYet(SimTK::Infinity),
    {
        // Parse inputs & prepare output
        // --------------------------------------------------------------------
	    //    //********** PART C.1 **********

        // Add a controller to the model to control the actuators it has
        // --------------------------------------------------------------------
        // C.2
        ********** PART C.2 **********

		// Set parameter limits/bounds for the optimization.
        // --------------------------------------------------------------------
        // ********** PART C.3 **********

    }
    SimTK::Vector initialParameters()
    {
        // ********** PART C.4 **********
    }
    
    /**
     * Defines desired features for the cat model's flip. Each call to this
     * function updates the model's control, runs a forward dynamic simulation
     * with this control, computes the objective value resulting from the
     * simulation, and saves the results to output.
     * */
    int objectiveFunc(const SimTK::Vector & parameters, bool new_parameters,
            SimTK::Real & f) const
    {
        // ...
        // Unpack parameters into the model (i.e., update spline points)
        // --------------------------------------------------------------------
        // ********** PART C.5         **********

		// Run a forward dynamics simulation
        // --------------------------------------------------------------------
        // ********** PART C.6 **********

        // Construct the objective function, term by term
        // --------------------------------------------------------------------
        // ********** PART C.7 **********

        // Update the log and outputs with the objective function value
        // --------------------------------------------------------------------
        // ********** PART C.8 Collapsible.**********

    }
    // Miscellaneous functions (used, but uninteresting)
    // ------------------------------------------------------------------------
    // TODO collapsible.
    //********** PART C.10 **********

private:

    // Objective function terms
    // ------------------------------------------------------------------------
    // ********** PART C.7, collapsible
     **********

	// Member variables
    // ------------------------------------------------------------------------
    	// 
    //********** PART C.9 **********

};

TODO why you would look at the member variables section.

C.1: Optimization parameters

...