- Index
- » Users
- » dafred
- » Profile
Posts
Posts
In http://book.xogeny.com/components/archi … placeable/ , in the subsection "Modifications", it is said that if I want modifications to a component not to persist in subsequent redeclarations, I need to put the modifications behind the variable name. This is my test package:
--
within ;
package testpackage
model firstOrder "simple decay with fixed half-life"
parameter Real initial_x= 1.0;
Real x;
initial equation
x= initial_x;
equation
der(x) = -x;
end firstOrder;
model firstOrder_hl "decay with half-life parameter"
parameter Real hl= 2;
parameter Real initial_x= 1.0;
Real a;
Real x;
initial equation
x= initial_x;
equation
Modelica.Constants.e ^ (-a * hl) = 0.5;
der(x)= -a*x;
end firstOrder_hl;
model myModel "package with a replaceable model"
replaceable firstOrder_hl subModel(hl=3, initial_x=2);
end myModel;
model myModel_2 "derived model in which submodel is redeclared" // <-- PROBLEM HERE
extends myModel(redeclare firstOrder subModel(initial_x=2));
end myModel_2;
end testpackage;
--
Why can I simulate myModel without errors but NOT myModel_2? I see this error:
[1] 20:10:09 Translation Error
[testpackage: 27:3-27:56]: Variable subModel: In modifier (hl = 3), class or component hl not found in <testpackage.firstOrder$subModel>.
To my understanding, this could mean that the modification did in fact persist although I did not want this.
Am I doing something wrong here?
My runtime issue with my Tensorflow model has finally been resolved!
My OMEdit, for some reason, despite being set to gcc in Tools->Options->Simulation->Target Compiler used clang!
I don't know how to properly resolve this but what worked for me was to do the following (CAUTION):
cd /usr/bin
mv clang clang_OLD
ln -s gcc clang
Basically, this tricks any program calling "clang" into using calling "gcc". This is bound to cause side-effects but helps me for the moment.
Thank you for your reply and time! So far, as this is more of an inconvenience than a fatal problem to my work, I have not yet tried another distribution.
I have, however, stumbled across another problem (that could possibly be related).
[EDIT] By this time, I asked the same question here: https://stackoverflow.com/questions/534 … d-gradient
I want to use the Tensorflow C++ API in a Modelica Model.
For this, I created a class in C++ that encapsulates the Tensorflow details.
Moreover, the same file contains 3 functions (to call the constructor, destructor and a function that uses an existing instance of my class. These functions are declared "extern" in the respective header file (only if read by a C++ compiler, I am using __cplusplus to differentiate).
I then compiled said file (the class and the 3 functions) into a .so using g++ (I did make use of -fPIC and -shared). In /usr/lib, I created a symlink to said shared object library.
(For completeness, I should mention that I had trouble with the "LibraryDirectory" and "IncludeDirectory" annotations. This is why I created symlinks to the contents of all the directories I would pass to g++/gcc using -L and -I (for my test program) right into Model/Resources/Library and Model/Resources/Include directories. As there were no more compilation errors, I thought that this was okay.)
Now the strange thing is:
I can use the 3 functions in a test program compiled with gcc. I linked it against all Tensorflow libraries (and libm, libstdc++ and my .so from above) and it just works as expected.
However, when I try to use these 3 functions in a) a Modelica Class (constructor and destructor), and b) a function using an "external" function call, it will compile fine but a runtime error occurs:
------------------------------------------------------------------------------------------------------------------------------------------------
stdout | OMEditInfo | <p>/tmp/OpenModelica_fred/OMEdit/TestCpp -port=44382 -logFormat=xmltcp -override=startTime=0,stopTime=1,stepSize=0.002,tolerance=1e-6,solver=dassl,outputFormat=mat,variableFilter=.* -r=TestCpp_res.mat -w -lv=LOG_STATS</p>
stdout | error | <p>2018-11-22 10:47:00.153977: F tensorflow/core/framework/function.cc:1440] Check failed: GetOpGradFactory()->insert({op, func}).second Duplicated gradient for MapAccumulate<br>
stdout | error | <p>Process crashed</p>
stdout | error | <p>Process crashed<br>
Simulation process failed. Exited with code 6.</p>
------------------------------------------------------------------------------------------------------------------------------------------------
How is this possible? I am not able to do anything in my test program with the 3 functions that leads to the same error. What could the OMC-generated executable be doing with them that I am not in my test program?
As stated in the description. The error I see and my steps there can be seen here:
output.txt
How can I fix this error?
- Index
- » Users
- » dafred
- » Profile