Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Redeclare models based on a parameter selection

Redeclare models based on a parameter selection

Hello everyone,

I've been battling with this problem but till now I couldn't find out the solution. I have several models that I'd like to be redeclared based on the selection of an integer parameter (depending on this parameter select either several simplified models of the same system or some more complex models).

Is there a way to do this? I am running out of ideas...

Regards and thanks in advance,
Manatax

Re: Redeclare models based on a parameter selection

There isn't an easy way to do this. Conditional components are rather ugly:

Code:


class WithAlternatives
  parameter Integer alternative;
  Real alt1 if alternative == 1;
  Integer alt2 if alternative == 2;
end WithAlternatives;

class A
  extends WithAlternatives(alternative = 2);
end A;

There are 0 guests and 0 other users also viewing this topic
You are here: