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
  • Index
  • » Users
  • » rationalise
  • » Profile

Posts

Posts

Jun-05-15 04:52:09
How to use enumeration subsets in vectors?
Category: Programming

Thank you perost. I'm getting more understanding of this part of modelica now.
current/smile

Jun-04-15 05:15:22
How to use enumeration subsets in vectors?
Category: Programming

Hi everyone, thanks for looking at my question.
I'm a beginner in Modelica, and encountered an issue with getting a subset of an enumeration vector:

I've 2 enumerations:

Code:


type TComponent = enumeration(A,B,C,Cost);
type TComponentSubset = enumeration(A,B,C);

and 2 vectors based on the enumeration:

Code:


type TComponentVector = Real[TComponent];
type TComponentSubsetVector = Real[TComponentSubset];

Now in a model, how do I go about multiplying a subset of Out with ComponentPrices in the equation section? I cannot get it to work(last line).

Code:

model test

   parameter TComponentSubsetVector ComponentPrices;
   parameter TComponentVector Out;
equation
   Out[TComponent.Cost] = Out[TComponentSubset] * ComponentPrices; //last line : error = illegal subscript TComponentSubset
end test

Similarly, I tried without success:

Code:

   Out[TComponent.Cost] = Out[TComponentSubset.A:TComponentSubset.C] * ComponentPrices; //last line : error = illegal subscript TComponentSubset

Could anyone tell me what I am doing wrong? Thanks!

  • Index
  • » Users
  • » rationalise
  • » Profile
You are here: