﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3057	Erronous FMI ModelStructure	Rüdiger Franke	Willi Braun	"In many cases the ModelStructure generated for FMI 2 is wrong. The following example triggers some of the problems: 
{{{
model ModelStructureTest
  parameter Integer switch = 1;
  parameter Real p = 1;
  input Real u1;
  input Real u2;
  output Integer y1;
  output Real y2;
equation
  y1 = switch;
  if switch > 0 then
    y2 = p*u1;
  else
    y2 = u2;
  end if;
end ModelStructureTest;
}}}

OpenModelica #23881 generates the following modelDescription.xml:
{{{
<ModelVariables>
  <!-- Index of variable = ""3"" -->
  <ScalarVariable name=""u1"" valueReference=""0"" variability=""continuous"" causality=""input"" initial=""approx""><Real/></ScalarVariable>
  <!-- Index of variable = ""4"" -->
  <ScalarVariable name=""u2"" valueReference=""1"" variability=""continuous"" causality=""input"" initial=""approx""><Real/></ScalarVariable>
  <!-- Index of variable = ""5"" -->
  <ScalarVariable name=""y2"" valueReference=""2"" variability=""continuous"" causality=""output"" initial=""calculated""><Real/></ScalarVariable>
  <!-- Index of variable = ""7"" -->
  <ScalarVariable name=""p"" valueReference=""3"" variability=""fixed"" causality=""parameter"" initial=""exact""><Real start=""1.0""/></ScalarVariable>
  <!-- Index of variable = ""6"" -->
  <ScalarVariable name=""y1"" valueReference=""0"" variability=""discrete"" causality=""output"" initial=""calculated""><Integer/></ScalarVariable>
  <!-- Index of variable = ""8"" -->
  <ScalarVariable name=""switch"" valueReference=""1"" variability=""fixed"" causality=""parameter"" initial=""exact""><Integer start=""1""/></ScalarVariable>
</ModelVariables>
<ModelStructure>
  <Outputs>
    <Unknown index=""5"" dependencies=""3"" dependenciesKind=""dependent""/>
    <Unknown index=""6""/>
  </Outputs>
  <Derivatives></Derivatives>
  <InitialUnknowns></InitialUnknowns>
</ModelStructure>
}}}

The ModelVariables and ModelStructure exhibit the following errors:
1. ModelVariables starts with index 3 instead of 1 (because the model contains no states?)
2. ModelVariables lists the indices 5, 7, 6, 8 in this order (because the model contains integers?)
3. ModelStructure/Outputs doesn't mention the dependency of y2 on u2 (because the parameter switch gets evaluated -- it works with an input switch?)
"	defect	closed	critical	1.9.2	FMI	trunk	fixed		
