Opened 10 years ago

Last modified 7 years ago

#2685 assigned defect

Connector with record fails with code generation issues

Reported by: adrpo Owned by: mahge930
Priority: critical Milestone: Future
Component: Code Generation Version: trunk
Keywords: Cc: wbraun, lochel, vwaurich, mahge930

Description

Hello everyone,

working on some controller model omc fails to reduce the variables using pantelides.

The error log is:
Error: Too many equations - overconstrained system. The model has 8 equations and 4 variables.
Error: Transformation Module PFPlusExt index Reduction Method Pantelides failed!

Find attached an examplemodel.
Unfortunately it is a bit complex therefore here is a short description.

A Record (with integer for value and enumeration for datatype)is used as connector (input and output).

within a block the value of the input changes to the output using an algorithm (simplification is done here!).

If you need further information with the model, let me know.

Attachments (1)

example.mo (3.3 KB) - added by anonymous 10 years ago.

Download all attachments as: .zip

Change History (25)

Changed 10 years ago by anonymous

comment:1 Changed 10 years ago by anonymous

sorry,

i forgot to mention the model not working is testmodel

comment:2 Changed 10 years ago by perost

  • Component changed from Backend to Frontend
  • Owner changed from probably noone to perost
  • Status changed from new to accepted

Seems to be some issues with flattening, outputConnector[i].signal turns into outputConnector.signal[i] in the flattened code. Not sure if this is the only issue, but I'll try to fix it.

comment:3 Changed 10 years ago by perost

  • Cc wbraun lochel added
  • Component changed from Frontend to Backend

Ok, I've found the issue with flattening but haven't figured out how to fix it without breaking other things yet. Fixing the flattening issue does not affect the model balance though. The issue seems to be that the algorithm in WriteSomeOutput is counted as 8 equations when it should be 4. So it seems like the main issue is in the Backend.

comment:4 Changed 10 years ago by perost

#2688 needs to be fixed before the flattening issues can be fixed. I'm not sure if the flattening issues are an issue in this case though.

comment:5 Changed 10 years ago by perost

  • Cc vwaurich added

comment:6 Changed 10 years ago by AndreasHofmann

Hi everyone,

are there any updates about this ticket (or ticket #2688).
We (Bosch Rexroth) need a model (based on this issue) running with omc for our controller development.

Can anyone give me an update how long this might take?

Best regards,
Andreas

comment:7 Changed 10 years ago by lochel

  • Cc mahge930 added

comment:8 follow-up: Changed 10 years ago by vwaurich

Hi,
commit [21524] fixed the backend-issue with the wrong number of solved variables for the algorithm. Now, the frontend issue has to be fixed since I get

"[CodegenC.tpl:7806:28-7806:28:writable] Error: Template error: Indexing non-array writeSomeOutput.outputConnector.signal[i]

and instead there should be: writeSomeOutput.outputConnector[i].signal

Per, Could you please have a look on it? If there is backend stuff breaking, you could commit it as a comment and i will have a look.

comment:9 Changed 10 years ago by vwaurich

  • Component changed from Backend to Frontend

comment:10 in reply to: ↑ 8 Changed 10 years ago by perost

Replying to vwaurich:

Per, Could you please have a look on it? If there is backend stuff breaking, you could commit it as a comment and i will have a look.

The issue is still #2688, the backend breaks if we stop converting crefs into ASUBs. Just comment out the call to replaceLoopDependentCrefs in InstSection.instForStatement.

comment:11 Changed 10 years ago by adrpo

  • Component changed from Frontend to Backend
  • Owner changed from perost to wbraun
  • Status changed from accepted to assigned

This seems to have been fixed for the front-end I guess via some commit by mahge930.

"Check of example.testmodel completed successfully.
Class example.testmodel has 12 equation(s) and 12 variable(s).
8 of these are trivial equation(s).
"

However simulation doesn't work as it has issues with the code generation.

comment:12 Changed 10 years ago by wbraun

  • Status changed from assigned to accepted

It seems that for some reasons in simVar the entry for Option<DAE.ComponentRef> arrayCref; is missing.

comment:13 Changed 10 years ago by wbraun

  • Component changed from Backend to Code Generation
  • Owner changed from wbraun to mahge930
  • Status changed from accepted to assigned

No, the underlying problem is fix the code generation to handle arrays of records.

comment:14 follow-up: Changed 10 years ago by sjoelund.se

These errors should really be fixed by someone in the back-end team. There are already tickets for these things as far as I know...

$PwriteSomeOutput$PoutputConnector$lB(modelica_integer)$Pi$rB$Psignal = (modelica_integer)$Pi

comment:15 in reply to: ↑ 14 Changed 10 years ago by mahge930

Replying to sjoelund.se:

These errors should really be fixed by someone in the back-end team.

This is me actually.
The problem with this issue was that it was a combination of multiple issues:

  • Front-end: missing dimension info in qualified names (wrong types created)
  • Back-end: variables were sorted in not so appropriate way, needed better sorting for indexing/offsetting to work
  • CodeGen: We didn't really have support for these cases. We can't do this with macros anymore.

I have fixed the front-end and back-end issues so far and codegen is ready partially. And I think I can actually simulate these models. I have to check again. The problem is missing array elements due to alias elimination and state var selection complicate things. They won't prevent simulation per se but will give you wrong results because you are accessing the wrong array elements.

Anyway I will try to finish up the codegen modifications I have now and commit it. Then we worry about the other stuff later.

I will create a ticket with the issues in more detail.

Last edited 10 years ago by mahge930 (previous) (diff)

comment:16 Changed 10 years ago by sjoelund.se

  • Milestone changed from 1.9.1 to 1.9.2

This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).

comment:17 Changed 10 years ago by sjoelund.se

  • Milestone changed from 1.9.2 to 1.9.3

Milestone changed to 1.9.3 since 1.9.2 was released.

comment:18 Changed 9 years ago by sjoelund.se

  • Milestone changed from 1.9.3 to 1.9.4

Moved to new milestone 1.9.4

comment:19 Changed 9 years ago by sjoelund.se

  • Milestone changed from 1.9.4 to 1.9.5

Milestone pushed to 1.9.5

comment:20 Changed 9 years ago by sjoelund.se

  • Milestone changed from 1.9.5 to 1.10.0

Milestone renamed

comment:21 Changed 8 years ago by wbraun

  • Summary changed from Index Reduction (Pantelides) fails to Connector with record fails with code generation issues

Error message update:

example.testmodel.c:128:3: warning: implicit declaration of function 'example_OutputConnector_array_create' is invalid in C99 [-Wimplicit-function-declaration]
  example_OutputConnector_array_create(&tmp21, ((modelica_example_OutputConnector*)&($PwriteSomeOutput$PoutputConnector_index(((modelica_integer) 1)))), 1, 2);
  ^
example.testmodel.c:128:50: error: use of undeclared identifier 'modelica_example_OutputConnector'; did you mean 'omc_example_OutputConnector'?
  example_OutputConnector_array_create(&tmp21, ((modelica_example_OutputConnector*)&($PwriteSomeOutput$PoutputConnector_index(((modelica_integer) 1)))), 1, 2);
                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                 omc_example_OutputConnector
./example.testmodel_functions.h:26:25: note: 'omc_example_OutputConnector' declared here
example_OutputConnector omc_example_OutputConnector(threadData_t *threadData, modelica_integer omc_signal, modelica_integer omc_signalType); /* record head */
                        ^
example.testmodel.c:128:83: error: expected expression
  example_OutputConnector_array_create(&tmp21, ((modelica_example_OutputConnector*)&($PwriteSomeOutput$PoutputConnector_index(((modelica_integer) 1)))), 1, 2);
                                                                                  ^
example.testmodel.c:128:86: warning: implicit declaration of function '$PwriteSomeOutput$PoutputConnector_index' is invalid in C99 [-Wimplicit-function-declaration]
  example_OutputConnector_array_create(&tmp21, ((modelica_example_OutputConnector*)&($PwriteSomeOutput$PoutputConnector_index(((modelica_integer) 1)))), 1, 2);
                                                                                     ^
example.testmodel.c:129:3: warning: implicit declaration of function 'copy_example_OutputConnector_array_data' is invalid in C99 [-Wimplicit-function-declaration]
  copy_example_OutputConnector_array_data(tmp20, &tmp21);
  ^
3 warnings and 2 errors generated.
make: *** [example.testmodel.o] Error 1
make: *** Waiting for unfinished jobs....
Compilation process failed. Exited with code 2.

comment:22 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.10.0 to 1.11.0

Ticket retargeted after milestone closed

comment:23 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.11.0 to 1.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:24 Changed 7 years ago by casella

  • Milestone changed from 1.12.0 to Future

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.

Note: See TracTickets for help on using tickets.