Class CompositeOptimizerUsingGradient

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, HandlesInternalLinks

    public class CompositeOptimizerUsingGradient
    extends ReflectComposite
    This actor implements a composite optimizer that optimizes a function provided as an SDF model in the inner composite. To use the composite optimizer, construct an SDF model on the inside that operates on the x input to output four values: (i) an intermediate result, that is a function of x and possibly other inputs, (ii) a double array containing the values of the constraints, calculated for the specific x input, (iii) a double matrix that is a gradient of a function of x, and (iv) an array of double matrices that is a gradient of the constraints. If the gradients (iii) and (iv) can't be defined, un-check the parameter "useGradient" in expert mode so that (iii) and (iv) are not used.

    In the case that the objective function is only a function of x, the trigger input should be used to start a new optimization round.

    The variable named "maxEvaluations" can be used to limit the number of evaluations. Specifically, the inside SDF model will be fired at most maxEvaluations times. There may be several reasons it is fired less than this number. The iteration may terminate due to any of the following reasons: (i) convergence criteria met (ii) user requests termination (iii) the roundoff errors become damaging, especially if the function is not smooth, and no optimal value can be found under given constraints (iv) maximum number of evaluations are reached.

    This actor is properly viewed as a "higher-order component" in that its contained actor is a parameter that specifies how to operate on input arrays. It is inspired by the higher-order functions of functional languages, but unlike those, the contained actor need not be functional. That is, it can have state.

    If the gradients are used (the parameter "useGradient" is checked), Barrier Method is used as the solver. Barrier Method performs optimization efficiently using gradients and estimating the hessian of the objective function and the constraints. If the parameter "useGradient" is un-checked, current implementation uses Cobyla as the solver. Cobyla implements the trust-region-reflective algorithm and performs a type of gradient descent optimization, ideal for objective functions that are non-convex and/or with unknown gradient.

    Since:
    Ptolemy II 11.0
    Version:
    $Id$
    Author:
    Shuhei Emoto, Ilge Akkaya, Edward A. Lee
    Pt.AcceptedRating:
    Pt.ProposedRating:
    Red (shuhei)
    • Field Detail

      • rhoBeg

        public Parameter rhoBeg
        The expert parameter that denotes the beginning step-size.
      • rhoEnd

        public Parameter rhoEnd
        The expert parameter that denotes the final step-size.
      • reusePreviousResult

        public Parameter reusePreviousResult
        The expert parameter that decides whether to reuse previous result as the initial value.
      • useGradient

        public Parameter useGradient
        The expert parameter that decides whether to use Interior point method or not.
      • maxEvaluations

        public Parameter maxEvaluations
        Maximum number of function evaluations per iteration.
      • mode

        public Parameter mode
        Optimization mode. ( min or max)
      • dimensionOfOptimizationSpace

        public Parameter dimensionOfOptimizationSpace
        The dimension of optimization space. Also equal to the length of the optimization variable array, x.
      • numberOfConstraints

        public Parameter numberOfConstraints
        Number of constraints checked at each evaluation. The expected type of constraints is a double array with length numberOfConstraints.
      • optimalValue

        public TypedIOPort optimalValue
        Optimal Value
    • Method Detail

      • clone

        public java.lang.Object clone​(Workspace workspace)
                               throws java.lang.CloneNotSupportedException
        Description copied from class: ReflectComposite
        Clone the object into the specified workspace. This overrides the base class to set up the associations in the mirror ports and to set a flag indicating that cloning is complete.
        Overrides:
        clone in class ReflectComposite
        Parameters:
        workspace - The workspace for the new object.
        Returns:
        A new NamedObj.
        Throws:
        java.lang.CloneNotSupportedException - If any of the attributes cannot be cloned.
        See Also:
        CompositeEntity.exportMoML(Writer, int, String)