Repository navigation
Conversation
…in the physical time (#308) Corleone integrates on a fixed horizon. A problem with a variable tf is written on [0, 1] in s = (t - t0) / (tf - t0), with tf a parameter to optimize and the derivatives and integrands multiplied by the duration tf - t0. The solve helper starts tf from the guess of the problem and puts the trajectory back on the physical time; the continuous comparison reads tf as the variable of the problem and divides the functions by the duration. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ee final time (#308) A Mayer cost on the final time, written in the reduced time. Passes the continuous comparison with OptimalControl, which fails when the dynamics, the final condition or the bound of tf is changed, and the smoke solve. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #308. Stacked on #451: its base is
feat/mtk-more-problems; retarget it tomainonce #451 is merged. Applied conventions:ct-conventions v0.12.0,ct-agents v0.4.0.An experiment, to decide whether the problems with a free final time can be written in the ModelingToolkit modeling:
mountain_carfirst. Eleven of the thirteen problems that #451 leaves have a variabletf.The idea
Corleone integrates on a fixed horizon, so
tfcannot be an unknown of theSystem. The ModelingToolkit model of such a problem is written in the reduced times = (t - t0) / (tf - t0)on[0, 1], with the final timetfas a parameter to optimize (tunable, with its bounds), the derivatives and the integrands multiplied by the durationtf - t0. It is an exact rewriting, and it is what SciML's catalogue does with a parameterT(hang_glider,goddarts_rocket).The OptimalControl and JuMP models are not touched. Only the ModelingToolkit files and the test helpers change. A page of the documentation will explain the reduced time, as the JuMP schemes have theirs (a separate pull request).
The parameter is named
tf, as the variable of the OptimalControl and JuMP models, so thatvariable_componentsand the start of the solve (init.variable) need no mapping.What changes in the tests
SolveModelingToolkit.free_final_time,times(physical(t0, tf),tfisnothingwhen free) andtspan((0, 1)when free).preparestarts the variables from the guess of the problem (variable_start), as the controls and the free initial states.t0 + (tf - t0) s, and recordstfas the variable.ContinuousModelingToolkit.problem_data) readstfas the variable, withtimes = v -> (t0, v[1]), and divides the dynamics and the integrand by the duration, evaluated at the reduced time of the point.Convention for the models written this way
The parameter is
tf; the horizon of theSystemis[0, 1]; the dynamics and the integrands carry the factortf - t0; a time that appears explicitly ist0 + (tf - t0) * s; the final conditions are written ats = 1.Test plan
Pkg.test(; test_args=["ModelingToolkit", "problem=mountain_car,bryson_denham,bioreactor"]): 170 passed (test_methods51,test_modelings50,test_problem66,test_smoke3), andcorepasses.mountain_car:achanged failsdynamics,vel_tf_minfailsboundary,tf_minfailsvariable_bounds.tfas a parameter to optimize: its bound and the bounds of the control are in the problem (lb,ub), and the objective moves in a solve of a few iterations.test ModelingToolkit backend.mountain_car(a solve on the default grid).Open
bioreactor,double_oscillatorand others are fixed-time here; among the free-time ones, which have an explicit time?).🤖 Generated with Claude Code