Opened 10 years ago

Closed 7 years ago

#3266 closed defect (fixed)

Differentiation of recursive function fails

Reported by: Rüdiger Franke Owned by: Willi Braun
Priority: high Milestone: 1.13.0
Component: Backend Version: trunk
Keywords: Cc: Adeel Asghar

Description

This is the smallest example I'm aware of that causes most trouble in OpenModelica.

model SortTest2
  input Real u; // prevent evaluation by frontend
  Real[:, :] M = [3, 4; 1 + u, 2];
  output Real[size(M, 1), size(M, 2)] N;
equation
  N = Modelica.Math.Matrices.sort(M);
  annotation(uses(Modelica(version="3.2.1")));
end SortTest2;

It not only knocks out the Cpp code generation (#3263), while it's reduced version crashes OMEdit (#3262). Also FMI export fails to generate the model structure -- translateModelFMU(SortTest2, version="2.0"):

Error: Internal error BackendDAEOptimize.generateSymbolicJacobian failed
Error: Internal error BackendDAEOptimize.createJacobian failed

Change History (28)

comment:1 by Adeel Asghar, 10 years ago

Component: FMIFMI-CPP
Owner: changed from Adeel Asghar to Marcus Walther

comment:2 by Rüdiger Franke, 10 years ago

Cc: Adeel Asghar added
Component: FMI-CPPFMI
Owner: changed from Marcus Walther to Willi Braun
Status: newassigned

It's not related to Cpp. We had similar issues with failed Jacobians in January.

Willi, could you have a look?

comment:3 by Adeel Asghar, 10 years ago

Well the C runtime works fine with the attached example. I checked it before changing it to FMI-CPP. So i don't understand why you set the component to FMI.

comment:4 by Rüdiger Franke, 10 years ago

Also when using the C runtime, translateModelFMU(SortTest2, version="2.0") gives the same error message:

Error: Internal error BackendDAEOptimize.generateSymbolicJacobian failed
Error: Internal error BackendDAEOptimize.createJacobian failed

The modelDescription.xml contains an empty ModelStructure section. Can it be that you checked using OMEdit -- it ignores this error message recently (did not ignore it back in December/January)?

comment:5 by Rüdiger Franke, 10 years ago

I might be wrong with my files from January/February -- I was mostly generating FMUs from the command line.

Can you please also check #3262 -- there are still issues with error handling OMEdit.

comment:6 by Adeel Asghar, 10 years ago

Which revision you have?
Post the output of getVersion().

comment:7 by Rüdiger Franke, 10 years ago

My current OMEdit has version r25313 -- the one crashing in #3262. Moreover I tried a local build of r25402. The Jacobian failure is the same in both versions.

comment:8 by Adeel Asghar, 10 years ago

See my comment in #3262 for OMEdit crash.
About Jacovian error, you are right. I wasn't checking for the errors when translateModelFMU returns true. I fixed it now in r25442.

Version 0, edited 10 years ago by Adeel Asghar (next)

comment:9 by Rüdiger Franke, 10 years ago

Btw. I just did

$ svn update
$ make omc

The update says "At revision 25447". getVersion() still reports "1.9.3+dev (r25402)". I like the treatment of dependencies a lot when building omc, saving a lot of time when only recompiling things that have changed.

But where does the result from getVersion() come from?

comment:10 by Adrian Pop, 10 years ago

It comes from Compiler/runtime/omc_config.h and is updated only if you runt configure I think.

comment:11 by Rüdiger Franke, 10 years ago

Right, configure updates the version -- and the compilation still treats dependencies. Thanks!

comment:12 by Willi Braun, 10 years ago

Status: assignedaccepted

comment:13 by Rüdiger Franke, 10 years ago

One reason could be that there are no states in the model. ModelVariables start with <!-- Index of variable = "3" -->.

comment:14 by Martin Sjölund, 9 years ago

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

comment:15 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

comment:16 by Martin Sjölund, 9 years ago

Milestone: 1.9.51.10.0

Milestone renamed

comment:17 by Martin Sjölund, 8 years ago

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

comment:18 by Martin Sjölund, 8 years ago

Milestone: 1.11.01.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:19 by Francesco Casella, 7 years ago

Milestone: 1.12.0Future

The milestone of this ticket has been reassigned to "Future".

If you think the issue is still valid and relevant for you, please select milestone 1.13.0 for back-end, code generation and run-time issues, or 2.0.0 for front-end issues.

If you are aware that the problem is no longer present, please select the milestone corresponding to the version of OMC you used to check that, and set the status to "worksforme".

In both cases, a short informative comment would be welcome.

comment:20 by Willi Braun, 7 years ago

Component: FMIBackend
Summary: FMU export fails to generate model structure for MSL matrix functionDifferentiation of recursive function fails

comment:21 by Rüdiger Franke, 7 years ago

Milestone: Future1.13.0

The situation has improved meanwhile. The example simulates in OMEdit now.

Remaining issues are:

  1. FMI export fails: [C:/dev/OpenModelica32bit/OMCompiler/Compiler/Util/Graph.mo: 990:5-990:101]: Interner Fehler Graph.addForbiddenColors failed. -- FMI export works with the debug flag -disableColoring
  2. OMEdit crashes during FMI export with the flag -disableDirectionalDerivatives

These remaining FMI issues can hopefully be solved as well.

comment:22 by Willi Braun, 7 years ago

Fixed the differentiation of recursive function in c15e7bd/OMCompiler.

comment:23 by Rüdiger Franke, 7 years ago

The crash is gone. Instead the following error message is raised:

[6] 18:37:22 Symbolic Error
[OpenModelica/OMCompiler/Compiler/BackEnd/Differentiate.mo: 395:3-395:155]: Derivative of expression "(N, _) = Modelica.Math.Matrices.sort({{3.0, 4.0}, {M[2,1], 2.0}}, true, true)" w.r.t. "dummyVarFMIDER" is non-existent.

comment:24 by Willi Braun, 7 years ago

Yes, I try to fix it with PR2203.

comment:25 by Rüdiger Franke, 7 years ago

Since PR2206 the FMU can be generated when using default OMC flags.

Do you think the ticket can be closed, i.e. the error message in comment:23 with the flag -disableDirectionalDerivatives is valid?

comment:26 by Willi Braun, 7 years ago

Actually, the differentiation of the function sort still fails and I'm try to fix this in PR2203. I think I'm almost done, currently only one issue with tuples return functions in algorithm section is failing in code generation phase.

comment:27 by Willi Braun, 7 years ago

It seems the differentiation fails for FMU's silently.

comment:28 by Willi Braun, 7 years ago

Resolution: fixed
Status: acceptedclosed

PR2203 is pushed, so I close it now.

Note: See TracTickets for help on using tickets.