classdef chompSolverOptions
%CHOMPSOLVEROPTIONS Solver options for CHOMP
%
%   OPTS = chompSolverOptions returns a solver options object, OPTS, which
%   can be used with manipulatorCHOMP to optimize a trajectory.
%
%   OPTS = chompSolverOptions(PropertyName=PropertyValue) sets properties
%   on the object using name-value arguments.
%
%   chompSolverOptions properties:
%       Verbosity         - Verbosity level of diagnostic output on
%                           MATLAB Command Window
%       FunctionTolerance - Termination tolerance on objective function
%       MaxTime           - Maximum time to optimize a trajectory
%       MaxIterations     - Maximum number of iterations
%       LearningRate      - Learning rate of solver
%
%   Example:
%       % Load a robot and create a CHOMP solver.
%       rbt = loadrobot("kinovaGen3",DataFormat="row");
%       chomp = manipulatorCHOMP(rbt);
%
%       % Create solver options for CHOMP solver.
%       solverOpts = chompSolverOptions;
%
%       % Set the optimize verbosity level and the maximum number of
%       %iterations to "concise" and 200, respectively.
%       solverOpts.Verbosity = "concise";
%       solverOpts.MaxIterations = 200;
%
%       % Add the solver options to CHOMP solver.
%       chomp.SolverOptions = solverOpts;
%
%   See also chompCollisionOptions, chompSmoothnessOptions

% Copyright 2022 The MathWorks, Inc.

%#codegen

    properties

        %Verbosity Verbosity level of diagnostic output on MATLAB Command Window
        %   Verbosity level indicating the level of detail associated with
        %   the diagnostic output of manipulatorCHOMP/optimize, specified
        %   as either of these options:
        %   - "none" - No diagnostic information
        %   - "concise" - Total object function diagnostic information
        %   - "detailed" - Smoothness and collision diagnostic information
        %
        %   Default: "none"
        Verbosity{...
            mustBeA(Verbosity,{'string','char'}),...
            validatestring(Verbosity,{'none','concise','detailed'})}='none'

        %FunctionTolerance Termination tolerance on the objective function
        %   Tolerance on the relative change in the objective function
        %   during manipulatorCHOMP/optimize, specified as a nonnegative
        %   numeric scalar. If the relative change in the objective
        %   function is below the specified function tolerance, the
        %   optimize function terminates.
        %
        %   Default: 1e-2
        FunctionTolerance (1,1) {...
            mustBeNumeric,...
            mustBeGreaterThanOrEqual(FunctionTolerance,0)}=1e-2

        %MaxTime Maximum time to optimize a trajectory
        %   Maximum time to optimize a trajectory specified as a
        %   nonnegative numeric scalar, in seconds.
        %
        %   Default: 10
        MaxTime (1,1) {...
            mustBeNumeric,...
            mustBeGreaterThanOrEqual(MaxTime,0)}=10

        %MaxIterations Maximum number of iterations
        %   Maximum number of iterations allowed to optimize a trajectory
        %   specified as a positive numeric scalar.
        %
        %   Default: 50
        MaxIterations (1,1) {...
            mustBeInteger,...
            mustBeGreaterThanOrEqual(MaxIterations,0)}=50

        %LearningRate Learning rate of solver
        %   Learning rate of solver, specified by a positive numeric
        %   scalar, at which the trajectory must be updated.
        %
        %   Default: 5
        LearningRate (1,1) {...
            mustBeNumeric,...
            mustBePositive}=5
    end

    methods
        function obj=chompSolverOptions(nvargs)
        %chompSolverOptions Constructor
            arguments
                nvargs.Verbosity
                nvargs.FunctionTolerance
                nvargs.MaxTime
                nvargs.MaxIterations
                nvargs.LearningRate
            end
            userProvidedProperties=fieldnames(nvargs);
            for i=coder.unroll(1:length(userProvidedProperties))
                obj.(userProvidedProperties{i})=nvargs.(userProvidedProperties{i});
            end
        end
    end
end
