From c2769ed522500b83c23f572312d1309a414d880d Mon Sep 17 00:00:00 2001 From: Charbie Date: Mon, 29 Apr 2024 11:04:07 -0400 Subject: [PATCH 1/2] needed to get the order of opperations --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e5dc8749..c57523bb0 100644 --- a/README.md +++ b/README.md @@ -328,7 +328,11 @@ algebraic states (s = optimization variables that are defined at each node but t built-in continuity constraints), and parameters (p = optimization variables defined once per phase). The state continuity constraints implementation may vary depending on the transcription of the problem (implicit vs explicit, direct multiple shooting vs direct collocations). -The cost function can include Mayer terms (function evaluated at one node) and Lagrange terms (functions integrated over the duration of the phase). +The cost function can include Mayer terms (function evaluated at one node, the default is the last node) and Lagrange terms (functions integrated over the duration of the phase). +The Lagrange terms are computed as +```python +L = sum((current_cost - cost_target)**2 * dt * weight) +``` The optimization variables can be subject to equality and/or inequality constraints. # A first practical example From e14ae096ba7df5c0d7f89de5dac3a014d44c0c97 Mon Sep 17 00:00:00 2001 From: Charbie Date: Mon, 29 Apr 2024 13:34:30 -0400 Subject: [PATCH 2/2] Ipuch's comments --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c57523bb0..0521788fb 100644 --- a/README.md +++ b/README.md @@ -329,10 +329,13 @@ built-in continuity constraints), and parameters (p = optimization variables def The state continuity constraints implementation may vary depending on the transcription of the problem (implicit vs explicit, direct multiple shooting vs direct collocations). The cost function can include Mayer terms (function evaluated at one node, the default is the last node) and Lagrange terms (functions integrated over the duration of the phase). -The Lagrange terms are computed as +The Lagrange terms are computed by default as EulerForward Integrals: ```python -L = sum((current_cost - cost_target)**2 * dt * weight) +L = 0 +for i in range(n_shooting): + L += weight * sum((evaluated_cost[:, i] - target_cost[:, i])**2 * dt) ``` +Where `weight` is by default 1 and `target_cost` is by default 0. For more advanced approximations, see QuadratureRule section. They can be used to evaluate more accurately the Lagrange terms of the cost function. The optimization variables can be subject to equality and/or inequality constraints. # A first practical example