Opened 8 years ago
Closed 7 years ago
#4329 closed defect (fixed)
Add warning about conflicting start values
Reported by: | Francesco Casella | Owned by: | Patrick Täuber |
---|---|---|---|
Priority: | high | Milestone: | 1.13.0 |
Component: | Backend | Version: | |
Keywords: | Cc: |
Description
Consider the following test case:
loadString(" type T = Real(start = 10); model Test T x; Real y(start = -10); Real z(start = -4); Real w; equation x = y; x + z = 0; (x-3)*(x+11) = 0; (w-10)*(w+4) = 0; end Test; ");getErrorString(); setCommandLineOptions("-d=initialization");getErrorString(); simulate(Test, simflags="-lv=LOG_NLS");getErrorString();
The last equation requires an iterative solution with unknown w
, and OMC appropriately issues the following warning:
Warning: Iteration variables with default zero start attribute in nonlinear equation system: w:VARIABLE() type: Real
However, there is another issue with the first three equations that should also be reported. There are three alias variables, x, y, z
. x
has a start value defined with a lower priority, while y
and z
have a higher priority start value, according to Section 8.6.2 of the Modelica Specification. As the priority is the same, either could be chosen, leading to a different solution of the system.
As this is potentially dangerous for the convergence of the solution, I would suggest that a warning is issued in all the cases where such a variable is the unknown or tearing variable of an implicit system to be solved iteratively, pointing out:
- the conflicting values with the same priority
- the value that was selected by OMC as initial guess for the solver
Change History (3)
comment:1 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → accepted |
comment:2 by , 7 years ago
comment:3 by , 7 years ago
Milestone: | 1.12.0 → 1.13.0 |
---|---|
Resolution: | → fixed |
Status: | accepted → closed |
This is the current output:
Warning: Alias set with conflicting start values having the same priority * Candidate: z(start = 4.0) * Candidate: y(start = -10.0) => Select value from z(start = 4.0) for variable: x
which is clear and up to the point.
As the alias conflicts are found way before the iteration variables are selected, it is not easily possible to print a good warning only if the alias variable with conflicts is selected as a tearing variable.
With OMCompiler/04560c9 a warning is always printed if there are conflicting aliases.
Since iteration variables could change unintendedly (e.g. by changing the equation order), it may be sensible to eliminate all the conflicts in the model, anyway.
The alias variables with conflicts and the same priority can be printed with
-d=aliasConflicts
.@casella Please close the ticket if this fulfills your expectations.