Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single phase problem and calcium summation in control #6

Merged
merged 48 commits into from
Nov 15, 2024

Conversation

Kev1CO
Copy link
Collaborator

@Kev1CO Kev1CO commented Oct 3, 2024

All Submissions:

  • Have you followed the guidelines in our Contributing document [docs/contribution.md]?
  • Have you checked to ensure there aren't other open [Pull Requests] for the same update/change?
  • Have you opened/linked the issue related to your pull request?
  • Have you used the tag [WIP] for ongoing changes, and removed it when the pull request was ready?
  • When ready to merge, have you sent a comment pinging @Kev1CO in it?

New Feature Submissions:

  1. Does your submission pass the tests (if not please explain why this is intended)?
  2. Did you write a proper documentation (docstrings and ReadMe)
  3. Have you linted your code locally prior to submission (using the command: black . -l120 --exclude "external/*")?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new examples for your core changes, as applicable?
  • Have you written new tests for your core changes, as applicable?

This change is Reviewable

Kevin CO and others added 30 commits September 10, 2024 17:08
fixed absurd control when in linearcontinuous type, enabled nmpc with old model
Copy link
Collaborator

@Ipuch Ipuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 84 of 97 files at r1, all commit messages.
Reviewable status: 84 of 97 files reviewed, 14 unresolved discussions (waiting on @Kev1CO)


cocofest/custom_constraints.py line 15 at r1 (raw file):

    @staticmethod
    def cn_sum(controller: PenaltyController, stim_time: list, stim_index: list) -> MX | SX:
        intensity_in_model = True if isinstance(controller.model, DingModelIntensityFrequency) else False
model = controller.model
model.compute_lambda_i(...) 
model.compute_r0(....)

Try to put the physics equations always in the model if in the model as much as possible.


cocofest/custom_constraints.py line 28 at r1 (raw file):

    @staticmethod
    def cn_sum_msk(controller: PenaltyController, stim_time: list, model_idx: int, sum_truncation: int) -> MX | SX:

remove truncation


cocofest/custom_constraints.py line 29 at r1 (raw file):

    @staticmethod
    def cn_sum_msk(controller: PenaltyController, stim_time: list, model_idx: int, sum_truncation: int) -> MX | SX:
        model = controller.model.muscles_dynamics_model[model_idx]

@Property such that
model.km_name


cocofest/custom_constraints.py line 47 at r1 (raw file):

        return controller.controls["Cn_sum_" + muscle_name].cx - model.cn_sum_fun(
            r0=r0, t=controller.time.cx, t_stim_prev=stim_time, lambda_i=lambda_i
        )

msk should use the core of cn_sum N times.


cocofest/dynamics/warm_start.py line 21 at r1 (raw file):

    Solver,
)

initial guess of warm start make sure you know


cocofest/examples/getting_started/pulse_duration_optimization.py line 23 at r1 (raw file):

        "min": minimum_pulse_duration,
        "max": 0.0006,
        "bimapping": True,

as_unique_variable ?


cocofest/examples/getting_started/pulse_intensity_optimization.py line 17 at r1 (raw file):

    stim_time=[0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
    n_shooting=100,
    final_time=1,

Think the interface twice.


cocofest/models/ding2003.py line 128 at r1 (raw file):

        cn: MX,
        f: MX,
        cn_sum: MX | float = None,

Can we get cn_sum approximate = True ?


cocofest/models/ding2003_integrate.py line 15 at r1 (raw file):

class DingModelFrequencyIntegrate(DingModelFrequency):

DingModelFrequencyApproximated vs DingModelFrequency


cocofest/models/ding2007.py line 134 at r1 (raw file):

            cn,
            f,
            a_scale,

a_scale_as_control ?


cocofest/models/state_configue.py line 215 at r1 (raw file):

            as_states,
            as_controls,
            as_states_dot,

state_confiture


cocofest/optimization/fes_ocp.py line 149 at r1 (raw file):

        pulse_duration : dict
            Dictionary containing parameters related to the duration of the pulse.
            Optional if not using DingModelPulseDurationFrequency or DingModelPulseDurationFrequencyWithFatigue.

document dicts


cocofest/optimization/fes_ocp.py line 377 at r1 (raw file):

                raise NotImplementedError("If added, pulse duration parameter mapping must be a bool type")

        if isinstance(

one function per check


cocofest/optimization/fes_ocp_dynamics_nmpc_cyclic.py line 20 at r1 (raw file):

    def update_stim(self, sol):
        stimulation_time = sol.decision_parameters()["pulse_apparition_time"]
        stim_prev = list(np.round(np.array(stimulation_time) - sol.ocp.phase_time[0], 3))

don't round ! It can be dangerous.

Code quote:

np.round(

@Kev1CO
Copy link
Collaborator Author

Kev1CO commented Oct 31, 2024

cocofest/examples/getting_started/pulse_intensity_optimization.py line 17 at r1 (raw file):

Previously, Ipuch (Pierre Puchaud) wrote…

Think the interface twice.

Done. Removed n_shooting option to automaticaly calculate it based on final time and stimulation instant

Copy link
Collaborator Author

@Kev1CO Kev1CO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 43 of 98 files reviewed, 14 unresolved discussions (waiting on @Ipuch)


cocofest/custom_constraints.py line 15 at r1 (raw file):

Previously, Ipuch (Pierre Puchaud) wrote…
model = controller.model
model.compute_lambda_i(...) 
model.compute_r0(....)

Try to put the physics equations always in the model if in the model as much as possible.

Done.


cocofest/custom_constraints.py line 28 at r1 (raw file):

Previously, Ipuch (Pierre Puchaud) wrote…

remove truncation

Done.


cocofest/custom_constraints.py line 29 at r1 (raw file):

Previously, Ipuch (Pierre Puchaud) wrote…

@Property such that
model.km_name

Done.


cocofest/custom_constraints.py line 47 at r1 (raw file):

Previously, Ipuch (Pierre Puchaud) wrote…

msk should use the core of cn_sum N times.

Done.


cocofest/dynamics/warm_start.py line 21 at r1 (raw file):

Previously, Ipuch (Pierre Puchaud) wrote…

initial guess of warm start make sure you know

Done.

@Kev1CO Kev1CO merged commit 105d4f7 into pyomeca:main Nov 15, 2024
3 of 5 checks passed
@Kev1CO Kev1CO deleted the single_phase branch November 15, 2024 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants