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

target_mapping not used #745

Closed
EveCharbie opened this issue Aug 8, 2023 · 1 comment
Closed

target_mapping not used #745

EveCharbie opened this issue Aug 8, 2023 · 1 comment

Comments

@EveCharbie
Copy link
Collaborator

EveCharbie commented Aug 8, 2023

this was introduced to make sure the targets were showing on the right plots, but is seems this part of the code is not used. It should be either removed or repaired)

        @staticmethod
        def minimize_controls(penalty: PenaltyOption, controller: PenaltyController, key: str):
            """
            Minimize the joint torque part of the control variables.
            By default this function is quadratic, meaning that it minimizes towards the target.
            Targets (default=np.zeros()) and indices (default=all_idx) can be specified.

            Parameters
            ----------
            penalty: PenaltyOption
                The actual penalty to declare
            controller: PenaltyController
                The penalty node elements
            key: str
                The name of the controls to minimize
            """

            penalty.quadratic = True if penalty.quadratic is None else penalty.quadratic
            if key in controller.get_nlp.variable_mappings:
                target_mapping = controller.get_nlp.variable_mappings[key]
            else:
                target_mapping = BiMapping(
                    to_first=list(range(controller.get_nlp.controls[key].cx_start.shape[0])),
                    to_second=list(range(controller.get_nlp.controls[key].cx_start.shape[0])),
                )  # TODO: why if condition, target_mapping not used (Pariterre?)

            if penalty.integration_rule == QuadratureRule.RECTANGLE_LEFT:
                # TODO: for trapezoidal integration (This should not be done here but in _set_penalty_function)
                penalty.add_target_to_plot(controller=controller, combine_to=f"{key}_controls")
            penalty.multi_thread = True if penalty.multi_thread is None else penalty.multi_thread

            # TODO: We should scale the target here!
            return controller.controls[key].cx_start
@EveCharbie
Copy link
Collaborator Author

Fixed in PR #851

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

No branches or pull requests

1 participant