Skip to main content

setupCommonOptimalControlSolverSettings.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% This function sets up the common set of settings for an optimal control
% problem and is used by Tracking Optimization, Verification Optimization,
% and Design Optimization
%
% (struct, struct, struct, struct, function handle, function handle)
% -> (struct)
% return a set of solver values common to all optimal control problems


function setup = setupCommonOptimalControlSolverSettings(inputs, ...
bounds, guess, params, continuousFunction, endpointFunction)
setup.name = params.solverSettings.optimizationFileName;
setup.functions.continuous = continuousFunction;
auxdata.ContinuousFunc = setup.functions.continuous;
setup.functions.endpoint = endpointFunction;
setup.auxdata = inputs;
setup.bounds = bounds;
setup.guess = guess;
setup.derivatives.supplier = params.solverSettings.derivativeSupplier;
setup.derivatives.derivativelevel = params.solverSettings.derivativeLevel;
setup.derivatives.dependencies = params.solverSettings.derivativeDependencies;
setup.derivatives.stepsize1 = params.solverSettings.stepSize;
setup.scales.method = params.solverSettings.scaleMethods;
setup.method = params.solverSettings.method;
setup.mesh.method = params.solverSettings.meshMethod;
setup.mesh.tolerance = params.solverSettings.meshTolerance;
setup.mesh.maxiterations = params.solverSettings.meshMaxIterations;
setup.mesh.colpointsmin = params.solverSettings.meshColpointsMin;
setup.mesh.colpointsmax = params.solverSettings.meshColpointsMax;
setup.mesh.splitmult = params.solverSettings.meshSplitMult;
setup.mesh.curveRatio = params.solverSettings.meshCurveRatio;
setup.mesh.R = params.solverSettings.meshR;
setup.mesh.sigma = params.solverSettings.meshSigma;
N = params.solverSettings.numCollocationPoints;
P = params.solverSettings.numIntervals;
setup.mesh.phase.colpoints = P * ones(1, N);
setup.mesh.phase.fraction = ones(1, N) / N;
setup.nlp.solver = params.solverSettings.solverType;
setup.nlp.ipoptoptions.linear_solver = params.solverSettings.linearSolverType;
setup.nlp.ipoptoptions.tolerance = params.solverSettings.solverTolerance;
setup.nlp.ipoptoptions.maxiterations = params.solverSettings.maxIterations;
setup.nlp.snoptoptions.linear_solver = params.solverSettings.linearSolverType;
setup.nlp.snoptoptions.tolerance = params.solverSettings.solverTolerance;
setup.nlp.snoptoptions.maxiterations = params.solverSettings.maxIterations;
setup.displaylevel = params.solverSettings.displayLevel;
end