-
Notifications
You must be signed in to change notification settings - Fork 13
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
Cannot set parameter in a class being extended #47
Comments
I thought that it may be necessary to instantiate |
@christiankral i tested your package, the error message is not correctly displayed due to parser error, So you can use the API in the following way , set the named argument
And the error message says that c is not found in Test.Example which is true, At least for this example you are not changing structural parameters and if your aim is to change only
|
@arun3688 Thanks for your comment. So if I want to change the structure of the model, too, by changing
then build and simulate the model. I am wondering how I can automate the change of parameters independent of being a structural parameter or not. The problem of automation is: how do I know the structural change cause by |
Asked differently: is there a way to flatten the investigated model |
Unfortunately currently there is no way to fetch all parameters from the flatten model with the API and then have just one API to set them in the top model. I am working on adding these. For now what OMEdit does is that it fetches the extends then gets the parameters from the entire instance hierarchy. Then uses |
For now I could even create a workaround based on proposal #45 (comment), which I somehow need for my project OMcsv.jl: If |
@christiankral , I am making changes to |
@christiankral , the
|
This makes sense and works. But, if I build the model prior to simulation, the parameter In order to easier check this behavior, I provide the code: using OMJulia
mod = OMJulia.OMCSession()
ModelicaSystem(mod, "Test.mo", "Test.Example")
getParameters(mod)
## use the setParameters() API
setParameters(mod, "c=9")
buildModel(mod)
simulate(mod)
c = getParameters(mod, "c")
x = getSolutions(mod, "x")[end][end]
println("c = ", c, "\tx = ", x) This code returns The result Is this a bug? |
@christiankral Actually
But as you pointed out it is a bug, the getParameters(c) should return |
@chrbertsch , the issue is fixed with this commit fd5e1ea, test it |
@arun3688 Yes, it all works now. Thank you. |
@christiankral I will close this issue, if there are further problems, please open a new issue |
@casella the issue is fixed and closed |
Sure, I just wanted to give you due credit for that :) |
Consider the following example and store it as
Test.mo
:The parameters
dyn
andc
are declared in the modelTest.Data
which is extended inTest.Example
.When running the following Julia script I run into issues:
Issues
getParameters(mod)
shows the following results, which totally makes sense, asc
anddyn
are parameters ofTest.Example
:sendExpression(mod, "setParameterValue(Test.Example, c, 9)")
causes an error for an unknown reason. As the parameterc
is shown bygetParameters(mod)
I would expectsetParameters
to work properly: but it doesn't. The error message is:c
in modelData
bysendExpression(mod, "setParameterValue(Test.Data, c, 9)")
. But is not a good solution as I have to know that the modelTest.Data
is used inTest.Example
. So I have to have knowledge on how the modelTest.Example
is written in Modelica and that cannot be a good solution.I think that the error of item 2. is a bug.
The text was updated successfully, but these errors were encountered: