-
Notifications
You must be signed in to change notification settings - Fork 41
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
Well-formed or illegal mutual dependency between discrete-valued variables? #2639
Comments
For background, the problem I was trying to solve using the structure of
|
I would say that the first two models are illegal. The fact that y has no impact in the algorithm in the 2nd example isn't something we would expect a tool to find. The InitialAlgorithmOrdering is on the other hand correct, as parameters with fixed=false are just unknowns for the initialization. The AlgorithmWithUnusedPre should also be legal. The initialization problem becomes:
where pre(x) has guess-value x.start. I admit that it's a bit weird to determine pre(x) in this backwards way, but at least it's consistent. |
Yes, that's the point of this issue. I can see how writing it nicely will be tricky, however, as one probably still want some kinds of simplifications to happen before analyzing the algorithm for dependencies, such as evaluation of if-equations and if-expressions with constant conditions, when-statement simplification for the initialization problem, etc… |
Does this mean solving for a discrete-valued variable on the right hand side of an equation is OK in general? I've had the impression that all discrete-valued variables should have their own equation in solved form (with the variable on the left hand side of an equation or statement), but I'm not aware of this being explicitly stated anywhere… |
Good point. The restriction is not explicitly stated, but since we want to handle alias equations x=y due to connections without specifying alias-handling in detail it would make sense to allow it in solved form with the variable either on the left or the right hand side. I also noticed that the support in Dymola is somewhat inconsistent. |
By the way, in appendix C Henrik linked above I see some strange |
Known issue #2629 |
Something like the following: It shall be possible to compute m without any cycles, provided that the rest of v is known (thus there might be cyclic dependencies between m and y that require the solution of systems of equations). The variables in m need to occur explicitly solved on one of the sides of an equation, or assigned in an algorithm. |
Almost. I'd like to split m into its continuous-valued (discrete-time |
Being assigned in a when-clause does not prevent loops:
|
Right, being assigned in a when-clause just means that there is no point requiring that the variable appears "explicitly solved on one side of the sides of an equation". I don't think we need to forbid loops like this, at least not for the same reasons why we don't want mutually dependent discrete-valued variables? |
I agree that part is automatically true for when-clauses, but the proposed text:
have two parts: solvable without cycles (which this examples fail), and they need to be explicitly solvable from an equation (which when-clauses must satisfy). Boolean equations can fail the first and/or the second part: It could be that it is not in one of the allowed forms (this example could actually be solved):
Note that the restriction to allowed forms says that the variables should occur explicitly, which is stronger than saying that discrete-valued equations must be on this form, consider:
Here b2 cannot be solved from any equation, and thus we don't have to figure out whether there is a cycle or not. I don't see the point of making an exception for the second part for when-clauses merely because when-clauses automatically fulfill that. |
Yes, and of the two parts, it's the cycles part that I don't find relevant for the discrete-time
Sure.
Right.
Agreed, there would be no point to make an exception for that reason. The reason for making an exception would be to not mix up the requirements needed for discrete-valued variables with any requirements needed for discrete-time variables. To me, the explicitly solvable and not-in-a-cycle has only to do with being discrete-valued, as it is the foundation for the "standard" fixed-point iteration method for solving systems of equations involving both discrete-valued and continuous-valued variables. |
Henrik: Start with discrete-valued ones. Requires splitting discrete-time variables in description. |
According to phone meeting decision on modelica#2639.
Even if #2702 didn't fully solve this one I would propose to close this issue and if necessary (at some point) open a new cleaner issue for the remaining part. |
Whether a discrete-valued variable could be solved on the right side of an equality was never the big question here, so I don't think having resolved #2702 is much of a reason to close this one. (But it is true that there are some parts that could be cleaned up as a result.) |
To me #2702 implicitly cleared up more than just right side of equality, so I'm unclear what remains of this one. |
Things remaining:
|
In appendix C, equation (C.1b), it is said that the discrete-valued variables m should be possible to determine by evaluation of fm(v, c). Even though this is some sort of high level informal description, the fact that this equation is given in the form of an assignment seems to suggest that given the other variables, one should be able to determine m in a straight-forward manner.
Does this mean that the following model does not fit this description, and therefore is invalid?
(SystemModeler currently rejects this model.)
If the model above is invalid, then what about this one?
The reason I ended up wondering is because of this model, where
pre(x)
takes the role ofy
during initialization:Of course, one of the assumptions in this last example was that the default equation for the inactive when-equation is really allowed to be solved for
pre(x)
, which would actually need clarification in the specification considering thatx
is a discrete-time variable. Perhaps a clarification would be good either way?The text was updated successfully, but these errors were encountered: