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

New design Heaviside pipeline #99

Merged
merged 28 commits into from
Jun 20, 2024
Merged

New design Heaviside pipeline #99

merged 28 commits into from
Jun 20, 2024

Conversation

apozharski
Copy link
Member

No description provided.

@apozharski apozharski linked an issue May 16, 2024 that may be closed by this pull request
@apozharski apozharski changed the title [WIP] New design heaviside pipline New design heaviside pipline May 17, 2024
@apozharski apozharski changed the title New design heaviside pipline New design Heaviside pipline May 17, 2024
@apozharski apozharski changed the title New design Heaviside pipline New design Heaviside pipeline May 24, 2024
@nurkanovic
Copy link
Collaborator

There are a few minor bugs I found so far:

  • In new_design_car_time_opt.m - the model class created as Heaviside does not recognize S as a field.
  • one must use problem_options.dcs_mode = "Step", since "Heaviside" is not recognized, this should be fixed.
  • new_design_friction_blocks_stewart - simulating with Heaviside, one of the subproblem becomes infeasible for some reason - is it again maybe a bad initialization for the complementarity variables? (one may also look did it converge with the old implementation, just to isolate bugs)

properties
f_x

c
Copy link
Collaborator

Choose a reason for hiding this comment

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

this already exists in base, why here again?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't believe it is in nosnoc.model.Base. As a matter of fact matlab will loudly complain if you double define a property.

@@ -0,0 +1,46 @@
classdef Heaviside < nosnoc.model.Base
properties
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add short comment (1-2 sentences) why is this not a PSS in some cases (will be in docu anyway)

obj.dims = dims;
end

function generate_variables_from_heaviside(obj, opts)
Copy link
Collaborator

Choose a reason for hiding this comment

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

the functions _pss and _heaviside (later also for equaitons) share a lot of code (Except for the theta and f_x parts, they are almost indentical).
What speak against of having one function for vars and eqs, and have a if-else or switch-case?

Copy link
Member Author

Choose a reason for hiding this comment

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

No extremely strong opinions here. I think in this case we can absolutely have an if statement. The only thing is sometimes it is nice to have a pseudo-linear way to read the code even if it requires some repetition. Perhaps this is an over-correction on my part however, as I have been quite frustrated during this rewrite with the interleaving ifs in the old design and disentangling them one by one.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree, but 90% is repetition and adds quite a few extra lines. Well, most of the old ifs are mostly resolved by having extra classes for every problem type.

I can live with the repetition, but shorter and still understandable code is also not bad.

@nurkanovic
Copy link
Collaborator

**nurkanovic ** commented Jun 18, 2024

I am not sure yet how to resolve, if one wants to use PSS with the Heaviside reformulation, but calls the Heaviside model by creating the model object.
One way it to support both options if it does not make code to complicated, or to just throw an instructive error (e.g. when trying to put in an S into an Heaviside).

@apozharski
Copy link
Member Author

**nurkanovic ** commented Jun 18, 2024

I am not sure yet how to resolve, if one wants to use PSS with the Heaviside reformulation, but calls the Heaviside model by creating the model object. One way it to support both options if it does not make code to complicated, or to just throw an instructive error (e.g. when trying to put in an S into an Heaviside).

My view on this is RTFM 😅. If a user uses the wrong class without reading even the top level documentation and gets Unrecognized property 'S' for class 'nosnoc.model.Heaviside' and doesn't immediately go to the docs I don't think that user can be saved.

@apozharski
Copy link
Member Author

apozharski commented Jun 19, 2024

new_design_friction_blocks_stewart - simulating with Heaviside, one of the subproblem becomes infeasible for some reason - is it again maybe a bad initialization for the complementarity variables? (one may also look did it converge with the old implementation, just to isolate bugs)

This is not a bug per se, but it is the fact that cross_comp_mode=3 and cross_comp_mode=4 were flipped. I need to check the Stewart version.

@nurkanovic
Copy link
Collaborator

**nurkanovic ** commented Jun 18, 2024

I am not sure yet how to resolve, if one wants to use PSS with the Heaviside reformulation, but calls the Heaviside model by creating the model object. One way it to support both options if it does not make code to complicated, or to just throw an instructive error (e.g. when trying to put in an S into an Heaviside).

My view on this is RTFM 😅. If a user uses the wrong class without reading even the top level documentation and gets Unrecognized property 'S' for class 'nosnoc.model.Heaviside' and doesn't immediately go to the docs I don't think that user can be saved.

What confused even me, that the commented code in the examples was suggesting that this is a valid path. :|

@apozharski
Copy link
Member Author

What confused even me, that the commented code in the examples was suggesting that this is a valid path. :|

Hmm well that is definitely something we should avoid then. Strictly speaking the point is that the Heaviside DCS reformulation should take a PSS or a Heaviside model, and theoretically one could directly formulate a PSS as an equivalent Heaviside model but that takes some thought.

Copy link
Collaborator

@nurkanovic nurkanovic left a comment

Choose a reason for hiding this comment

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

LGTM GJ

@nurkanovic nurkanovic merged commit 6823cda into main Jun 20, 2024
1 check passed
@nurkanovic nurkanovic deleted the new-design-heaviside branch June 20, 2024 09:56
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.

Implement new pipeline design for Heaviside Step reformulation of PSS
2 participants