Browse Source

stategraph sample exported from modelica

Cláudio Gomes 7 years ago
parent
commit
377d75f1b2
100 changed files with 28196 additions and 0 deletions
  1. 41 0
      ModelicaModels/StategraphSample.mo
  2. 11 0
      ModelicaModels/StategraphSampletest.mo
  3. BIN
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample.fmu
  4. 0 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/binaries/win32/StategraphSample_FMU.libs
  5. 736 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/modelDescription.xml
  6. 62 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/Makefile
  7. 62 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/Makefile.in
  8. 586 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample.c
  9. 2 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample.makefile
  10. 26 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_01exo.c
  11. 12 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_02nls.c
  12. 18 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_03lsy.c
  13. 16 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_04set.c
  14. 192 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_05evt.c
  15. 614 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_06inz.c
  16. 19 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_07dly.c
  17. 344 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_08bnd.c
  18. 84 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_09alg.c
  19. 20 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_10asr.c
  20. 10 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_11mix.c
  21. 0 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_11mix.h
  22. 89 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_12jac.c
  23. 49 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_12jac.h
  24. 14 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_13opt.c
  25. 11 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_13opt.h
  26. 44 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_14lnz.c
  27. 59 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_15syn.c
  28. 9 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_16dae.c
  29. 428 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_FMU.c
  30. 0 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_FMU.libs
  31. BIN
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_FMU.o
  32. 49 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_functions.c
  33. 28 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_functions.h
  34. 0 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_includes.h
  35. 1 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_info.c
  36. 548 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_init_fmu.c
  37. 8 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_literals.h
  38. 91 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_model.h
  39. 13 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_records.c
  40. 242 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/configure.ac
  41. 184 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/Makefile.objs
  42. 113 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/ModelicaUtilities.h
  43. 910 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/ParModelica/explicit/openclrt/OCLRuntimeUtil.cl
  44. 116 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/ParModelica/explicit/openclrt/omc_ocl_common_header.h
  45. 195 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/ParModelica/explicit/openclrt/omc_ocl_interface.h
  46. 106 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/ParModelica/explicit/openclrt/omc_ocl_memory_ops.h
  47. 158 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/blaswrap.h
  48. 160 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/blaswrap.h
  49. 7262 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/clapack.h
  50. 370 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/cminpack.h
  51. 389 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dgemm.c
  52. 194 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dger.c
  53. 138 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dgesv.c
  54. 194 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dgetf2.c
  55. 219 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dgetrf.c
  56. 186 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dgetrs.c
  57. 1006 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dlamch.c
  58. 158 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dlaswp.c
  59. 253 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dogleg_.c
  60. 207 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dpmpar_.c
  61. 96 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dscal.c
  62. 114 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dswap.c
  63. 490 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dtrsm.c
  64. 196 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/enorm_.c
  65. 225 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/f2c.h
  66. 612 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/hybrj_.c
  67. 19 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/i_nint.c
  68. 93 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/idamax.c
  69. 166 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/ieeeck.c
  70. 654 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/ilaenv.c
  71. 282 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/iparmq.c
  72. 117 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/lsame.c
  73. 301 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/minpack.h
  74. 41 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/pow_di.c
  75. 145 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/qform_.c
  76. 245 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/qrfac_.c
  77. 145 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/r1mpyq_.c
  78. 283 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/r1updt_.c
  79. 50 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/s_cmp.c
  80. 57 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/s_copy.c
  81. 65 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/xerbla.c
  82. 292 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi1/fmiModelFunctions.h
  83. 92 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi1/fmiModelTypes.h
  84. 968 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi1/fmu1_model_interface.c
  85. 69 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi1/fmu1_model_interface.h
  86. 247 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi2/fmi2FunctionTypes.h
  87. 339 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi2/fmi2Functions.h
  88. 115 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi2/fmi2TypesPlatform.h
  89. 1285 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi2/fmu2_model_interface.c
  90. 95 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi2/fmu2_model_interface.h
  91. 1942 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/gc.h
  92. 267 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/gc/memory_pool.c
  93. 55 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/gc/memory_pool.h
  94. 245 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/gc/omc_gc.h
  95. 390 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/gc_config_macros.h
  96. 101 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/gc_pthread_redirects.h
  97. 47 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/gc_version.h
  98. 55 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/linearization/linearize.h
  99. 140 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/math-support/pivot.c
  100. 0 0
      SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/meta/meta_modelica.h

+ 41 - 0
ModelicaModels/StategraphSample.mo

@@ -0,0 +1,41 @@
+model StategraphSample
+  Modelica.Blocks.Interfaces.RealInput u annotation(
+    Placement(visible = true, transformation(origin = {-100, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-58, 46}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
+  Modelica.StateGraph.InitialStepWithSignal s1 annotation(
+    Placement(visible = true, transformation(origin = {-22, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  Modelica.StateGraph.Transition t1(condition = u > 0.5, waitTime = 0)  annotation(
+    Placement(visible = true, transformation(origin = {4, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  Modelica.StateGraph.Transition t2(enableTimer = true, waitTime = 1)  annotation(
+    Placement(visible = true, transformation(origin = {0, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
+  inner Modelica.StateGraph.StateGraphRoot stateGraphRoot annotation(
+    Placement(visible = true, transformation(origin = {-66, 64}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  Modelica.Blocks.Logical.Switch switch1 annotation(
+    Placement(visible = true, transformation(origin = {-22, -40}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
+  Modelica.Blocks.Sources.RealExpression realExpression1(y = 0.0)  annotation(
+    Placement(visible = true, transformation(origin = {14, -24}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
+  Modelica.Blocks.Sources.RealExpression realExpression2(y = 1) annotation(
+    Placement(visible = true, transformation(origin = {-54, -24}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  Modelica.Blocks.Interfaces.RealOutput y annotation(
+    Placement(visible = true, transformation(origin = {50, -48}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {56, -30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  Modelica.StateGraph.Step step1 annotation(
+    Placement(visible = true, transformation(origin = {32, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+equation
+  connect(step1.outPort[1], t2.inPort) annotation(
+    Line(points = {{42, 0}, {48, 0}, {48, 40}, {4, 40}, {4, 40}}));
+  connect(t1.outPort, step1.inPort[1]) annotation(
+    Line(points = {{6, 0}, {20, 0}, {20, 0}, {20, 0}}));
+  connect(switch1.y, y) annotation(
+    Line(points = {{-22, -52}, {-22, -52}, {-22, -48}, {50, -48}, {50, -48}}, color = {0, 0, 127}));
+  connect(s1.active, switch1.u2) annotation(
+    Line(points = {{-22, -12}, {-22, -12}, {-22, -28}, {-22, -28}}, color = {255, 0, 255}));
+  connect(realExpression1.y, switch1.u1) annotation(
+    Line(points = {{2, -24}, {-14, -24}, {-14, -28}, {-14, -28}}, color = {0, 0, 127}));
+  connect(realExpression2.y, switch1.u3) annotation(
+    Line(points = {{-42, -24}, {-30, -24}, {-30, -28}, {-30, -28}}, color = {0, 0, 127}));
+  connect(s1.outPort[1], t1.inPort) annotation(
+    Line(points = {{-12, 0}, {0, 0}, {0, 0}, {0, 0}}));
+  connect(t2.outPort, s1.inPort[1]) annotation(
+    Line(points = {{-2, 40}, {-60, 40}, {-60, 0}, {-34, 0}, {-34, 0}}));
+  annotation(
+    uses(Modelica(version = "3.2.2")));
+end StategraphSample;

+ 11 - 0
ModelicaModels/StategraphSampletest.mo

@@ -0,0 +1,11 @@
+model StategraphSampletest
+  StategraphSample stategraphSample1 annotation(
+    Placement(visible = true, transformation(origin = {-10, 8}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  Modelica.Blocks.Sources.Ramp ramp1 annotation(
+    Placement(visible = true, transformation(origin = {-70, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+equation
+  connect(ramp1.y, stategraphSample1.u) annotation(
+    Line(points = {{-58, 10}, {-18, 10}, {-18, 13}, {-16, 13}}, color = {0, 0, 127}));
+  annotation(
+    uses(Modelica(version = "3.2.2")));
+end StategraphSampletest;

BIN
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample.fmu


+ 0 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/binaries/win32/StategraphSample_FMU.libs


+ 736 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/modelDescription.xml

@@ -0,0 +1,736 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fmiModelDescription
+  fmiVersion="2.0"
+  modelName="StategraphSample"
+  guid="{1bbd4064-0ef0-405e-a6e3-a61a868199f5}"
+  description=""
+  generationTool="OpenModelica Compiler v1.12.0-dev-77-g56dc448 (32-bit)"
+  generationDateAndTime="2017-01-16T11:20:36Z"
+  variableNamingConvention="structured"
+  numberOfEventIndicators="3">
+  <CoSimulation
+    modelIdentifier="StategraphSample"
+    needsExecutionTool="false"
+    canHandleVariableCommunicationStepSize="true"
+    canInterpolateInputs="false"
+    maxOutputDerivativeOrder="1"
+    canRunAsynchronuously = "false"
+    canBeInstantiatedOnlyOncePerProcess="false"
+    canNotUseMemoryManagementFunctions="false"
+    canGetAndSetFMUstate="false"
+    canSerializeFMUstate="false"
+     />
+  <LogCategories>
+    <Category name="logEvents" />
+    <Category name="logSingularLinearSystems" />
+    <Category name="logNonlinearSystems" />
+    <Category name="logDynamicStateSelection" />
+    <Category name="logStatusWarning" />
+    <Category name="logStatusDiscard" />
+    <Category name="logStatusError" />
+    <Category name="logStatusFatal" />
+    <Category name="logStatusPending" />
+    <Category name="logAll" />
+    <Category name="logFmi2Call" />
+  </LogCategories>
+  <DefaultExperiment startTime="0.0" stopTime="1.0" tolerance="1e-006"/>
+  <ModelVariables>
+  <!-- Index of variable = "1" -->
+  <ScalarVariable
+    name="realExpression1.y"
+    valueReference="0"
+    description="Value of Real output"
+    variability="continuous"
+    causality="local"
+    initial="calculated">
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "2" -->
+  <ScalarVariable
+    name="realExpression2.y"
+    valueReference="1"
+    description="Value of Real output"
+    variability="continuous"
+    causality="local"
+    initial="calculated">
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "3" -->
+  <ScalarVariable
+    name="s1.outerStatePort.subgraphStatePort.activeSteps"
+    valueReference="2"
+    description="Number of active steps in the CompositeStep"
+    variability="continuous"
+    causality="local"
+    initial="calculated">
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "4" -->
+  <ScalarVariable
+    name="stateGraphRoot.subgraphStatePort.activeSteps"
+    valueReference="3"
+    description="Number of active steps in the CompositeStep"
+    variability="continuous"
+    causality="local"
+    initial="calculated">
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "5" -->
+  <ScalarVariable
+    name="stateGraphRoot.subgraphStatePort.activeStepsDummy"
+    valueReference="4"
+    description="Dummy variable in order that connector fulfills restriction of connector"
+    variability="continuous"
+    causality="local"
+    initial="calculated">
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "6" -->
+  <ScalarVariable
+    name="step1.outerStatePort.subgraphStatePort.activeSteps"
+    valueReference="5"
+    description="Number of active steps in the CompositeStep"
+    variability="continuous"
+    causality="local"
+    initial="calculated">
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "7" -->
+  <ScalarVariable
+    name="t1.t"
+    valueReference="6"
+    description="= actual waiting time (transition will fire when t &gt; waitTime)"
+    variability="continuous"
+    causality="local"
+    initial="calculated">
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "8" -->
+  <ScalarVariable
+    name="t1.t_dummy"
+    valueReference="7"
+    variability="continuous"
+    causality="local"
+    initial="calculated">
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "9" -->
+  <ScalarVariable
+    name="t1.t_start"
+    valueReference="8"
+    description="Time instant at which the transition would fire, if waitTime would be zero"
+    variability="continuous"
+    causality="local"
+    initial="calculated">
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "10" -->
+  <ScalarVariable
+    name="t2.t"
+    valueReference="9"
+    description="= actual waiting time (transition will fire when t &gt; waitTime)"
+    variability="continuous"
+    causality="local"
+    initial="calculated">
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "11" -->
+  <ScalarVariable
+    name="t2.t_dummy"
+    valueReference="10"
+    variability="continuous"
+    causality="local"
+    initial="calculated">
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "12" -->
+  <ScalarVariable
+    name="u"
+    valueReference="11"
+    variability="continuous"
+    causality="input"
+    >
+    <Real start="0.0"/>
+  </ScalarVariable>
+  <!-- Index of variable = "13" -->
+  <ScalarVariable
+    name="y"
+    valueReference="12"
+    variability="continuous"
+    causality="output"
+    initial="calculated">
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "14" -->
+  <ScalarVariable
+    name="t2.t_start"
+    valueReference="13"
+    description="Time instant at which the transition would fire, if waitTime would be zero"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "15" -->
+  <ScalarVariable
+    name="t1.waitTime"
+    valueReference="14"
+    description="Wait time before transition fires"
+    variability="fixed"
+    causality="parameter"
+    initial="exact">
+    <Real start="0.0" min="0.0"/>
+  </ScalarVariable>
+  <!-- Index of variable = "16" -->
+  <ScalarVariable
+    name="t2.waitTime"
+    valueReference="15"
+    description="Wait time before transition fires"
+    variability="fixed"
+    causality="parameter"
+    initial="exact">
+    <Real start="1.0" min="0.0"/>
+  </ScalarVariable>
+  <!-- Index of variable = "17" -->
+  <ScalarVariable
+    name="s1.outerStatePort.subgraphStatePort.activeStepsDummy"
+    valueReference="4"
+    description="Dummy variable in order that connector fulfills restriction of connector"
+    variability="continuous"
+    causality="local"
+    >
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "18" -->
+  <ScalarVariable
+    name="step1.outerStatePort.subgraphStatePort.activeStepsDummy"
+    valueReference="4"
+    description="Dummy variable in order that connector fulfills restriction of connector"
+    variability="continuous"
+    causality="local"
+    >
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "19" -->
+  <ScalarVariable
+    name="switch1.u1"
+    valueReference="0"
+    description="Connector of first Real input signal"
+    variability="continuous"
+    causality="local"
+    >
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "20" -->
+  <ScalarVariable
+    name="switch1.u3"
+    valueReference="1"
+    description="Connector of second Real input signal"
+    variability="continuous"
+    causality="local"
+    >
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "21" -->
+  <ScalarVariable
+    name="switch1.y"
+    valueReference="12"
+    description="Connector of Real output signal"
+    variability="continuous"
+    causality="local"
+    >
+    <Real/>
+  </ScalarVariable>
+  <!-- Index of variable = "22" -->
+  <ScalarVariable
+    name="stateGraphRoot.activeSteps"
+    valueReference="0"
+    description="Number of active steps within the stategraph"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Integer/>
+  </ScalarVariable>
+  <!-- Index of variable = "23" -->
+  <ScalarVariable
+    name="s1.nIn"
+    valueReference="1"
+    description="Number of input connections"
+    variability="fixed"
+    causality="calculatedParameter"
+    initial="calculated">
+    <Integer/>
+  </ScalarVariable>
+  <!-- Index of variable = "24" -->
+  <ScalarVariable
+    name="s1.nOut"
+    valueReference="2"
+    description="Number of output connections"
+    variability="fixed"
+    causality="calculatedParameter"
+    initial="calculated">
+    <Integer/>
+  </ScalarVariable>
+  <!-- Index of variable = "25" -->
+  <ScalarVariable
+    name="step1.nIn"
+    valueReference="3"
+    description="Number of input connections"
+    variability="fixed"
+    causality="calculatedParameter"
+    initial="calculated">
+    <Integer/>
+  </ScalarVariable>
+  <!-- Index of variable = "26" -->
+  <ScalarVariable
+    name="step1.nOut"
+    valueReference="4"
+    description="Number of output connections"
+    variability="fixed"
+    causality="calculatedParameter"
+    initial="calculated">
+    <Integer/>
+  </ScalarVariable>
+  <!-- Index of variable = "27" -->
+  <ScalarVariable
+    name="_D_whenCondition1"
+    valueReference="0"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "28" -->
+  <ScalarVariable
+    name="s1.active"
+    valueReference="1"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "29" -->
+  <ScalarVariable
+    name="s1.localActive"
+    valueReference="2"
+    description="= true if step is active, otherwise the step is not active"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "30" -->
+  <ScalarVariable
+    name="s1.newActive"
+    valueReference="3"
+    description="Value of active in the next iteration"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "31" -->
+  <ScalarVariable
+    name="s1.oldActive"
+    valueReference="4"
+    description="Value of active when CompositeStep was aborted"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "32" -->
+  <ScalarVariable
+    name="stateGraphRoot.resume"
+    valueReference="5"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "33" -->
+  <ScalarVariable
+    name="stateGraphRoot.suspend"
+    valueReference="6"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "34" -->
+  <ScalarVariable
+    name="step1.active"
+    valueReference="7"
+    description="= true if step is active, otherwise the step is not active"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "35" -->
+  <ScalarVariable
+    name="step1.localActive"
+    valueReference="8"
+    description="= true if step is active, otherwise the step is not active"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "36" -->
+  <ScalarVariable
+    name="step1.newActive"
+    valueReference="9"
+    description="Value of active in the next iteration"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "37" -->
+  <ScalarVariable
+    name="step1.oldActive"
+    valueReference="10"
+    description="Value of active when CompositeStep was aborted"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "38" -->
+  <ScalarVariable
+    name="t1.condition"
+    valueReference="11"
+    description="= true, if transition may fire (time varying expression)"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "39" -->
+  <ScalarVariable
+    name="t1.enableFire"
+    valueReference="12"
+    description="= true, if all firing conditions are true"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "40" -->
+  <ScalarVariable
+    name="t2.condition"
+    valueReference="13"
+    description="= true, if transition may fire (time varying expression)"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "41" -->
+  <ScalarVariable
+    name="t2.enableFire"
+    valueReference="14"
+    description="= true, if all firing conditions are true"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "42" -->
+  <ScalarVariable
+    name="t2.fire"
+    valueReference="15"
+    description="= true, if transition fires"
+    variability="discrete"
+    causality="local"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "43" -->
+  <ScalarVariable
+    name="t1.enableTimer"
+    valueReference="16"
+    description="= true, if timer is enabled"
+    variability="fixed"
+    causality="calculatedParameter"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "44" -->
+  <ScalarVariable
+    name="t2.enableTimer"
+    valueReference="17"
+    description="= true, if timer is enabled"
+    variability="fixed"
+    causality="calculatedParameter"
+    initial="calculated">
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "45" -->
+  <ScalarVariable
+    name="s1.inPort[1].occupied"
+    valueReference="1"
+    description="true, if step is active"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "46" -->
+  <ScalarVariable
+    name="s1.inPort[1].set"
+    valueReference="15"
+    description="true, if transition fires and step is activated"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "47" -->
+  <ScalarVariable
+    name="s1.outPort[1].available"
+    valueReference="1"
+    description="true, if step is active"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "48" -->
+  <ScalarVariable
+    name="s1.outPort[1].reset"
+    valueReference="12"
+    description="true, if transition fires and step is deactivated"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "49" -->
+  <ScalarVariable
+    name="s1.outerStatePort.subgraphStatePort.resume"
+    valueReference="5"
+    description="= true, if resume transition of CompositeStep fires"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "50" -->
+  <ScalarVariable
+    name="s1.outerStatePort.subgraphStatePort.suspend"
+    valueReference="6"
+    description="= true, if suspend transition of CompositeStep fires"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "51" -->
+  <ScalarVariable
+    name="stateGraphRoot.subgraphStatePort.resume"
+    valueReference="5"
+    description="= true, if resume transition of CompositeStep fires"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "52" -->
+  <ScalarVariable
+    name="stateGraphRoot.subgraphStatePort.suspend"
+    valueReference="6"
+    description="= true, if suspend transition of CompositeStep fires"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "53" -->
+  <ScalarVariable
+    name="step1.inPort[1].occupied"
+    valueReference="7"
+    description="true, if step is active"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "54" -->
+  <ScalarVariable
+    name="step1.inPort[1].set"
+    valueReference="12"
+    description="true, if transition fires and step is activated"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "55" -->
+  <ScalarVariable
+    name="step1.outPort[1].available"
+    valueReference="7"
+    description="true, if step is active"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "56" -->
+  <ScalarVariable
+    name="step1.outPort[1].reset"
+    valueReference="15"
+    description="true, if transition fires and step is deactivated"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "57" -->
+  <ScalarVariable
+    name="step1.outerStatePort.subgraphStatePort.resume"
+    valueReference="5"
+    description="= true, if resume transition of CompositeStep fires"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "58" -->
+  <ScalarVariable
+    name="step1.outerStatePort.subgraphStatePort.suspend"
+    valueReference="6"
+    description="= true, if suspend transition of CompositeStep fires"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "59" -->
+  <ScalarVariable
+    name="switch1.u2"
+    valueReference="1"
+    description="Connector of Boolean input signal"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "60" -->
+  <ScalarVariable
+    name="t1.fire"
+    valueReference="12"
+    description="= true, if transition fires"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "61" -->
+  <ScalarVariable
+    name="t1.inPort.available"
+    valueReference="1"
+    description="true, if step connected to the transition input is active"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "62" -->
+  <ScalarVariable
+    name="t1.inPort.reset"
+    valueReference="12"
+    description="true, if transition fires and the step connected to the transition input is deactivated"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "63" -->
+  <ScalarVariable
+    name="t1.localCondition"
+    valueReference="11"
+    description="= true, if transition may fire"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "64" -->
+  <ScalarVariable
+    name="t1.outPort.occupied"
+    valueReference="7"
+    description="true, if step connected to the transition output is active"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "65" -->
+  <ScalarVariable
+    name="t1.outPort.set"
+    valueReference="12"
+    description="true, if transition fires and step connected to the transition output becomes active"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "66" -->
+  <ScalarVariable
+    name="t2.inPort.available"
+    valueReference="7"
+    description="true, if step connected to the transition input is active"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "67" -->
+  <ScalarVariable
+    name="t2.inPort.reset"
+    valueReference="15"
+    description="true, if transition fires and the step connected to the transition input is deactivated"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "68" -->
+  <ScalarVariable
+    name="t2.localCondition"
+    valueReference="13"
+    description="= true, if transition may fire"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "69" -->
+  <ScalarVariable
+    name="t2.outPort.occupied"
+    valueReference="1"
+    description="true, if step connected to the transition output is active"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  <!-- Index of variable = "70" -->
+  <ScalarVariable
+    name="t2.outPort.set"
+    valueReference="15"
+    description="true, if transition fires and step connected to the transition output becomes active"
+    variability="discrete"
+    causality="local"
+    >
+    <Boolean/>
+  </ScalarVariable>
+  </ModelVariables>
+  <ModelStructure>
+    <Outputs>
+      <Unknown index="13" dependencies="" dependenciesKind="" />
+    </Outputs>
+  </ModelStructure>
+</fmiModelDescription>

File diff suppressed because it is too large
+ 62 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/Makefile


+ 62 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/Makefile.in

@@ -0,0 +1,62 @@
+# Makefile generated by OpenModelica
+CC=@CC@
+AR=@AR@
+CFLAGS=@CFLAGS@
+LD=$(CC) -shared
+LDFLAGS=@LDFLAGS@ @LIBS@
+DLLEXT=@DLLEXT@
+NEED_RUNTIME=@NEED_RUNTIME@
+NEED_DGESV=@NEED_DGESV@
+FMIPLATFORM=@FMIPLATFORM@
+# Note: Simulation of the fmu with dymola does not work with -finline-small-functions (enabled by most optimization levels)
+CPPFLAGS=@CPPFLAGS@
+OMC_NUM_LINEAR_SYSTEMS=0
+OMC_NUM_NONLINEAR_SYSTEMS=0
+OMC_NUM_MIXED_SYSTEMS=0
+OMC_NDELAY_EXPRESSIONS=0
+OMC_NVAR_STRING=0
+
+override CPPFLAGS += -Iinclude/ -Iinclude/fmi2 -I.    -DOMC_MODEL_PREFIX=StategraphSample -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0
+
+MAINFILE=StategraphSample_FMU.c
+MAINOBJ=StategraphSample_FMU.o
+CFILES=StategraphSample.c StategraphSample_functions.c StategraphSample_records.c \
+StategraphSample_01exo.c StategraphSample_02nls.c StategraphSample_03lsy.c StategraphSample_04set.c StategraphSample_05evt.c StategraphSample_06inz.c StategraphSample_07dly.c \
+StategraphSample_08bnd.c StategraphSample_09alg.c StategraphSample_10asr.c StategraphSample_11mix.c StategraphSample_12jac.c StategraphSample_13opt.c StategraphSample_14lnz.c \
+StategraphSample_15syn.c StategraphSample_16dae.c StategraphSample_init_fmu.c
+OFILES=$(CFILES:.c=.o)
+GENERATEDFILES=$(MAINFILE) StategraphSample_FMU.makefile StategraphSample_literals.h StategraphSample_model.h StategraphSample_includes.h StategraphSample_functions.h  StategraphSample_11mix.h StategraphSample_12jac.h StategraphSample_13opt.h StategraphSample_init_fmu.c StategraphSample_info.c $(CFILES) StategraphSample_FMU.libs
+
+# FIXME: before you push into master...
+RUNTIMEDIR=include
+OMC_MINIMAL_RUNTIME=1
+OMC_FMI_RUNTIME=1
+include $(RUNTIMEDIR)/Makefile.objs
+ifneq ($(NEED_RUNTIME),)
+RUNTIMEFILES=$(FMI_ME_OBJS:%=$(RUNTIMEDIR)/%.o)
+endif
+
+PHONY: StategraphSample_FMU
+StategraphSample_FMU: $(MAINOBJ) StategraphSample_functions.h StategraphSample_literals.h $(OFILES) $(RUNTIMEFILES)
+	$(CXX) -shared -I. -o StategraphSample$(DLLEXT) $(MAINOBJ) $(RUNTIMEFILES) $(OFILES) $(CPPFLAGS) -L"C:/Users/clagms/Source Control/Git_HybridCosimulation/ModelicaModels"   $(CFLAGS) $(LDFLAGS) -llis -Wl,--kill-at
+	mkdir.exe -p ../binaries/win32
+	dlltool -d StategraphSample.def --dllname StategraphSample$(DLLEXT) --output-lib StategraphSample.lib --kill-at
+	cp StategraphSample$(DLLEXT) StategraphSample.lib StategraphSample_FMU.libs ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/libsundials_*.dll ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/libopenblas.dll ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/libexpat*.dll ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/libgfortran*.dll ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/libquadmath*.dll ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/libwinpthread*.dll ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/zlib*.dll ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/libszip*.dll ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/libhdf5*.dll ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/libsystre*.dll ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/libtre*.dll ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/libintl*.dll ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/libiconv*.dll ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/libgcc_s_*.dll ../binaries/win32/
+	cp C:/OpenModelica1.12.0-dev-32bit//bin/libstdc*.dll ../binaries/win32/
+	rm -f StategraphSample.def StategraphSample.o StategraphSample$(DLLEXT) $(OFILES) $(RUNTIMEFILES)
+	cd .. && rm -f ../StategraphSample.fmu && zip -r ../StategraphSample.fmu *
+

+ 586 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample.c

@@ -0,0 +1,586 @@
+/* Main Simulation File */
+#include "StategraphSample_model.h"
+
+
+/* dummy VARINFO and FILEINFO */
+const FILE_INFO dummyFILE_INFO = omc_dummyFileInfo;
+const VAR_INFO dummyVAR_INFO = omc_dummyVarInfo;
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+int StategraphSample_input_function(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+
+  data->localData[0]->realVars[11] /* u variable */ = data->simulationInfo->inputVars[0];
+  
+  TRACE_POP
+  return 0;
+}
+
+int StategraphSample_input_function_init(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+
+  data->simulationInfo->inputVars[0] = data->modelData->realVarsData[11].attribute.start;
+  
+  TRACE_POP
+  return 0;
+}
+
+int StategraphSample_input_function_updateStartValues(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+
+  data->modelData->realVarsData[11].attribute.start = data->simulationInfo->inputVars[0];
+  
+  TRACE_POP
+  return 0;
+}
+
+int StategraphSample_inputNames(DATA *data, char ** names){
+  TRACE_PUSH
+
+  names[0] = (char *) data->modelData->realVarsData[11].info.name;
+  
+  TRACE_POP
+  return 0;
+}
+
+int StategraphSample_output_function(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+
+  data->simulationInfo->outputVars[0] = data->localData[0]->realVars[12] /* y variable */;
+  
+  TRACE_POP
+  return 0;
+}
+
+
+/*
+ equation index: 40
+ type: SIMPLE_ASSIGN
+ step1._active = pre(step1.newActive)
+ */
+void StategraphSample_eqFunction_40(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,40};
+  data->localData[0]->booleanVars[7] /* step1._active DISCRETE */ = data->simulationInfo->booleanVarsPre[9] /* step1._newActive DISCRETE */;
+  TRACE_POP
+}
+/*
+ equation index: 41
+ type: SIMPLE_ASSIGN
+ step1._outerStatePort._subgraphStatePort._activeSteps = if step1.active then 1.0 else 0.0
+ */
+void StategraphSample_eqFunction_41(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,41};
+  data->localData[0]->realVars[5] /* step1._outerStatePort._subgraphStatePort._activeSteps variable */ = (data->localData[0]->booleanVars[7] /* step1._active DISCRETE */?1.0:0.0);
+  TRACE_POP
+}
+/*
+ equation index: 42
+ type: WHEN
+ 
+ when {} then
+   step1._oldActive = step1.active;
+ end when;
+ */
+void StategraphSample_eqFunction_42(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,42};
+  if(0)
+  {
+    data->localData[0]->booleanVars[10] /* step1._oldActive DISCRETE */ = data->localData[0]->booleanVars[7] /* step1._active DISCRETE */;
+  }
+  TRACE_POP
+}
+/*
+ equation index: 43
+ type: SIMPLE_ASSIGN
+ step1._localActive = step1.active
+ */
+void StategraphSample_eqFunction_43(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,43};
+  data->localData[0]->booleanVars[8] /* step1._localActive DISCRETE */ = data->localData[0]->booleanVars[7] /* step1._active DISCRETE */;
+  TRACE_POP
+}
+/*
+ equation index: 44
+ type: SIMPLE_ASSIGN
+ t1._condition = u > 0.5
+ */
+void StategraphSample_eqFunction_44(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,44};
+  modelica_boolean tmp25;
+  RELATIONHYSTERESIS(tmp25, data->localData[0]->realVars[11] /* u variable */, 0.5, 0, Greater);
+  data->localData[0]->booleanVars[11] /* t1._condition DISCRETE */ = tmp25;
+  TRACE_POP
+}
+/*
+ equation index: 45
+ type: SIMPLE_ASSIGN
+ s1._active = pre(s1.newActive)
+ */
+void StategraphSample_eqFunction_45(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,45};
+  data->localData[0]->booleanVars[1] /* s1._active DISCRETE */ = data->simulationInfo->booleanVarsPre[3] /* s1._newActive DISCRETE */;
+  TRACE_POP
+}
+/*
+ equation index: 46
+ type: SIMPLE_ASSIGN
+ s1._outerStatePort._subgraphStatePort._activeSteps = if s1.active then 1.0 else 0.0
+ */
+void StategraphSample_eqFunction_46(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,46};
+  data->localData[0]->realVars[2] /* s1._outerStatePort._subgraphStatePort._activeSteps variable */ = (data->localData[0]->booleanVars[1] /* s1._active DISCRETE */?1.0:0.0);
+  TRACE_POP
+}
+/*
+ equation index: 47
+ type: SIMPLE_ASSIGN
+ stateGraphRoot._subgraphStatePort._activeSteps = (-s1.outerStatePort.subgraphStatePort.activeSteps) - step1.outerStatePort.subgraphStatePort.activeSteps
+ */
+void StategraphSample_eqFunction_47(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,47};
+  data->localData[0]->realVars[3] /* stateGraphRoot._subgraphStatePort._activeSteps variable */ = (-data->localData[0]->realVars[2] /* s1._outerStatePort._subgraphStatePort._activeSteps variable */) - data->localData[0]->realVars[5] /* step1._outerStatePort._subgraphStatePort._activeSteps variable */;
+  TRACE_POP
+}
+/*
+ equation index: 48
+ type: SIMPLE_ASSIGN
+ stateGraphRoot._activeSteps = -integer(stateGraphRoot.subgraphStatePort.activeSteps, 0)
+ */
+void StategraphSample_eqFunction_48(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,48};
+  data->localData[0]->integerVars[0] /* stateGraphRoot._activeSteps DISCRETE */ = (-(_event_integer(data->localData[0]->realVars[3] /* stateGraphRoot._subgraphStatePort._activeSteps variable */, ((modelica_integer) 0), data)));
+  TRACE_POP
+}
+/*
+ equation index: 49
+ type: SIMPLE_ASSIGN
+ y = if s1.active then 0.0 else 1.0
+ */
+void StategraphSample_eqFunction_49(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,49};
+  data->localData[0]->realVars[12] /* y variable */ = (data->localData[0]->booleanVars[1] /* s1._active DISCRETE */?0.0:1.0);
+  TRACE_POP
+}
+/*
+ equation index: 50
+ type: SIMPLE_ASSIGN
+ $whenCondition1 = step1.active and not s1.active
+ */
+void StategraphSample_eqFunction_50(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,50};
+  data->localData[0]->booleanVars[0] /* $whenCondition1 DISCRETE */ = (data->localData[0]->booleanVars[7] /* step1._active DISCRETE */ && (!data->localData[0]->booleanVars[1] /* s1._active DISCRETE */));
+  TRACE_POP
+}
+/*
+ equation index: 51
+ type: WHEN
+ 
+ when {$whenCondition1} then
+   t2._t_start = time;
+ end when;
+ */
+void StategraphSample_eqFunction_51(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,51};
+  if((data->localData[0]->booleanVars[0] /* $whenCondition1 DISCRETE */ && !data->simulationInfo->booleanVarsPre[0] /* $whenCondition1 DISCRETE */ /* edge */))
+  {
+    data->localData[0]->realVars[13] /* t2._t_start DISCRETE */ = data->localData[0]->timeValue;
+  }
+  TRACE_POP
+}
+/*
+ equation index: 52
+ type: SIMPLE_ASSIGN
+ t2._t_dummy = time - t2.t_start
+ */
+void StategraphSample_eqFunction_52(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,52};
+  data->localData[0]->realVars[10] /* t2._t_dummy variable */ = data->localData[0]->timeValue - data->localData[0]->realVars[13] /* t2._t_start DISCRETE */;
+  TRACE_POP
+}
+/*
+ equation index: 53
+ type: SIMPLE_ASSIGN
+ t2._fire = $whenCondition1 and time >= t2.t_start + t2.waitTime
+ */
+void StategraphSample_eqFunction_53(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,53};
+  modelica_boolean tmp26;
+  RELATIONHYSTERESIS(tmp26, data->localData[0]->timeValue, data->localData[0]->realVars[13] /* t2._t_start DISCRETE */ + data->simulationInfo->realParameter[1] /* t2._waitTime PARAM */, 1, GreaterEq);
+  data->localData[0]->booleanVars[15] /* t2._fire DISCRETE */ = (data->localData[0]->booleanVars[0] /* $whenCondition1 DISCRETE */ && tmp26);
+  TRACE_POP
+}
+/*
+ equation index: 54
+ type: SIMPLE_ASSIGN
+ t2._t = if $whenCondition1 then t2.t_dummy else 0.0
+ */
+void StategraphSample_eqFunction_54(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,54};
+  data->localData[0]->realVars[9] /* t2._t variable */ = (data->localData[0]->booleanVars[0] /* $whenCondition1 DISCRETE */?data->localData[0]->realVars[10] /* t2._t_dummy variable */:0.0);
+  TRACE_POP
+}
+/*
+ equation index: 55
+ type: SIMPLE_ASSIGN
+ t2._enableFire = $whenCondition1
+ */
+void StategraphSample_eqFunction_55(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,55};
+  data->localData[0]->booleanVars[14] /* t2._enableFire DISCRETE */ = data->localData[0]->booleanVars[0] /* $whenCondition1 DISCRETE */;
+  TRACE_POP
+}
+/*
+ equation index: 56
+ type: SIMPLE_ASSIGN
+ t1._enableFire = t1.condition and s1.active and not step1.active
+ */
+void StategraphSample_eqFunction_56(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,56};
+  data->localData[0]->booleanVars[12] /* t1._enableFire DISCRETE */ = ((data->localData[0]->booleanVars[11] /* t1._condition DISCRETE */ && data->localData[0]->booleanVars[1] /* s1._active DISCRETE */) && (!data->localData[0]->booleanVars[7] /* step1._active DISCRETE */));
+  TRACE_POP
+}
+/*
+ equation index: 57
+ type: SIMPLE_ASSIGN
+ step1._newActive = Modelica.StateGraph.Temporary.anyTrue({t1.enableFire}) or step1.active and not Modelica.StateGraph.Temporary.anyTrue({t2.fire})
+ */
+void StategraphSample_eqFunction_57(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,57};
+  boolean_array tmp27;
+  boolean_array tmp28;
+  array_alloc_scalar_boolean_array(&tmp27, 1, (modelica_boolean)data->localData[0]->booleanVars[12] /* t1._enableFire DISCRETE */);
+  array_alloc_scalar_boolean_array(&tmp28, 1, (modelica_boolean)data->localData[0]->booleanVars[15] /* t2._fire DISCRETE */);
+  data->localData[0]->booleanVars[9] /* step1._newActive DISCRETE */ = (omc_Modelica_StateGraph_Temporary_anyTrue(threadData, tmp27) || (data->localData[0]->booleanVars[7] /* step1._active DISCRETE */ && (!omc_Modelica_StateGraph_Temporary_anyTrue(threadData, tmp28))));
+  TRACE_POP
+}
+/*
+ equation index: 58
+ type: SIMPLE_ASSIGN
+ s1._newActive = Modelica.StateGraph.Temporary.anyTrue({t2.fire}) or s1.active and not Modelica.StateGraph.Temporary.anyTrue({t1.enableFire})
+ */
+void StategraphSample_eqFunction_58(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,58};
+  boolean_array tmp29;
+  boolean_array tmp30;
+  array_alloc_scalar_boolean_array(&tmp29, 1, (modelica_boolean)data->localData[0]->booleanVars[15] /* t2._fire DISCRETE */);
+  array_alloc_scalar_boolean_array(&tmp30, 1, (modelica_boolean)data->localData[0]->booleanVars[12] /* t1._enableFire DISCRETE */);
+  data->localData[0]->booleanVars[3] /* s1._newActive DISCRETE */ = (omc_Modelica_StateGraph_Temporary_anyTrue(threadData, tmp29) || (data->localData[0]->booleanVars[1] /* s1._active DISCRETE */ && (!omc_Modelica_StateGraph_Temporary_anyTrue(threadData, tmp30))));
+  TRACE_POP
+}
+/*
+ equation index: 59
+ type: WHEN
+ 
+ when {} then
+   s1._oldActive = s1.active;
+ end when;
+ */
+void StategraphSample_eqFunction_59(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,59};
+  if(0)
+  {
+    data->localData[0]->booleanVars[4] /* s1._oldActive DISCRETE */ = data->localData[0]->booleanVars[1] /* s1._active DISCRETE */;
+  }
+  TRACE_POP
+}
+/*
+ equation index: 60
+ type: SIMPLE_ASSIGN
+ s1._localActive = s1.active
+ */
+void StategraphSample_eqFunction_60(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,60};
+  data->localData[0]->booleanVars[2] /* s1._localActive DISCRETE */ = data->localData[0]->booleanVars[1] /* s1._active DISCRETE */;
+  TRACE_POP
+}
+
+
+int StategraphSample_functionDAE(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  int equationIndexes[1] = {0};
+  
+  data->simulationInfo->needToIterate = 0;
+  data->simulationInfo->discreteCall = 1;
+  StategraphSample_functionLocalKnownVars(data, threadData);
+  StategraphSample_eqFunction_40(data, threadData);
+
+  StategraphSample_eqFunction_41(data, threadData);
+
+  StategraphSample_eqFunction_42(data, threadData);
+
+  StategraphSample_eqFunction_43(data, threadData);
+
+  StategraphSample_eqFunction_44(data, threadData);
+
+  StategraphSample_eqFunction_45(data, threadData);
+
+  StategraphSample_eqFunction_46(data, threadData);
+
+  StategraphSample_eqFunction_47(data, threadData);
+
+  StategraphSample_eqFunction_48(data, threadData);
+
+  StategraphSample_eqFunction_49(data, threadData);
+
+  StategraphSample_eqFunction_50(data, threadData);
+
+  StategraphSample_eqFunction_51(data, threadData);
+
+  StategraphSample_eqFunction_52(data, threadData);
+
+  StategraphSample_eqFunction_53(data, threadData);
+
+  StategraphSample_eqFunction_54(data, threadData);
+
+  StategraphSample_eqFunction_55(data, threadData);
+
+  StategraphSample_eqFunction_56(data, threadData);
+
+  StategraphSample_eqFunction_57(data, threadData);
+
+  StategraphSample_eqFunction_58(data, threadData);
+
+  StategraphSample_eqFunction_59(data, threadData);
+
+  StategraphSample_eqFunction_60(data, threadData);
+  data->simulationInfo->discreteCall = 0;
+  
+  TRACE_POP
+  return 0;
+}
+
+
+int StategraphSample_functionLocalKnownVars(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+
+  
+  TRACE_POP
+  return 0;
+}
+
+int StategraphSample_symEulerUpdate(DATA *data, modelica_real dt)
+{
+  return -1;
+}
+
+
+
+int StategraphSample_functionODE(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+
+  
+  data->simulationInfo->callStatistics.functionODE++;
+  
+  StategraphSample_functionLocalKnownVars(data, threadData);
+  /* no ODE systems */
+
+  
+  TRACE_POP
+  return 0;
+}
+
+#ifdef FMU_EXPERIMENTAL
+#endif
+/* forward the main in the simulation runtime */
+extern int _main_SimulationRuntime(int argc, char**argv, DATA *data, threadData_t *threadData);
+
+#include "StategraphSample_12jac.h"
+#include "StategraphSample_13opt.h"
+
+struct OpenModelicaGeneratedFunctionCallbacks StategraphSample_callback = {
+   NULL,
+   NULL,
+   NULL,
+   StategraphSample_callExternalObjectConstructors,
+   StategraphSample_callExternalObjectDestructors,
+   NULL,
+   NULL,
+   NULL,
+   #if !defined(OMC_NO_STATESELECTION)
+   StategraphSample_initializeStateSets,
+   #else
+   NULL,
+   #endif
+   StategraphSample_initializeDAEmodeData,
+   StategraphSample_functionODE,
+   StategraphSample_functionAlgebraics,
+   StategraphSample_functionDAE,
+   StategraphSample_functionLocalKnownVars,
+   StategraphSample_input_function,
+   StategraphSample_input_function_init,
+   StategraphSample_input_function_updateStartValues,
+   StategraphSample_output_function,
+   StategraphSample_function_storeDelayed,
+   StategraphSample_updateBoundVariableAttributes,
+   0 /* useHomotopy */,
+   StategraphSample_functionInitialEquations,
+   StategraphSample_functionInitialEquations_lambda0,
+   StategraphSample_functionRemovedInitialEquations,
+   StategraphSample_updateBoundParameters,
+   StategraphSample_checkForAsserts,
+   StategraphSample_function_ZeroCrossingsEquations,
+   StategraphSample_function_ZeroCrossings,
+   StategraphSample_function_updateRelations,
+   StategraphSample_checkForDiscreteChanges,
+   StategraphSample_zeroCrossingDescription,
+   StategraphSample_relationDescription,
+   StategraphSample_function_initSample,
+   StategraphSample_INDEX_JAC_A,
+   StategraphSample_INDEX_JAC_B,
+   StategraphSample_INDEX_JAC_C,
+   StategraphSample_INDEX_JAC_D,
+   StategraphSample_initialAnalyticJacobianA,
+   StategraphSample_initialAnalyticJacobianB,
+   StategraphSample_initialAnalyticJacobianC,
+   StategraphSample_initialAnalyticJacobianD,
+   StategraphSample_functionJacA_column,
+   StategraphSample_functionJacB_column,
+   StategraphSample_functionJacC_column,
+   StategraphSample_functionJacD_column,
+   StategraphSample_linear_model_frame,
+   StategraphSample_linear_model_datarecovery_frame,
+   StategraphSample_mayer,
+   StategraphSample_lagrange,
+   StategraphSample_pickUpBoundsForInputsInOptimization,
+   StategraphSample_setInputData,
+   StategraphSample_getTimeGrid,
+   StategraphSample_symEulerUpdate,
+   StategraphSample_function_initSynchronous,
+   StategraphSample_function_updateSynchronous,
+   StategraphSample_function_equationsSynchronous,
+   StategraphSample_read_input_fmu
+   #ifdef FMU_EXPERIMENTAL
+   ,StategraphSample_functionODE_Partial
+   ,StategraphSample_functionFMIJacobian
+   #endif
+   ,StategraphSample_inputNames
+
+
+};
+
+void StategraphSample_setupDataStruc(DATA *data, threadData_t *threadData)
+{
+  assertStreamPrint(threadData,0!=data, "Error while initialize Data");
+  data->callback = &StategraphSample_callback;
+  data->modelData->modelName = "StategraphSample";
+  data->modelData->modelFilePrefix = "StategraphSample";
+  data->modelData->resultFileName = NULL;
+  data->modelData->modelDir = "C:/Users/clagms/Source Control/Git_HybridCosimulation/ModelicaModels";
+  data->modelData->modelGUID = "{1bbd4064-0ef0-405e-a6e3-a61a868199f5}";
+  data->modelData->initXMLData = NULL;
+  data->modelData->modelDataXml.infoXMLData =
+  #if defined(OMC_MINIMAL_METADATA)
+    NULL;
+  #else
+  #include "StategraphSample_info.c"
+  #endif
+  ;
+  
+  data->modelData->nStates = 0;
+  data->modelData->nVariablesReal = 14;
+  data->modelData->nDiscreteReal = 1;
+  data->modelData->nVariablesInteger = 1;
+  data->modelData->nVariablesBoolean = 16;
+  data->modelData->nVariablesString = 0;
+  data->modelData->nParametersReal = 2;
+  data->modelData->nParametersInteger = 4;
+  data->modelData->nParametersBoolean = 2;
+  data->modelData->nParametersString = 0;
+  data->modelData->nInputVars = 1;
+  data->modelData->nOutputVars = 1;
+  
+  data->modelData->nAliasReal = 5;
+  data->modelData->nAliasInteger = 0;
+  data->modelData->nAliasBoolean = 26;
+  data->modelData->nAliasString = 0;
+  
+  data->modelData->nZeroCrossings = 3;
+  data->modelData->nSamples = 0;
+  data->modelData->nRelations = 2;
+  data->modelData->nMathEvents = 1;
+  data->modelData->nExtObjs = 0;
+  data->modelData->modelDataXml.fileName = "StategraphSample_info.json";
+  data->modelData->modelDataXml.modelInfoXmlLength = 0;
+  data->modelData->modelDataXml.nFunctions = 1;
+  data->modelData->modelDataXml.nProfileBlocks = 0;
+  data->modelData->modelDataXml.nEquations = 73;
+  data->modelData->nMixedSystems = 0;
+  data->modelData->nLinearSystems = 0;
+  data->modelData->nNonLinearSystems = 0;
+  data->modelData->nStateSets = 0;
+  data->modelData->nJacobians = 4;
+  data->modelData->nOptimizeConstraints = 0;
+  data->modelData->nOptimizeFinalConstraints = 0;
+  
+  data->modelData->nDelayExpressions = 0;
+  
+  data->modelData->nClocks = 0;
+  data->modelData->nSubClocks = 0;
+  
+  data->modelData->nSensitivityVars = 0;
+  data->modelData->nSensitivityParamVars = 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+static int rml_execution_failed()
+{
+  fflush(NULL);
+  fprintf(stderr, "Execution failed!\n");
+  fflush(NULL);
+  return 1;
+}
+

+ 2 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample.makefile

@@ -0,0 +1,2 @@
+# Dummy file so OMDEV Compile.bat works
+include Makefile

+ 26 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_01exo.c

@@ -0,0 +1,26 @@
+/* External objects file */
+#include "StategraphSample_model.h"
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Has to be performed after _init.xml file has been read */
+void StategraphSample_callExternalObjectConstructors(DATA *data, threadData_t *threadData)
+{
+  /* data->simulationInfo->extObjs = NULL; */
+  infoStreamPrint(LOG_DEBUG, 0, "call external Object Constructors");
+  infoStreamPrint(LOG_DEBUG, 0, "call external Object Constructors finished");
+}
+
+void StategraphSample_callExternalObjectDestructors(DATA *data, threadData_t *threadData)
+{
+  if(data->simulationInfo->extObjs)
+  {
+    free(data->simulationInfo->extObjs);
+    data->simulationInfo->extObjs = 0;
+  }
+}
+#if defined(__cplusplus)
+}
+#endif
+

+ 12 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_02nls.c

@@ -0,0 +1,12 @@
+/* Non Linear Systems */
+#include "StategraphSample_model.h"
+#include "StategraphSample_12jac.h"
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+
+#if defined(__cplusplus)
+}
+#endif
+

+ 18 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_03lsy.c

@@ -0,0 +1,18 @@
+/* Linear Systems */
+#include "StategraphSample_model.h"
+#include "StategraphSample_12jac.h"
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* initial linear systems */
+/* initial_lambda0 linear systems */
+/* parameter linear systems */
+/* model linear systems */
+/* jacobians linear systems */
+
+
+#if defined(__cplusplus)
+}
+#endif
+

+ 16 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_04set.c

@@ -0,0 +1,16 @@
+/* Initial State Set */
+#include "StategraphSample_model.h"
+#include "StategraphSample_11mix.h"
+#include "StategraphSample_12jac.h"
+#if defined(__cplusplus)
+extern "C" {
+#endif
+/* funtion initialize state sets */
+void StategraphSample_initializeStateSets(int nStateSets, STATE_SET_DATA* statesetData, DATA *data)
+{
+}
+
+#if defined(__cplusplus)
+}
+#endif
+

+ 192 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_05evt.c

@@ -0,0 +1,192 @@
+/* Events: Sample, Zero Crossings, Relations, Discrete Changes */
+#include "StategraphSample_model.h"
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Initializes the raw time events of the simulation using the now
+   calcualted parameters. */
+void StategraphSample_function_initSample(DATA *data, threadData_t *threadData)
+{
+  long i=0;
+}
+
+const char *StategraphSample_zeroCrossingDescription(int i, int **out_EquationIndexes)
+{
+  static const char *res[] = {"u > 0.5",
+  "integer(stateGraphRoot.subgraphStatePort.activeSteps, 0)",
+  "$whenCondition1 and time >= t2.t_start + t2.waitTime"};
+  static const int occurEqs0[] = {1,44};
+  static const int occurEqs1[] = {1,48};
+  static const int occurEqs2[] = {1,53};
+  static const int *occurEqs[] = {occurEqs0,occurEqs1,occurEqs2};
+  *out_EquationIndexes = (int*) occurEqs[i];
+  return res[i];
+}
+
+/* forwarded equations */
+extern void StategraphSample_eqFunction_40(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_41(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_45(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_46(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_47(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_50(DATA* data, threadData_t *threadData);
+
+int StategraphSample_function_ZeroCrossingsEquations(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+
+  data->simulationInfo->callStatistics.functionZeroCrossingsEquations++;
+
+  StategraphSample_eqFunction_40(data, threadData);
+
+  StategraphSample_eqFunction_41(data, threadData);
+
+  StategraphSample_eqFunction_45(data, threadData);
+
+  StategraphSample_eqFunction_46(data, threadData);
+
+  StategraphSample_eqFunction_47(data, threadData);
+
+  StategraphSample_eqFunction_50(data, threadData);
+  
+  TRACE_POP
+  return 0;
+}
+
+int StategraphSample_function_ZeroCrossings(DATA *data, threadData_t *threadData, double *gout)
+{
+  TRACE_PUSH
+  modelica_boolean tmp1;
+  modelica_boolean tmp2;
+  
+  data->simulationInfo->callStatistics.functionZeroCrossings++;
+  
+  tmp1 = GreaterZC(data->localData[0]->realVars[11] /* u variable */, 0.5, data->simulationInfo->storedRelations[0]);
+  gout[0] = (tmp1) ? 1 : -1;
+  gout[1] = (floor(data->localData[0]->realVars[3] /* stateGraphRoot._subgraphStatePort._activeSteps variable */) != floor(data->simulationInfo->mathEventsValuePre[((modelica_integer) 0)])) ? 1 : -1;
+  tmp2 = GreaterEqZC(data->localData[0]->timeValue, data->localData[0]->realVars[13] /* t2._t_start DISCRETE */ + data->simulationInfo->realParameter[1] /* t2._waitTime PARAM */, data->simulationInfo->storedRelations[1]);
+  gout[2] = ((data->localData[0]->booleanVars[0] /* $whenCondition1 DISCRETE */ && tmp2)) ? 1 : -1;
+  
+  TRACE_POP
+  return 0;
+}
+
+const char *StategraphSample_relationDescription(int i)
+{
+  const char *res[] = {"u > 0.5",
+  "time >= t2.t_start + t2.waitTime"};
+  return res[i];
+}
+
+int StategraphSample_function_updateRelations(DATA *data, threadData_t *threadData, int evalforZeroCross)
+{
+  TRACE_PUSH
+  modelica_boolean tmp3;
+  modelica_boolean tmp4;
+  
+  if(evalforZeroCross) {
+    tmp3 = GreaterZC(data->localData[0]->realVars[11] /* u variable */, 0.5, data->simulationInfo->storedRelations[0]);
+    data->simulationInfo->relations[0] = tmp3;
+    tmp4 = GreaterEqZC(data->localData[0]->timeValue, data->localData[0]->realVars[13] /* t2._t_start DISCRETE */ + data->simulationInfo->realParameter[1] /* t2._waitTime PARAM */, data->simulationInfo->storedRelations[1]);
+    data->simulationInfo->relations[1] = tmp4;
+  } else {
+    data->simulationInfo->relations[0] = (data->localData[0]->realVars[11] /* u variable */ > 0.5);
+    data->simulationInfo->relations[1] = (data->localData[0]->timeValue >= data->localData[0]->realVars[13] /* t2._t_start DISCRETE */ + data->simulationInfo->realParameter[1] /* t2._waitTime PARAM */);
+  }
+  
+  TRACE_POP
+  return 0;
+}
+
+int StategraphSample_checkForDiscreteChanges(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  int needToIterate = 0;
+
+  infoStreamPrint(LOG_EVENTS_V, 1, "check for discrete changes at time=%.12g", data->localData[0]->timeValue);
+  if(data->localData[0]->booleanVars[8] /* step1._localActive DISCRETE */ != data->simulationInfo->booleanVarsPre[8] /* step1._localActive DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: step1._localActive from %d to %d", data->simulationInfo->booleanVarsPre[8] /* step1._localActive DISCRETE */, data->localData[0]->booleanVars[8] /* step1._localActive DISCRETE */);
+    needToIterate = 1;
+  }
+  if(data->localData[0]->booleanVars[14] /* t2._enableFire DISCRETE */ != data->simulationInfo->booleanVarsPre[14] /* t2._enableFire DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: t2._enableFire from %d to %d", data->simulationInfo->booleanVarsPre[14] /* t2._enableFire DISCRETE */, data->localData[0]->booleanVars[14] /* t2._enableFire DISCRETE */);
+    needToIterate = 1;
+  }
+  if(data->localData[0]->booleanVars[2] /* s1._localActive DISCRETE */ != data->simulationInfo->booleanVarsPre[2] /* s1._localActive DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: s1._localActive from %d to %d", data->simulationInfo->booleanVarsPre[2] /* s1._localActive DISCRETE */, data->localData[0]->booleanVars[2] /* s1._localActive DISCRETE */);
+    needToIterate = 1;
+  }
+  if(data->localData[0]->booleanVars[0] /* $whenCondition1 DISCRETE */ != data->simulationInfo->booleanVarsPre[0] /* $whenCondition1 DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: $whenCondition1 from %d to %d", data->simulationInfo->booleanVarsPre[0] /* $whenCondition1 DISCRETE */, data->localData[0]->booleanVars[0] /* $whenCondition1 DISCRETE */);
+    needToIterate = 1;
+  }
+  if(data->localData[0]->booleanVars[3] /* s1._newActive DISCRETE */ != data->simulationInfo->booleanVarsPre[3] /* s1._newActive DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: s1._newActive from %d to %d", data->simulationInfo->booleanVarsPre[3] /* s1._newActive DISCRETE */, data->localData[0]->booleanVars[3] /* s1._newActive DISCRETE */);
+    needToIterate = 1;
+  }
+  if(data->localData[0]->booleanVars[4] /* s1._oldActive DISCRETE */ != data->simulationInfo->booleanVarsPre[4] /* s1._oldActive DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: s1._oldActive from %d to %d", data->simulationInfo->booleanVarsPre[4] /* s1._oldActive DISCRETE */, data->localData[0]->booleanVars[4] /* s1._oldActive DISCRETE */);
+    needToIterate = 1;
+  }
+  if(data->localData[0]->booleanVars[1] /* s1._active DISCRETE */ != data->simulationInfo->booleanVarsPre[1] /* s1._active DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: s1._active from %d to %d", data->simulationInfo->booleanVarsPre[1] /* s1._active DISCRETE */, data->localData[0]->booleanVars[1] /* s1._active DISCRETE */);
+    needToIterate = 1;
+  }
+  if(data->localData[0]->booleanVars[12] /* t1._enableFire DISCRETE */ != data->simulationInfo->booleanVarsPre[12] /* t1._enableFire DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: t1._enableFire from %d to %d", data->simulationInfo->booleanVarsPre[12] /* t1._enableFire DISCRETE */, data->localData[0]->booleanVars[12] /* t1._enableFire DISCRETE */);
+    needToIterate = 1;
+  }
+  if(data->localData[0]->booleanVars[11] /* t1._condition DISCRETE */ != data->simulationInfo->booleanVarsPre[11] /* t1._condition DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: t1._condition from %d to %d", data->simulationInfo->booleanVarsPre[11] /* t1._condition DISCRETE */, data->localData[0]->booleanVars[11] /* t1._condition DISCRETE */);
+    needToIterate = 1;
+  }
+  if(data->localData[0]->booleanVars[15] /* t2._fire DISCRETE */ != data->simulationInfo->booleanVarsPre[15] /* t2._fire DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: t2._fire from %d to %d", data->simulationInfo->booleanVarsPre[15] /* t2._fire DISCRETE */, data->localData[0]->booleanVars[15] /* t2._fire DISCRETE */);
+    needToIterate = 1;
+  }
+  if(data->localData[0]->realVars[13] /* t2._t_start DISCRETE */ != data->simulationInfo->realVarsPre[13] /* t2._t_start DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: t2._t_start from %g to %g", data->simulationInfo->realVarsPre[13] /* t2._t_start DISCRETE */, data->localData[0]->realVars[13] /* t2._t_start DISCRETE */);
+    needToIterate = 1;
+  }
+  if(data->localData[0]->integerVars[0] /* stateGraphRoot._activeSteps DISCRETE */ != data->simulationInfo->integerVarsPre[0] /* stateGraphRoot._activeSteps DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: stateGraphRoot._activeSteps from %ld to %ld", data->simulationInfo->integerVarsPre[0] /* stateGraphRoot._activeSteps DISCRETE */, data->localData[0]->integerVars[0] /* stateGraphRoot._activeSteps DISCRETE */);
+    needToIterate = 1;
+  }
+  if(data->localData[0]->booleanVars[9] /* step1._newActive DISCRETE */ != data->simulationInfo->booleanVarsPre[9] /* step1._newActive DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: step1._newActive from %d to %d", data->simulationInfo->booleanVarsPre[9] /* step1._newActive DISCRETE */, data->localData[0]->booleanVars[9] /* step1._newActive DISCRETE */);
+    needToIterate = 1;
+  }
+  if(data->localData[0]->booleanVars[10] /* step1._oldActive DISCRETE */ != data->simulationInfo->booleanVarsPre[10] /* step1._oldActive DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: step1._oldActive from %d to %d", data->simulationInfo->booleanVarsPre[10] /* step1._oldActive DISCRETE */, data->localData[0]->booleanVars[10] /* step1._oldActive DISCRETE */);
+    needToIterate = 1;
+  }
+  if(data->localData[0]->booleanVars[7] /* step1._active DISCRETE */ != data->simulationInfo->booleanVarsPre[7] /* step1._active DISCRETE */)
+  {
+    infoStreamPrint(LOG_EVENTS_V, 0, "discrete var changed: step1._active from %d to %d", data->simulationInfo->booleanVarsPre[7] /* step1._active DISCRETE */, data->localData[0]->booleanVars[7] /* step1._active DISCRETE */);
+    needToIterate = 1;
+  }
+  if (ACTIVE_STREAM(LOG_EVENTS_V)) messageClose(LOG_EVENTS_V);
+  
+  TRACE_POP
+  return needToIterate;
+}
+
+#if defined(__cplusplus)
+}
+#endif
+

+ 614 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_06inz.c

@@ -0,0 +1,614 @@
+/* Initialization */
+#include "StategraphSample_model.h"
+#include "StategraphSample_11mix.h"
+#include "StategraphSample_12jac.h"
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+void StategraphSample_functionInitialEquations_0(DATA *data, threadData_t *threadData);
+
+
+/*
+ equation index: 1
+ type: SIMPLE_ASSIGN
+ stateGraphRoot._resume = false
+ */
+void StategraphSample_eqFunction_1(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,1};
+  data->localData[0]->booleanVars[5] /* stateGraphRoot._resume DISCRETE */ = 0;
+  TRACE_POP
+}
+
+/*
+ equation index: 2
+ type: SIMPLE_ASSIGN
+ stateGraphRoot._suspend = false
+ */
+void StategraphSample_eqFunction_2(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,2};
+  data->localData[0]->booleanVars[6] /* stateGraphRoot._suspend DISCRETE */ = 0;
+  TRACE_POP
+}
+
+/*
+ equation index: 3
+ type: SIMPLE_ASSIGN
+ realExpression2._y = 1.0
+ */
+void StategraphSample_eqFunction_3(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,3};
+  data->localData[0]->realVars[1] /* realExpression2._y variable */ = 1.0;
+  TRACE_POP
+}
+
+/*
+ equation index: 4
+ type: SIMPLE_ASSIGN
+ realExpression1._y = 0.0
+ */
+void StategraphSample_eqFunction_4(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,4};
+  data->localData[0]->realVars[0] /* realExpression1._y variable */ = 0.0;
+  TRACE_POP
+}
+
+/*
+ equation index: 5
+ type: SIMPLE_ASSIGN
+ t2._condition = true
+ */
+void StategraphSample_eqFunction_5(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,5};
+  data->localData[0]->booleanVars[13] /* t2._condition DISCRETE */ = 1;
+  TRACE_POP
+}
+
+/*
+ equation index: 6
+ type: SIMPLE_ASSIGN
+ stateGraphRoot._subgraphStatePort._activeStepsDummy = 0.0
+ */
+void StategraphSample_eqFunction_6(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,6};
+  data->localData[0]->realVars[4] /* stateGraphRoot._subgraphStatePort._activeStepsDummy variable */ = 0.0;
+  TRACE_POP
+}
+
+/*
+ equation index: 7
+ type: SIMPLE_ASSIGN
+ t1._t = 0.0
+ */
+void StategraphSample_eqFunction_7(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,7};
+  data->localData[0]->realVars[6] /* t1._t variable */ = 0.0;
+  TRACE_POP
+}
+
+/*
+ equation index: 8
+ type: SIMPLE_ASSIGN
+ t1._t_dummy = 0.0
+ */
+void StategraphSample_eqFunction_8(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,8};
+  data->localData[0]->realVars[7] /* t1._t_dummy variable */ = 0.0;
+  TRACE_POP
+}
+
+/*
+ equation index: 9
+ type: SIMPLE_ASSIGN
+ t1._t_start = 0.0
+ */
+void StategraphSample_eqFunction_9(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,9};
+  data->localData[0]->realVars[8] /* t1._t_start variable */ = 0.0;
+  TRACE_POP
+}
+
+/*
+ equation index: 10
+ type: SIMPLE_ASSIGN
+ t1._condition = u > 0.5
+ */
+void StategraphSample_eqFunction_10(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,10};
+  modelica_boolean tmp0;
+  tmp0 = Greater(data->localData[0]->realVars[11] /* u variable */,0.5);
+  data->localData[0]->booleanVars[11] /* t1._condition DISCRETE */ = tmp0;
+  TRACE_POP
+}
+
+/*
+ equation index: 11
+ type: SIMPLE_ASSIGN
+ step1._active = false
+ */
+void StategraphSample_eqFunction_11(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,11};
+  data->localData[0]->booleanVars[7] /* step1._active DISCRETE */ = 0;
+  TRACE_POP
+}
+
+/*
+ equation index: 12
+ type: SIMPLE_ASSIGN
+ step1._localActive = step1.active
+ */
+void StategraphSample_eqFunction_12(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,12};
+  data->localData[0]->booleanVars[8] /* step1._localActive DISCRETE */ = data->localData[0]->booleanVars[7] /* step1._active DISCRETE */;
+  TRACE_POP
+}
+
+/*
+ equation index: 13
+ type: SIMPLE_ASSIGN
+ $PRE._step1._newActive = step1.localActive
+ */
+void StategraphSample_eqFunction_13(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,13};
+  data->simulationInfo->booleanVarsPre[9] /* step1._newActive DISCRETE */ = data->localData[0]->booleanVars[8] /* step1._localActive DISCRETE */;
+  TRACE_POP
+}
+
+/*
+ equation index: 14
+ type: SIMPLE_ASSIGN
+ $PRE._step1._localActive = $PRE.step1.newActive
+ */
+void StategraphSample_eqFunction_14(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,14};
+  data->simulationInfo->booleanVarsPre[8] /* step1._localActive DISCRETE */ = data->simulationInfo->booleanVarsPre[9] /* step1._newActive DISCRETE */;
+  TRACE_POP
+}
+
+/*
+ equation index: 15
+ type: SIMPLE_ASSIGN
+ $PRE._step1._oldActive = $PRE.step1.localActive
+ */
+void StategraphSample_eqFunction_15(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,15};
+  data->simulationInfo->booleanVarsPre[10] /* step1._oldActive DISCRETE */ = data->simulationInfo->booleanVarsPre[8] /* step1._localActive DISCRETE */;
+  TRACE_POP
+}
+
+/*
+ equation index: 16
+ type: SIMPLE_ASSIGN
+ step1._oldActive = $PRE.step1.oldActive
+ */
+void StategraphSample_eqFunction_16(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,16};
+  data->localData[0]->booleanVars[10] /* step1._oldActive DISCRETE */ = data->simulationInfo->booleanVarsPre[10] /* step1._oldActive DISCRETE */;
+  TRACE_POP
+}
+
+/*
+ equation index: 17
+ type: SIMPLE_ASSIGN
+ step1._outerStatePort._subgraphStatePort._activeSteps = if step1.localActive then 1.0 else 0.0
+ */
+void StategraphSample_eqFunction_17(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,17};
+  data->localData[0]->realVars[5] /* step1._outerStatePort._subgraphStatePort._activeSteps variable */ = (data->localData[0]->booleanVars[8] /* step1._localActive DISCRETE */?1.0:0.0);
+  TRACE_POP
+}
+
+/*
+ equation index: 18
+ type: SIMPLE_ASSIGN
+ $PRE._t2._t_start = time
+ */
+void StategraphSample_eqFunction_18(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,18};
+  data->simulationInfo->realVarsPre[13] /* t2._t_start DISCRETE */ = data->localData[0]->timeValue;
+  TRACE_POP
+}
+
+/*
+ equation index: 19
+ type: SIMPLE_ASSIGN
+ t2._t_start = $PRE.t2.t_start
+ */
+void StategraphSample_eqFunction_19(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,19};
+  data->localData[0]->realVars[13] /* t2._t_start DISCRETE */ = data->simulationInfo->realVarsPre[13] /* t2._t_start DISCRETE */;
+  TRACE_POP
+}
+
+/*
+ equation index: 20
+ type: SIMPLE_ASSIGN
+ t2._t_dummy = time - t2.t_start
+ */
+void StategraphSample_eqFunction_20(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,20};
+  data->localData[0]->realVars[10] /* t2._t_dummy variable */ = data->localData[0]->timeValue - data->localData[0]->realVars[13] /* t2._t_start DISCRETE */;
+  TRACE_POP
+}
+
+/*
+ equation index: 21
+ type: SIMPLE_ASSIGN
+ s1._active = true
+ */
+void StategraphSample_eqFunction_21(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,21};
+  data->localData[0]->booleanVars[1] /* s1._active DISCRETE */ = 1;
+  TRACE_POP
+}
+
+/*
+ equation index: 22
+ type: SIMPLE_ASSIGN
+ s1._localActive = s1.active
+ */
+void StategraphSample_eqFunction_22(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,22};
+  data->localData[0]->booleanVars[2] /* s1._localActive DISCRETE */ = data->localData[0]->booleanVars[1] /* s1._active DISCRETE */;
+  TRACE_POP
+}
+
+/*
+ equation index: 23
+ type: SIMPLE_ASSIGN
+ $PRE._s1._newActive = s1.localActive
+ */
+void StategraphSample_eqFunction_23(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,23};
+  data->simulationInfo->booleanVarsPre[3] /* s1._newActive DISCRETE */ = data->localData[0]->booleanVars[2] /* s1._localActive DISCRETE */;
+  TRACE_POP
+}
+
+/*
+ equation index: 24
+ type: SIMPLE_ASSIGN
+ $PRE._s1._localActive = $PRE.s1.newActive
+ */
+void StategraphSample_eqFunction_24(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,24};
+  data->simulationInfo->booleanVarsPre[2] /* s1._localActive DISCRETE */ = data->simulationInfo->booleanVarsPre[3] /* s1._newActive DISCRETE */;
+  TRACE_POP
+}
+
+/*
+ equation index: 25
+ type: SIMPLE_ASSIGN
+ $PRE._s1._oldActive = $PRE.s1.localActive
+ */
+void StategraphSample_eqFunction_25(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,25};
+  data->simulationInfo->booleanVarsPre[4] /* s1._oldActive DISCRETE */ = data->simulationInfo->booleanVarsPre[2] /* s1._localActive DISCRETE */;
+  TRACE_POP
+}
+
+/*
+ equation index: 26
+ type: SIMPLE_ASSIGN
+ s1._oldActive = $PRE.s1.oldActive
+ */
+void StategraphSample_eqFunction_26(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,26};
+  data->localData[0]->booleanVars[4] /* s1._oldActive DISCRETE */ = data->simulationInfo->booleanVarsPre[4] /* s1._oldActive DISCRETE */;
+  TRACE_POP
+}
+
+/*
+ equation index: 27
+ type: SIMPLE_ASSIGN
+ s1._outerStatePort._subgraphStatePort._activeSteps = if s1.localActive then 1.0 else 0.0
+ */
+void StategraphSample_eqFunction_27(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,27};
+  data->localData[0]->realVars[2] /* s1._outerStatePort._subgraphStatePort._activeSteps variable */ = (data->localData[0]->booleanVars[2] /* s1._localActive DISCRETE */?1.0:0.0);
+  TRACE_POP
+}
+
+/*
+ equation index: 28
+ type: SIMPLE_ASSIGN
+ stateGraphRoot._subgraphStatePort._activeSteps = (-s1.outerStatePort.subgraphStatePort.activeSteps) - step1.outerStatePort.subgraphStatePort.activeSteps
+ */
+void StategraphSample_eqFunction_28(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,28};
+  data->localData[0]->realVars[3] /* stateGraphRoot._subgraphStatePort._activeSteps variable */ = (-data->localData[0]->realVars[2] /* s1._outerStatePort._subgraphStatePort._activeSteps variable */) - data->localData[0]->realVars[5] /* step1._outerStatePort._subgraphStatePort._activeSteps variable */;
+  TRACE_POP
+}
+
+/*
+ equation index: 29
+ type: SIMPLE_ASSIGN
+ stateGraphRoot._activeSteps = -integer(stateGraphRoot.subgraphStatePort.activeSteps)
+ */
+void StategraphSample_eqFunction_29(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,29};
+  data->localData[0]->integerVars[0] /* stateGraphRoot._activeSteps DISCRETE */ = (-((modelica_integer)floor(data->localData[0]->realVars[3] /* stateGraphRoot._subgraphStatePort._activeSteps variable */)));
+  TRACE_POP
+}
+
+/*
+ equation index: 30
+ type: SIMPLE_ASSIGN
+ t1._enableFire = t1.condition and s1.localActive and not step1.localActive
+ */
+void StategraphSample_eqFunction_30(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,30};
+  data->localData[0]->booleanVars[12] /* t1._enableFire DISCRETE */ = ((data->localData[0]->booleanVars[11] /* t1._condition DISCRETE */ && data->localData[0]->booleanVars[2] /* s1._localActive DISCRETE */) && (!data->localData[0]->booleanVars[8] /* step1._localActive DISCRETE */));
+  TRACE_POP
+}
+
+/*
+ equation index: 31
+ type: SIMPLE_ASSIGN
+ t2._enableFire = step1.localActive and not s1.localActive
+ */
+void StategraphSample_eqFunction_31(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,31};
+  data->localData[0]->booleanVars[14] /* t2._enableFire DISCRETE */ = (data->localData[0]->booleanVars[8] /* step1._localActive DISCRETE */ && (!data->localData[0]->booleanVars[2] /* s1._localActive DISCRETE */));
+  TRACE_POP
+}
+
+/*
+ equation index: 32
+ type: SIMPLE_ASSIGN
+ $whenCondition1 = t2.enableFire
+ */
+void StategraphSample_eqFunction_32(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,32};
+  data->localData[0]->booleanVars[0] /* $whenCondition1 DISCRETE */ = data->localData[0]->booleanVars[14] /* t2._enableFire DISCRETE */;
+  TRACE_POP
+}
+
+/*
+ equation index: 33
+ type: SIMPLE_ASSIGN
+ t2._t = if t2.enableFire then t2.t_dummy else 0.0
+ */
+void StategraphSample_eqFunction_33(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,33};
+  data->localData[0]->realVars[9] /* t2._t variable */ = (data->localData[0]->booleanVars[14] /* t2._enableFire DISCRETE */?data->localData[0]->realVars[10] /* t2._t_dummy variable */:0.0);
+  TRACE_POP
+}
+
+/*
+ equation index: 34
+ type: SIMPLE_ASSIGN
+ t2._fire = t2.enableFire and time >= t2.t_start + t2.waitTime
+ */
+void StategraphSample_eqFunction_34(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,34};
+  modelica_boolean tmp1;
+  tmp1 = GreaterEq(data->localData[0]->timeValue,data->localData[0]->realVars[13] /* t2._t_start DISCRETE */ + data->simulationInfo->realParameter[1] /* t2._waitTime PARAM */);
+  data->localData[0]->booleanVars[15] /* t2._fire DISCRETE */ = (data->localData[0]->booleanVars[14] /* t2._enableFire DISCRETE */ && tmp1);
+  TRACE_POP
+}
+
+/*
+ equation index: 35
+ type: SIMPLE_ASSIGN
+ s1._newActive = Modelica.StateGraph.Temporary.anyTrue({t2.fire}) or s1.localActive and not Modelica.StateGraph.Temporary.anyTrue({t1.enableFire})
+ */
+void StategraphSample_eqFunction_35(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,35};
+  boolean_array tmp2;
+  boolean_array tmp3;
+  array_alloc_scalar_boolean_array(&tmp2, 1, (modelica_boolean)data->localData[0]->booleanVars[15] /* t2._fire DISCRETE */);
+  array_alloc_scalar_boolean_array(&tmp3, 1, (modelica_boolean)data->localData[0]->booleanVars[12] /* t1._enableFire DISCRETE */);
+  data->localData[0]->booleanVars[3] /* s1._newActive DISCRETE */ = (omc_Modelica_StateGraph_Temporary_anyTrue(threadData, tmp2) || (data->localData[0]->booleanVars[2] /* s1._localActive DISCRETE */ && (!omc_Modelica_StateGraph_Temporary_anyTrue(threadData, tmp3))));
+  TRACE_POP
+}
+
+/*
+ equation index: 36
+ type: SIMPLE_ASSIGN
+ step1._newActive = Modelica.StateGraph.Temporary.anyTrue({t1.enableFire}) or step1.localActive and not Modelica.StateGraph.Temporary.anyTrue({t2.fire})
+ */
+void StategraphSample_eqFunction_36(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,36};
+  boolean_array tmp4;
+  boolean_array tmp5;
+  array_alloc_scalar_boolean_array(&tmp4, 1, (modelica_boolean)data->localData[0]->booleanVars[12] /* t1._enableFire DISCRETE */);
+  array_alloc_scalar_boolean_array(&tmp5, 1, (modelica_boolean)data->localData[0]->booleanVars[15] /* t2._fire DISCRETE */);
+  data->localData[0]->booleanVars[9] /* step1._newActive DISCRETE */ = (omc_Modelica_StateGraph_Temporary_anyTrue(threadData, tmp4) || (data->localData[0]->booleanVars[8] /* step1._localActive DISCRETE */ && (!omc_Modelica_StateGraph_Temporary_anyTrue(threadData, tmp5))));
+  TRACE_POP
+}
+
+/*
+ equation index: 37
+ type: SIMPLE_ASSIGN
+ y = if s1.localActive then 0.0 else 1.0
+ */
+void StategraphSample_eqFunction_37(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,37};
+  data->localData[0]->realVars[12] /* y variable */ = (data->localData[0]->booleanVars[2] /* s1._localActive DISCRETE */?0.0:1.0);
+  TRACE_POP
+}
+
+/*
+ equation index: 38
+ type: SIMPLE_ASSIGN
+ $PRE._t2._enableFire = false
+ */
+void StategraphSample_eqFunction_38(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,38};
+  data->simulationInfo->booleanVarsPre[14] /* t2._enableFire DISCRETE */ = 0;
+  TRACE_POP
+}
+
+/*
+ equation index: 39
+ type: SIMPLE_ASSIGN
+ $PRE._t1._enableFire = false
+ */
+void StategraphSample_eqFunction_39(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,39};
+  data->simulationInfo->booleanVarsPre[12] /* t1._enableFire DISCRETE */ = 0;
+  TRACE_POP
+}
+void StategraphSample_functionInitialEquations_0(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  StategraphSample_eqFunction_1(data, threadData);
+  StategraphSample_eqFunction_2(data, threadData);
+  StategraphSample_eqFunction_3(data, threadData);
+  StategraphSample_eqFunction_4(data, threadData);
+  StategraphSample_eqFunction_5(data, threadData);
+  StategraphSample_eqFunction_6(data, threadData);
+  StategraphSample_eqFunction_7(data, threadData);
+  StategraphSample_eqFunction_8(data, threadData);
+  StategraphSample_eqFunction_9(data, threadData);
+  StategraphSample_eqFunction_10(data, threadData);
+  StategraphSample_eqFunction_11(data, threadData);
+  StategraphSample_eqFunction_12(data, threadData);
+  StategraphSample_eqFunction_13(data, threadData);
+  StategraphSample_eqFunction_14(data, threadData);
+  StategraphSample_eqFunction_15(data, threadData);
+  StategraphSample_eqFunction_16(data, threadData);
+  StategraphSample_eqFunction_17(data, threadData);
+  StategraphSample_eqFunction_18(data, threadData);
+  StategraphSample_eqFunction_19(data, threadData);
+  StategraphSample_eqFunction_20(data, threadData);
+  StategraphSample_eqFunction_21(data, threadData);
+  StategraphSample_eqFunction_22(data, threadData);
+  StategraphSample_eqFunction_23(data, threadData);
+  StategraphSample_eqFunction_24(data, threadData);
+  StategraphSample_eqFunction_25(data, threadData);
+  StategraphSample_eqFunction_26(data, threadData);
+  StategraphSample_eqFunction_27(data, threadData);
+  StategraphSample_eqFunction_28(data, threadData);
+  StategraphSample_eqFunction_29(data, threadData);
+  StategraphSample_eqFunction_30(data, threadData);
+  StategraphSample_eqFunction_31(data, threadData);
+  StategraphSample_eqFunction_32(data, threadData);
+  StategraphSample_eqFunction_33(data, threadData);
+  StategraphSample_eqFunction_34(data, threadData);
+  StategraphSample_eqFunction_35(data, threadData);
+  StategraphSample_eqFunction_36(data, threadData);
+  StategraphSample_eqFunction_37(data, threadData);
+  StategraphSample_eqFunction_38(data, threadData);
+  StategraphSample_eqFunction_39(data, threadData);
+  TRACE_POP
+}
+
+
+int StategraphSample_functionInitialEquations(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+
+  data->simulationInfo->discreteCall = 1;
+  StategraphSample_functionInitialEquations_0(data, threadData);
+  data->simulationInfo->discreteCall = 0;
+  
+  TRACE_POP
+  return 0;
+}
+
+
+int StategraphSample_functionInitialEquations_lambda0(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+
+  data->simulationInfo->discreteCall = 1;
+  data->simulationInfo->discreteCall = 0;
+  
+  TRACE_POP
+  return 0;
+}
+int StategraphSample_functionRemovedInitialEquations(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int *equationIndexes = NULL;
+  double res = 0.0;
+
+  
+  TRACE_POP
+  return 0;
+}
+
+
+#if defined(__cplusplus)
+}
+#endif
+

+ 19 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_07dly.c

@@ -0,0 +1,19 @@
+/* Delay */
+#include "StategraphSample_model.h"
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+int StategraphSample_function_storeDelayed(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+
+  
+  TRACE_POP
+  return 0;
+}
+
+#if defined(__cplusplus)
+}
+#endif
+

+ 344 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_08bnd.c

@@ -0,0 +1,344 @@
+/* update bound parameters and variable attributes (start, nominal, min, max) */
+#include "StategraphSample_model.h"
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+int StategraphSample_updateBoundVariableAttributes(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  /* min ******************************************************** */
+  
+  infoStreamPrint(LOG_INIT, 1, "updating min-values");
+  if (ACTIVE_STREAM(LOG_INIT)) messageClose(LOG_INIT);
+  
+  /* max ******************************************************** */
+  
+  infoStreamPrint(LOG_INIT, 1, "updating max-values");
+  if (ACTIVE_STREAM(LOG_INIT)) messageClose(LOG_INIT);
+  
+  /* nominal **************************************************** */
+  
+  infoStreamPrint(LOG_INIT, 1, "updating nominal-values");
+  if (ACTIVE_STREAM(LOG_INIT)) messageClose(LOG_INIT);
+  
+  /* start ****************************************************** */
+  
+  infoStreamPrint(LOG_INIT, 1, "updating start-values");
+  if (ACTIVE_STREAM(LOG_INIT)) messageClose(LOG_INIT);
+  
+  TRACE_POP
+  return 0;
+}
+
+
+/*
+ equation index: 61
+ type: SIMPLE_ASSIGN
+ s1._nIn = 1
+ */
+void StategraphSample_eqFunction_61(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,61};
+  data->simulationInfo->integerParameter[0] /* s1._nIn PARAM */ = ((modelica_integer) 1);
+  TRACE_POP
+}
+
+/*
+ equation index: 62
+ type: SIMPLE_ASSIGN
+ s1._nOut = 1
+ */
+void StategraphSample_eqFunction_62(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,62};
+  data->simulationInfo->integerParameter[1] /* s1._nOut PARAM */ = ((modelica_integer) 1);
+  TRACE_POP
+}
+
+/*
+ equation index: 63
+ type: SIMPLE_ASSIGN
+ t1._enableTimer = false
+ */
+void StategraphSample_eqFunction_63(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,63};
+  data->simulationInfo->booleanParameter[0] /* t1._enableTimer PARAM */ = 0;
+  TRACE_POP
+}
+
+/*
+ equation index: 64
+ type: SIMPLE_ASSIGN
+ t2._enableTimer = true
+ */
+void StategraphSample_eqFunction_64(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,64};
+  data->simulationInfo->booleanParameter[1] /* t2._enableTimer PARAM */ = 1;
+  TRACE_POP
+}
+
+/*
+ equation index: 65
+ type: SIMPLE_ASSIGN
+ step1._nIn = 1
+ */
+void StategraphSample_eqFunction_65(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,65};
+  data->simulationInfo->integerParameter[2] /* step1._nIn PARAM */ = ((modelica_integer) 1);
+  TRACE_POP
+}
+
+/*
+ equation index: 66
+ type: SIMPLE_ASSIGN
+ step1._nOut = 1
+ */
+void StategraphSample_eqFunction_66(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,66};
+  data->simulationInfo->integerParameter[3] /* step1._nOut PARAM */ = ((modelica_integer) 1);
+  TRACE_POP
+}
+
+/*
+ equation index: 67
+ type: ALGORITHM
+ 
+   assert(s1.nIn >= 0, "Variable violating min constraint: 0 <= s1.nIn, has value: " + String(s1.nIn, "d"));
+ */
+void StategraphSample_eqFunction_67(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,67};
+  modelica_boolean tmp0;
+  static const MMC_DEFSTRINGLIT(tmp1,59,"Variable violating min constraint: 0 <= s1.nIn, has value: ");
+  modelica_string tmp2;
+  static int tmp3 = 0;
+  modelica_metatype tmpMeta[1] __attribute__((unused)) = {0};
+  if(!tmp3)
+  {
+    tmp0 = GreaterEq((modelica_integer)data->simulationInfo->integerParameter[0] /* s1._nIn PARAM */,((modelica_integer) 0));
+    if(!tmp0)
+    {
+      tmp2 = modelica_integer_to_modelica_string_format((modelica_integer)data->simulationInfo->integerParameter[0] /* s1._nIn PARAM */, (modelica_string) mmc_strings_len1[100]);
+      tmpMeta[0] = stringAppend(MMC_REFSTRINGLIT(tmp1),tmp2);
+      {
+        FILE_INFO info = {"C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo",1973,5,1973,67,0};
+        omc_assert_warning(info, "The following assertion has been violated %sat time %f\ns1.nIn >= 0", initial() ? "during initialization " : "", data->localData[0]->timeValue);
+        omc_assert_warning_withEquationIndexes(info, equationIndexes, MMC_STRINGDATA(tmpMeta[0]));
+      }
+      tmp3 = 1;
+    }
+  }
+  TRACE_POP
+}
+
+/*
+ equation index: 68
+ type: ALGORITHM
+ 
+   assert(s1.nOut >= 0, "Variable violating min constraint: 0 <= s1.nOut, has value: " + String(s1.nOut, "d"));
+ */
+void StategraphSample_eqFunction_68(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,68};
+  modelica_boolean tmp4;
+  static const MMC_DEFSTRINGLIT(tmp5,60,"Variable violating min constraint: 0 <= s1.nOut, has value: ");
+  modelica_string tmp6;
+  static int tmp7 = 0;
+  modelica_metatype tmpMeta[1] __attribute__((unused)) = {0};
+  if(!tmp7)
+  {
+    tmp4 = GreaterEq((modelica_integer)data->simulationInfo->integerParameter[1] /* s1._nOut PARAM */,((modelica_integer) 0));
+    if(!tmp4)
+    {
+      tmp6 = modelica_integer_to_modelica_string_format((modelica_integer)data->simulationInfo->integerParameter[1] /* s1._nOut PARAM */, (modelica_string) mmc_strings_len1[100]);
+      tmpMeta[0] = stringAppend(MMC_REFSTRINGLIT(tmp5),tmp6);
+      {
+        FILE_INFO info = {"C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo",1974,5,1974,69,0};
+        omc_assert_warning(info, "The following assertion has been violated %sat time %f\ns1.nOut >= 0", initial() ? "during initialization " : "", data->localData[0]->timeValue);
+        omc_assert_warning_withEquationIndexes(info, equationIndexes, MMC_STRINGDATA(tmpMeta[0]));
+      }
+      tmp7 = 1;
+    }
+  }
+  TRACE_POP
+}
+
+/*
+ equation index: 69
+ type: ALGORITHM
+ 
+   assert(t1.waitTime >= 0.0, "Variable violating min constraint: 0.0 <= t1.waitTime, has value: " + String(t1.waitTime, "g"));
+ */
+void StategraphSample_eqFunction_69(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,69};
+  modelica_boolean tmp8;
+  static const MMC_DEFSTRINGLIT(tmp9,66,"Variable violating min constraint: 0.0 <= t1.waitTime, has value: ");
+  modelica_string tmp10;
+  static int tmp11 = 0;
+  modelica_metatype tmpMeta[1] __attribute__((unused)) = {0};
+  if(!tmp11)
+  {
+    tmp8 = GreaterEq(data->simulationInfo->realParameter[0] /* t1._waitTime PARAM */,0.0);
+    if(!tmp8)
+    {
+      tmp10 = modelica_real_to_modelica_string_format(data->simulationInfo->realParameter[0] /* t1._waitTime PARAM */, (modelica_string) mmc_strings_len1[103]);
+      tmpMeta[0] = stringAppend(MMC_REFSTRINGLIT(tmp9),tmp10);
+      {
+        FILE_INFO info = {"C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo",2066,5,2068,61,0};
+        omc_assert_warning(info, "The following assertion has been violated %sat time %f\nt1.waitTime >= 0.0", initial() ? "during initialization " : "", data->localData[0]->timeValue);
+        omc_assert_warning_withEquationIndexes(info, equationIndexes, MMC_STRINGDATA(tmpMeta[0]));
+      }
+      tmp11 = 1;
+    }
+  }
+  TRACE_POP
+}
+
+/*
+ equation index: 70
+ type: ALGORITHM
+ 
+   assert(t2.waitTime >= 0.0, "Variable violating min constraint: 0.0 <= t2.waitTime, has value: " + String(t2.waitTime, "g"));
+ */
+void StategraphSample_eqFunction_70(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,70};
+  modelica_boolean tmp12;
+  static const MMC_DEFSTRINGLIT(tmp13,66,"Variable violating min constraint: 0.0 <= t2.waitTime, has value: ");
+  modelica_string tmp14;
+  static int tmp15 = 0;
+  modelica_metatype tmpMeta[1] __attribute__((unused)) = {0};
+  if(!tmp15)
+  {
+    tmp12 = GreaterEq(data->simulationInfo->realParameter[1] /* t2._waitTime PARAM */,0.0);
+    if(!tmp12)
+    {
+      tmp14 = modelica_real_to_modelica_string_format(data->simulationInfo->realParameter[1] /* t2._waitTime PARAM */, (modelica_string) mmc_strings_len1[103]);
+      tmpMeta[0] = stringAppend(MMC_REFSTRINGLIT(tmp13),tmp14);
+      {
+        FILE_INFO info = {"C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo",2066,5,2068,61,0};
+        omc_assert_warning(info, "The following assertion has been violated %sat time %f\nt2.waitTime >= 0.0", initial() ? "during initialization " : "", data->localData[0]->timeValue);
+        omc_assert_warning_withEquationIndexes(info, equationIndexes, MMC_STRINGDATA(tmpMeta[0]));
+      }
+      tmp15 = 1;
+    }
+  }
+  TRACE_POP
+}
+
+/*
+ equation index: 71
+ type: ALGORITHM
+ 
+   assert(step1.nIn >= 0, "Variable violating min constraint: 0 <= step1.nIn, has value: " + String(step1.nIn, "d"));
+ */
+void StategraphSample_eqFunction_71(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,71};
+  modelica_boolean tmp16;
+  static const MMC_DEFSTRINGLIT(tmp17,62,"Variable violating min constraint: 0 <= step1.nIn, has value: ");
+  modelica_string tmp18;
+  static int tmp19 = 0;
+  modelica_metatype tmpMeta[1] __attribute__((unused)) = {0};
+  if(!tmp19)
+  {
+    tmp16 = GreaterEq((modelica_integer)data->simulationInfo->integerParameter[2] /* step1._nIn PARAM */,((modelica_integer) 0));
+    if(!tmp16)
+    {
+      tmp18 = modelica_integer_to_modelica_string_format((modelica_integer)data->simulationInfo->integerParameter[2] /* step1._nIn PARAM */, (modelica_string) mmc_strings_len1[100]);
+      tmpMeta[0] = stringAppend(MMC_REFSTRINGLIT(tmp17),tmp18);
+      {
+        FILE_INFO info = {"C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo",1973,5,1973,67,0};
+        omc_assert_warning(info, "The following assertion has been violated %sat time %f\nstep1.nIn >= 0", initial() ? "during initialization " : "", data->localData[0]->timeValue);
+        omc_assert_warning_withEquationIndexes(info, equationIndexes, MMC_STRINGDATA(tmpMeta[0]));
+      }
+      tmp19 = 1;
+    }
+  }
+  TRACE_POP
+}
+
+/*
+ equation index: 72
+ type: ALGORITHM
+ 
+   assert(step1.nOut >= 0, "Variable violating min constraint: 0 <= step1.nOut, has value: " + String(step1.nOut, "d"));
+ */
+void StategraphSample_eqFunction_72(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  const int equationIndexes[2] = {1,72};
+  modelica_boolean tmp20;
+  static const MMC_DEFSTRINGLIT(tmp21,63,"Variable violating min constraint: 0 <= step1.nOut, has value: ");
+  modelica_string tmp22;
+  static int tmp23 = 0;
+  modelica_metatype tmpMeta[1] __attribute__((unused)) = {0};
+  if(!tmp23)
+  {
+    tmp20 = GreaterEq((modelica_integer)data->simulationInfo->integerParameter[3] /* step1._nOut PARAM */,((modelica_integer) 0));
+    if(!tmp20)
+    {
+      tmp22 = modelica_integer_to_modelica_string_format((modelica_integer)data->simulationInfo->integerParameter[3] /* step1._nOut PARAM */, (modelica_string) mmc_strings_len1[100]);
+      tmpMeta[0] = stringAppend(MMC_REFSTRINGLIT(tmp21),tmp22);
+      {
+        FILE_INFO info = {"C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo",1974,5,1974,69,0};
+        omc_assert_warning(info, "The following assertion has been violated %sat time %f\nstep1.nOut >= 0", initial() ? "during initialization " : "", data->localData[0]->timeValue);
+        omc_assert_warning_withEquationIndexes(info, equationIndexes, MMC_STRINGDATA(tmpMeta[0]));
+      }
+      tmp23 = 1;
+    }
+  }
+  TRACE_POP
+}
+int StategraphSample_updateBoundParameters(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  StategraphSample_eqFunction_61(data, threadData);
+
+  StategraphSample_eqFunction_62(data, threadData);
+
+  StategraphSample_eqFunction_63(data, threadData);
+
+  StategraphSample_eqFunction_64(data, threadData);
+
+  StategraphSample_eqFunction_65(data, threadData);
+
+  StategraphSample_eqFunction_66(data, threadData);
+
+  StategraphSample_eqFunction_67(data, threadData);
+
+  StategraphSample_eqFunction_68(data, threadData);
+
+  StategraphSample_eqFunction_69(data, threadData);
+
+  StategraphSample_eqFunction_70(data, threadData);
+
+  StategraphSample_eqFunction_71(data, threadData);
+
+  StategraphSample_eqFunction_72(data, threadData);
+  
+  TRACE_POP
+  return 0;
+}
+
+#if defined(__cplusplus)
+}
+#endif
+

+ 84 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_09alg.c

@@ -0,0 +1,84 @@
+/* Algebraic */
+#include "StategraphSample_model.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* forwarded equations */
+extern void StategraphSample_eqFunction_40(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_41(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_43(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_44(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_45(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_46(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_47(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_48(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_49(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_50(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_52(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_53(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_54(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_55(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_56(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_57(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_58(DATA* data, threadData_t *threadData);
+extern void StategraphSample_eqFunction_60(DATA* data, threadData_t *threadData);
+
+static void functionAlg_system0(DATA *data, threadData_t *threadData)
+{
+  StategraphSample_eqFunction_40(data, threadData);
+
+  StategraphSample_eqFunction_41(data, threadData);
+
+  StategraphSample_eqFunction_43(data, threadData);
+
+  StategraphSample_eqFunction_44(data, threadData);
+
+  StategraphSample_eqFunction_45(data, threadData);
+
+  StategraphSample_eqFunction_46(data, threadData);
+
+  StategraphSample_eqFunction_47(data, threadData);
+
+  StategraphSample_eqFunction_48(data, threadData);
+
+  StategraphSample_eqFunction_49(data, threadData);
+
+  StategraphSample_eqFunction_50(data, threadData);
+
+  StategraphSample_eqFunction_52(data, threadData);
+
+  StategraphSample_eqFunction_53(data, threadData);
+
+  StategraphSample_eqFunction_54(data, threadData);
+
+  StategraphSample_eqFunction_55(data, threadData);
+
+  StategraphSample_eqFunction_56(data, threadData);
+
+  StategraphSample_eqFunction_57(data, threadData);
+
+  StategraphSample_eqFunction_58(data, threadData);
+
+  StategraphSample_eqFunction_60(data, threadData);
+}
+/* for continuous time variables */
+int StategraphSample_functionAlgebraics(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  
+  data->simulationInfo->callStatistics.functionAlgebraics++;
+  
+  functionAlg_system0(data, threadData);
+
+  StategraphSample_function_savePreSynchronous(data, threadData);
+  
+  TRACE_POP
+  return 0;
+}
+
+#ifdef __cplusplus
+}
+#endif

+ 20 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_10asr.c

@@ -0,0 +1,20 @@
+/* Asserts */
+#include "StategraphSample_model.h"
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* function to check assert after a step is done */
+int StategraphSample_checkForAsserts(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+
+  
+  TRACE_POP
+  return 0;
+}
+
+#if defined(__cplusplus)
+}
+#endif
+

+ 10 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_11mix.c

@@ -0,0 +1,10 @@
+/* Mixed Systems */
+#include "StategraphSample_model.h"
+#include "StategraphSample_11mix.h"
+/* initial mixed systems */
+/* initial_lambda0 mixed systems */
+/* parameter mixed systems */
+/* model mixed systems */
+/* jacobians mixed systems */
+
+

+ 0 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_11mix.h


+ 89 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_12jac.c

@@ -0,0 +1,89 @@
+/* Jacobians */
+#include "StategraphSample_model.h"
+#include "StategraphSample_12jac.h"
+
+int StategraphSample_initialAnalyticJacobianD(void* inData, threadData_t *threadData)
+{
+  TRACE_PUSH
+  DATA* data = ((DATA*)inData);
+  int index = StategraphSample_INDEX_JAC_D;
+  const int colPtrIndex[1+1] = {0,0};
+  const int rowIndex[0] = {};
+  int i = 0;
+  
+  data->simulationInfo->analyticJacobians[index].sizeCols = 1;
+  data->simulationInfo->analyticJacobians[index].sizeRows = 1;
+  data->simulationInfo->analyticJacobians[index].sizeTmpVars = 0;
+  data->simulationInfo->analyticJacobians[index].seedVars = (modelica_real*) calloc(1,sizeof(modelica_real));
+  data->simulationInfo->analyticJacobians[index].resultVars = (modelica_real*) calloc(1,sizeof(modelica_real));
+  data->simulationInfo->analyticJacobians[index].tmpVars = (modelica_real*) calloc(0,sizeof(modelica_real));
+  data->simulationInfo->analyticJacobians[index].sparsePattern.leadindex = (unsigned int*) malloc((1+1)*sizeof(int));
+  data->simulationInfo->analyticJacobians[index].sparsePattern.index = (unsigned int*) malloc(0*sizeof(int));
+  data->simulationInfo->analyticJacobians[index].sparsePattern.numberOfNoneZeros = 0;
+  data->simulationInfo->analyticJacobians[index].sparsePattern.colorCols = (unsigned int*) malloc(1*sizeof(int));
+  data->simulationInfo->analyticJacobians[index].sparsePattern.maxColors = 1;
+  data->simulationInfo->analyticJacobians[index].jacobian = NULL;
+  
+  /* write lead index of compressed sparse column */
+  memcpy(data->simulationInfo->analyticJacobians[index].sparsePattern.leadindex, colPtrIndex, (1+1)*sizeof(int));
+  
+  for(i=2;i<1+1;++i)
+    data->simulationInfo->analyticJacobians[index].sparsePattern.leadindex[i] += data->simulationInfo->analyticJacobians[index].sparsePattern.leadindex[i-1];
+  
+  /* call sparse index */
+  memcpy(data->simulationInfo->analyticJacobians[index].sparsePattern.index, rowIndex, 0*sizeof(int));
+  
+  /* write color array */
+  data->simulationInfo->analyticJacobians[index].sparsePattern.colorCols[0] = 1;
+  TRACE_POP
+  return 0;
+}
+int StategraphSample_initialAnalyticJacobianC(void* inData, threadData_t *threadData)
+{
+  TRACE_PUSH
+  TRACE_POP
+  return 1;
+}
+int StategraphSample_initialAnalyticJacobianB(void* inData, threadData_t *threadData)
+{
+  TRACE_PUSH
+  TRACE_POP
+  return 1;
+}
+int StategraphSample_initialAnalyticJacobianA(void* inData, threadData_t *threadData)
+{
+  TRACE_PUSH
+  TRACE_POP
+  return 1;
+}
+
+int StategraphSample_functionJacD_column(void* inData, threadData_t *threadData)
+{
+  TRACE_PUSH
+
+  DATA* data = ((DATA*)inData);
+  int index = StategraphSample_INDEX_JAC_D;
+  
+  TRACE_POP
+  return 0;
+}
+int StategraphSample_functionJacC_column(void* data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  TRACE_POP
+  return 0;
+}
+int StategraphSample_functionJacB_column(void* data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  TRACE_POP
+  return 0;
+}
+int StategraphSample_functionJacA_column(void* data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  TRACE_POP
+  return 0;
+}
+
+

+ 49 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_12jac.h

@@ -0,0 +1,49 @@
+/* Jacobians */
+static const REAL_ATTRIBUTE dummyREAL_ATTRIBUTE = omc_dummyRealAttribute;
+/* Jacobian Variables */
+#if defined(__cplusplus)
+extern "C" {
+#endif
+  #define StategraphSample_INDEX_JAC_D 3
+  int StategraphSample_functionJacD_column(void* data, threadData_t *threadData);
+  int StategraphSample_initialAnalyticJacobianD(void* data, threadData_t *threadData);
+#if defined(__cplusplus)
+}
+#endif
+/* D */
+#define $PuSeedD data->simulationInfo->analyticJacobians[3].seedVars[0]
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+  #define StategraphSample_INDEX_JAC_C 2
+  int StategraphSample_functionJacC_column(void* data, threadData_t *threadData);
+  int StategraphSample_initialAnalyticJacobianC(void* data, threadData_t *threadData);
+#if defined(__cplusplus)
+}
+#endif
+/* C */
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+  #define StategraphSample_INDEX_JAC_B 1
+  int StategraphSample_functionJacB_column(void* data, threadData_t *threadData);
+  int StategraphSample_initialAnalyticJacobianB(void* data, threadData_t *threadData);
+#if defined(__cplusplus)
+}
+#endif
+/* B */
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+  #define StategraphSample_INDEX_JAC_A 0
+  int StategraphSample_functionJacA_column(void* data, threadData_t *threadData);
+  int StategraphSample_initialAnalyticJacobianA(void* data, threadData_t *threadData);
+#if defined(__cplusplus)
+}
+#endif
+/* A */
+
+

+ 14 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_13opt.c

@@ -0,0 +1,14 @@
+/* Optimization */
+#include "StategraphSample_model.h"
+#include "StategraphSample_12jac.h"
+#if defined(__cplusplus)
+extern "C" {
+#endif
+int StategraphSample_mayer(DATA* data, modelica_real** res,short *i){return -1;}
+int StategraphSample_lagrange(DATA* data, modelica_real** res, short * i1, short*i2){return -1;}
+int StategraphSample_pickUpBoundsForInputsInOptimization(DATA* data, modelica_real* min, modelica_real* max, modelica_real*nominal, modelica_boolean *useNominal, char ** name, modelica_real * start, modelica_real * startTimeOpt){return -1;}
+int StategraphSample_setInputData(DATA *data, const modelica_boolean file){return -1;}
+int StategraphSample_getTimeGrid(DATA *data, modelica_integer * nsi, modelica_real**t){return -1;}
+#if defined(__cplusplus)
+}
+#endif

+ 11 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_13opt.h

@@ -0,0 +1,11 @@
+#if defined(__cplusplus)
+  extern "C" {
+#endif
+  int StategraphSample_mayer(DATA* data, modelica_real** res, short*);
+  int StategraphSample_lagrange(DATA* data, modelica_real** res, short *, short *);
+  int StategraphSample_pickUpBoundsForInputsInOptimization(DATA* data, modelica_real* min, modelica_real* max, modelica_real*nominal, modelica_boolean *useNominal, char ** name, modelica_real * start, modelica_real * startTimeOpt);
+  int StategraphSample_setInputData(DATA *data, const modelica_boolean file);
+  int StategraphSample_getTimeGrid(DATA *data, modelica_integer * nsi, modelica_real**t);
+#if defined(__cplusplus)
+}
+#endif

File diff suppressed because it is too large
+ 44 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_14lnz.c


+ 59 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_15syn.c

@@ -0,0 +1,59 @@
+/* Synchronous systems */
+#include "StategraphSample_model.h"
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Initializes the clocks of model. */
+void StategraphSample_function_initSynchronous(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+  long i=0, j=0;
+  TRACE_POP
+}
+
+/* Update the base clock. */
+void StategraphSample_function_updateSynchronous(DATA *data, threadData_t *threadData, long i)
+{
+  TRACE_PUSH
+  modelica_boolean ret;
+  switch (i) {
+    default:
+      throwStreamPrint(NULL, "Internal Error: unknown base partition %ld", i);
+      break;
+  }
+  TRACE_POP
+}
+
+
+
+/*Clocked systems equations */
+int StategraphSample_function_equationsSynchronous(DATA *data, threadData_t *threadData, long i)
+{
+  TRACE_PUSH
+  int ret;
+
+  switch (i) {
+    default:
+      throwStreamPrint(NULL, "Internal Error: unknown sub partition %ld", i);
+      ret = 1;
+      break;
+  }
+
+  TRACE_POP
+  return ret;
+}
+
+/* pre(%v%) = %v% */
+void StategraphSample_function_savePreSynchronous(DATA *data, threadData_t *threadData)
+{
+  TRACE_PUSH
+
+  
+  TRACE_POP
+}
+
+#if defined(__cplusplus)
+}
+#endif
+

+ 9 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_16dae.c

@@ -0,0 +1,9 @@
+/* DAE residuals is empty */
+ #include "StategraphSample_model.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+int StategraphSample_initializeDAEmodeData(DATA *inData, DAEMODE_DATA* daeModeData){ return -1; }
+#ifdef __cplusplus
+}
+#endif

+ 428 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_FMU.c

@@ -0,0 +1,428 @@
+
+// define class name and unique id
+#define MODEL_IDENTIFIER StategraphSample
+#define MODEL_GUID "{1bbd4064-0ef0-405e-a6e3-a61a868199f5}"
+
+// include fmu header files, typedefs and macros
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include "openmodelica.h"
+#include "openmodelica_func.h"
+#include "simulation_data.h"
+#include "util/omc_error.h"
+#include "StategraphSample_functions.h"
+#include "simulation/solver/initialization/initialization.h"
+#include "simulation/solver/events.h"
+#include "fmu2_model_interface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void setStartValues(ModelInstance *comp);
+void setDefaultStartValues(ModelInstance *comp);
+void eventUpdate(ModelInstance* comp, fmi2EventInfo* eventInfo);
+fmi2Real getReal(ModelInstance* comp, const fmi2ValueReference vr);
+fmi2Status setReal(ModelInstance* comp, const fmi2ValueReference vr, const fmi2Real value);
+fmi2Integer getInteger(ModelInstance* comp, const fmi2ValueReference vr);
+fmi2Status setInteger(ModelInstance* comp, const fmi2ValueReference vr, const fmi2Integer value);
+fmi2Boolean getBoolean(ModelInstance* comp, const fmi2ValueReference vr);
+fmi2Status setBoolean(ModelInstance* comp, const fmi2ValueReference vr, const fmi2Boolean value);
+fmi2String getString(ModelInstance* comp, const fmi2ValueReference vr);
+fmi2Status setString(ModelInstance* comp, const fmi2ValueReference vr, fmi2String value);
+fmi2Status setExternalFunction(ModelInstance* c, const fmi2ValueReference vr, const void* value);
+
+// define model size
+#define NUMBER_OF_STATES 0
+#define NUMBER_OF_EVENT_INDICATORS 3
+#define NUMBER_OF_REALS 21
+#define NUMBER_OF_INTEGERS 5
+#define NUMBER_OF_STRINGS 0
+#define NUMBER_OF_BOOLEANS 44
+#define NUMBER_OF_EXTERNALFUNCTIONS 0
+
+// define variable data for model
+#define $PrealExpression1$Py_vr 0 // "Value of Real output"
+#define $PrealExpression2$Py_vr 1 // "Value of Real output"
+#define $Ps1$PouterStatePort$PsubgraphStatePort$PactiveSteps_vr 2 // "Number of active steps in the CompositeStep"
+#define $PstateGraphRoot$PsubgraphStatePort$PactiveSteps_vr 3 // "Number of active steps in the CompositeStep"
+#define $PstateGraphRoot$PsubgraphStatePort$PactiveStepsDummy_vr 4 // "Dummy variable in order that connector fulfills restriction of connector"
+#define $Pstep1$PouterStatePort$PsubgraphStatePort$PactiveSteps_vr 5 // "Number of active steps in the CompositeStep"
+#define $Pt1$Pt_vr 6 // "= actual waiting time (transition will fire when t > waitTime)"
+#define $Pt1$Pt_dummy_vr 7 
+#define $Pt1$Pt_start_vr 8 // "Time instant at which the transition would fire, if waitTime would be zero"
+#define $Pt2$Pt_vr 9 // "= actual waiting time (transition will fire when t > waitTime)"
+#define $Pt2$Pt_dummy_vr 10 
+#define $Pu_vr 11 
+#define $Py_vr 12 
+#define $Pt2$Pt_start_vr 13 // "Time instant at which the transition would fire, if waitTime would be zero"
+#define $Pt1$PwaitTime_vr 14 // "Wait time before transition fires"
+#define $Pt2$PwaitTime_vr 15 // "Wait time before transition fires"
+#define $Ps1$PouterStatePort$PsubgraphStatePort$PactiveStepsDummy_vr 16 // "Dummy variable in order that connector fulfills restriction of connector"
+#define $Pstep1$PouterStatePort$PsubgraphStatePort$PactiveStepsDummy_vr 17 // "Dummy variable in order that connector fulfills restriction of connector"
+#define $Pswitch1$Pu1_vr 18 // "Connector of first Real input signal"
+#define $Pswitch1$Pu3_vr 19 // "Connector of second Real input signal"
+#define $Pswitch1$Py_vr 20 // "Connector of Real output signal"
+#define $PstateGraphRoot$PactiveSteps_vr 0 // "Number of active steps within the stategraph"
+#define $Ps1$PnIn_vr 1 // "Number of input connections"
+#define $Ps1$PnOut_vr 2 // "Number of output connections"
+#define $Pstep1$PnIn_vr 3 // "Number of input connections"
+#define $Pstep1$PnOut_vr 4 // "Number of output connections"
+#define $P$whenCondition1_vr 0 
+#define $Ps1$Pactive_vr 1 
+#define $Ps1$PlocalActive_vr 2 // "= true if step is active, otherwise the step is not active"
+#define $Ps1$PnewActive_vr 3 // "Value of active in the next iteration"
+#define $Ps1$PoldActive_vr 4 // "Value of active when CompositeStep was aborted"
+#define $PstateGraphRoot$Presume_vr 5 
+#define $PstateGraphRoot$Psuspend_vr 6 
+#define $Pstep1$Pactive_vr 7 // "= true if step is active, otherwise the step is not active"
+#define $Pstep1$PlocalActive_vr 8 // "= true if step is active, otherwise the step is not active"
+#define $Pstep1$PnewActive_vr 9 // "Value of active in the next iteration"
+#define $Pstep1$PoldActive_vr 10 // "Value of active when CompositeStep was aborted"
+#define $Pt1$Pcondition_vr 11 // "= true, if transition may fire (time varying expression)"
+#define $Pt1$PenableFire_vr 12 // "= true, if all firing conditions are true"
+#define $Pt2$Pcondition_vr 13 // "= true, if transition may fire (time varying expression)"
+#define $Pt2$PenableFire_vr 14 // "= true, if all firing conditions are true"
+#define $Pt2$Pfire_vr 15 // "= true, if transition fires"
+#define $Pt1$PenableTimer_vr 16 // "= true, if timer is enabled"
+#define $Pt2$PenableTimer_vr 17 // "= true, if timer is enabled"
+#define $Ps1$PinPort$lB1$rB$Poccupied_vr 18 // "true, if step is active"
+#define $Ps1$PinPort$lB1$rB$Pset_vr 19 // "true, if transition fires and step is activated"
+#define $Ps1$PoutPort$lB1$rB$Pavailable_vr 20 // "true, if step is active"
+#define $Ps1$PoutPort$lB1$rB$Preset_vr 21 // "true, if transition fires and step is deactivated"
+#define $Ps1$PouterStatePort$PsubgraphStatePort$Presume_vr 22 // "= true, if resume transition of CompositeStep fires"
+#define $Ps1$PouterStatePort$PsubgraphStatePort$Psuspend_vr 23 // "= true, if suspend transition of CompositeStep fires"
+#define $PstateGraphRoot$PsubgraphStatePort$Presume_vr 24 // "= true, if resume transition of CompositeStep fires"
+#define $PstateGraphRoot$PsubgraphStatePort$Psuspend_vr 25 // "= true, if suspend transition of CompositeStep fires"
+#define $Pstep1$PinPort$lB1$rB$Poccupied_vr 26 // "true, if step is active"
+#define $Pstep1$PinPort$lB1$rB$Pset_vr 27 // "true, if transition fires and step is activated"
+#define $Pstep1$PoutPort$lB1$rB$Pavailable_vr 28 // "true, if step is active"
+#define $Pstep1$PoutPort$lB1$rB$Preset_vr 29 // "true, if transition fires and step is deactivated"
+#define $Pstep1$PouterStatePort$PsubgraphStatePort$Presume_vr 30 // "= true, if resume transition of CompositeStep fires"
+#define $Pstep1$PouterStatePort$PsubgraphStatePort$Psuspend_vr 31 // "= true, if suspend transition of CompositeStep fires"
+#define $Pswitch1$Pu2_vr 32 // "Connector of Boolean input signal"
+#define $Pt1$Pfire_vr 33 // "= true, if transition fires"
+#define $Pt1$PinPort$Pavailable_vr 34 // "true, if step connected to the transition input is active"
+#define $Pt1$PinPort$Preset_vr 35 // "true, if transition fires and the step connected to the transition input is deactivated"
+#define $Pt1$PlocalCondition_vr 36 // "= true, if transition may fire"
+#define $Pt1$PoutPort$Poccupied_vr 37 // "true, if step connected to the transition output is active"
+#define $Pt1$PoutPort$Pset_vr 38 // "true, if transition fires and step connected to the transition output becomes active"
+#define $Pt2$PinPort$Pavailable_vr 39 // "true, if step connected to the transition input is active"
+#define $Pt2$PinPort$Preset_vr 40 // "true, if transition fires and the step connected to the transition input is deactivated"
+#define $Pt2$PlocalCondition_vr 41 // "= true, if transition may fire"
+#define $Pt2$PoutPort$Poccupied_vr 42 // "true, if step connected to the transition output is active"
+#define $Pt2$PoutPort$Pset_vr 43 // "true, if transition fires and step connected to the transition output becomes active"
+
+
+// define initial state vector as vector of value references
+#define STATES {  }
+#define STATESDERIVATIVES {  }
+
+
+// implementation of the Model Exchange functions
+  extern void StategraphSample_setupDataStruc(DATA *data);
+  #define fmu2_model_interface_setupDataStruc StategraphSample_setupDataStruc
+  #include "fmu2_model_interface.c"
+
+// Set values for all variables that define a start value
+void setDefaultStartValues(ModelInstance *comp) {
+
+comp->fmuData->modelData->realVarsData[0].attribute.start = 0;
+comp->fmuData->modelData->realVarsData[1].attribute.start = 0;
+comp->fmuData->modelData->realVarsData[2].attribute.start = 0;
+comp->fmuData->modelData->realVarsData[3].attribute.start = 0;
+comp->fmuData->modelData->realVarsData[4].attribute.start = 0;
+comp->fmuData->modelData->realVarsData[5].attribute.start = 0;
+comp->fmuData->modelData->realVarsData[6].attribute.start = 0;
+comp->fmuData->modelData->realVarsData[7].attribute.start = 0;
+comp->fmuData->modelData->realVarsData[8].attribute.start = 0;
+comp->fmuData->modelData->realVarsData[9].attribute.start = 0;
+comp->fmuData->modelData->realVarsData[10].attribute.start = 0;
+comp->fmuData->modelData->realVarsData[11].attribute.start = 0;
+comp->fmuData->modelData->realVarsData[12].attribute.start = 0;
+comp->fmuData->modelData->realVarsData[13].attribute.start = 0;
+comp->fmuData->modelData->integerVarsData[0].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[0].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[1].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[2].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[3].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[4].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[5].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[6].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[7].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[8].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[9].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[10].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[11].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[12].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[13].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[14].attribute.start = 0;
+comp->fmuData->modelData->booleanVarsData[15].attribute.start = 0;
+comp->fmuData->modelData->realParameterData[0].attribute.start = 0.0;
+comp->fmuData->modelData->realParameterData[1].attribute.start = 1.0;
+comp->fmuData->modelData->integerParameterData[0].attribute.start = 1;
+comp->fmuData->modelData->integerParameterData[1].attribute.start = 1;
+comp->fmuData->modelData->integerParameterData[2].attribute.start = 1;
+comp->fmuData->modelData->integerParameterData[3].attribute.start = 1;
+comp->fmuData->modelData->booleanParameterData[0].attribute.start = 0;
+comp->fmuData->modelData->booleanParameterData[1].attribute.start = 1;
+}
+// Set values for all variables that define a start value
+void setStartValues(ModelInstance *comp) {
+
+  comp->fmuData->modelData->realVarsData[0].attribute.start =  comp->fmuData->localData[0]->realVars[0];
+  comp->fmuData->modelData->realVarsData[1].attribute.start =  comp->fmuData->localData[0]->realVars[1];
+  comp->fmuData->modelData->realVarsData[2].attribute.start =  comp->fmuData->localData[0]->realVars[2];
+  comp->fmuData->modelData->realVarsData[3].attribute.start =  comp->fmuData->localData[0]->realVars[3];
+  comp->fmuData->modelData->realVarsData[4].attribute.start =  comp->fmuData->localData[0]->realVars[4];
+  comp->fmuData->modelData->realVarsData[5].attribute.start =  comp->fmuData->localData[0]->realVars[5];
+  comp->fmuData->modelData->realVarsData[6].attribute.start =  comp->fmuData->localData[0]->realVars[6];
+  comp->fmuData->modelData->realVarsData[7].attribute.start =  comp->fmuData->localData[0]->realVars[7];
+  comp->fmuData->modelData->realVarsData[8].attribute.start =  comp->fmuData->localData[0]->realVars[8];
+  comp->fmuData->modelData->realVarsData[9].attribute.start =  comp->fmuData->localData[0]->realVars[9];
+  comp->fmuData->modelData->realVarsData[10].attribute.start =  comp->fmuData->localData[0]->realVars[10];
+  comp->fmuData->modelData->realVarsData[11].attribute.start =  comp->fmuData->localData[0]->realVars[11];
+  comp->fmuData->modelData->realVarsData[12].attribute.start =  comp->fmuData->localData[0]->realVars[12];
+  comp->fmuData->modelData->realVarsData[13].attribute.start =  comp->fmuData->localData[0]->realVars[13];
+  comp->fmuData->modelData->integerVarsData[0].attribute.start =  comp->fmuData->localData[0]->integerVars[0];
+  comp->fmuData->modelData->booleanVarsData[0].attribute.start =  comp->fmuData->localData[0]->booleanVars[0];
+  comp->fmuData->modelData->booleanVarsData[1].attribute.start =  comp->fmuData->localData[0]->booleanVars[1];
+  comp->fmuData->modelData->booleanVarsData[2].attribute.start =  comp->fmuData->localData[0]->booleanVars[2];
+  comp->fmuData->modelData->booleanVarsData[3].attribute.start =  comp->fmuData->localData[0]->booleanVars[3];
+  comp->fmuData->modelData->booleanVarsData[4].attribute.start =  comp->fmuData->localData[0]->booleanVars[4];
+  comp->fmuData->modelData->booleanVarsData[5].attribute.start =  comp->fmuData->localData[0]->booleanVars[5];
+  comp->fmuData->modelData->booleanVarsData[6].attribute.start =  comp->fmuData->localData[0]->booleanVars[6];
+  comp->fmuData->modelData->booleanVarsData[7].attribute.start =  comp->fmuData->localData[0]->booleanVars[7];
+  comp->fmuData->modelData->booleanVarsData[8].attribute.start =  comp->fmuData->localData[0]->booleanVars[8];
+  comp->fmuData->modelData->booleanVarsData[9].attribute.start =  comp->fmuData->localData[0]->booleanVars[9];
+  comp->fmuData->modelData->booleanVarsData[10].attribute.start =  comp->fmuData->localData[0]->booleanVars[10];
+  comp->fmuData->modelData->booleanVarsData[11].attribute.start =  comp->fmuData->localData[0]->booleanVars[11];
+  comp->fmuData->modelData->booleanVarsData[12].attribute.start =  comp->fmuData->localData[0]->booleanVars[12];
+  comp->fmuData->modelData->booleanVarsData[13].attribute.start =  comp->fmuData->localData[0]->booleanVars[13];
+  comp->fmuData->modelData->booleanVarsData[14].attribute.start =  comp->fmuData->localData[0]->booleanVars[14];
+  comp->fmuData->modelData->booleanVarsData[15].attribute.start =  comp->fmuData->localData[0]->booleanVars[15];
+comp->fmuData->modelData->realParameterData[0].attribute.start = comp->fmuData->simulationInfo->realParameter[0];
+comp->fmuData->modelData->realParameterData[1].attribute.start = comp->fmuData->simulationInfo->realParameter[1];
+comp->fmuData->modelData->integerParameterData[0].attribute.start = comp->fmuData->simulationInfo->integerParameter[0];
+comp->fmuData->modelData->integerParameterData[1].attribute.start = comp->fmuData->simulationInfo->integerParameter[1];
+comp->fmuData->modelData->integerParameterData[2].attribute.start = comp->fmuData->simulationInfo->integerParameter[2];
+comp->fmuData->modelData->integerParameterData[3].attribute.start = comp->fmuData->simulationInfo->integerParameter[3];
+comp->fmuData->modelData->booleanParameterData[0].attribute.start = comp->fmuData->simulationInfo->booleanParameter[0];
+comp->fmuData->modelData->booleanParameterData[1].attribute.start = comp->fmuData->simulationInfo->booleanParameter[1];
+}
+  // Used to set the next time event, if any.
+  void eventUpdate(ModelInstance* comp, fmi2EventInfo* eventInfo) {
+  }
+  
+  fmi2Real getReal(ModelInstance* comp, const fmi2ValueReference vr) {
+    switch (vr) {
+        case $PrealExpression1$Py_vr : return comp->fmuData->localData[0]->realVars[0]; break;
+        case $PrealExpression2$Py_vr : return comp->fmuData->localData[0]->realVars[1]; break;
+        case $Ps1$PouterStatePort$PsubgraphStatePort$PactiveSteps_vr : return comp->fmuData->localData[0]->realVars[2]; break;
+        case $PstateGraphRoot$PsubgraphStatePort$PactiveSteps_vr : return comp->fmuData->localData[0]->realVars[3]; break;
+        case $PstateGraphRoot$PsubgraphStatePort$PactiveStepsDummy_vr : return comp->fmuData->localData[0]->realVars[4]; break;
+        case $Pstep1$PouterStatePort$PsubgraphStatePort$PactiveSteps_vr : return comp->fmuData->localData[0]->realVars[5]; break;
+        case $Pt1$Pt_vr : return comp->fmuData->localData[0]->realVars[6]; break;
+        case $Pt1$Pt_dummy_vr : return comp->fmuData->localData[0]->realVars[7]; break;
+        case $Pt1$Pt_start_vr : return comp->fmuData->localData[0]->realVars[8]; break;
+        case $Pt2$Pt_vr : return comp->fmuData->localData[0]->realVars[9]; break;
+        case $Pt2$Pt_dummy_vr : return comp->fmuData->localData[0]->realVars[10]; break;
+        case $Pu_vr : return comp->fmuData->localData[0]->realVars[11]; break;
+        case $Py_vr : return comp->fmuData->localData[0]->realVars[12]; break;
+        case $Pt2$Pt_start_vr : return comp->fmuData->localData[0]->realVars[13]; break;
+        case $Pt1$PwaitTime_vr : return comp->fmuData->simulationInfo->realParameter[0]; break;
+        case $Pt2$PwaitTime_vr : return comp->fmuData->simulationInfo->realParameter[1]; break;
+        case $Ps1$PouterStatePort$PsubgraphStatePort$PactiveStepsDummy_vr : return getReal(comp, $PstateGraphRoot$PsubgraphStatePort$PactiveStepsDummy_vr); break;
+        case $Pstep1$PouterStatePort$PsubgraphStatePort$PactiveStepsDummy_vr : return getReal(comp, $PstateGraphRoot$PsubgraphStatePort$PactiveStepsDummy_vr); break;
+        case $Pswitch1$Pu1_vr : return getReal(comp, $PrealExpression1$Py_vr); break;
+        case $Pswitch1$Pu3_vr : return getReal(comp, $PrealExpression2$Py_vr); break;
+        case $Pswitch1$Py_vr : return getReal(comp, $Py_vr); break;
+        default:
+            return 0;
+    }
+  }
+  
+  fmi2Status setReal(ModelInstance* comp, const fmi2ValueReference vr, const fmi2Real value) {
+    switch (vr) {
+        case $PrealExpression1$Py_vr : comp->fmuData->localData[0]->realVars[0] = value; break;
+        case $PrealExpression2$Py_vr : comp->fmuData->localData[0]->realVars[1] = value; break;
+        case $Ps1$PouterStatePort$PsubgraphStatePort$PactiveSteps_vr : comp->fmuData->localData[0]->realVars[2] = value; break;
+        case $PstateGraphRoot$PsubgraphStatePort$PactiveSteps_vr : comp->fmuData->localData[0]->realVars[3] = value; break;
+        case $PstateGraphRoot$PsubgraphStatePort$PactiveStepsDummy_vr : comp->fmuData->localData[0]->realVars[4] = value; break;
+        case $Pstep1$PouterStatePort$PsubgraphStatePort$PactiveSteps_vr : comp->fmuData->localData[0]->realVars[5] = value; break;
+        case $Pt1$Pt_vr : comp->fmuData->localData[0]->realVars[6] = value; break;
+        case $Pt1$Pt_dummy_vr : comp->fmuData->localData[0]->realVars[7] = value; break;
+        case $Pt1$Pt_start_vr : comp->fmuData->localData[0]->realVars[8] = value; break;
+        case $Pt2$Pt_vr : comp->fmuData->localData[0]->realVars[9] = value; break;
+        case $Pt2$Pt_dummy_vr : comp->fmuData->localData[0]->realVars[10] = value; break;
+        case $Pu_vr : comp->fmuData->localData[0]->realVars[11] = value; break;
+        case $Py_vr : comp->fmuData->localData[0]->realVars[12] = value; break;
+        case $Pt2$Pt_start_vr : comp->fmuData->localData[0]->realVars[13] = value; break;
+        case $Pt1$PwaitTime_vr : comp->fmuData->simulationInfo->realParameter[0] = value; break;
+        case $Pt2$PwaitTime_vr : comp->fmuData->simulationInfo->realParameter[1] = value; break;
+        case $Ps1$PouterStatePort$PsubgraphStatePort$PactiveStepsDummy_vr : return setReal(comp, $PstateGraphRoot$PsubgraphStatePort$PactiveStepsDummy_vr, value); break;
+        case $Pstep1$PouterStatePort$PsubgraphStatePort$PactiveStepsDummy_vr : return setReal(comp, $PstateGraphRoot$PsubgraphStatePort$PactiveStepsDummy_vr, value); break;
+        case $Pswitch1$Pu1_vr : return setReal(comp, $PrealExpression1$Py_vr, value); break;
+        case $Pswitch1$Pu3_vr : return setReal(comp, $PrealExpression2$Py_vr, value); break;
+        case $Pswitch1$Py_vr : return setReal(comp, $Py_vr, value); break;
+        default:
+            return fmi2Error;
+    }
+    return fmi2OK;
+  }
+  
+  fmi2Integer getInteger(ModelInstance* comp, const fmi2ValueReference vr) {
+    switch (vr) {
+        case $PstateGraphRoot$PactiveSteps_vr : return comp->fmuData->localData[0]->integerVars[0]; break;
+        case $Ps1$PnIn_vr : return comp->fmuData->simulationInfo->integerParameter[0]; break;
+        case $Ps1$PnOut_vr : return comp->fmuData->simulationInfo->integerParameter[1]; break;
+        case $Pstep1$PnIn_vr : return comp->fmuData->simulationInfo->integerParameter[2]; break;
+        case $Pstep1$PnOut_vr : return comp->fmuData->simulationInfo->integerParameter[3]; break;
+        default:
+            return 0;
+    }
+  }
+  fmi2Status setInteger(ModelInstance* comp, const fmi2ValueReference vr, const fmi2Integer value) {
+    switch (vr) {
+        case $PstateGraphRoot$PactiveSteps_vr : comp->fmuData->localData[0]->integerVars[0] = value; break;
+        case $Ps1$PnIn_vr : comp->fmuData->simulationInfo->integerParameter[0] = value; break;
+        case $Ps1$PnOut_vr : comp->fmuData->simulationInfo->integerParameter[1] = value; break;
+        case $Pstep1$PnIn_vr : comp->fmuData->simulationInfo->integerParameter[2] = value; break;
+        case $Pstep1$PnOut_vr : comp->fmuData->simulationInfo->integerParameter[3] = value; break;
+        default:
+            return fmi2Error;
+    }
+    return fmi2OK;
+  }
+  fmi2Boolean getBoolean(ModelInstance* comp, const fmi2ValueReference vr) {
+    switch (vr) {
+        case $P$whenCondition1_vr : return comp->fmuData->localData[0]->booleanVars[0]; break;
+        case $Ps1$Pactive_vr : return comp->fmuData->localData[0]->booleanVars[1]; break;
+        case $Ps1$PlocalActive_vr : return comp->fmuData->localData[0]->booleanVars[2]; break;
+        case $Ps1$PnewActive_vr : return comp->fmuData->localData[0]->booleanVars[3]; break;
+        case $Ps1$PoldActive_vr : return comp->fmuData->localData[0]->booleanVars[4]; break;
+        case $PstateGraphRoot$Presume_vr : return comp->fmuData->localData[0]->booleanVars[5]; break;
+        case $PstateGraphRoot$Psuspend_vr : return comp->fmuData->localData[0]->booleanVars[6]; break;
+        case $Pstep1$Pactive_vr : return comp->fmuData->localData[0]->booleanVars[7]; break;
+        case $Pstep1$PlocalActive_vr : return comp->fmuData->localData[0]->booleanVars[8]; break;
+        case $Pstep1$PnewActive_vr : return comp->fmuData->localData[0]->booleanVars[9]; break;
+        case $Pstep1$PoldActive_vr : return comp->fmuData->localData[0]->booleanVars[10]; break;
+        case $Pt1$Pcondition_vr : return comp->fmuData->localData[0]->booleanVars[11]; break;
+        case $Pt1$PenableFire_vr : return comp->fmuData->localData[0]->booleanVars[12]; break;
+        case $Pt2$Pcondition_vr : return comp->fmuData->localData[0]->booleanVars[13]; break;
+        case $Pt2$PenableFire_vr : return comp->fmuData->localData[0]->booleanVars[14]; break;
+        case $Pt2$Pfire_vr : return comp->fmuData->localData[0]->booleanVars[15]; break;
+        case $Pt1$PenableTimer_vr : return comp->fmuData->simulationInfo->booleanParameter[0]; break;
+        case $Pt2$PenableTimer_vr : return comp->fmuData->simulationInfo->booleanParameter[1]; break;
+        case $Ps1$PinPort$lB1$rB$Poccupied_vr : return getBoolean(comp, $Ps1$Pactive_vr); break;
+        case $Ps1$PinPort$lB1$rB$Pset_vr : return getBoolean(comp, $Pt2$Pfire_vr); break;
+        case $Ps1$PoutPort$lB1$rB$Pavailable_vr : return getBoolean(comp, $Ps1$Pactive_vr); break;
+        case $Ps1$PoutPort$lB1$rB$Preset_vr : return getBoolean(comp, $Pt1$PenableFire_vr); break;
+        case $Ps1$PouterStatePort$PsubgraphStatePort$Presume_vr : return getBoolean(comp, $PstateGraphRoot$Presume_vr); break;
+        case $Ps1$PouterStatePort$PsubgraphStatePort$Psuspend_vr : return getBoolean(comp, $PstateGraphRoot$Psuspend_vr); break;
+        case $PstateGraphRoot$PsubgraphStatePort$Presume_vr : return getBoolean(comp, $PstateGraphRoot$Presume_vr); break;
+        case $PstateGraphRoot$PsubgraphStatePort$Psuspend_vr : return getBoolean(comp, $PstateGraphRoot$Psuspend_vr); break;
+        case $Pstep1$PinPort$lB1$rB$Poccupied_vr : return getBoolean(comp, $Pstep1$Pactive_vr); break;
+        case $Pstep1$PinPort$lB1$rB$Pset_vr : return getBoolean(comp, $Pt1$PenableFire_vr); break;
+        case $Pstep1$PoutPort$lB1$rB$Pavailable_vr : return getBoolean(comp, $Pstep1$Pactive_vr); break;
+        case $Pstep1$PoutPort$lB1$rB$Preset_vr : return getBoolean(comp, $Pt2$Pfire_vr); break;
+        case $Pstep1$PouterStatePort$PsubgraphStatePort$Presume_vr : return getBoolean(comp, $PstateGraphRoot$Presume_vr); break;
+        case $Pstep1$PouterStatePort$PsubgraphStatePort$Psuspend_vr : return getBoolean(comp, $PstateGraphRoot$Psuspend_vr); break;
+        case $Pswitch1$Pu2_vr : return getBoolean(comp, $Ps1$Pactive_vr); break;
+        case $Pt1$Pfire_vr : return getBoolean(comp, $Pt1$PenableFire_vr); break;
+        case $Pt1$PinPort$Pavailable_vr : return getBoolean(comp, $Ps1$Pactive_vr); break;
+        case $Pt1$PinPort$Preset_vr : return getBoolean(comp, $Pt1$PenableFire_vr); break;
+        case $Pt1$PlocalCondition_vr : return getBoolean(comp, $Pt1$Pcondition_vr); break;
+        case $Pt1$PoutPort$Poccupied_vr : return getBoolean(comp, $Pstep1$Pactive_vr); break;
+        case $Pt1$PoutPort$Pset_vr : return getBoolean(comp, $Pt1$PenableFire_vr); break;
+        case $Pt2$PinPort$Pavailable_vr : return getBoolean(comp, $Pstep1$Pactive_vr); break;
+        case $Pt2$PinPort$Preset_vr : return getBoolean(comp, $Pt2$Pfire_vr); break;
+        case $Pt2$PlocalCondition_vr : return getBoolean(comp, $Pt2$Pcondition_vr); break;
+        case $Pt2$PoutPort$Poccupied_vr : return getBoolean(comp, $Ps1$Pactive_vr); break;
+        case $Pt2$PoutPort$Pset_vr : return getBoolean(comp, $Pt2$Pfire_vr); break;
+        default:
+            return fmi2False;
+    }
+  }
+  
+  fmi2Status setBoolean(ModelInstance* comp, const fmi2ValueReference vr, const fmi2Boolean value) {
+    switch (vr) {
+        case $P$whenCondition1_vr : comp->fmuData->localData[0]->booleanVars[0] = value; break;
+        case $Ps1$Pactive_vr : comp->fmuData->localData[0]->booleanVars[1] = value; break;
+        case $Ps1$PlocalActive_vr : comp->fmuData->localData[0]->booleanVars[2] = value; break;
+        case $Ps1$PnewActive_vr : comp->fmuData->localData[0]->booleanVars[3] = value; break;
+        case $Ps1$PoldActive_vr : comp->fmuData->localData[0]->booleanVars[4] = value; break;
+        case $PstateGraphRoot$Presume_vr : comp->fmuData->localData[0]->booleanVars[5] = value; break;
+        case $PstateGraphRoot$Psuspend_vr : comp->fmuData->localData[0]->booleanVars[6] = value; break;
+        case $Pstep1$Pactive_vr : comp->fmuData->localData[0]->booleanVars[7] = value; break;
+        case $Pstep1$PlocalActive_vr : comp->fmuData->localData[0]->booleanVars[8] = value; break;
+        case $Pstep1$PnewActive_vr : comp->fmuData->localData[0]->booleanVars[9] = value; break;
+        case $Pstep1$PoldActive_vr : comp->fmuData->localData[0]->booleanVars[10] = value; break;
+        case $Pt1$Pcondition_vr : comp->fmuData->localData[0]->booleanVars[11] = value; break;
+        case $Pt1$PenableFire_vr : comp->fmuData->localData[0]->booleanVars[12] = value; break;
+        case $Pt2$Pcondition_vr : comp->fmuData->localData[0]->booleanVars[13] = value; break;
+        case $Pt2$PenableFire_vr : comp->fmuData->localData[0]->booleanVars[14] = value; break;
+        case $Pt2$Pfire_vr : comp->fmuData->localData[0]->booleanVars[15] = value; break;
+        case $Pt1$PenableTimer_vr : comp->fmuData->simulationInfo->booleanParameter[0] = value; break;
+        case $Pt2$PenableTimer_vr : comp->fmuData->simulationInfo->booleanParameter[1] = value; break;
+        case $Ps1$PinPort$lB1$rB$Poccupied_vr : return setBoolean(comp, $Ps1$Pactive_vr, value); break;
+        case $Ps1$PinPort$lB1$rB$Pset_vr : return setBoolean(comp, $Pt2$Pfire_vr, value); break;
+        case $Ps1$PoutPort$lB1$rB$Pavailable_vr : return setBoolean(comp, $Ps1$Pactive_vr, value); break;
+        case $Ps1$PoutPort$lB1$rB$Preset_vr : return setBoolean(comp, $Pt1$PenableFire_vr, value); break;
+        case $Ps1$PouterStatePort$PsubgraphStatePort$Presume_vr : return setBoolean(comp, $PstateGraphRoot$Presume_vr, value); break;
+        case $Ps1$PouterStatePort$PsubgraphStatePort$Psuspend_vr : return setBoolean(comp, $PstateGraphRoot$Psuspend_vr, value); break;
+        case $PstateGraphRoot$PsubgraphStatePort$Presume_vr : return setBoolean(comp, $PstateGraphRoot$Presume_vr, value); break;
+        case $PstateGraphRoot$PsubgraphStatePort$Psuspend_vr : return setBoolean(comp, $PstateGraphRoot$Psuspend_vr, value); break;
+        case $Pstep1$PinPort$lB1$rB$Poccupied_vr : return setBoolean(comp, $Pstep1$Pactive_vr, value); break;
+        case $Pstep1$PinPort$lB1$rB$Pset_vr : return setBoolean(comp, $Pt1$PenableFire_vr, value); break;
+        case $Pstep1$PoutPort$lB1$rB$Pavailable_vr : return setBoolean(comp, $Pstep1$Pactive_vr, value); break;
+        case $Pstep1$PoutPort$lB1$rB$Preset_vr : return setBoolean(comp, $Pt2$Pfire_vr, value); break;
+        case $Pstep1$PouterStatePort$PsubgraphStatePort$Presume_vr : return setBoolean(comp, $PstateGraphRoot$Presume_vr, value); break;
+        case $Pstep1$PouterStatePort$PsubgraphStatePort$Psuspend_vr : return setBoolean(comp, $PstateGraphRoot$Psuspend_vr, value); break;
+        case $Pswitch1$Pu2_vr : return setBoolean(comp, $Ps1$Pactive_vr, value); break;
+        case $Pt1$Pfire_vr : return setBoolean(comp, $Pt1$PenableFire_vr, value); break;
+        case $Pt1$PinPort$Pavailable_vr : return setBoolean(comp, $Ps1$Pactive_vr, value); break;
+        case $Pt1$PinPort$Preset_vr : return setBoolean(comp, $Pt1$PenableFire_vr, value); break;
+        case $Pt1$PlocalCondition_vr : return setBoolean(comp, $Pt1$Pcondition_vr, value); break;
+        case $Pt1$PoutPort$Poccupied_vr : return setBoolean(comp, $Pstep1$Pactive_vr, value); break;
+        case $Pt1$PoutPort$Pset_vr : return setBoolean(comp, $Pt1$PenableFire_vr, value); break;
+        case $Pt2$PinPort$Pavailable_vr : return setBoolean(comp, $Pstep1$Pactive_vr, value); break;
+        case $Pt2$PinPort$Preset_vr : return setBoolean(comp, $Pt2$Pfire_vr, value); break;
+        case $Pt2$PlocalCondition_vr : return setBoolean(comp, $Pt2$Pcondition_vr, value); break;
+        case $Pt2$PoutPort$Poccupied_vr : return setBoolean(comp, $Ps1$Pactive_vr, value); break;
+        case $Pt2$PoutPort$Pset_vr : return setBoolean(comp, $Pt2$Pfire_vr, value); break;
+        default:
+            return fmi2Error;
+    }
+    return fmi2OK;
+  }
+  
+  fmi2String getString(ModelInstance* comp, const fmi2ValueReference vr) {
+    switch (vr) {
+        default:
+            return "";
+    }
+  }
+  
+  fmi2Status setString(ModelInstance* comp, const fmi2ValueReference vr, fmi2String value) {
+    switch (vr) {
+        default:
+            return fmi2Error;
+    }
+    return fmi2OK;
+  }
+  
+  fmi2Status setExternalFunction(ModelInstance* c, const fmi2ValueReference vr, const void* value){
+    switch (vr) {
+        default:
+            return fmi2Error;
+    }
+    return fmi2OK;
+  }
+  
+
+#ifdef __cplusplus
+}
+#endif
+

+ 0 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_FMU.libs


BIN
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_FMU.o


+ 49 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_functions.c

@@ -0,0 +1,49 @@
+#include "StategraphSample_functions.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "StategraphSample_includes.h"
+
+
+DLLExport
+modelica_boolean omc_Modelica_StateGraph_Temporary_anyTrue(threadData_t *threadData, boolean_array _b)
+{
+  modelica_boolean _result;
+  modelica_integer tmp1;
+  modelica_integer tmp2;
+  modelica_integer tmp3;
+  modelica_integer tmp4;
+  _tailrecursive: OMC_LABEL_UNUSED
+  _result = 0;
+
+  tmp4 = size_of_dimension_base_array(_b, ((modelica_integer) 1));
+  tmp1 = ((modelica_integer) 1); tmp2 = 1; tmp3 = tmp4;
+  if(!tmp2)
+  {
+    FILE_INFO info = omc_dummyFileInfo;
+    omc_assert(threadData, info, "assertion range step != 0 failed");
+  }
+  else if(!(((tmp2 > 0) && (tmp1 > tmp3)) || ((tmp2 < 0) && (tmp1 < tmp3))))
+  {
+    modelica_integer _i;
+    for(_i = ((modelica_integer) 1); in_range_integer(_i, tmp1, tmp3); _i += tmp2)
+    {
+      _result = (_result || (*boolean_array_element_addr1(&_b, 1, /* modelica_integer */ (modelica_integer)_i)));
+    }
+  }
+  _return: OMC_LABEL_UNUSED
+  return _result;
+}
+modelica_metatype boxptr_Modelica_StateGraph_Temporary_anyTrue(threadData_t *threadData, modelica_metatype _b)
+{
+  modelica_boolean _result;
+  modelica_metatype out_result;
+  _result = omc_Modelica_StateGraph_Temporary_anyTrue(threadData, *((base_array_t*)_b));
+  out_result = mmc_mk_icon(_result);
+  return out_result;
+}
+
+#ifdef __cplusplus
+}
+#endif

+ 28 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_functions.h

@@ -0,0 +1,28 @@
+#ifndef StategraphSample__H
+#define StategraphSample__H
+#include "meta/meta_modelica.h"
+#include "util/modelica.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "simulation/simulation_runtime.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+DLLExport
+modelica_boolean omc_Modelica_StateGraph_Temporary_anyTrue(threadData_t *threadData, boolean_array _b);
+DLLExport
+modelica_metatype boxptr_Modelica_StateGraph_Temporary_anyTrue(threadData_t *threadData, modelica_metatype _b);
+static const MMC_DEFSTRUCTLIT(boxvar_lit_Modelica_StateGraph_Temporary_anyTrue,2,0) {(void*) boxptr_Modelica_StateGraph_Temporary_anyTrue,0}};
+#define boxvar_Modelica_StateGraph_Temporary_anyTrue MMC_REFSTRUCTLIT(boxvar_lit_Modelica_StateGraph_Temporary_anyTrue)
+#include "StategraphSample_model.h"
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+

+ 0 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_includes.h


File diff suppressed because it is too large
+ 1 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_info.c


+ 548 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_init_fmu.c

@@ -0,0 +1,548 @@
+#include <simulation_data.h>
+
+void StategraphSample_read_input_fmu(MODEL_DATA* modelData, SIMULATION_INFO* simulationInfo)
+{
+  simulationInfo->startTime = 0.0;
+  simulationInfo->stopTime = 1.0;
+  simulationInfo->stepSize = 0.002;
+  simulationInfo->tolerance = 1e-006;
+  simulationInfo->solverMethod = "dassl";
+  simulationInfo->outputFormat = "mat";
+  simulationInfo->variableFilter = ".*";
+  simulationInfo->OPENMODELICAHOME = "C:/OpenModelica1.12.0-dev-32bit/";
+  modelData->realVarsData[0].info.id = 1000;
+  modelData->realVarsData[0].info.name = "realExpression1.y";
+  modelData->realVarsData[0].info.comment = "Value of Real output";
+  modelData->realVarsData[0].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/Blocks/Sources.mo";
+  modelData->realVarsData[0].info.info.lineStart = 11;
+  modelData->realVarsData[0].info.info.colStart = 5;
+  modelData->realVarsData[0].info.info.lineEnd = 13;
+  modelData->realVarsData[0].info.info.colEnd = 56;
+  modelData->realVarsData[0].info.info.readonly = 0;
+  modelData->realVarsData[0].attribute.unit = "";
+  modelData->realVarsData[0].attribute.displayUnit = "";
+  modelData->realVarsData[0].attribute.min = -DBL_MAX;
+  modelData->realVarsData[0].attribute.max = DBL_MAX;
+  modelData->realVarsData[0].attribute.fixed = 0;
+  modelData->realVarsData[0].attribute.useNominal = 0;
+  modelData->realVarsData[0].attribute.nominal = 0.0;
+  modelData->realVarsData[0].attribute.start = 0.0;
+  modelData->realVarsData[1].info.id = 1001;
+  modelData->realVarsData[1].info.name = "realExpression2.y";
+  modelData->realVarsData[1].info.comment = "Value of Real output";
+  modelData->realVarsData[1].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/Blocks/Sources.mo";
+  modelData->realVarsData[1].info.info.lineStart = 11;
+  modelData->realVarsData[1].info.info.colStart = 5;
+  modelData->realVarsData[1].info.info.lineEnd = 13;
+  modelData->realVarsData[1].info.info.colEnd = 56;
+  modelData->realVarsData[1].info.info.readonly = 0;
+  modelData->realVarsData[1].attribute.unit = "";
+  modelData->realVarsData[1].attribute.displayUnit = "";
+  modelData->realVarsData[1].attribute.min = -DBL_MAX;
+  modelData->realVarsData[1].attribute.max = DBL_MAX;
+  modelData->realVarsData[1].attribute.fixed = 0;
+  modelData->realVarsData[1].attribute.useNominal = 0;
+  modelData->realVarsData[1].attribute.nominal = 0.0;
+  modelData->realVarsData[1].attribute.start = 0.0;
+  modelData->realVarsData[2].info.id = 1002;
+  modelData->realVarsData[2].info.name = "s1.outerStatePort.subgraphStatePort.activeSteps";
+  modelData->realVarsData[2].info.comment = "Number of active steps in the CompositeStep";
+  modelData->realVarsData[2].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->realVarsData[2].info.info.lineStart = 1955;
+  modelData->realVarsData[2].info.info.colStart = 5;
+  modelData->realVarsData[2].info.info.lineEnd = 1955;
+  modelData->realVarsData[2].info.info.colEnd = 72;
+  modelData->realVarsData[2].info.info.readonly = 0;
+  modelData->realVarsData[2].attribute.unit = "";
+  modelData->realVarsData[2].attribute.displayUnit = "";
+  modelData->realVarsData[2].attribute.min = -DBL_MAX;
+  modelData->realVarsData[2].attribute.max = DBL_MAX;
+  modelData->realVarsData[2].attribute.fixed = 0;
+  modelData->realVarsData[2].attribute.useNominal = 0;
+  modelData->realVarsData[2].attribute.nominal = 0.0;
+  modelData->realVarsData[2].attribute.start = 0.0;
+  modelData->realVarsData[3].info.id = 1003;
+  modelData->realVarsData[3].info.name = "stateGraphRoot.subgraphStatePort.activeSteps";
+  modelData->realVarsData[3].info.comment = "Number of active steps in the CompositeStep";
+  modelData->realVarsData[3].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->realVarsData[3].info.info.lineStart = 1967;
+  modelData->realVarsData[3].info.info.colStart = 5;
+  modelData->realVarsData[3].info.info.lineEnd = 1967;
+  modelData->realVarsData[3].info.info.colEnd = 72;
+  modelData->realVarsData[3].info.info.readonly = 0;
+  modelData->realVarsData[3].attribute.unit = "";
+  modelData->realVarsData[3].attribute.displayUnit = "";
+  modelData->realVarsData[3].attribute.min = -DBL_MAX;
+  modelData->realVarsData[3].attribute.max = DBL_MAX;
+  modelData->realVarsData[3].attribute.fixed = 0;
+  modelData->realVarsData[3].attribute.useNominal = 0;
+  modelData->realVarsData[3].attribute.nominal = 0.0;
+  modelData->realVarsData[3].attribute.start = 0.0;
+  modelData->realVarsData[4].info.id = 1004;
+  modelData->realVarsData[4].info.name = "stateGraphRoot.subgraphStatePort.activeStepsDummy";
+  modelData->realVarsData[4].info.comment = "Dummy variable in order that connector fulfills restriction of connector";
+  modelData->realVarsData[4].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->realVarsData[4].info.info.lineStart = 1964;
+  modelData->realVarsData[4].info.info.colStart = 5;
+  modelData->realVarsData[4].info.info.lineEnd = 1966;
+  modelData->realVarsData[4].info.info.colEnd = 109;
+  modelData->realVarsData[4].info.info.readonly = 0;
+  modelData->realVarsData[4].attribute.unit = "";
+  modelData->realVarsData[4].attribute.displayUnit = "";
+  modelData->realVarsData[4].attribute.min = -DBL_MAX;
+  modelData->realVarsData[4].attribute.max = DBL_MAX;
+  modelData->realVarsData[4].attribute.fixed = 0;
+  modelData->realVarsData[4].attribute.useNominal = 0;
+  modelData->realVarsData[4].attribute.nominal = 0.0;
+  modelData->realVarsData[4].attribute.start = 0.0;
+  modelData->realVarsData[5].info.id = 1005;
+  modelData->realVarsData[5].info.name = "step1.outerStatePort.subgraphStatePort.activeSteps";
+  modelData->realVarsData[5].info.comment = "Number of active steps in the CompositeStep";
+  modelData->realVarsData[5].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->realVarsData[5].info.info.lineStart = 1955;
+  modelData->realVarsData[5].info.info.colStart = 5;
+  modelData->realVarsData[5].info.info.lineEnd = 1955;
+  modelData->realVarsData[5].info.info.colEnd = 72;
+  modelData->realVarsData[5].info.info.readonly = 0;
+  modelData->realVarsData[5].attribute.unit = "";
+  modelData->realVarsData[5].attribute.displayUnit = "";
+  modelData->realVarsData[5].attribute.min = -DBL_MAX;
+  modelData->realVarsData[5].attribute.max = DBL_MAX;
+  modelData->realVarsData[5].attribute.fixed = 0;
+  modelData->realVarsData[5].attribute.useNominal = 0;
+  modelData->realVarsData[5].attribute.nominal = 0.0;
+  modelData->realVarsData[5].attribute.start = 0.0;
+  modelData->realVarsData[6].info.id = 1006;
+  modelData->realVarsData[6].info.name = "t1.t";
+  modelData->realVarsData[6].info.comment = "= actual waiting time (transition will fire when t > waitTime)";
+  modelData->realVarsData[6].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->realVarsData[6].info.info.lineStart = 2069;
+  modelData->realVarsData[6].info.info.colStart = 5;
+  modelData->realVarsData[6].info.info.lineEnd = 2070;
+  modelData->realVarsData[6].info.info.colEnd = 73;
+  modelData->realVarsData[6].info.info.readonly = 0;
+  modelData->realVarsData[6].attribute.unit = "s";
+  modelData->realVarsData[6].attribute.displayUnit = "";
+  modelData->realVarsData[6].attribute.min = -DBL_MAX;
+  modelData->realVarsData[6].attribute.max = DBL_MAX;
+  modelData->realVarsData[6].attribute.fixed = 0;
+  modelData->realVarsData[6].attribute.useNominal = 0;
+  modelData->realVarsData[6].attribute.nominal = 0.0;
+  modelData->realVarsData[6].attribute.start = 0.0;
+  modelData->realVarsData[7].info.id = 1007;
+  modelData->realVarsData[7].info.name = "t1.t_dummy";
+  modelData->realVarsData[7].info.comment = "";
+  modelData->realVarsData[7].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->realVarsData[7].info.info.lineStart = 2083;
+  modelData->realVarsData[7].info.info.colStart = 5;
+  modelData->realVarsData[7].info.info.lineEnd = 2083;
+  modelData->realVarsData[7].info.info.colEnd = 17;
+  modelData->realVarsData[7].info.info.readonly = 0;
+  modelData->realVarsData[7].attribute.unit = "";
+  modelData->realVarsData[7].attribute.displayUnit = "";
+  modelData->realVarsData[7].attribute.min = -DBL_MAX;
+  modelData->realVarsData[7].attribute.max = DBL_MAX;
+  modelData->realVarsData[7].attribute.fixed = 0;
+  modelData->realVarsData[7].attribute.useNominal = 0;
+  modelData->realVarsData[7].attribute.nominal = 0.0;
+  modelData->realVarsData[7].attribute.start = 0.0;
+  modelData->realVarsData[8].info.id = 1008;
+  modelData->realVarsData[8].info.name = "t1.t_start";
+  modelData->realVarsData[8].info.comment = "Time instant at which the transition would fire, if waitTime would be zero";
+  modelData->realVarsData[8].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->realVarsData[8].info.info.lineStart = 2081;
+  modelData->realVarsData[8].info.info.colStart = 5;
+  modelData->realVarsData[8].info.info.lineEnd = 2082;
+  modelData->realVarsData[8].info.info.colEnd = 85;
+  modelData->realVarsData[8].info.info.readonly = 0;
+  modelData->realVarsData[8].attribute.unit = "s";
+  modelData->realVarsData[8].attribute.displayUnit = "";
+  modelData->realVarsData[8].attribute.min = -DBL_MAX;
+  modelData->realVarsData[8].attribute.max = DBL_MAX;
+  modelData->realVarsData[8].attribute.fixed = 0;
+  modelData->realVarsData[8].attribute.useNominal = 0;
+  modelData->realVarsData[8].attribute.nominal = 0.0;
+  modelData->realVarsData[8].attribute.start = 0.0;
+  modelData->realVarsData[9].info.id = 1009;
+  modelData->realVarsData[9].info.name = "t2.t";
+  modelData->realVarsData[9].info.comment = "= actual waiting time (transition will fire when t > waitTime)";
+  modelData->realVarsData[9].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->realVarsData[9].info.info.lineStart = 2069;
+  modelData->realVarsData[9].info.info.colStart = 5;
+  modelData->realVarsData[9].info.info.lineEnd = 2070;
+  modelData->realVarsData[9].info.info.colEnd = 73;
+  modelData->realVarsData[9].info.info.readonly = 0;
+  modelData->realVarsData[9].attribute.unit = "s";
+  modelData->realVarsData[9].attribute.displayUnit = "";
+  modelData->realVarsData[9].attribute.min = -DBL_MAX;
+  modelData->realVarsData[9].attribute.max = DBL_MAX;
+  modelData->realVarsData[9].attribute.fixed = 0;
+  modelData->realVarsData[9].attribute.useNominal = 0;
+  modelData->realVarsData[9].attribute.nominal = 0.0;
+  modelData->realVarsData[9].attribute.start = 0.0;
+  modelData->realVarsData[10].info.id = 1010;
+  modelData->realVarsData[10].info.name = "t2.t_dummy";
+  modelData->realVarsData[10].info.comment = "";
+  modelData->realVarsData[10].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->realVarsData[10].info.info.lineStart = 2083;
+  modelData->realVarsData[10].info.info.colStart = 5;
+  modelData->realVarsData[10].info.info.lineEnd = 2083;
+  modelData->realVarsData[10].info.info.colEnd = 17;
+  modelData->realVarsData[10].info.info.readonly = 0;
+  modelData->realVarsData[10].attribute.unit = "";
+  modelData->realVarsData[10].attribute.displayUnit = "";
+  modelData->realVarsData[10].attribute.min = -DBL_MAX;
+  modelData->realVarsData[10].attribute.max = DBL_MAX;
+  modelData->realVarsData[10].attribute.fixed = 0;
+  modelData->realVarsData[10].attribute.useNominal = 0;
+  modelData->realVarsData[10].attribute.nominal = 0.0;
+  modelData->realVarsData[10].attribute.start = 0.0;
+  modelData->realVarsData[11].info.id = 1011;
+  modelData->realVarsData[11].info.name = "u";
+  modelData->realVarsData[11].info.comment = "";
+  modelData->realVarsData[11].info.info.filename = "StategraphSample";
+  modelData->realVarsData[11].info.info.lineStart = 2;
+  modelData->realVarsData[11].info.info.colStart = 3;
+  modelData->realVarsData[11].info.info.lineEnd = 3;
+  modelData->realVarsData[11].info.info.colEnd = 201;
+  modelData->realVarsData[11].info.info.readonly = 0;
+  modelData->realVarsData[11].attribute.unit = "";
+  modelData->realVarsData[11].attribute.displayUnit = "";
+  modelData->realVarsData[11].attribute.min = -DBL_MAX;
+  modelData->realVarsData[11].attribute.max = DBL_MAX;
+  modelData->realVarsData[11].attribute.fixed = 0;
+  modelData->realVarsData[11].attribute.useNominal = 0;
+  modelData->realVarsData[11].attribute.nominal = 0.0;
+  modelData->realVarsData[11].attribute.start = 0.0;
+  modelData->realVarsData[12].info.id = 1012;
+  modelData->realVarsData[12].info.name = "y";
+  modelData->realVarsData[12].info.comment = "";
+  modelData->realVarsData[12].info.info.filename = "StategraphSample";
+  modelData->realVarsData[12].info.info.lineStart = 18;
+  modelData->realVarsData[12].info.info.colStart = 3;
+  modelData->realVarsData[12].info.info.lineEnd = 19;
+  modelData->realVarsData[12].info.info.colEnd = 201;
+  modelData->realVarsData[12].info.info.readonly = 0;
+  modelData->realVarsData[12].attribute.unit = "";
+  modelData->realVarsData[12].attribute.displayUnit = "";
+  modelData->realVarsData[12].attribute.min = -DBL_MAX;
+  modelData->realVarsData[12].attribute.max = DBL_MAX;
+  modelData->realVarsData[12].attribute.fixed = 0;
+  modelData->realVarsData[12].attribute.useNominal = 0;
+  modelData->realVarsData[12].attribute.nominal = 0.0;
+  modelData->realVarsData[12].attribute.start = 0.0;
+  modelData->realVarsData[13].info.id = 1013;
+  modelData->realVarsData[13].info.name = "t2.t_start";
+  modelData->realVarsData[13].info.comment = "Time instant at which the transition would fire, if waitTime would be zero";
+  modelData->realVarsData[13].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->realVarsData[13].info.info.lineStart = 2081;
+  modelData->realVarsData[13].info.info.colStart = 5;
+  modelData->realVarsData[13].info.info.lineEnd = 2082;
+  modelData->realVarsData[13].info.info.colEnd = 85;
+  modelData->realVarsData[13].info.info.readonly = 0;
+  modelData->realVarsData[13].attribute.unit = "s";
+  modelData->realVarsData[13].attribute.displayUnit = "";
+  modelData->realVarsData[13].attribute.min = -DBL_MAX;
+  modelData->realVarsData[13].attribute.max = DBL_MAX;
+  modelData->realVarsData[13].attribute.fixed = 0;
+  modelData->realVarsData[13].attribute.useNominal = 0;
+  modelData->realVarsData[13].attribute.nominal = 0.0;
+  modelData->realVarsData[13].attribute.start = 0.0;
+  modelData->realParameterData[0].info.id = 1014;
+  modelData->realParameterData[0].info.name = "t1.waitTime";
+  modelData->realParameterData[0].info.comment = "Wait time before transition fires";
+  modelData->realParameterData[0].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->realParameterData[0].info.info.lineStart = 2066;
+  modelData->realParameterData[0].info.info.colStart = 5;
+  modelData->realParameterData[0].info.info.lineEnd = 2068;
+  modelData->realParameterData[0].info.info.colEnd = 61;
+  modelData->realParameterData[0].info.info.readonly = 0;
+  modelData->realParameterData[0].attribute.unit = "s";
+  modelData->realParameterData[0].attribute.displayUnit = "";
+  modelData->realParameterData[0].attribute.min = 0.0;
+  modelData->realParameterData[0].attribute.max = DBL_MAX;
+  modelData->realParameterData[0].attribute.fixed = 1;
+  modelData->realParameterData[0].attribute.useNominal = 0;
+  modelData->realParameterData[0].attribute.nominal = 0.0;
+  modelData->realParameterData[0].attribute.start = 0.0;
+  modelData->realParameterData[1].info.id = 1015;
+  modelData->realParameterData[1].info.name = "t2.waitTime";
+  modelData->realParameterData[1].info.comment = "Wait time before transition fires";
+  modelData->realParameterData[1].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->realParameterData[1].info.info.lineStart = 2066;
+  modelData->realParameterData[1].info.info.colStart = 5;
+  modelData->realParameterData[1].info.info.lineEnd = 2068;
+  modelData->realParameterData[1].info.info.colEnd = 61;
+  modelData->realParameterData[1].info.info.readonly = 0;
+  modelData->realParameterData[1].attribute.unit = "s";
+  modelData->realParameterData[1].attribute.displayUnit = "";
+  modelData->realParameterData[1].attribute.min = 0.0;
+  modelData->realParameterData[1].attribute.max = DBL_MAX;
+  modelData->realParameterData[1].attribute.fixed = 1;
+  modelData->realParameterData[1].attribute.useNominal = 0;
+  modelData->realParameterData[1].attribute.nominal = 0.0;
+  modelData->realParameterData[1].attribute.start = 1.0;
+  modelData->integerVarsData[0].info.id = 1016;
+  modelData->integerVarsData[0].info.name = "stateGraphRoot.activeSteps";
+  modelData->integerVarsData[0].info.comment = "Number of active steps within the stategraph";
+  modelData->integerVarsData[0].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->integerVarsData[0].info.info.lineStart = 2815;
+  modelData->integerVarsData[0].info.info.colStart = 3;
+  modelData->integerVarsData[0].info.info.lineEnd = 2815;
+  modelData->integerVarsData[0].info.info.colEnd = 76;
+  modelData->integerVarsData[0].info.info.readonly = 0;
+  modelData->integerVarsData[0].attribute.min = -DBL_MAX;
+  modelData->integerVarsData[0].attribute.max = DBL_MAX;
+  modelData->integerVarsData[0].attribute.fixed = 0;
+  modelData->integerVarsData[0].attribute.start = 0;
+  modelData->integerParameterData[0].info.id = 1017;
+  modelData->integerParameterData[0].info.name = "s1.nIn";
+  modelData->integerParameterData[0].info.comment = "Number of input connections";
+  modelData->integerParameterData[0].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->integerParameterData[0].info.info.lineStart = 1973;
+  modelData->integerParameterData[0].info.info.colStart = 5;
+  modelData->integerParameterData[0].info.info.lineEnd = 1973;
+  modelData->integerParameterData[0].info.info.colEnd = 67;
+  modelData->integerParameterData[0].info.info.readonly = 0;
+  modelData->integerParameterData[0].attribute.min = -DBL_MAX;
+  modelData->integerParameterData[0].attribute.max = DBL_MAX;
+  modelData->integerParameterData[0].attribute.fixed = 1;
+  modelData->integerParameterData[0].attribute.start = 1;
+  modelData->integerParameterData[1].info.id = 1018;
+  modelData->integerParameterData[1].info.name = "s1.nOut";
+  modelData->integerParameterData[1].info.comment = "Number of output connections";
+  modelData->integerParameterData[1].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->integerParameterData[1].info.info.lineStart = 1974;
+  modelData->integerParameterData[1].info.info.colStart = 5;
+  modelData->integerParameterData[1].info.info.lineEnd = 1974;
+  modelData->integerParameterData[1].info.info.colEnd = 69;
+  modelData->integerParameterData[1].info.info.readonly = 0;
+  modelData->integerParameterData[1].attribute.min = -DBL_MAX;
+  modelData->integerParameterData[1].attribute.max = DBL_MAX;
+  modelData->integerParameterData[1].attribute.fixed = 1;
+  modelData->integerParameterData[1].attribute.start = 1;
+  modelData->integerParameterData[2].info.id = 1019;
+  modelData->integerParameterData[2].info.name = "step1.nIn";
+  modelData->integerParameterData[2].info.comment = "Number of input connections";
+  modelData->integerParameterData[2].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->integerParameterData[2].info.info.lineStart = 1973;
+  modelData->integerParameterData[2].info.info.colStart = 5;
+  modelData->integerParameterData[2].info.info.lineEnd = 1973;
+  modelData->integerParameterData[2].info.info.colEnd = 67;
+  modelData->integerParameterData[2].info.info.readonly = 0;
+  modelData->integerParameterData[2].attribute.min = -DBL_MAX;
+  modelData->integerParameterData[2].attribute.max = DBL_MAX;
+  modelData->integerParameterData[2].attribute.fixed = 1;
+  modelData->integerParameterData[2].attribute.start = 1;
+  modelData->integerParameterData[3].info.id = 1020;
+  modelData->integerParameterData[3].info.name = "step1.nOut";
+  modelData->integerParameterData[3].info.comment = "Number of output connections";
+  modelData->integerParameterData[3].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->integerParameterData[3].info.info.lineStart = 1974;
+  modelData->integerParameterData[3].info.info.colStart = 5;
+  modelData->integerParameterData[3].info.info.lineEnd = 1974;
+  modelData->integerParameterData[3].info.info.colEnd = 69;
+  modelData->integerParameterData[3].info.info.readonly = 0;
+  modelData->integerParameterData[3].attribute.min = -DBL_MAX;
+  modelData->integerParameterData[3].attribute.max = DBL_MAX;
+  modelData->integerParameterData[3].attribute.fixed = 1;
+  modelData->integerParameterData[3].attribute.start = 1;
+  modelData->booleanVarsData[0].info.id = 1021;
+  modelData->booleanVarsData[0].info.name = "$whenCondition1";
+  modelData->booleanVarsData[0].info.comment = "";
+  modelData->booleanVarsData[0].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[0].info.info.lineStart = 2098;
+  modelData->booleanVarsData[0].info.info.colStart = 9;
+  modelData->booleanVarsData[0].info.info.lineEnd = 2098;
+  modelData->booleanVarsData[0].info.info.colEnd = 23;
+  modelData->booleanVarsData[0].info.info.readonly = 0;
+  modelData->booleanVarsData[0].attribute.fixed = 1;
+  modelData->booleanVarsData[0].attribute.start = 0;
+  modelData->booleanVarsData[1].info.id = 1022;
+  modelData->booleanVarsData[1].info.name = "s1.active";
+  modelData->booleanVarsData[1].info.comment = "";
+  modelData->booleanVarsData[1].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[1].info.info.lineStart = 2191;
+  modelData->booleanVarsData[1].info.info.colStart = 3;
+  modelData->booleanVarsData[1].info.info.lineEnd = 2195;
+  modelData->booleanVarsData[1].info.info.colEnd = 26;
+  modelData->booleanVarsData[1].info.info.readonly = 0;
+  modelData->booleanVarsData[1].attribute.fixed = 0;
+  modelData->booleanVarsData[1].attribute.start = 0;
+  modelData->booleanVarsData[2].info.id = 1023;
+  modelData->booleanVarsData[2].info.name = "s1.localActive";
+  modelData->booleanVarsData[2].info.comment = "= true if step is active, otherwise the step is not active";
+  modelData->booleanVarsData[2].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[2].info.info.lineStart = 1980;
+  modelData->booleanVarsData[2].info.info.colStart = 5;
+  modelData->booleanVarsData[2].info.info.lineEnd = 1982;
+  modelData->booleanVarsData[2].info.info.colEnd = 35;
+  modelData->booleanVarsData[2].info.info.readonly = 0;
+  modelData->booleanVarsData[2].attribute.fixed = 0;
+  modelData->booleanVarsData[2].attribute.start = 0;
+  modelData->booleanVarsData[3].info.id = 1024;
+  modelData->booleanVarsData[3].info.name = "s1.newActive";
+  modelData->booleanVarsData[3].info.comment = "Value of active in the next iteration";
+  modelData->booleanVarsData[3].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[3].info.info.lineStart = 1994;
+  modelData->booleanVarsData[3].info.info.colStart = 5;
+  modelData->booleanVarsData[3].info.info.lineEnd = 1995;
+  modelData->booleanVarsData[3].info.info.colEnd = 35;
+  modelData->booleanVarsData[3].info.info.readonly = 0;
+  modelData->booleanVarsData[3].attribute.fixed = 0;
+  modelData->booleanVarsData[3].attribute.start = 0;
+  modelData->booleanVarsData[4].info.id = 1025;
+  modelData->booleanVarsData[4].info.name = "s1.oldActive";
+  modelData->booleanVarsData[4].info.comment = "Value of active when CompositeStep was aborted";
+  modelData->booleanVarsData[4].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[4].info.info.lineStart = 1996;
+  modelData->booleanVarsData[4].info.info.colStart = 5;
+  modelData->booleanVarsData[4].info.info.lineEnd = 1996;
+  modelData->booleanVarsData[4].info.info.colEnd = 71;
+  modelData->booleanVarsData[4].info.info.readonly = 0;
+  modelData->booleanVarsData[4].attribute.fixed = 0;
+  modelData->booleanVarsData[4].attribute.start = 0;
+  modelData->booleanVarsData[5].info.id = 1026;
+  modelData->booleanVarsData[5].info.name = "stateGraphRoot.resume";
+  modelData->booleanVarsData[5].info.comment = "";
+  modelData->booleanVarsData[5].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[5].info.info.lineStart = 2133;
+  modelData->booleanVarsData[5].info.info.colStart = 5;
+  modelData->booleanVarsData[5].info.info.lineEnd = 2133;
+  modelData->booleanVarsData[5].info.info.colEnd = 35;
+  modelData->booleanVarsData[5].info.info.readonly = 0;
+  modelData->booleanVarsData[5].attribute.fixed = 0;
+  modelData->booleanVarsData[5].attribute.start = 0;
+  modelData->booleanVarsData[6].info.id = 1027;
+  modelData->booleanVarsData[6].info.name = "stateGraphRoot.suspend";
+  modelData->booleanVarsData[6].info.comment = "";
+  modelData->booleanVarsData[6].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[6].info.info.lineStart = 2132;
+  modelData->booleanVarsData[6].info.info.colStart = 5;
+  modelData->booleanVarsData[6].info.info.lineEnd = 2132;
+  modelData->booleanVarsData[6].info.info.colEnd = 35;
+  modelData->booleanVarsData[6].info.info.readonly = 0;
+  modelData->booleanVarsData[6].attribute.fixed = 0;
+  modelData->booleanVarsData[6].attribute.start = 0;
+  modelData->booleanVarsData[7].info.id = 1028;
+  modelData->booleanVarsData[7].info.name = "step1.active";
+  modelData->booleanVarsData[7].info.comment = "= true if step is active, otherwise the step is not active";
+  modelData->booleanVarsData[7].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[7].info.info.lineStart = 2225;
+  modelData->booleanVarsData[7].info.info.colStart = 3;
+  modelData->booleanVarsData[7].info.info.lineEnd = 2226;
+  modelData->booleanVarsData[7].info.info.colEnd = 67;
+  modelData->booleanVarsData[7].info.info.readonly = 0;
+  modelData->booleanVarsData[7].attribute.fixed = 0;
+  modelData->booleanVarsData[7].attribute.start = 0;
+  modelData->booleanVarsData[8].info.id = 1029;
+  modelData->booleanVarsData[8].info.name = "step1.localActive";
+  modelData->booleanVarsData[8].info.comment = "= true if step is active, otherwise the step is not active";
+  modelData->booleanVarsData[8].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[8].info.info.lineStart = 1980;
+  modelData->booleanVarsData[8].info.info.colStart = 5;
+  modelData->booleanVarsData[8].info.info.lineEnd = 1982;
+  modelData->booleanVarsData[8].info.info.colEnd = 35;
+  modelData->booleanVarsData[8].info.info.readonly = 0;
+  modelData->booleanVarsData[8].attribute.fixed = 0;
+  modelData->booleanVarsData[8].attribute.start = 0;
+  modelData->booleanVarsData[9].info.id = 1030;
+  modelData->booleanVarsData[9].info.name = "step1.newActive";
+  modelData->booleanVarsData[9].info.comment = "Value of active in the next iteration";
+  modelData->booleanVarsData[9].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[9].info.info.lineStart = 1994;
+  modelData->booleanVarsData[9].info.info.colStart = 5;
+  modelData->booleanVarsData[9].info.info.lineEnd = 1995;
+  modelData->booleanVarsData[9].info.info.colEnd = 35;
+  modelData->booleanVarsData[9].info.info.readonly = 0;
+  modelData->booleanVarsData[9].attribute.fixed = 0;
+  modelData->booleanVarsData[9].attribute.start = 0;
+  modelData->booleanVarsData[10].info.id = 1031;
+  modelData->booleanVarsData[10].info.name = "step1.oldActive";
+  modelData->booleanVarsData[10].info.comment = "Value of active when CompositeStep was aborted";
+  modelData->booleanVarsData[10].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[10].info.info.lineStart = 1996;
+  modelData->booleanVarsData[10].info.info.colStart = 5;
+  modelData->booleanVarsData[10].info.info.lineEnd = 1996;
+  modelData->booleanVarsData[10].info.info.colEnd = 71;
+  modelData->booleanVarsData[10].info.info.readonly = 0;
+  modelData->booleanVarsData[10].attribute.fixed = 0;
+  modelData->booleanVarsData[10].attribute.start = 0;
+  modelData->booleanVarsData[11].info.id = 1032;
+  modelData->booleanVarsData[11].info.name = "t1.condition";
+  modelData->booleanVarsData[11].info.comment = "= true, if transition may fire (time varying expression)";
+  modelData->booleanVarsData[11].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[11].info.info.lineStart = 2290;
+  modelData->booleanVarsData[11].info.info.colStart = 3;
+  modelData->booleanVarsData[11].info.info.lineEnd = 2292;
+  modelData->booleanVarsData[11].info.info.colEnd = 48;
+  modelData->booleanVarsData[11].info.info.readonly = 0;
+  modelData->booleanVarsData[11].attribute.fixed = 0;
+  modelData->booleanVarsData[11].attribute.start = 0;
+  modelData->booleanVarsData[12].info.id = 1033;
+  modelData->booleanVarsData[12].info.name = "t1.enableFire";
+  modelData->booleanVarsData[12].info.comment = "= true, if all firing conditions are true";
+  modelData->booleanVarsData[12].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[12].info.info.lineStart = 2071;
+  modelData->booleanVarsData[12].info.info.colStart = 5;
+  modelData->booleanVarsData[12].info.info.lineEnd = 2071;
+  modelData->booleanVarsData[12].info.info.colEnd = 74;
+  modelData->booleanVarsData[12].info.info.readonly = 0;
+  modelData->booleanVarsData[12].attribute.fixed = 0;
+  modelData->booleanVarsData[12].attribute.start = 0;
+  modelData->booleanVarsData[13].info.id = 1034;
+  modelData->booleanVarsData[13].info.name = "t2.condition";
+  modelData->booleanVarsData[13].info.comment = "= true, if transition may fire (time varying expression)";
+  modelData->booleanVarsData[13].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[13].info.info.lineStart = 2290;
+  modelData->booleanVarsData[13].info.info.colStart = 3;
+  modelData->booleanVarsData[13].info.info.lineEnd = 2292;
+  modelData->booleanVarsData[13].info.info.colEnd = 48;
+  modelData->booleanVarsData[13].info.info.readonly = 0;
+  modelData->booleanVarsData[13].attribute.fixed = 0;
+  modelData->booleanVarsData[13].attribute.start = 0;
+  modelData->booleanVarsData[14].info.id = 1035;
+  modelData->booleanVarsData[14].info.name = "t2.enableFire";
+  modelData->booleanVarsData[14].info.comment = "= true, if all firing conditions are true";
+  modelData->booleanVarsData[14].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[14].info.info.lineStart = 2071;
+  modelData->booleanVarsData[14].info.info.colStart = 5;
+  modelData->booleanVarsData[14].info.info.lineEnd = 2071;
+  modelData->booleanVarsData[14].info.info.colEnd = 74;
+  modelData->booleanVarsData[14].info.info.readonly = 0;
+  modelData->booleanVarsData[14].attribute.fixed = 0;
+  modelData->booleanVarsData[14].attribute.start = 0;
+  modelData->booleanVarsData[15].info.id = 1036;
+  modelData->booleanVarsData[15].info.name = "t2.fire";
+  modelData->booleanVarsData[15].info.comment = "= true, if transition fires";
+  modelData->booleanVarsData[15].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanVarsData[15].info.info.lineStart = 2072;
+  modelData->booleanVarsData[15].info.info.colStart = 5;
+  modelData->booleanVarsData[15].info.info.lineEnd = 2072;
+  modelData->booleanVarsData[15].info.info.colEnd = 83;
+  modelData->booleanVarsData[15].info.info.readonly = 0;
+  modelData->booleanVarsData[15].attribute.fixed = 0;
+  modelData->booleanVarsData[15].attribute.start = 0;
+  modelData->booleanParameterData[0].info.id = 1037;
+  modelData->booleanParameterData[0].info.name = "t1.enableTimer";
+  modelData->booleanParameterData[0].info.comment = "= true, if timer is enabled";
+  modelData->booleanParameterData[0].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanParameterData[0].info.info.lineStart = 2064;
+  modelData->booleanParameterData[0].info.info.colStart = 5;
+  modelData->booleanParameterData[0].info.info.lineEnd = 2065;
+  modelData->booleanParameterData[0].info.info.colEnd = 56;
+  modelData->booleanParameterData[0].info.info.readonly = 0;
+  modelData->booleanParameterData[0].attribute.fixed = 1;
+  modelData->booleanParameterData[0].attribute.start = 0;
+  modelData->booleanParameterData[1].info.id = 1038;
+  modelData->booleanParameterData[1].info.name = "t2.enableTimer";
+  modelData->booleanParameterData[1].info.comment = "= true, if timer is enabled";
+  modelData->booleanParameterData[1].info.info.filename = "C:/OpenModelica1.12.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/StateGraph.mo";
+  modelData->booleanParameterData[1].info.info.lineStart = 2064;
+  modelData->booleanParameterData[1].info.info.colStart = 5;
+  modelData->booleanParameterData[1].info.info.lineEnd = 2065;
+  modelData->booleanParameterData[1].info.info.colEnd = 56;
+  modelData->booleanParameterData[1].info.info.readonly = 0;
+  modelData->booleanParameterData[1].attribute.fixed = 1;
+  modelData->booleanParameterData[1].attribute.start = 1;
+}

+ 8 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_literals.h

@@ -0,0 +1,8 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif

+ 91 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_model.h

@@ -0,0 +1,91 @@
+/* Simulation code for StategraphSample generated by the OpenModelica Compiler v1.12.0-dev-77-g56dc448 (32-bit). */
+#if !defined(StategraphSample__MODEL_H)
+#define StategraphSample__MODEL_H
+#include "openmodelica.h"
+#include "openmodelica_func.h"
+#include "simulation_data.h"
+#include "simulation/simulation_info_json.h"
+#include "simulation/simulation_runtime.h"
+#include "util/omc_error.h"
+#include "simulation/solver/model_help.h"
+#include "simulation/solver/delay.h"
+#include "simulation/solver/linearSystem.h"
+#include "simulation/solver/nonlinearSystem.h"
+#include "simulation/solver/mixedSystem.h"
+
+#include <string.h>
+
+#include "StategraphSample_functions.h"
+
+#define Modelica_StateGraph_Temporary_anyTrue_index 0
+
+extern void StategraphSample_callExternalObjectConstructors(DATA *data, threadData_t *threadData);
+extern void StategraphSample_callExternalObjectDestructors(DATA *_data, threadData_t *threadData);
+#if !defined(OMC_NUM_NONLINEAR_SYSTEMS) || OMC_NUM_NONLINEAR_SYSTEMS>0
+#endif
+#if !defined(OMC_NUM_LINEAR_SYSTEMS) || OMC_NUM_LINEAR_SYSTEMS>0
+#endif
+#if !defined(OMC_NUM_MIXED_SYSTEMS) || OMC_NUM_MIXED_SYSTEMS>0
+#endif
+#if !defined(OMC_NO_STATESELECTION)
+extern void StategraphSample_initializeStateSets(int nStateSets, STATE_SET_DATA* statesetData, DATA *data);
+#endif
+extern int StategraphSample_functionAlgebraics(DATA *data, threadData_t *threadData);
+extern int StategraphSample_function_storeDelayed(DATA *data, threadData_t *threadData);
+extern int StategraphSample_updateBoundVariableAttributes(DATA *data, threadData_t *threadData);
+extern int StategraphSample_functionInitialEquations(DATA *data, threadData_t *threadData);
+extern int StategraphSample_functionInitialEquations_lambda0(DATA *data, threadData_t *threadData);
+extern int StategraphSample_functionRemovedInitialEquations(DATA *data, threadData_t *threadData);
+extern int StategraphSample_updateBoundParameters(DATA *data, threadData_t *threadData);
+extern int StategraphSample_checkForAsserts(DATA *data, threadData_t *threadData);
+extern int StategraphSample_function_ZeroCrossingsEquations(DATA *data, threadData_t *threadData);
+extern int StategraphSample_function_ZeroCrossings(DATA *data, threadData_t *threadData, double* gout);
+extern int StategraphSample_function_updateRelations(DATA *data, threadData_t *threadData, int evalZeroCross);
+extern int StategraphSample_checkForDiscreteChanges(DATA *data, threadData_t *threadData);
+extern const char* StategraphSample_zeroCrossingDescription(int i, int **out_EquationIndexes);
+extern const char* StategraphSample_relationDescription(int i);
+extern void StategraphSample_function_initSample(DATA *data, threadData_t *threadData);
+extern int StategraphSample_initialAnalyticJacobianG(void* data, threadData_t *threadData);
+extern int StategraphSample_initialAnalyticJacobianA(void* data, threadData_t *threadData);
+extern int StategraphSample_initialAnalyticJacobianB(void* data, threadData_t *threadData);
+extern int StategraphSample_initialAnalyticJacobianC(void* data, threadData_t *threadData);
+extern int StategraphSample_initialAnalyticJacobianD(void* data, threadData_t *threadData);
+extern int StategraphSample_functionJacG_column(void* data, threadData_t *threadData);
+extern int StategraphSample_functionJacA_column(void* data, threadData_t *threadData);
+extern int StategraphSample_functionJacB_column(void* data, threadData_t *threadData);
+extern int StategraphSample_functionJacC_column(void* data, threadData_t *threadData);
+extern int StategraphSample_functionJacD_column(void* data, threadData_t *threadData);
+extern const char* StategraphSample_linear_model_frame(void);
+extern const char* StategraphSample_linear_model_datarecovery_frame(void);
+extern int StategraphSample_mayer(DATA* data, modelica_real** res, short *);
+extern int StategraphSample_lagrange(DATA* data, modelica_real** res, short *, short *);
+extern int StategraphSample_pickUpBoundsForInputsInOptimization(DATA* data, modelica_real* min, modelica_real* max, modelica_real*nominal, modelica_boolean *useNominal, char ** name, modelica_real * start, modelica_real * startTimeOpt);
+extern int StategraphSample_setInputData(DATA *data, const modelica_boolean file);
+extern int StategraphSample_getTimeGrid(DATA *data, modelica_integer * nsi, modelica_real**t);
+extern void StategraphSample_function_initSynchronous(DATA * data, threadData_t *threadData);
+extern void StategraphSample_function_updateSynchronous(DATA * data, threadData_t *threadData, long i);
+extern int StategraphSample_function_equationsSynchronous(DATA * data, threadData_t *threadData, long i);
+extern void StategraphSample_read_input_fmu(MODEL_DATA* modelData, SIMULATION_INFO* simulationData);
+extern void StategraphSample_function_savePreSynchronous(DATA *data, threadData_t *threadData);
+extern int StategraphSample_inputNames(DATA* data, char ** names);
+extern int StategraphSample_initializeDAEmodeData(DATA *data, DAEMODE_DATA*);
+extern int StategraphSample_functionLocalKnownVars(DATA*, threadData_t*);
+
+#include "StategraphSample_literals.h"
+
+
+
+
+#if defined(HPCOM) && !defined(_OPENMP)
+  #error "HPCOM requires OpenMP or the results are wrong"
+#endif
+#if defined(_OPENMP)
+  #include <omp.h>
+#else
+  /* dummy omp defines */
+  #define omp_get_max_threads() 1
+#endif
+
+#endif
+
+

+ 13 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/StategraphSample_records.c

@@ -0,0 +1,13 @@
+/* Additional record code for StategraphSample generated by the OpenModelica Compiler v1.12.0-dev-77-g56dc448 (32-bit). */
+
+#include "meta/meta_modelica.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+

+ 242 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/configure.ac

@@ -0,0 +1,242 @@
+ Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.63])
+AC_INIT([OpenModelica Exported FMU],[dev],[https://trac.openmodelica.org/OpenModelica],[openmodelica],[https://openmodelica.org])
+
+AC_SUBST(AR)
+AC_SUBST(DLLEXT)
+AC_SUBST(FMIPLATFORM)
+AC_SUBST(NEED_DGESV)
+AC_SUBST(NEED_RUNTIME)
+AC_SUBST(LIBTYPE_STATIC)
+AC_SUBST(LIBTYPE_DYNAMIC)
+
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+AC_CANONICAL_TARGET
+
+build_short=$build_cpu-$build_os
+if test "$host_os" = "none"; then
+  host_short=$host_cpu
+else
+  host_short=$host_cpu-$host_os
+fi
+
+echo "build_short: $build_short"
+echo "host_short: $host_short"
+
+ORIGCC="$CC"
+
+dnl Checks for programs.
+AC_LANG([C])
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_MAKE_SET
+
+AC_MSG_CHECKING([for cross-compilation flags])
+if test "$host_short" = "$build_short"; then
+  # Not cross-compiling or found a good tool; don't need special flags
+  AC_MSG_RESULT([not cross-compiling])
+elif echo "$CC" | grep -q "$host_short" || echo "$CC" | grep -q "$host" || echo "$CC" | grep -q "$host_cpu"; then
+  AC_MSG_RESULT([not needed; $CC contains the prefix])
+elif test "$host_os" = "$build_os" && test "$host_short" = "x86_64"; then
+  CFLAGS_BEFORE="$CFLAGS"
+  CFLAGS="$CFLAGS -m64"
+  AC_TRY_LINK([void abc() {}], [abc();], [AC_MSG_RESULT([-m64])], [AC_MSG_ERROR([-m64 not working])])
+elif test "$host_os" = "$build_os" && echo "$host_short" | grep -q "i.86"; then
+  CFLAGS_BEFORE="$CFLAGS"
+  CFLAGS="$CFLAGS -m32"
+  LDFLAGS="$LDFLAGS -m32"
+  AC_TRY_LINK([void abc() {}], [abc();], [AC_MSG_RESULT([-m32])], [AC_MSG_ERROR([-m32 not working])])
+elif test ! -z "$ORIGCC"; then
+  AC_MSG_RESULT([user sent an explicit CC=$ORIGCC. Trusting the user.])
+else
+  CC="$host-cc"
+  if which $host-cc > /dev/null 2>&1; then
+    CC="$host-cc"
+  else
+    CC=clang
+    CFLAGS="$CFLAGS -target $host"
+  fi
+  AC_TRY_LINK([void abc() {}], [abc();], [AC_MSG_RESULT([$CC $CFLAGS])], [AC_MSG_ERROR([unknown platform and $CC $CFLAGS not working])])
+fi
+
+if false; then
+CC_BEFORE="$CC"
+CC="clang -target $host_short"
+AC_MSG_CHECKING([looking for $CC to replace $CC_BEFORE])
+AC_TRY_LINK([void abc() {}], [abc();], [AC_MSG_RESULT([yes])], [CC="$CC_BEFORE";AC_MSG_RESULT([no])])
+fi
+
+CFLAGS_BEFORE="$CFLAGS"
+CFLAGS="$CFLAGS -Werror"
+AC_MSG_CHECKING([if -Werror works])
+AC_TRY_LINK([void abc() {}], [abc();], [AC_MSG_RESULT([ok])], [AC_MSG_ERROR([failed (check your CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS CPPFLAGS=$CPPFLAGS)])])
+CFLAGS="$CFLAGS_BEFORE"
+
+LDFLAGS_BEFORE="$LDFLAGS"
+LDFLAGS="$LDFLAGS -Wl,--no-undefined -Werror"
+AC_MSG_CHECKING([looking for --no-undefined])
+AC_TRY_LINK([void abc() {}], [abc();], [AC_MSG_RESULT([yes]);LD_NOUNDEFINED=" -Wl,--no-undefined"], [AC_MSG_RESULT([no])])
+LDFLAGS="$LDFLAGS_BEFORE"
+
+dnl Enable to handle AVR pre-processor not handling $ as symbol names; but fails on assembler anyway
+
+AC_MSG_CHECKING([looking for dollars in identifiers])
+AC_TRY_LINK([
+void $a$b$c() {}
+#define $a$b$c$d $a$b$c
+], [$a$b$c$d();], [AC_MSG_RESULT([not needed])], [
+  CPPFLAGS="$CPPFLAGS -fdollars-in-identifiers"
+  AC_TRY_LINK([
+    void fx() {}
+    #define \$a\$b fx
+    ], [\$a\$b();], [AC_MSG_RESULT([CPPFLAGS: -fdollars-in-identifiers])], [
+    AC_MSG_ERROR([the compiler does not handle dollar in identifiers])
+  ])
+])
+
+dnl Disables the default CFLAGS="-g -O2"
+
+AC_ARG_ENABLE(static, [  --enable-static], [
+  if test "$enableval" = "yes"; then
+    LIBTYPE_STATIC=1
+  elif test "$enableval" = "no"; then
+    LIBTYPE_STATIC=0
+  else
+    AC_MSG_ERROR([Unknown value --enable-static=$withval (use yes or no, or no value)])
+  fi
+], [LIBTYPE_STATIC=0])
+
+AC_ARG_ENABLE(shared, [  --disable-shared], [
+  if test "$enableval" = "yes"; then
+    LIBTYPE_DYNAMIC=1
+  elif test "$enableval" = "no"; then
+    LIBTYPE_DYNAMIC=0
+  else
+    AC_MSG_ERROR([Unknown value --enable-dynamic=$withval (use yes or no, or no value)])
+  fi
+], [LIBTYPE_DYNAMIC=1])
+
+if test "$LIBTYPE_DYNAMIC" = 0 -a "$LIBTYPE_STATIC" = 0; then
+  AC_MSG_ERROR([Need to --enable-shared or --enable-static (both were disabled)])
+fi
+
+if test "$LIBTYPE_DYNAMIC" = 1; then
+  LDFLAGS="$LDFLAGS -shared"
+fi
+
+if test "$LIBTYPE_STATIC" = 1; then
+  AC_CHECK_TOOL([AR], [ar], [:])
+  if test "$AR" = ":"; then
+    AC_MSG_ERROR([Did not find a suitable ar])
+  fi
+fi
+
+
+TRY_FLAGS="-fno-stack-protector -Wno-parentheses-equality -Wno-unused-variable -fPIC"
+
+for flag in $TRY_FLAGS; do
+  OLD_CFLAGS="$CFLAGS"
+  CFLAGS="$RUNTIMECFLAGS $flag -Werror"
+  AC_TRY_LINK([], [return 0;], [CFLAGS="$OLD_CFLAGS $flag"],[CFLAGS="$OLD_CFLAGS"])
+done
+
+TRY_FLAGS="-static-libgcc"
+for flag in $TRY_FLAGS; do
+  OLD_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $flag"
+  AC_TRY_LINK([], [return 0;], [LDFLAGS="$OLD_LDFLAGS $flag"],[LDFLAGS="$OLD_LDFLAGS"])
+done
+
+if test "`getconf LONG_BIT`" = "32"; then
+dnl Simulations spin forever unless -msse2 -mfpmath=sse is set
+
+CFLAGS_BEFORE=$CFLAGS
+CFLAGS="-mfpmath=sse -Werror"
+AC_MSG_CHECKING([for floating point bugs])
+AC_TRY_LINK([int abc() {}], [abc();], [AC_MSG_RESULT([force SSE2]); FPMATHFORTRAN="-msse -mfpmath=sse"], [AC_MSG_RESULT([no]); FPMATHFORTRAN=-ffloat-store])
+CFLAGS=$CFLAGS_BEFORE
+
+fi # End x86-specific CFLAGS
+
+dnl Checks for libraries.
+
+dnl Checks for header files.
+AC_HEADER_STDC
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_SIZE_T
+
+dnl Checks for library functions.
+AC_FUNC_VPRINTF
+AC_CHECK_FUNCS(strdup strerror)
+
+m4_include([../../../../m4/lapack.m4])
+OMC_AC_LAPACK(static)
+if test -z "$LD_LAPACK"; then
+  NEED_DGESV=1
+else
+  LIBS="$LIBS $LD_LAPACK"
+fi
+
+AC_MSG_CHECKING([for static pthreads])
+OLDLIBS=$LIBS
+LIBS="$OLDLIBS -Wl,-Bstatic -lpthread -Wl,-Bdynamic"
+AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_mutex_lock])],[AC_MSG_RESULT([OK (static)])],[
+  AC_MSG_RESULT([no])
+  LIBS="$OLDLIBS"
+  AC_CHECK_LIB(pthread,[pthread_mutex_lock],[],[
+    if test "$LIBTYPE_DYNAMIC" = 1; then
+      AC_MSG_ERROR([pthreads not found and requested dynamic linking])
+    else
+      AC_MSG_RESULT([pthreads disabled])
+      CPPFLAGS="$CPPFLAGS -DOMC_NO_THREADS"
+    fi
+  ])
+])
+
+AC_CHECK_LIB([m],[cos],[],[AC_MSG_ERROR([math library not found])])
+
+AC_MSG_CHECKING([for filesystem access])
+AC_TRY_LINK([#include <stdio.h>], [fopen("a.txt", "r");], [AC_MSG_RESULT([OK])], [AC_MSG_RESULT([no]); CPPFLAGS="$CPPFLAGS -DOMC_NO_FILESYSTEM"])
+
+AC_ARG_WITH(dynamic-om-runtime,  [  --with-dynamic-om-runtime    (uses the OMC runtime as a shared object instead of compiling it statically into the the FMU.)],[OPENMODELICADYNAMIC=yes],[OPENMODELICADYNAMIC=no])
+
+if test "$OPENMODELICADYNAMIC" = "no"; then
+  CPPFLAGS="$CPPFLAGS -DOMC_MINIMAL_RUNTIME=1 -DCMINPACK_NO_DLL=1"
+  NEED_RUNTIME=1
+fi
+
+if echo "$host_os" | grep -q darwin; then
+  DLLEXT=".dylib"
+  if echo "$host_cpu" | grep -q i@<:@3456@:>@86; then
+    FMIPLATFORM=darwin32
+  elif echo "$host_cpu" | grep -q x86_64; then
+    FMIPLATFORM=darwin64
+  fi
+elif echo "$host_os" | grep -q mingw; then
+  DLLEXT=".dll"
+  if echo "$host_cpu" | grep -q i@<:@3456@:>@86; then
+    FMIPLATFORM=win32
+  elif echo "$host_cpu" | grep -q x86_64; then
+    FMIPLATFORM=win64
+  fi
+elif echo "$host_os" | grep -q linux; then
+  DLLEXT=".so"
+  if echo "$host_cpu" | grep -q i@<:@3456@:>@86; then
+    FMIPLATFORM=linux32
+  elif echo "$host_cpu" | grep -q x86_64; then
+    FMIPLATFORM=linux64
+  fi
+else
+  DLLEXT=".so"
+fi
+
+# Non-standard platforms also need some love
+if test -z "$FMIPLATFORM"; then
+  FMIPLATFORM=$host_short
+fi
+
+AC_OUTPUT(Makefile)

File diff suppressed because it is too large
+ 184 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/Makefile.objs


+ 113 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/ModelicaUtilities.h

@@ -0,0 +1,113 @@
+#ifndef MODELICA_UTILITIES_H
+#define MODELICA_UTILITIES_H
+
+#include <stddef.h>
+#include <stdarg.h>
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Utility functions which can be called by external Modelica functions.
+
+   These functions are defined in section 12.8.6 of the
+   Modelica Specification 3.0 and section 12.9.6 of the
+   Modelica Specification 3.1 and 3.2.
+
+   A generic C-implementation of these functions cannot be given,
+   because it is tool dependent how strings are output in a
+   window of the respective simulation tool. Therefore, only
+   this header file is shipped with the Modelica Standard Library.
+*/
+
+/*
+ * Some of the functions never return to the caller. In order to compile
+ * external Modelica C-code in most compilers, noreturn attributes need to
+ * be present to avoid warnings or errors.
+ *
+ * The following macros handle noreturn attributes according to the latest
+ * C11/C++11 standard with fallback to GNU or MSVC extensions if using an
+ * older compiler.
+ */
+#if __STDC_VERSION__ >= 201112L
+#define MODELICA_NORETURN _Noreturn
+#define MODELICA_NORETURNATTR
+#elif __cplusplus >= 201103L
+#define MODELICA_NORETURN [[noreturn]]
+#define MODELICA_NORETURNATTR
+#elif defined(__GNUC__)
+#define MODELICA_NORETURN
+#define MODELICA_NORETURNATTR __attribute__((noreturn))
+#elif defined(_MSC_VER)
+#define MODELICA_NORETURN __declspec(noreturn)
+#define MODELICA_NORETURNATTR
+#else
+#define MODELICA_NORETURN
+#define MODELICA_NORETURNATTR
+#endif
+
+void ModelicaMessage(const char *string);
+/*
+Output the message string (no format control).
+*/
+
+
+void ModelicaFormatMessage(const char *string,...);
+  /*
+Output the message under the same format control as the C-function printf.
+  */
+
+
+void ModelicaVFormatMessage(const char *string, va_list);
+  /*
+Output the message under the same format control as the C-function vprintf.
+  */
+
+
+MODELICA_NORETURN void ModelicaError(const char *string) MODELICA_NORETURNATTR;
+/*
+Output the error message string (no format control). This function
+never returns to the calling function, but handles the error
+similarly to an assert in the Modelica code.
+*/
+
+
+MODELICA_NORETURN void ModelicaFormatError(const char *string,...) MODELICA_NORETURNATTR;
+/*
+Output the error message under the same format control as the C-function
+printf. This function never returns to the calling function,
+but handles the error similarly to an assert in the Modelica code.
+*/
+
+
+MODELICA_NORETURN void ModelicaVFormatError(const char *string, va_list) MODELICA_NORETURNATTR;
+/*
+Output the error message under the same format control as the C-function
+vprintf. This function never returns to the calling function,
+but handles the error similarly to an assert in the Modelica code.
+*/
+
+
+char* ModelicaAllocateString(size_t len);
+/*
+Allocate memory for a Modelica string which is used as return
+argument of an external Modelica function. Note, that the storage
+for string arrays (= pointer to string array) is still provided by the
+calling program, as for any other array. If an error occurs, this
+function does not return, but calls "ModelicaError".
+*/
+
+
+char* ModelicaAllocateStringWithErrorReturn(size_t len);
+/*
+Same as ModelicaAllocateString, except that in case of error, the
+function returns 0. This allows the external function to close files
+and free other open resources in case of error. After cleaning up
+resources use ModelicaError or ModelicaFormatError to signal
+the error.
+*/
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif

+ 910 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/ParModelica/explicit/openclrt/OCLRuntimeUtil.cl

@@ -0,0 +1,910 @@
+/*
+ * This file is part of OpenModelica.
+ *
+ * Copyright (c) 1998-CurrentYear, Linköping University,
+ * Department of Computer and Information Science,
+ * SE-58183 Linköping, Sweden.
+ *
+ * All rights reserved.
+ *
+ * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
+ * AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
+ * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
+ * ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
+ *
+ * The OpenModelica software and the Open Source Modelica
+ * Consortium (OSMC) Public License (OSMC-PL) are obtained
+ * from Linköping University, either from the above address,
+ * from the URLs: http://www.ida.liu.se/projects/OpenModelica or
+ * http://www.openmodelica.org, and in the OpenModelica distribution.
+ * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without
+ * even the implied warranty of  MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
+ * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
+ * OF OSMC-PL.
+ *
+ * See the full OSMC Public License conditions for more details.
+ *
+ */
+
+
+/*
+
+ This file contains functions and objects used at runtime
+ by OpenCL code. This file is included in every OpenCL
+ computation from modelica. It provides utilities when running
+ computations on GPUs and also on CPUs in OpenCL mode.
+
+ It is the OpenCL counterpart of the C runtime for
+ normal modelica execution.
+
+ Mahder.Gebremedhin@liu.se  2012-03-31
+
+*/
+
+
+#ifdef cl_amd_printf
+  #pragma OPENCL EXTENSION cl_amd_printf : enable
+  #define PRINTF_AVAILABLE
+#endif
+
+#ifdef cl_intel_printf
+  #pragma OPENCL EXTENSION cl_intel_printf : enable
+  #define PRINTF_AVAILABLE
+#endif
+
+#ifdef PRINTF_AVAILABLE
+  #define omc_assert(td,i,s) (printf("Assertion: %s, Line %d, info %d\n", s, __LINE__, i))
+  #define omc_assert_withEquationIndexes(td,i,idx,s) (printf("Assertion: %s, Line %d, info %d\n", s, __LINE__, i))
+  #define throwStreamPrint(td,str,exp) (printf("Assertion: %s\n, expression %s, Line %d\n", str, exp, __LINE__))
+  #define printline() printf("At line %d\n", __LINE__)
+#else
+  #define omc_assert(td,i,s)
+  #define omc_assert_withEquationIndexes(td,i,idx,s)
+  #define throwStreamPrint(td,str,exp)
+  #define printline()
+#endif
+
+#ifdef cl_khr_fp64
+  #pragma OPENCL EXTENSION cl_khr_fp64 : enable
+  #define DOUBLE_PREC_AVAILABLE
+#endif
+
+#ifdef cl_amd_fp64
+  #pragma OPENCL EXTENSION cl_amd_fp64 : enable
+  #define DOUBLE_PREC_AVAILABLE
+#endif
+
+
+#define FILE_INFO modelica_integer
+#define threadData_t integer
+#define threadData NULL
+#define omc_dummyFileInfo __LINE__
+
+#define sin(v,m) (sin(v))
+#define cos(v,m) (cos(v))
+
+#ifdef DOUBLE_PREC_AVAILABLE
+typedef long  modelica_integer;
+typedef double modelica_real;
+#else
+typedef float modelica_real;
+typedef int  modelica_integer;
+#endif
+
+typedef bool modelica_boolean;
+typedef modelica_integer _index_t;
+
+
+#define state modelica_boolean
+
+modelica_boolean get_memory_state() {return true;}
+void restore_memory_state(modelica_boolean in_state) {}
+
+
+struct gr_array
+{
+    int ndims;
+    __global modelica_integer* dim_size;
+    __global modelica_real* data;
+};
+
+struct gi_array
+{
+    int ndims;
+    __global modelica_integer* dim_size;
+    __global modelica_integer* data;
+};
+typedef struct gr_array real_array;
+typedef struct gi_array integer_array;
+
+struct lr_array
+{
+    int ndims;
+    local modelica_integer* dim_size;
+    local modelica_real* data;
+};
+
+struct li_array
+{
+    int ndims;
+    local modelica_integer* dim_size;
+    local modelica_integer* data;
+};
+typedef struct lr_array local_real_array;
+typedef struct li_array local_integer_array;
+
+
+// ParModelica versions of OpenCL thread managment functions.
+// They start counting from 0. Parmodelica/Modelica starts from 1.
+modelica_integer  oclGetGlobalId(modelica_integer dim) {
+    return get_global_id(dim - 1) + 1;
+}
+
+modelica_integer  oclGetLocalId(modelica_integer dim) {
+    return get_local_id(dim - 1) + 1;
+}
+
+modelica_integer  oclGetLocalSize(modelica_integer dim) {
+    return get_local_size(dim - 1);
+}
+
+modelica_integer  oclGetGlobalSize(modelica_integer dim) {
+    return get_global_size(dim - 1);
+}
+
+modelica_integer  oclGetGroupId(modelica_integer dim) {
+    return get_group_id(dim - 1) + 1;
+}
+
+modelica_integer  oclGetNumGroups(modelica_integer dim) {
+    return get_num_groups(dim - 1);
+}
+
+#define oclGlobalBarrier() barrier(CLK_GLOBAL_MEM_FENCE)
+#define oclLocalBarrier() barrier(CLK_LOCAL_MEM_FENCE)
+
+
+
+inline int in_range_integer(modelica_integer i,
+         modelica_integer start,
+         modelica_integer stop)
+{
+  if (start <= stop) {
+      if ((i >= start) && (i <= stop)) {
+          return 1;
+      }
+  } else {
+      if ((i >= stop) && (i <= start)) {
+          return 1;
+      }
+  }
+  return 0;
+}
+
+inline int in_range_real(modelica_real i,
+      modelica_real start,
+      modelica_real stop)
+{
+  if (start <= stop) {
+      if ((i >= start) && (i <= stop)) {
+          return 1;
+      }
+  } else {
+      if ((i >= stop) && (i <= start)) {
+          return 1;
+      }
+  }
+  return 0;
+}
+
+
+size_t integer_array_nr_of_elements(integer_array *a)
+{
+    int i;
+    size_t nr_of_elements = 1;
+    for (i = 0; i < a->ndims; ++i) {
+       nr_of_elements *= a->dim_size[i];
+    }
+    return nr_of_elements;
+}
+
+size_t real_array_nr_of_elements(real_array *a)
+{
+    int i;
+    size_t nr_of_elements = 1;
+    for (i = 0; i < a->ndims; ++i) {
+       nr_of_elements *= a->dim_size[i];
+    }
+    return nr_of_elements;
+}
+
+void copy_integer_array_data(integer_array *source, integer_array *dest)
+{
+    size_t i, nr_of_elements;
+
+
+    nr_of_elements = integer_array_nr_of_elements(source);
+
+    for (i = 0; i < nr_of_elements; ++i) {
+        ((__global modelica_integer *) dest->data)[i] = ((__global modelica_integer *) source->data)[i];
+    }
+}
+
+void copy_real_array_data(real_array *source, real_array *dest)
+{
+    size_t i, nr_of_elements;
+
+
+    nr_of_elements = real_array_nr_of_elements(source);
+
+    for (i = 0; i < nr_of_elements; ++i) {
+        ((__global modelica_real *) dest->data)[i] = ((__global modelica_real *) source->data)[i];
+    }
+}
+
+
+
+#define integer_array_element_addr_c99_1(L, d, i) (((L)->data) + i - 1)
+#define integer_array_element_addr_c99_2(L, d, i, j) ((((L)->data)) + (i - 1)*((L)->dim_size[1]) + (j - 1))
+
+#define real_array_element_addr_c99_1(L, d, i) (((L)->data) + i - 1)
+#define real_array_element_addr_c99_2(L, d, i, j) ((((L)->data)) + (i - 1)*((L)->dim_size[1]) + (j - 1))
+
+
+
+// typedef modelica_real cos_rettype;
+// typedef modelica_real cosh_rettype;
+// typedef modelica_real acos_rettype;
+// typedef modelica_real sin_rettype;
+// typedef modelica_real sinh_rettype;
+// typedef modelica_real asin_rettype;
+// typedef modelica_real log_rettype;
+// typedef modelica_real log10_rettype;
+// typedef modelica_real tan_rettype;
+// typedef modelica_real tanh_rettype;
+// typedef modelica_real atan_rettype;
+// typedef modelica_real exp_rettype;
+// typedef modelica_real sqrt_rettype;
+// typedef modelica_real atan2_rettype;
+// typedef modelica_real div_rettype;
+// typedef modelica_real mod_rettype;
+
+
+// ///////////////////////////////////////////////////////////
+// //memory_pool
+
+// #define NR_REAL_ELEMENTS    1024
+// #define NR_INTEGER_ELEMENTS 1024
+// #define NR_BOOLEAN_ELEMENTS 1
+// #define NR_SIZE_ELEMENTS    100
+
+// #define PRECENTAGE_REAL_BUFFER       40
+// #define PRECENTAGE_INTEGER_BUFFER     40
+// #define PRECENTAGE_BOOLEAN_BUFFER    15
+// #define PRECENTAGE_SIZE_BUFFER        5
+
+
+// struct gr_array
+// {
+    // int ndims;
+    // __global modelica_integer* dim_size;
+    // __global modelica_real* data;
+// };
+
+// struct gi_array
+// {
+    // int ndims;
+    // __global modelica_integer* dim_size;
+    // __global modelica_integer* data;
+// };
+// typedef struct gr_array real_array;
+// typedef struct gi_array integer_array;
+
+// struct lr_array
+// {
+    // int ndims;
+    // __local modelica_integer* dim_size;
+    // __local modelica_real* data;
+// };
+
+// struct li_array
+// {
+    // int ndims;
+    // __local modelica_integer* dim_size;
+    // __local modelica_integer* data;
+// };
+// typedef __local struct lr_array local_real_array;
+// typedef __local struct li_array local_integer_array;
+
+
+
+// // HELL starts here. Enjoy!
+
+// struct local_state_s {
+  // _index_t real_count;
+  // _index_t integer_count;
+  // _index_t boolean_count;
+  // _index_t size_count;
+  // __local modelica_real* local_real_buffer_ptr;
+  // __local modelica_integer* local_integer_buffer_ptr;
+  // __local modelica_boolean* local_boolean_buffer_ptr;
+  // __local modelica_integer* local_size_buffer_ptr;
+// };
+// typedef __local struct local_state_s local_state;
+
+// struct global_state_s {
+  // __global modelica_real* global_real_buffer_ptr;
+  // __global modelica_integer* global_integer_buffer_ptr;
+  // __global modelica_boolean* global_boolean_buffer_ptr;
+  // __global modelica_integer* global_size_buffer_ptr;
+// };
+// typedef struct global_state_s global_state;
+
+
+// struct state_s{
+  // global_state saved_global_state;
+  // local_state saved_local_state;
+// };
+// typedef struct state_s state;
+
+// struct buffer_s{
+  // __global modelica_real* global_real_buffer;
+  // __global modelica_integer* global_integer_buffer;
+  // __global modelica_boolean* global_boolean_buffer;
+  // __global modelica_integer* global_size_buffer;
+  // __local modelica_real* local_real_buffer;
+  // __local modelica_integer* local_integer_buffer;
+  // __local modelica_boolean* local_boolean_buffer;
+  // __local modelica_integer* local_size_buffer;
+// };
+// typedef struct buffer_s buffer;
+
+
+// struct memory_s{
+    // global_state* current_global_state;
+    // local_state* current_local_state;
+    // buffer* data_buffer;
+// };
+// typedef struct memory_s memory;
+
+// /*
+// void print_memory_state(memory* m)
+// {
+  // printf("=== Current state ===\n");
+  // printf("real ptr at: %d\n",(int)m->current_global_state->global_real_buffer_ptr);
+  // printf("integer ptr at: %d\n",(int)m->current_global_state->global_integer_buffer_ptr);
+  // printf("boolean ptr at: %d\n",(int)m->current_global_state->global_boolean_buffer_ptr);
+  // printf("size ptr at: %d\n",(int)m->current_global_state->global_size_buffer_ptr);
+  // printf("real counter at: %d\n",(int)m->current_global_state->real_count);
+  // printf("integer counter at: %d\n",(int)m->current_global_state->integer_count);
+  // printf("boolean counter at: %d\n",(int)m->current_global_state->boolean_count);
+  // printf("size counter at: %d\n",(int)m->current_global_state->size_count);
+// }
+
+
+// void print_state(state* m)
+// {
+  // printf("=== Current state ===\n");
+  // printf("real ptr at: %d\n",(int)m->global_real_buffer_ptr);
+  // printf("integer ptr at: %d\n",(int)m->global_integer_buffer_ptr);
+  // printf("boolean ptr at: %d\n",(int)m->global_boolean_buffer_ptr);
+  // printf("size ptr at: %d\n",(int)m->global_size_buffer_ptr);
+  // printf("real counter at: %d\n",(int)m->real_count);
+  // printf("integer counter at: %d\n",(int)m->integer_count);
+  // printf("boolean counter at: %d\n",(int)m->boolean_count);
+  // printf("size counter at: %d\n",(int)m->size_count);
+// }
+
+
+// */
+// void initialize_global_buffer(__global void* exec_buffer, modelica_integer buffer_size, memory* current_memory){
+    // size_t num_threads = 1;
+    // size_t ndims = get_work_dim();
+    // for(int i = 0; i < ndims; i++)
+        // num_threads *= get_global_size(i);
+
+    // size_t universalId;
+    // if(ndims == 1)
+        // universalId = get_global_id(0);
+    // else if(ndims == 2)
+        // universalId = get_global_id(1)*get_global_size(0) + get_global_id(0);
+    // else if(ndims == 3)
+        // universalId = get_global_id(2)*get_global_size(1)*get_global_size(0) + get_global_id(1)*get_global_size(0) + get_global_id(0);
+
+
+// typedef __global void* global_void_ptr;
+
+    // global_void_ptr  thread_buff_start;
+    // size_t buffer_per_thread;
+    // size_t real_buffer_per_thread;
+    // size_t integer_buffer_per_thread;
+    // size_t boolean_buffer_per_thread;
+    // size_t size_buffer_per_thread;
+
+    // buffer_per_thread = (buffer_size/num_threads);
+    // thread_buff_start = exec_buffer + universalId*buffer_per_thread;
+
+    // global_void_ptr real_start = thread_buff_start;
+    // current_memory->data_buffer->global_real_buffer = (__global modelica_real*)real_start;
+    // real_buffer_per_thread = (buffer_per_thread*PRECENTAGE_REAL_BUFFER)/100;
+
+    // global_void_ptr integer_start = real_start + real_buffer_per_thread;
+    // current_memory->data_buffer->global_integer_buffer = (__global modelica_integer*)integer_start;
+    // integer_buffer_per_thread = (buffer_per_thread*PRECENTAGE_INTEGER_BUFFER)/100;
+
+    // global_void_ptr size_start = integer_start + integer_buffer_per_thread;
+    // current_memory->data_buffer->global_size_buffer = (__global modelica_integer*)size_start;
+    // size_buffer_per_thread = (buffer_per_thread*PRECENTAGE_SIZE_BUFFER)/100;
+
+    // global_void_ptr boolean_start = size_start + size_buffer_per_thread;
+    // current_memory->data_buffer->global_boolean_buffer = (__global modelica_boolean*)boolean_start;
+    // boolean_buffer_per_thread = (buffer_per_thread*PRECENTAGE_BOOLEAN_BUFFER)/100;
+
+
+    // current_memory->current_global_state->global_real_buffer_ptr = current_memory->data_buffer->global_real_buffer;
+    // current_memory->current_global_state->global_integer_buffer_ptr = current_memory->data_buffer->global_integer_buffer;
+    // current_memory->current_global_state->global_size_buffer_ptr = current_memory->data_buffer->global_size_buffer;
+    // current_memory->current_global_state->global_boolean_buffer_ptr = current_memory->data_buffer->global_boolean_buffer;
+
+    // /*
+    // if(get_global_id(0) == 0){
+        // printf("execution buffer starts from %d\n", exec_buffer);
+        // printf("execution buffer per thread %d KB\n", buffer_per_thread/1024);
+        // printf("thread %d starts from %d\n", get_global_id(0), thread_buff_start);
+        // //printf("REAL buffer SIZE  %d KB\n", (integer_start - real_start)/1024);
+        // printf("max nr of real elements  %d\n", (integer_start - real_start)/sizeof(modelica_real));
+        // //printf("INTEGER buffer SIZE  %d KB\n", (boolean_start - integer_start)/1024);
+        // printf("max nr of integer elements  %d\n", (boolean_start - integer_start)/sizeof(modelica_integer));
+        // //printf("BOOLEAN buffer SIZE  %d B\n", (size_start - boolean_start));
+        // printf("max nr of boolean elements  %d\n", sizeof(modelica_boolean));
+        // //printf("SIZE buffer SIZE  %d KB\n", (thread_buff_start + buffer_per_thread - size_start)/1024);
+        // printf("max nr of size elements  %d\n", (thread_buff_start + buffer_per_thread - size_start)/sizeof(modelica_integer));
+        // //printf("execution buffer for this thread ends at %d\n", current_memory->data_buffer->global_size_buffer + size_buffer_per_thread);
+        // //printf("thread %d starts from %d\n", get_global_id(0) + 1, thread_buff_start + buffer_per_thread);
+        // print_current_global_state(current_memory);
+    // }
+    // */
+
+// ///////////////////////////////Global Memory initialized!////////////////////////////////////////////////////////////////////////
+
+// }
+
+// // HELL ends here. You made it! yay!
+
+
+
+// /*
+// state get_memory_state(){
+  // return current_state;
+// }
+// */
+
+// #define get_memory_state() (state){*(memory_state->current_global_state), *(memory_state->current_local_state)}; barrier(CLK_LOCAL_MEM_FENCE);
+
+// /*
+// void restore_memory_state(state s){
+    // current_state = s;
+// }
+// */
+
+// #define restore_memory_state(s) *(memory_state->current_global_state) = s.saved_global_state; *(memory_state->current_local_state) = s.saved_local_state; barrier(CLK_LOCAL_MEM_FENCE);
+
+// //memory_pool ends here.
+// ///////////////////////////////////////////////////////////
+
+
+// ///////////////////////////////////////////////////////////
+// //utility + builtin functions
+
+// int in_range_integer(modelica_integer i,
+         // modelica_integer start,
+         // modelica_integer stop)
+// {
+  // if (start <= stop) if ((i >= start) && (i <= stop)) return 1;
+  // if (start > stop) if ((i >= stop) && (i <= start)) return 1;
+  // return 0;
+// }
+
+// int in_range_real(modelica_real i,
+      // modelica_real start,
+      // modelica_real stop)
+// {
+  // if (start <= stop) if ((i >= start) && (i <= stop)) return 1;
+  // if (start > stop) if ((i >= stop) && (i <= start)) return 1;
+  // return 0;
+// }
+
+// modelica_real modelica_div(modelica_real x, modelica_real y)
+// {
+  // return (modelica_real)((modelica_integer)(x/y));
+// }
+
+// modelica_real modelica_mod_real(modelica_real x, modelica_real y)
+// {
+  // return (x - floor(x/y) * y);
+// }
+
+// modelica_integer modelica_mod_integer(modelica_integer x, modelica_integer y)
+// {
+  // return x % y;
+// }
+
+// modelica_real modelica_rem_real(modelica_real x, modelica_real y)
+// {
+  // return x - y*(modelica_div(x,y));
+// }
+
+// modelica_integer modelica_rem_integer(modelica_integer x, modelica_integer y)
+// {
+  // return x - y*((x/y));
+// }
+
+
+// //utility + builtin functions ends here
+// ///////////////////////////////////////////////////////////
+
+
+
+
+
+
+
+// ///////////////////////////////////////////////////////////
+// //Array related utilities
+
+
+// void alloc_integer_array_c99_1(integer_array* dest, int ndims, modelica_integer size_1, memory* memory_state)
+// {
+    // size_t elements = 0;
+    // _index_t start;
+    // dest->ndims = 1;
+
+    // //assert(n>=0);
+    // //assert(n + current_global_state.global_size_buffer_ptr < NR_SIZE_ELEMENTS);
+    // if( memory_state->current_global_state->global_size_buffer_ptr + 2 >= memory_state->current_global_state->global_boolean_buffer_ptr){
+        // //printf("Size buffer pointer passed limit\n");
+    // }
+
+    // dest->dim_size = memory_state->current_global_state->global_size_buffer_ptr;
+    // memory_state->current_global_state->global_size_buffer_ptr += 1;
+    // dest->dim_size[0] = size_1;
+
+    // elements = integer_array_nr_of_elements(dest);
+    // //assert(n>=0);
+    // //assert(current_global_state.global_integer_buffer_ptr +n < NR_INTEGER_ELEMENTS);
+    // if( memory_state->current_global_state->global_integer_buffer_ptr + elements >= memory_state->current_global_state->global_size_buffer_ptr){
+        // //printf("Integer buffer pointer passed limit\n");
+    // }
+
+    // dest->data = memory_state->current_global_state->global_integer_buffer_ptr;
+    // memory_state->current_global_state->global_integer_buffer_ptr += elements;
+// }
+
+// void alloc_real_array_c99_1(real_array* dest, int ndims, modelica_integer size_1, memory* memory_state)
+// {
+    // size_t elements = 0;
+    // _index_t start;
+    // dest->ndims = 1;
+
+    // //assert(n>=0);
+    // //assert(n + current_global_state.global_size_buffer_ptr < NR_SIZE_ELEMENTS);
+    // if( memory_state->current_global_state->global_size_buffer_ptr + 2 >= memory_state->current_global_state->global_boolean_buffer_ptr){
+        // //printf("Size buffer pointer passed limit\n");
+    // }
+    // dest->dim_size = memory_state->current_global_state->global_size_buffer_ptr;
+    // memory_state->current_global_state->global_size_buffer_ptr += 1;
+    // dest->dim_size[0] = size_1;
+
+    // elements = real_array_nr_of_elements(dest);
+    // //assert(n>=0);
+    // //assert(current_global_state.global_integer_buffer_ptr +n < NR_INTEGER_ELEMENTS);
+    // if( memory_state->current_global_state->global_real_buffer_ptr + elements >= memory_state->current_global_state->global_integer_buffer_ptr){
+        // //printf("Real buffer pointer passed limit\n");
+    // }
+
+    // dest->data = memory_state->current_global_state->global_real_buffer_ptr;
+    // memory_state->current_global_state->global_real_buffer_ptr += elements;
+
+// }
+
+
+// void alloc_integer_array_c99_2(integer_array* dest, int ndims, modelica_integer size_1, modelica_integer size_2, memory* memory_state)
+// {
+    // size_t elements = 0;
+    // _index_t start;
+    // dest->ndims = 2;
+
+    // //assert(n>=0);
+    // //assert(n + current_global_state->global_size_buffer_ptr < NR_SIZE_ELEMENTS);
+    // if( memory_state->current_global_state->global_size_buffer_ptr + 2 >= memory_state->current_global_state->global_boolean_buffer_ptr){
+        // //printf("Size buffer pointer passed limit\n");
+    // }
+    // dest->dim_size = memory_state->current_global_state->global_size_buffer_ptr;
+    // memory_state->current_global_state->global_size_buffer_ptr += 2;
+    // dest->dim_size[0] = size_1;
+    // dest->dim_size[1] = size_2;
+
+    // elements = integer_array_nr_of_elements(dest);
+    // //assert(n>=0);
+    // //assert(current_global_state->global_integer_buffer_ptr +n < NR_INTEGER_ELEMENTS);
+
+    // if( memory_state->current_global_state->global_integer_buffer_ptr + elements >= memory_state->current_global_state->global_size_buffer_ptr){
+        // //printf("Integer buffer pointer passed limit\n");
+    // }
+    // dest->data = memory_state->current_global_state->global_integer_buffer_ptr;
+    // memory_state->current_global_state->global_integer_buffer_ptr += elements;
+// }
+
+// void alloc_real_array_c99_2(real_array* dest, int ndims, modelica_integer size_1, modelica_integer size_2, memory* memory_state)
+// {
+    // size_t elements = 0;
+    // _index_t start;
+    // dest->ndims = 2;
+
+    // //assert(n>=0);
+    // //assert(n + current_global_state->global_size_buffer_ptr < NR_SIZE_ELEMENTS);
+    // if( memory_state->current_global_state->global_size_buffer_ptr + 2 >= memory_state->current_global_state->global_boolean_buffer_ptr){
+        // //printf("Size buffer pointer passed limit\n");
+    // }
+    // dest->dim_size = memory_state->current_global_state->global_size_buffer_ptr;
+    // memory_state->current_global_state->global_size_buffer_ptr += 2;
+    // dest->dim_size[0] = size_1;
+    // dest->dim_size[1] = size_2;
+
+    // elements = real_array_nr_of_elements(dest);
+    // //assert(n>=0);
+    // //assert(current_global_state->global_integer_buffer_ptr +n < NR_INTEGER_ELEMENTS);
+
+    // if( memory_state->current_global_state->global_real_buffer_ptr + elements >= memory_state->current_global_state->global_integer_buffer_ptr){
+        // //printf("Real buffer pointer passed limit\n");
+    // }
+    // dest->data = memory_state->current_global_state->global_real_buffer_ptr;
+    // memory_state->current_global_state->global_real_buffer_ptr += elements;
+// }
+
+// void copy_integer_array_data(integer_array *source, integer_array *dest)
+// {
+    // size_t i, nr_of_elements;
+
+
+    // nr_of_elements = real_array_nr_of_elements(source);
+
+    // for (i = 0; i < nr_of_elements; ++i) {
+        // ((__global modelica_integer *) dest->data)[i] = ((__global modelica_integer *) source->data)[i];
+    // }
+// }
+
+// void copy_real_array_data(real_array *source, real_array *dest)
+// {
+    // size_t i, nr_of_elements;
+
+
+    // nr_of_elements = real_array_nr_of_elements(source);
+
+    // for (i = 0; i < nr_of_elements; ++i) {
+        // ((__global modelica_real *) dest->data)[i] = ((__global modelica_real *) source->data)[i];
+    // }
+// }
+
+// #define real_array_element_addr_c99_1(L, d, i) (((L)->data) + i - 1)
+// /*
+// __global modelica_real* real_array_element_addr_c99_1(real_array* L, int dim, modelica_integer i){
+    // return ((__global modelica_real*)(L->data)) + i - 1;
+// }
+
+// __local modelica_real* local_integer_array_element_addr_c99_1(local_real_array* L, int dim, modelica_integer i){
+    // return ((__local modelica_real*)(L->data)) + i - 1;
+// }
+// */
+
+// #define integer_array_element_addr_c99_1(L, d, i) (((L)->data) + i - 1)
+// /*
+// __global modelica_integer* integer_array_element_addr_c99_1(integer_array* L, int dim, modelica_integer i){
+    // return ((__global modelica_integer*)(L->data)) + i - 1;
+// }
+
+// __local modelica_integer* local_integer_array_element_addr_c99_1(local_integer_array* L, int dim, modelica_integer i){
+    // return ((__local modelica_integer*)(L->data)) + i - 1;
+// }
+// */
+
+// #define real_array_element_addr_c99_2(L, d, i, j) ((((L)->data)) + (i - 1)*((L)->dim_size[1]) + (j - 1))
+// /*
+// __global modelica_real* real_array_element_addr_c99_2(real_array* L, int dim, modelica_integer i, modelica_integer j){
+    // return ((__global modelica_real*)(L->data)) + (i - 1)*L->dim_size[1] + (j - 1);
+// }
+
+// __local modelica_real* real_array_element_addr_c99_2(local_real_array* L, int dim, modelica_integer i, modelica_integer j){
+    // return ((__local modelica_real*)(L->data)) + (i - 1)*L->dim_size[1] + (j - 1);
+// }
+// */
+
+// #define integer_array_element_addr_c99_2(L, d, i, j) ((((L)->data)) + (i - 1)*((L)->dim_size[1]) + (j - 1))
+// /*
+// __global modelica_integer* integer_array_element_addr_c99_2(integer_array* L, int dim, modelica_integer i, modelica_integer j){
+    // return ((__global modelica_integer*)(L->data)) + (i - 1)*L->dim_size[1] + (j - 1);
+// }
+
+// __local modelica_integer* integer_array_element_addr_c99_2(local_integer_array* L, int dim, modelica_integer i, modelica_integer j){
+    // return ((__local modelica_integer*)(L->data)) + (i - 1)*L->dim_size[1] + (j - 1);
+// }
+// */
+
+// #define real_array_element_addr_c99_3(L, d, i, j, k) ((((L)->data)) + (i - 1)*((L)->dim_size[1])*((L)->dim_size[2]) + (j - 1)*((L)->dim_size[2]) + (k - 1))
+// /*
+// __global modelica_real* real_array_element_addr_c99_3(real_array* L, int dim, modelica_integer i, modelica_integer j, modelica_integer k){
+    // return ((__global modelica_real*)(L->data)) + (i - 1)*L->dim_size[1]*L->dim_size[2] + (j - 1)*L->dim_size[2] + (k - 1);
+// }
+
+// __local modelica_real* real_array_element_addr_c99_3(local_real_array* L, int dim, modelica_integer i, modelica_integer j, modelica_integer k){
+    // return ((__local modelica_real*)(L->data)) + (i - 1)*L->dim_size[1]*L->dim_size[2] + (j - 1)*L->dim_size[2] + (k - 1);
+// }
+// */
+
+// #define integer_array_element_addr_c99_3(L, d, i, j, k) ((((L)->data)) + (i - 1)*((L)->dim_size[1])*((L)->dim_size[2]) + (j - 1)*((L)->dim_size[2]) + (k - 1))
+// /*
+// __global modelica_integer* integer_array_element_addr_c99_3(integer_array* L, int dim, modelica_integer i, modelica_integer j, modelica_integer k){
+    // return ((__global modelica_integer*)(L->data)) + (i - 1)*L->dim_size[1]*L->dim_size[2] + (j - 1)*L->dim_size[2] + (k - 1);
+// }
+
+// __local modelica_integer* integer_array_element_addr_c99_3(local_integer_array* L, int dim, modelica_integer i, modelica_integer j, modelica_integer k){
+    // return ((__local modelica_integer*)(L->data)) + (i - 1)*L->dim_size[1]*L->dim_size[2] + (j - 1)*L->dim_size[2] + (k - 1);
+// }
+// */
+
+// //uArray related utilities end here
+// ///////////////////////////////////////////////////////////
+
+
+
+
+// size_t local_integer_array_nr_of_elements(local_integer_array *a)
+// {
+    // int i;
+    // size_t nr_of_elements = 1;
+    // for (i = 0; i < a->ndims; ++i) {
+       // nr_of_elements *= a->dim_size[i];
+    // }
+    // return nr_of_elements;
+// }
+
+// size_t local_real_array_nr_of_elements(local_real_array *a)
+// {
+    // int i;
+    // size_t nr_of_elements = 1;
+    // for (i = 0; i < a->ndims; ++i) {
+       // nr_of_elements *= a->dim_size[i];
+    // }
+    // return nr_of_elements;
+// }
+
+
+// void alloc_local_integer_array_c99_1(local_integer_array* dest, int ndims, modelica_integer size_1, memory* memory_state)
+// {
+    // size_t elements = 0;
+    // dest->ndims = 1;
+
+    // //assert(n>=0);
+    // //assert(n + current_state.local_size_buffer_ptr < NR_SIZE_ELEMENTS);
+    // if( memory_state->current_local_state->size_count + 2 >= NR_SIZE_ELEMENTS){
+        // //printf("Size buffer pointer passed limit\n");
+    // }
+
+
+    // dest->dim_size = memory_state->current_local_state->local_size_buffer_ptr;
+
+    // memory_state->current_local_state->local_size_buffer_ptr += 1;
+    // memory_state->current_local_state->size_count += 1;
+    // dest->dim_size[0] = size_1;
+
+    // elements = local_integer_array_nr_of_elements(dest);
+
+    // //assert(n>=0);
+    // //assert(current_state.global_integer_buffer_ptr +n < NR_INTEGER_ELEMENTS);
+    // if( memory_state->current_local_state->integer_count + elements >= NR_INTEGER_ELEMENTS){
+        // //printf("Integer buffer pointer passed limit\n");
+    // }
+
+    // dest->data = memory_state->current_local_state->local_integer_buffer_ptr;
+    // memory_state->current_local_state->local_integer_buffer_ptr += elements;
+    // memory_state->current_local_state->integer_count += elements;
+// }
+
+// void alloc_local_integer_array_c99_2(local_integer_array* dest, int ndims, modelica_integer size_1, modelica_integer size_2, memory* memory_state)
+// {
+    // size_t elements = 0;
+    // dest->ndims = 2;
+
+    // //assert(n>=0);
+    // //assert(n + current_state.local_size_buffer_ptr < NR_SIZE_ELEMENTS);
+    // if( memory_state->current_local_state->size_count + 2 >= NR_SIZE_ELEMENTS){
+        // //printf("Size buffer pointer passed limit\n");
+    // }
+
+
+    // dest->dim_size = memory_state->current_local_state->local_size_buffer_ptr;
+
+    // memory_state->current_local_state->local_size_buffer_ptr += 2;
+    // memory_state->current_local_state->size_count += 2;
+    // dest->dim_size[0] = size_1;
+    // dest->dim_size[1] = size_2;
+
+    // elements = local_integer_array_nr_of_elements(dest);
+
+    // //assert(n>=0);
+    // //assert(current_state.global_integer_buffer_ptr +n < NR_INTEGER_ELEMENTS);
+    // if( memory_state->current_local_state->integer_count + elements >= NR_INTEGER_ELEMENTS){
+        // //printf("Integer buffer pointer passed limit\n");
+    // }
+
+    // dest->data = memory_state->current_local_state->local_integer_buffer_ptr;
+    // memory_state->current_local_state->local_integer_buffer_ptr += elements;
+    // memory_state->current_local_state->integer_count += elements;
+// }
+
+
+// void alloc_local_real_array_c99_1(local_real_array* dest, int ndims, modelica_integer size_1, memory* memory_state)
+// {
+    // size_t elements = 0;
+    // dest->ndims = 1;
+
+    // //assert(n>=0);
+    // //assert(n + current_state.local_size_buffer_ptr < NR_SIZE_ELEMENTS);
+    // if( memory_state->current_local_state->size_count + 2 >= NR_SIZE_ELEMENTS){
+        // //printf("Size buffer pointer passed limit\n");
+    // }
+
+
+    // dest->dim_size = memory_state->current_local_state->local_size_buffer_ptr;
+
+    // memory_state->current_local_state->local_size_buffer_ptr += 1;
+    // memory_state->current_local_state->size_count += 1;
+    // dest->dim_size[0] = size_1;
+
+    // elements = local_real_array_nr_of_elements(dest);
+
+    // //assert(n>=0);
+    // //assert(current_state.global_real_buffer_ptr +n < NR_REAL_ELEMENTS);
+    // if( memory_state->current_local_state->real_count + elements >= NR_REAL_ELEMENTS){
+        // //printf("Integer buffer pointer passed limit\n");
+    // }
+
+    // dest->data = memory_state->current_local_state->local_real_buffer_ptr;
+    // memory_state->current_local_state->local_real_buffer_ptr += elements;
+    // memory_state->current_local_state->integer_count += elements;
+// }
+
+// void alloc_local_real_array_c99_2(local_real_array* dest, int ndims, modelica_integer size_1, modelica_integer size_2, memory* memory_state)
+// {
+    // size_t elements = 0;
+    // dest->ndims = 2;
+
+    // //assert(n>=0);
+    // //assert(n + current_state.local_size_buffer_ptr < NR_SIZE_ELEMENTS);
+    // if( memory_state->current_local_state->size_count + 2 >= NR_SIZE_ELEMENTS){
+        // //printf("Size buffer pointer passed limit\n");
+    // }
+
+
+    // dest->dim_size = memory_state->current_local_state->local_size_buffer_ptr;
+
+    // memory_state->current_local_state->local_size_buffer_ptr += 2;
+    // memory_state->current_local_state->size_count += 2;
+    // dest->dim_size[0] = size_1;
+    // dest->dim_size[1] = size_2;
+
+    // elements = local_real_array_nr_of_elements(dest);
+
+    // //assert(n>=0);
+    // //assert(current_state.global_real_buffer_ptr +n < NR_REAL_ELEMENTS);
+    // if( memory_state->current_local_state->real_count + elements >= NR_REAL_ELEMENTS){
+        // //printf("Integer buffer pointer passed limit\n");
+    // }
+
+    // dest->data = memory_state->current_local_state->local_real_buffer_ptr;
+    // memory_state->current_local_state->local_real_buffer_ptr += elements;
+    // memory_state->current_local_state->integer_count += elements;
+// }

+ 116 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/ParModelica/explicit/openclrt/omc_ocl_common_header.h

@@ -0,0 +1,116 @@
+/*
+ * This file is part of OpenModelica.
+ *
+ * Copyright (c) 1998-CurrentYear, Linköping University,
+ * Department of Computer and Information Science,
+ * SE-58183 Linköping, Sweden.
+ *
+ * All rights reserved.
+ *
+ * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
+ * AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
+ * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
+ * ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
+ *
+ * The OpenModelica software and the Open Source Modelica
+ * Consortium (OSMC) Public License (OSMC-PL) are obtained
+ * from Linköping University, either from the above address,
+ * from the URLs: http://www.ida.liu.se/projects/OpenModelica or
+ * http://www.openmodelica.org, and in the OpenModelica distribution.
+ * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without
+ * even the implied warranty of  MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
+ * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
+ * OF OSMC-PL.
+ *
+ * See the full OSMC Public License conditions for more details.
+ *
+ */
+
+
+/*
+
+ Common hader file included by other headers in the openCLRuntime
+
+ Mahder.Gebremedhin@liu.se  2012-03-31
+
+*/
+
+
+
+#ifndef _OMC_OCL_COMMON_HEADER
+#define _OMC_OCL_COMMON_HEADER
+
+#include <stdio.h>
+#ifdef __APPLE__
+#include <OpenCL/cl.h>
+#else
+#include <CL/cl.h>
+#endif
+#include <openmodelica.h>
+#include <stdarg.h>
+#include <sys/time.h>
+
+
+
+#define MAX_DEVICE 4
+#define SHOW_DEVICE_SELECTION
+// #define SHOW_ARG_SET_ERRORS
+#define DEFAULT_DEVICE 1
+#define OCL_BUFFER_SIZE_FRACTION 4
+
+
+// DEFINED IN: omc_ocl_util
+void ocl_initialize();
+void ocl_error_check(int operation, cl_int error_code);
+cl_program ocl_build_p_from_src(const char* source, int isfile);
+cl_kernel ocl_create_kernel(cl_program program, const char* kernel_name);
+
+
+//executes a kernel
+void ocl_execute_kernel(cl_kernel kernel);
+
+
+typedef cl_mem device_integer;
+typedef cl_mem device_real;
+
+
+struct dev_buff{
+ cl_mem buffer;
+ modelica_integer size;
+};
+
+typedef struct dev_buff device_buffer;
+
+
+typedef struct dev_arr{
+ cl_mem data;
+ cl_mem info_dev;
+ modelica_integer* info;
+} device_array;
+
+typedef device_array device_integer_array;
+typedef device_array device_real_array;
+
+// typedef struct dev_local_arr{
+ // cl_mem data;
+ // cl_mem info_dev;
+ // modelica_integer* info;
+// } device_local_array;
+
+typedef device_array device_local_real_array;
+typedef device_array device_local_integer_array;
+
+
+enum ocl_error {OCL_BUILD_PROGRAM, OCL_CREATE_KERNEL, OCL_CREATE_BUFFER, OCL_CREATE_CONTEXT,
+                OCL_CREATE_COMMAND_QUEUE, OCL_SET_KER_ARGS, OCL_ENQUE_ND_RANGE_KERNEL, OCL_COPY_DEV_TO_DEV,
+                OCL_COPY_HOST_TO_DEV, OCL_COPY_DEV_TO_HOST, OCL_REALEASE_MEM_OBJECT};
+
+
+
+// Defined in: omc_ocl_interface.cpp
+size_t device_array_nr_of_elements(device_array *a);
+
+#endif

+ 195 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/ParModelica/explicit/openclrt/omc_ocl_interface.h

@@ -0,0 +1,195 @@
+/*
+ * This file is part of OpenModelica.
+ *
+ * Copyright (c) 1998-CurrentYear, Linköping University,
+ * Department of Computer and Information Science,
+ * SE-58183 Linköping, Sweden.
+ *
+ * All rights reserved.
+ *
+ * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
+ * AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
+ * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
+ * ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
+ *
+ * The OpenModelica software and the Open Source Modelica
+ * Consortium (OSMC) Public License (OSMC-PL) are obtained
+ * from Linköping University, either from the above address,
+ * from the URLs: http://www.ida.liu.se/projects/OpenModelica or
+ * http://www.openmodelica.org, and in the OpenModelica distribution.
+ * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without
+ * even the implied warranty of  MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
+ * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
+ * OF OSMC-PL.
+ *
+ * See the full OSMC Public License conditions for more details.
+ *
+ */
+
+
+/*
+
+ This file contains interfacing functions. Theses are the
+ actuall functions that are available for calling by the
+ code generated from Modelica source.
+ If a function is not called from the generated code please
+ don not add it here.
+ If the feature involves complex operations then define it
+ somewhere else and and just create interface for it here
+ (If it needs to be exported.)
+
+
+ Mahder.Gebremedhin@liu.se  2012-03-31
+
+*/
+
+
+
+#ifndef _OMC_OCL_INTERFACE_H
+#define _OMC_OCL_INTERFACE_H
+
+
+#include "omc_ocl_common_header.h"
+#include "omc_ocl_memory_ops.h"
+
+
+
+// Just to stick to  OpenModelica's function naming pattern
+#define oclSetNumThreadsOnlyGlobal(...) ocl_set_num_threads( __VA_ARGS__ )
+#define oclSetNumThreadsGlobalLocal(...) ocl_set_num_threads( __VA_ARGS__ )
+#define oclSetNumThreadsGlobalLocal1D(...) ocl_set_num_threads( __VA_ARGS__ )
+#define oclSetNumThreadsGlobalLocal2D(...) ocl_set_num_threads( __VA_ARGS__ )
+#define oclSetNumThreadsGlobalLocal3D(...) ocl_set_num_threads( __VA_ARGS__ )
+
+
+// sets the number of threads for subsequent parallel operations
+// arguments are arrays of work_dim size specifiying each workgroup dimension
+void ocl_set_num_threads(integer_array_t global_threads_in, integer_array_t local_threads_in);
+
+
+// sets the number of threads for subsequent parallel operations.
+// similar to the above function with arrays of size 1 only.
+void ocl_set_num_threads(modelica_integer global_threads_in, modelica_integer local_threads_in);
+
+//sets the number of threads for subsequent parallel operations.
+//This time only the total number of threads desired is given. OpenCL will
+//automatically distribute workitems/threads into work groups.
+//it ca also be used(by passing 0) to reset the number of total threads to the max value of one group (default).
+void ocl_set_num_threads(modelica_integer global_threads_in);
+
+//sets a single Kernel cl_mem (device pointer) argument.
+void ocl_set_kernel_arg(cl_kernel kernel, int arg_nr, cl_mem in_arg);
+//sets a single Kernel Real argument.
+void ocl_set_kernel_arg(cl_kernel kernel, int arg_nr, modelica_real in_arg);
+//sets a single Kernel Integer argument.
+void ocl_set_kernel_arg(cl_kernel kernel, int arg_nr, modelica_integer in_arg);
+
+// sets a __local Kernel argument. The size should be given.
+void ocl_set_local_kernel_arg(cl_kernel kernel, int arg_nr, size_t in_size);
+
+
+
+//overloaded functions from real/integer/boolean _array in the C_runtime library
+//for allocating and copying arrays to openCL device
+
+void alloc_integer_array(device_integer_array *dest, int ndims, ...);
+
+void alloc_real_array(device_integer_array *dest, int ndims, ...);
+
+void alloc_device_local_real_array(device_local_real_array *dest, int ndims, ...);
+
+void copy_real_array_data(device_real_array dev_array_ptr, real_array_t* host_array_ptr);
+
+void copy_real_array_data(real_array_t host_array_ptr, device_real_array* dev_array_ptr);
+
+void copy_real_array_data(device_real_array dev_array_ptr1, device_real_array* dev_array_ptr2);
+
+void copy_integer_array_data(device_integer_array dev_array_ptr, integer_array_t* host_array_ptr);
+
+void copy_integer_array_data(integer_array_t host_array_ptr, device_integer_array* dev_array_ptr);
+
+void copy_integer_array_data(device_integer_array dev_array_ptr1, device_integer_array* dev_array_ptr2);
+
+
+// //functions used for copying scalars. Scalars in the normal(serial C) code genertation
+// //of modelica are copied by assignment (a = b). However to be able to copy them b'n
+// //GPU and host CPU we need to change the assignments to copy functions.
+// void copy_assignment_helper_integer(modelica_integer* i1, modelica_integer* i2);
+
+// void copy_assignment_helper_integer(device_integer* i1, modelica_integer* i2);
+
+// void copy_assignment_helper_integer(modelica_integer* i1, device_integer* i2);
+
+// void copy_assignment_helper_integer(device_integer* i1, device_integer* i2);
+
+// void copy_assignment_helper_real(modelica_real* i1, modelica_real* i2);
+
+// void copy_assignment_helper_real(device_real* i1, modelica_real* i2);
+
+// void copy_assignment_helper_real(modelica_real* i1, device_real* i2);
+
+// void copy_assignment_helper_real(device_real* i1, device_real* i2);
+
+//these functions are added to solve a problem with a memory leak when returning arrays
+//from functions. Arrays used to be assigned just like normal scalar variables. Which causes the
+//allocated memory on the lhs to be lost when the pointer is replaced with the new one.
+//this fixes the problem for parallel arrays. for serial arrays the memory is restored when the
+//function returns(not dynamic allocation), So the only lose in serial case is visible just until
+//the function returns.
+void swap_and_release(device_array* lhs, device_array* rhs);
+
+void swap_and_release(base_array_t* lhs, base_array_t* rhs);
+
+//functions fallowing here are just the same function(the one in real/integer_array.c/h) declared with different names
+//this is done to be able to use the same generated code in normal c runtime and as well as in OpenCL kernels
+//which right now doesn't support overloading or the stdarg standard library.
+//even though the functions have the same body here they will have different body on the OpenCL counterparts
+
+modelica_real* real_array_element_addr_c99_1(real_array_t* source,int ndims,...);
+
+modelica_real* real_array_element_addr_c99_2(real_array_t* source,int ndims,...);
+
+modelica_real* real_array_element_addr_c99_3(real_array_t* source,int ndims,...);
+
+modelica_integer* integer_array_element_addr_c99_1(integer_array_t* source,int ndims,...);
+
+modelica_integer* integer_array_element_addr_c99_2(integer_array_t* source,int ndims,...);
+
+modelica_integer* integer_array_element_addr_c99_3(integer_array_t* source,int ndims,...);
+
+
+//array dimension size functions. returns the size of a given dimension for device real array
+modelica_integer size_of_dimension_real_array(device_real_array dev_arr, modelica_integer dim);
+
+//array dimension size functions. returns the size of a given dimension for device integer array
+modelica_integer size_of_dimension_integer_array(device_integer_array dev_arr, modelica_integer dim);
+
+//Free a device array memory.
+void free_device_array(device_array *dest);
+
+// This is just overloaded to allow the device arrays
+// be freed properly.
+void free_device_array(base_array_t* dest);
+
+//prints information about a device array. useful for debugging.
+void print_array_info(device_real_array* arr);
+
+//prints array. useful for debugging.
+void print_array(real_array_t* arr);
+
+//ATTENTION: printing a device array means copying back and then printing. Exprensive Operation.
+//void print_array(device_real_array* dev_arr);
+
+
+
+
+#endif
+
+
+
+
+
+

+ 106 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/ParModelica/explicit/openclrt/omc_ocl_memory_ops.h

@@ -0,0 +1,106 @@
+/*
+ * This file is part of OpenModelica.
+ *
+ * Copyright (c) 1998-CurrentYear, Linköping University,
+ * Department of Computer and Information Science,
+ * SE-58183 Linköping, Sweden.
+ *
+ * All rights reserved.
+ *
+ * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
+ * AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
+ * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
+ * ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
+ *
+ * The OpenModelica software and the Open Source Modelica
+ * Consortium (OSMC) Public License (OSMC-PL) are obtained
+ * from Linköping University, either from the above address,
+ * from the URLs: http://www.ida.liu.se/projects/OpenModelica or
+ * http://www.openmodelica.org, and in the OpenModelica distribution.
+ * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without
+ * even the implied warranty of  MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
+ * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
+ * OF OSMC-PL.
+ *
+ * See the full OSMC Public License conditions for more details.
+ *
+ */
+
+
+/*
+
+ This file contains functions for memory related operations.
+ Allocating, initializing, copying of memory on/from GPU/CPU
+ to GPU/CPU is handled by this functions.
+
+ Mahder.Gebremedhin@liu.se  2012-03-31
+
+*/
+
+
+#ifndef _OMC_OCL_MEMORY_OPS_H
+#define _OMC_OCL_MEMORY_OPS_H
+
+
+#include "omc_ocl_common_header.h"
+
+
+extern cl_command_queue device_comm_queue;
+extern cl_context  device_context;
+extern cl_device_id ocl_device;
+
+
+cl_mem ocl_device_alloc_init(modelica_integer* host_array, size_t size);
+
+cl_mem ocl_device_alloc_init(modelica_real* host_array, size_t size);
+
+cl_mem ocl_device_alloc(size_t size);
+
+
+//allocates memory space on device and returns the handle to the buffer object
+//also initializes if from host memory IF src_data is not NULL.
+//size is the actuall size in bytes.
+cl_mem ocl_alloc_init(void* src_data, size_t size);
+
+//ATTENTION: This function allocates a large amount of memory
+//to be used for creatinfg arrays inside parallel functions.
+//If this fails try reducing the amount by increasing the #define OCL_BUFFER_SIZE_FRACTION
+//which defines the freaction of memory from the availabel GLOBAL_MEM_SIZE to be used as buffer.
+void ocl_create_execution_memory_buffer(device_buffer* d_buff);
+
+//allocates a double array on device and returns the handle to the buffer object
+//also initializes if from host array IF host array is not NULL.
+//Use size 1 to allocate a Scalar.
+cl_mem ocl_alloc_init_real_arr(modelica_real* host_array, int a_size);
+
+//allocates an int array on device and returns the handle to the buffer object
+//also initializes if from host array IF host array is not NULL.
+//Use size 1 to allocate a Scalar.
+cl_mem ocl_alloc_init_integer_arr(modelica_integer* host_array, int a_size);
+
+
+
+//copies a double array to ALREADY allocated device buffer
+//Size is the number of elements in the src array
+void ocl_copy_to_device_real(cl_mem dev_dest_array, modelica_real* src_host_array, int a_size);
+
+//copies one buffer to another on the device
+//Size is the number of elements in the src array
+void ocl_copy_device_to_device_real(cl_mem dev_src_array, cl_mem device_dest_array, int a_size);
+
+//copies a double array back to host
+void ocl_copy_back_to_host_real(cl_mem dev_output_array, modelica_real* dest_host_array, int a_size);
+
+//copies an integer array to ALREADY allocated device buffer
+void ocl_copy_to_device_integer(cl_mem dev_dest_array, modelica_integer* src_host_array, int a_size);
+
+//Size is the number of elements in the src array
+void ocl_copy_device_to_device_integer(cl_mem dev_src_array, cl_mem device_dest_array, int a_size);
+
+//copies an int array back to host
+void ocl_copy_back_to_host_integer(cl_mem dev_output_array, modelica_integer* dest_host_array, int a_size);
+
+#endif

+ 158 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/blaswrap.h

@@ -0,0 +1,158 @@
+/* CLAPACK 3.0 BLAS wrapper macros
+ * Feb 5, 2000
+ */
+
+#ifndef __BLASWRAP_H
+#define __BLASWRAP_H
+
+#ifndef NO_BLAS_WRAP
+
+/* BLAS1 routines */
+#define srotg_ f2c_srotg
+#define drotg_ f2c_drotg
+#define srotmg_ f2c_srotmg
+#define drotmg_ f2c_drotmg
+#define srot_ f2c_srot
+#define drot_ f2c_drot
+#define srotm_ f2c_srotm
+#define drotm_ f2c_drotm
+#define sswap_ f2c_sswap
+#define dswap_ f2c_dswap
+#define cswap_ f2c_cswap
+#define zswap_ f2c_zswap
+#define sscal_ f2c_sscal
+#define dscal_ f2c_dscal
+#define cscal_ f2c_cscal
+#define zscal_ f2c_zscal
+#define csscal_ f2c_csscal
+#define zdscal_ f2c_zdscal
+#define scopy_ f2c_scopy
+#define dcopy_ f2c_dcopy
+#define ccopy_ f2c_ccopy
+#define zcopy_ f2c_zcopy
+#define saxpy_ f2c_saxpy
+#define daxpy_ f2c_daxpy
+#define caxpy_ f2c_caxpy
+#define zaxpy_ f2c_zaxpy
+#define sdot_ f2c_sdot
+#define ddot_ f2c_ddot
+#define cdotu_ f2c_cdotu
+#define zdotu_ f2c_zdotu
+#define cdotc_ f2c_cdotc
+#define zdotc_ f2c_zdotc
+#define snrm2_ f2c_snrm2
+#define dnrm2_ f2c_dnrm2
+#define scnrm2_ f2c_scnrm2
+#define dznrm2_ f2c_dznrm2
+#define sasum_ f2c_sasum
+#define dasum_ f2c_dasum
+#define scasum_ f2c_scasum
+#define dzasum_ f2c_dzasum
+#define isamax_ f2c_isamax
+#define idamax_ f2c_idamax
+#define icamax_ f2c_icamax
+#define izamax_ f2c_izamax
+
+/* BLAS2 routines */
+#define sgemv_ f2c_sgemv
+#define dgemv_ f2c_dgemv
+#define cgemv_ f2c_cgemv
+#define zgemv_ f2c_zgemv
+#define sgbmv_ f2c_sgbmv
+#define dgbmv_ f2c_dgbmv
+#define cgbmv_ f2c_cgbmv
+#define zgbmv_ f2c_zgbmv
+#define chemv_ f2c_chemv
+#define zhemv_ f2c_zhemv
+#define chbmv_ f2c_chbmv
+#define zhbmv_ f2c_zhbmv
+#define chpmv_ f2c_chpmv
+#define zhpmv_ f2c_zhpmv
+#define ssymv_ f2c_ssymv
+#define dsymv_ f2c_dsymv
+#define ssbmv_ f2c_ssbmv
+#define dsbmv_ f2c_dsbmv
+#define sspmv_ f2c_sspmv
+#define dspmv_ f2c_dspmv
+#define strmv_ f2c_strmv
+#define dtrmv_ f2c_dtrmv
+#define ctrmv_ f2c_ctrmv
+#define ztrmv_ f2c_ztrmv
+#define stbmv_ f2c_stbmv
+#define dtbmv_ f2c_dtbmv
+#define ctbmv_ f2c_ctbmv
+#define ztbmv_ f2c_ztbmv
+#define stpmv_ f2c_stpmv
+#define dtpmv_ f2c_dtpmv
+#define ctpmv_ f2c_ctpmv
+#define ztpmv_ f2c_ztpmv
+#define strsv_ f2c_strsv
+#define dtrsv_ f2c_dtrsv
+#define ctrsv_ f2c_ctrsv
+#define ztrsv_ f2c_ztrsv
+#define stbsv_ f2c_stbsv
+#define dtbsv_ f2c_dtbsv
+#define ctbsv_ f2c_ctbsv
+#define ztbsv_ f2c_ztbsv
+#define stpsv_ f2c_stpsv
+#define dtpsv_ f2c_dtpsv
+#define ctpsv_ f2c_ctpsv
+#define ztpsv_ f2c_ztpsv
+#define sger_ f2c_sger
+#define dger_ f2c_dger
+#define cgeru_ f2c_cgeru
+#define zgeru_ f2c_zgeru
+#define cgerc_ f2c_cgerc
+#define zgerc_ f2c_zgerc
+#define cher_ f2c_cher
+#define zher_ f2c_zher
+#define chpr_ f2c_chpr
+#define zhpr_ f2c_zhpr
+#define cher2_ f2c_cher2
+#define zher2_ f2c_zher2
+#define chpr2_ f2c_chpr2
+#define zhpr2_ f2c_zhpr2
+#define ssyr_ f2c_ssyr
+#define dsyr_ f2c_dsyr
+#define sspr_ f2c_sspr
+#define dspr_ f2c_dspr
+#define ssyr2_ f2c_ssyr2
+#define dsyr2_ f2c_dsyr2
+#define sspr2_ f2c_sspr2
+#define dspr2_ f2c_dspr2
+
+/* BLAS3 routines */
+#define sgemm_ f2c_sgemm
+#define dgemm_ f2c_dgemm
+#define cgemm_ f2c_cgemm
+#define zgemm_ f2c_zgemm
+#define ssymm_ f2c_ssymm
+#define dsymm_ f2c_dsymm
+#define csymm_ f2c_csymm
+#define zsymm_ f2c_zsymm
+#define chemm_ f2c_chemm
+#define zhemm_ f2c_zhemm
+#define ssyrk_ f2c_ssyrk
+#define dsyrk_ f2c_dsyrk
+#define csyrk_ f2c_csyrk
+#define zsyrk_ f2c_zsyrk
+#define cherk_ f2c_cherk
+#define zherk_ f2c_zherk
+#define ssyr2k_ f2c_ssyr2k
+#define dsyr2k_ f2c_dsyr2k
+#define csyr2k_ f2c_csyr2k
+#define zsyr2k_ f2c_zsyr2k
+#define cher2k_ f2c_cher2k
+#define zher2k_ f2c_zher2k
+#define strmm_ f2c_strmm
+#define dtrmm_ f2c_dtrmm
+#define ctrmm_ f2c_ctrmm
+#define ztrmm_ f2c_ztrmm
+#define strsm_ f2c_strsm
+#define dtrsm_ f2c_dtrsm
+#define ctrsm_ f2c_ctrsm
+#define ztrsm_ f2c_ztrsm
+
+#endif /* NO_BLAS_WRAP */
+
+#endif /* __BLASWRAP_H */

+ 160 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/blaswrap.h

@@ -0,0 +1,160 @@
+/* CLAPACK 3.0 BLAS wrapper macros
+ * Feb 5, 2000
+ */
+
+#ifndef __BLASWRAP_H
+#define __BLASWRAP_H
+
+#ifndef NO_BLAS_WRAP
+ 
+/* BLAS1 routines */
+#define srotg_ f2c_srotg
+#define crotg_ f2c_crotg
+#define drotg_ f2c_drotg
+#define zrotg_ f2c_zrotg
+#define srotmg_ f2c_srotmg
+#define drotmg_ f2c_drotmg
+#define srot_ f2c_srot
+#define drot_ f2c_drot
+#define srotm_ f2c_srotm
+#define drotm_ f2c_drotm
+#define sswap_ f2c_sswap
+#define dswap_ f2c_dswap
+#define cswap_ f2c_cswap
+#define zswap_ f2c_zswap
+#define sscal_ f2c_sscal
+#define dscal_ f2c_dscal
+#define cscal_ f2c_cscal
+#define zscal_ f2c_zscal
+#define csscal_ f2c_csscal
+#define zdscal_ f2c_zdscal
+#define scopy_ f2c_scopy
+#define dcopy_ f2c_dcopy
+#define ccopy_ f2c_ccopy
+#define zcopy_ f2c_zcopy
+#define saxpy_ f2c_saxpy
+#define daxpy_ f2c_daxpy
+#define caxpy_ f2c_caxpy
+#define zaxpy_ f2c_zaxpy
+#define sdot_ f2c_sdot
+#define ddot_ f2c_ddot
+#define cdotu_ f2c_cdotu
+#define zdotu_ f2c_zdotu
+#define cdotc_ f2c_cdotc
+#define zdotc_ f2c_zdotc
+#define snrm2_ f2c_snrm2
+#define dnrm2_ f2c_dnrm2
+#define scnrm2_ f2c_scnrm2
+#define dznrm2_ f2c_dznrm2
+#define sasum_ f2c_sasum
+#define dasum_ f2c_dasum
+#define scasum_ f2c_scasum
+#define dzasum_ f2c_dzasum
+#define isamax_ f2c_isamax
+#define idamax_ f2c_idamax
+#define icamax_ f2c_icamax
+#define izamax_ f2c_izamax
+ 
+/* BLAS2 routines */
+#define sgemv_ f2c_sgemv
+#define dgemv_ f2c_dgemv
+#define cgemv_ f2c_cgemv
+#define zgemv_ f2c_zgemv
+#define sgbmv_ f2c_sgbmv
+#define dgbmv_ f2c_dgbmv
+#define cgbmv_ f2c_cgbmv
+#define zgbmv_ f2c_zgbmv
+#define chemv_ f2c_chemv
+#define zhemv_ f2c_zhemv
+#define chbmv_ f2c_chbmv
+#define zhbmv_ f2c_zhbmv
+#define chpmv_ f2c_chpmv
+#define zhpmv_ f2c_zhpmv
+#define ssymv_ f2c_ssymv
+#define dsymv_ f2c_dsymv
+#define ssbmv_ f2c_ssbmv
+#define dsbmv_ f2c_dsbmv
+#define sspmv_ f2c_sspmv
+#define dspmv_ f2c_dspmv
+#define strmv_ f2c_strmv
+#define dtrmv_ f2c_dtrmv
+#define ctrmv_ f2c_ctrmv
+#define ztrmv_ f2c_ztrmv
+#define stbmv_ f2c_stbmv
+#define dtbmv_ f2c_dtbmv
+#define ctbmv_ f2c_ctbmv
+#define ztbmv_ f2c_ztbmv
+#define stpmv_ f2c_stpmv
+#define dtpmv_ f2c_dtpmv
+#define ctpmv_ f2c_ctpmv
+#define ztpmv_ f2c_ztpmv
+#define strsv_ f2c_strsv
+#define dtrsv_ f2c_dtrsv
+#define ctrsv_ f2c_ctrsv
+#define ztrsv_ f2c_ztrsv
+#define stbsv_ f2c_stbsv
+#define dtbsv_ f2c_dtbsv
+#define ctbsv_ f2c_ctbsv
+#define ztbsv_ f2c_ztbsv
+#define stpsv_ f2c_stpsv
+#define dtpsv_ f2c_dtpsv
+#define ctpsv_ f2c_ctpsv
+#define ztpsv_ f2c_ztpsv
+#define sger_ f2c_sger
+#define dger_ f2c_dger
+#define cgeru_ f2c_cgeru
+#define zgeru_ f2c_zgeru
+#define cgerc_ f2c_cgerc
+#define zgerc_ f2c_zgerc
+#define cher_ f2c_cher
+#define zher_ f2c_zher
+#define chpr_ f2c_chpr
+#define zhpr_ f2c_zhpr
+#define cher2_ f2c_cher2
+#define zher2_ f2c_zher2
+#define chpr2_ f2c_chpr2
+#define zhpr2_ f2c_zhpr2
+#define ssyr_ f2c_ssyr
+#define dsyr_ f2c_dsyr
+#define sspr_ f2c_sspr
+#define dspr_ f2c_dspr
+#define ssyr2_ f2c_ssyr2
+#define dsyr2_ f2c_dsyr2
+#define sspr2_ f2c_sspr2
+#define dspr2_ f2c_dspr2
+ 
+/* BLAS3 routines */
+#define sgemm_ f2c_sgemm
+#define dgemm_ f2c_dgemm
+#define cgemm_ f2c_cgemm
+#define zgemm_ f2c_zgemm
+#define ssymm_ f2c_ssymm
+#define dsymm_ f2c_dsymm
+#define csymm_ f2c_csymm
+#define zsymm_ f2c_zsymm
+#define chemm_ f2c_chemm
+#define zhemm_ f2c_zhemm
+#define ssyrk_ f2c_ssyrk
+#define dsyrk_ f2c_dsyrk
+#define csyrk_ f2c_csyrk
+#define zsyrk_ f2c_zsyrk
+#define cherk_ f2c_cherk
+#define zherk_ f2c_zherk
+#define ssyr2k_ f2c_ssyr2k
+#define dsyr2k_ f2c_dsyr2k
+#define csyr2k_ f2c_csyr2k
+#define zsyr2k_ f2c_zsyr2k
+#define cher2k_ f2c_cher2k
+#define zher2k_ f2c_zher2k
+#define strmm_ f2c_strmm
+#define dtrmm_ f2c_dtrmm
+#define ctrmm_ f2c_ctrmm
+#define ztrmm_ f2c_ztrmm
+#define strsm_ f2c_strsm
+#define dtrsm_ f2c_dtrsm
+#define ctrsm_ f2c_ctrsm
+#define ztrsm_ f2c_ztrsm
+
+#endif /* NO_BLAS_WRAP */
+
+#endif /* __BLASWRAP_H */

File diff suppressed because it is too large
+ 7262 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/clapack.h


+ 370 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/cminpack.h

@@ -0,0 +1,370 @@
+/* Header file for cminpack, by Frederic Devernay.
+   The documentation for all functions can be found in the file
+   minpack-documentation.txt from the distribution, or in the source
+   code of each function. */
+
+#ifndef __CMINPACK_H__
+#define __CMINPACK_H__
+
+/* The default floating-point type is "double" for C/C++ and "float" for CUDA,
+   but you can change this by defining one of the following symbols when
+   compiling the library, and before including cminpack.h when using it:
+   __cminpack_double__ for double
+   __cminpack_float__ for float
+   __cminpack_half__ for half from the OpenEXR library (in this case, you must
+                     compile cminpack with a C++ compiler)
+*/
+#ifdef __cminpack_double__
+#define __cminpack_real__ double
+#endif
+
+#ifdef __cminpack_float__
+#define __cminpack_real__ float
+#endif
+
+#ifdef __cminpack_half__
+#include <OpenEXR/half.h>
+#define __cminpack_real__ half
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Cmake will define cminpack_EXPORTS on Windows when it
+configures to build a shared library. If you are going to use
+another build system on windows or create the visual studio
+projects by hand you need to define cminpack_EXPORTS when
+building a DLL on windows.
+*/
+#if defined (__GNUC__)
+#define CMINPACK_DECLSPEC_EXPORT  __declspec(__dllexport__)
+#define CMINPACK_DECLSPEC_IMPORT  __declspec(__dllimport__)
+#endif
+#if defined (_MSC_VER) || defined (__BORLANDC__)
+#define CMINPACK_DECLSPEC_EXPORT  __declspec(dllexport)
+#define CMINPACK_DECLSPEC_IMPORT  __declspec(dllimport)
+#endif
+#ifdef __WATCOMC__
+#define CMINPACK_DECLSPEC_EXPORT  __export
+#define CMINPACK_DECLSPEC_IMPORT  __import
+#endif
+#ifdef __IBMC__
+#define CMINPACK_DECLSPEC_EXPORT  _Export
+#define CMINPACK_DECLSPEC_IMPORT  _Import
+#endif
+
+#if !defined(CMINPACK_NO_DLL) && (defined(__WIN32__) || defined(WIN32) || defined (_WIN32))
+#if defined(cminpack_EXPORTS) || defined(CMINPACK_EXPORTS) || defined(CMINPACK_DLL_EXPORTS)
+    #define  CMINPACK_EXPORT CMINPACK_DECLSPEC_EXPORT
+  #else
+    #define  CMINPACK_EXPORT CMINPACK_DECLSPEC_IMPORT
+  #endif /* cminpack_EXPORTS */
+#else /* defined (_WIN32) */
+ #define CMINPACK_EXPORT
+#endif
+
+#if defined(__CUDA_ARCH__) || defined(__CUDACC__)
+#define __cminpack_attr__ __device__
+#ifndef __cminpack_real__
+#define __cminpack_float__
+#define __cminpack_real__ float
+#endif
+#define __cminpack_type_fcn_nn__        __cminpack_attr__ int fcn_nn
+#define __cminpack_type_fcnder_nn__     __cminpack_attr__ int fcnder_nn
+#define __cminpack_type_fcn_mn__        __cminpack_attr__ int fcn_mn
+#define __cminpack_type_fcnder_mn__     __cminpack_attr__ int fcnder_mn
+#define __cminpack_type_fcnderstr_mn__  __cminpack_attr__ int fcnderstr_mn
+#define __cminpack_decl_fcn_nn__
+#define __cminpack_decl_fcnder_nn__
+#define __cminpack_decl_fcn_mn__
+#define __cminpack_decl_fcnder_mn__
+#define __cminpack_decl_fcnderstr_mn__
+#define __cminpack_param_fcn_nn__
+#define __cminpack_param_fcnder_nn__
+#define __cminpack_param_fcn_mn__
+#define __cminpack_param_fcnder_mn__
+#define __cminpack_param_fcnderstr_mn__
+#else
+#define __cminpack_attr__
+#ifndef __cminpack_real__
+#define __cminpack_double__
+#define __cminpack_real__ double
+#endif
+#define __cminpack_type_fcn_nn__        typedef int (*cminpack_func_nn)
+#define __cminpack_type_fcnder_nn__     typedef int (*cminpack_funcder_nn)
+#define __cminpack_type_fcn_mn__        typedef int (*cminpack_func_mn)
+#define __cminpack_type_fcnder_mn__     typedef int (*cminpack_funcder_mn)
+#define __cminpack_type_fcnderstr_mn__  typedef int (*cminpack_funcderstr_mn)
+#define __cminpack_decl_fcn_nn__        cminpack_func_nn fcn_nn,
+#define __cminpack_decl_fcnder_nn__     cminpack_funcder_nn fcnder_nn,
+#define __cminpack_decl_fcn_mn__        cminpack_func_mn fcn_mn,
+#define __cminpack_decl_fcnder_mn__     cminpack_funcder_mn fcnder_mn,
+#define __cminpack_decl_fcnderstr_mn__  cminpack_funcderstr_mn fcnderstr_mn,
+#define __cminpack_param_fcn_nn__       fcn_nn,
+#define __cminpack_param_fcnder_nn__    fcnder_nn,
+#define __cminpack_param_fcn_mn__       fcn_mn,
+#define __cminpack_param_fcnder_mn__    fcnder_mn,
+#define __cminpack_param_fcnderstr_mn__ fcnderstr_mn,
+#endif
+
+#ifdef __cminpack_double__
+#define __cminpack_func__(func) func
+#endif
+
+#ifdef __cminpack_float__
+#define __cminpack_func__(func) s ## func
+#endif
+
+#ifdef __cminpack_half__
+#define __cminpack_func__(func) h ## func
+#endif
+
+/* Declarations for minpack */
+
+/* Function types: */
+/* The first argument can be used to store extra function parameters, thus */
+/* avoiding the use of global variables. */
+/* the iflag parameter is input-only (with respect to the FORTRAN */
+/*  version), the output iflag value is the return value of the function. */
+/* If iflag=0, the function shoulkd just print the current values (see */
+/* the nprint parameters below). */
+  
+/* for hybrd1 and hybrd: */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/* return a negative value to terminate hybrd1/hybrd */
+__cminpack_type_fcn_nn__(void *p, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, int iflag );
+
+/* for hybrj1 and hybrj */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/* return a negative value to terminate hybrj1/hybrj */
+__cminpack_type_fcnder_nn__(void *p, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
+                                  int ldfjac, int iflag, void *user_data );
+
+/* for lmdif1 and lmdif */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         if iflag = 1 the result is used to compute the residuals. */
+/*         if iflag = 2 the result is used to compute the Jacobian by finite differences. */
+/*         Jacobian computation requires exactly n function calls with iflag = 2. */
+/* return a negative value to terminate lmdif1/lmdif */
+__cminpack_type_fcn_mn__(void *p, int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec,
+                               int iflag );
+
+/* for lmder1 and lmder */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/* return a negative value to terminate lmder1/lmder */
+__cminpack_type_fcnder_mn__(void *p, int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec,
+                                  __cminpack_real__ *fjac, int ldfjac, int iflag );
+
+/* for lmstr1 and lmstr */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         if iflag = i calculate the (i-1)-st row of the */
+/*         jacobian at x and return this vector in fjrow. */
+/* return a negative value to terminate lmstr1/lmstr */
+__cminpack_type_fcnderstr_mn__(void *p, int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec,
+                                     __cminpack_real__ *fjrow, int iflag );
+
+
+
+
+
+
+/* MINPACK functions: */
+/* the info parameter was removed from most functions: the return */
+/* value of the function is used instead. */
+/* The argument 'p' can be used to store extra function parameters, thus */
+/* avoiding the use of global variables. You can also think of it as a */
+/* 'this' pointer a la C++. */
+
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (Jacobian calculated by
+   a forward-difference approximation) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(hybrd1)( __cminpack_decl_fcn_nn__ 
+	       void *p, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ tol,
+	       __cminpack_real__ *wa, int lwa );
+
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (Jacobian calculated by
+   a forward-difference approximation, more general). */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(hybrd)( __cminpack_decl_fcn_nn__
+	      void *p, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ xtol, int maxfev,
+	      int ml, int mu, __cminpack_real__ epsfcn, __cminpack_real__ *diag, int mode,
+	      __cminpack_real__ factor, int nprint, int *nfev,
+	      __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ *r, int lr, __cminpack_real__ *qtf,
+	      __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3, __cminpack_real__ *wa4);
+  
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (user-supplied Jacobian) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(hybrj1)( __cminpack_decl_fcnder_nn__ void *p, int n, __cminpack_real__ *x,
+	       __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ tol,
+	       __cminpack_real__ *wa, int lwa, void *user_data );
+          
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (user-supplied Jacobian,
+   more general) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(hybrj)( __cminpack_decl_fcnder_nn__ void *p, int n, __cminpack_real__ *x,
+	      __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac, __cminpack_real__ xtol,
+	      int maxfev, __cminpack_real__ *diag, int mode, __cminpack_real__ factor,
+	      int nprint, int *nfev, int *njev, __cminpack_real__ *r,
+	      int lr, __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2,
+	      __cminpack_real__ *wa3, __cminpack_real__ *wa4, void *user_data );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (Jacobian calculated by a forward-difference approximation) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(lmdif1)( __cminpack_decl_fcn_mn__
+	       void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ tol,
+	       int *iwa, __cminpack_real__ *wa, int lwa );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (Jacobian calculated by a forward-difference approximation, more
+   general) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(lmdif)( __cminpack_decl_fcn_mn__
+	      void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ ftol,
+	      __cminpack_real__ xtol, __cminpack_real__ gtol, int maxfev, __cminpack_real__ epsfcn,
+	      __cminpack_real__ *diag, int mode, __cminpack_real__ factor, int nprint,
+	      int *nfev, __cminpack_real__ *fjac, int ldfjac, int *ipvt,
+	      __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3,
+	      __cminpack_real__ *wa4 );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(lmder1)( __cminpack_decl_fcnder_mn__
+	       void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
+	       int ldfjac, __cminpack_real__ tol, int *ipvt,
+	       __cminpack_real__ *wa, int lwa );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian, more general) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(lmder)( __cminpack_decl_fcnder_mn__
+	      void *p, int m, int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
+	      int ldfjac, __cminpack_real__ ftol, __cminpack_real__ xtol, __cminpack_real__ gtol,
+	      int maxfev, __cminpack_real__ *diag, int mode, __cminpack_real__ factor,
+	      int nprint, int *nfev, int *njev, int *ipvt,
+	      __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3,
+	      __cminpack_real__ *wa4 );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian, minimal storage) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(lmstr1)( __cminpack_decl_fcnderstr_mn__ void *p, int m, int n,
+	       __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac,
+	       __cminpack_real__ tol, int *ipvt, __cminpack_real__ *wa, int lwa );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian, minimal storage, more general) */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(lmstr)(  __cminpack_decl_fcnderstr_mn__ void *p, int m,
+	      int n, __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
+	      int ldfjac, __cminpack_real__ ftol, __cminpack_real__ xtol, __cminpack_real__ gtol,
+	      int maxfev, __cminpack_real__ *diag, int mode, __cminpack_real__ factor,
+	      int nprint, int *nfev, int *njev, int *ipvt,
+	      __cminpack_real__ *qtf, __cminpack_real__ *wa1, __cminpack_real__ *wa2, __cminpack_real__ *wa3,
+	      __cminpack_real__ *wa4 );
+ 
+__cminpack_attr__
+void CMINPACK_EXPORT __cminpack_func__(chkder)( int m, int n, const __cminpack_real__ *x, __cminpack_real__ *fvec, __cminpack_real__ *fjac,
+	       int ldfjac, __cminpack_real__ *xp, __cminpack_real__ *fvecp, int mode,
+	       __cminpack_real__ *err  );
+
+__cminpack_attr__
+__cminpack_real__ CMINPACK_EXPORT __cminpack_func__(dpmpar)( int i );
+
+__cminpack_attr__
+__cminpack_real__ CMINPACK_EXPORT __cminpack_func__(enorm)( int n, const __cminpack_real__ *x );
+
+/* compute a forward-difference approximation to the m by n jacobian
+   matrix associated with a specified problem of m functions in n
+   variables. */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(fdjac2)(__cminpack_decl_fcn_mn__
+	     void *p, int m, int n, __cminpack_real__ *x, const __cminpack_real__ *fvec, __cminpack_real__ *fjac,
+	     int ldfjac, __cminpack_real__ epsfcn, __cminpack_real__ *wa);
+
+/* compute a forward-difference approximation to the n by n jacobian
+   matrix associated with a specified problem of n functions in n
+   variables. if the jacobian has a banded form, then function
+   evaluations are saved by only approximating the nonzero terms. */
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(fdjac1)(__cminpack_decl_fcn_nn__
+	     void *p, int n, __cminpack_real__ *x, const __cminpack_real__ *fvec, __cminpack_real__ *fjac, int ldfjac,
+	     int ml, int mu, __cminpack_real__ epsfcn, __cminpack_real__ *wa1,
+	     __cminpack_real__ *wa2);
+
+/* compute inverse(JtJ) after a run of lmdif or lmder. The covariance matrix is obtained
+   by scaling the result by enorm(y)**2/(m-n). If JtJ is singular and k = rank(J), the
+   pseudo-inverse is computed, and the result has to be scaled by enorm(y)**2/(m-k). */
+__cminpack_attr__
+void CMINPACK_EXPORT __cminpack_func__(covar)(int n, __cminpack_real__ *r, int ldr, 
+           const int *ipvt, __cminpack_real__ tol, __cminpack_real__ *wa);
+
+/* covar1 estimates the variance-covariance matrix:
+   C = sigma**2 (JtJ)**+
+   where (JtJ)**+ is the inverse of JtJ or the pseudo-inverse of JtJ (in case J does not have full rank),
+   and sigma**2 = fsumsq / (m - k)
+   where fsumsq is the residual sum of squares and k is the rank of J.
+   The function returns 0 if J has full rank, else the rank of J.
+*/
+__cminpack_attr__
+int CMINPACK_EXPORT __cminpack_func__(covar1)(int m, int n, __cminpack_real__ fsumsq, __cminpack_real__ *r, int ldr, 
+                           const int *ipvt, __cminpack_real__ tol, __cminpack_real__ *wa);
+
+/* internal MINPACK subroutines */
+__cminpack_attr__
+void __cminpack_func__(dogleg)(int n, const __cminpack_real__ *r, int lr, 
+             const __cminpack_real__ *diag, const __cminpack_real__ *qtb, __cminpack_real__ delta, __cminpack_real__ *x, 
+             __cminpack_real__ *wa1, __cminpack_real__ *wa2);
+__cminpack_attr__
+void __cminpack_func__(qrfac)(int m, int n, __cminpack_real__ *a, int
+            lda, int pivot, int *ipvt, int lipvt, __cminpack_real__ *rdiag,
+            __cminpack_real__ *acnorm, __cminpack_real__ *wa);
+__cminpack_attr__
+void __cminpack_func__(qrsolv)(int n, __cminpack_real__ *r, int ldr, 
+             const int *ipvt, const __cminpack_real__ *diag, const __cminpack_real__ *qtb, __cminpack_real__ *x, 
+             __cminpack_real__ *sdiag, __cminpack_real__ *wa);
+__cminpack_attr__
+void __cminpack_func__(qform)(int m, int n, __cminpack_real__ *q, int
+            ldq, __cminpack_real__ *wa);
+__cminpack_attr__
+void __cminpack_func__(r1updt)(int m, int n, __cminpack_real__ *s, int
+             ls, const __cminpack_real__ *u, __cminpack_real__ *v, __cminpack_real__ *w, int *sing);
+__cminpack_attr__
+void __cminpack_func__(r1mpyq)(int m, int n, __cminpack_real__ *a, int
+             lda, const __cminpack_real__ *v, const __cminpack_real__ *w);
+__cminpack_attr__
+void __cminpack_func__(lmpar)(int n, __cminpack_real__ *r, int ldr, 
+            const int *ipvt, const __cminpack_real__ *diag, const __cminpack_real__ *qtb, __cminpack_real__ delta, 
+            __cminpack_real__ *par, __cminpack_real__ *x, __cminpack_real__ *sdiag, __cminpack_real__ *wa1, 
+            __cminpack_real__ *wa2);
+__cminpack_attr__
+void __cminpack_func__(rwupdt)(int n, __cminpack_real__ *r, int ldr, 
+             const __cminpack_real__ *w, __cminpack_real__ *b, __cminpack_real__ *alpha, __cminpack_real__ *cos, 
+             __cminpack_real__ *sin);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __CMINPACK_H__ */

+ 389 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dgemm.c

@@ -0,0 +1,389 @@
+/* dgemm.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+	on Microsoft Windows system, link with libf2c.lib;
+	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+	or, if you install libf2c.a in a standard place, with -lf2c -lm
+	-- in that order, at the end of the command line, as in
+		cc *.o -lf2c -lm
+	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+		http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+
+/* Subroutine */ int dgemm_(char *transa, char *transb, integer *m, integer *
+	n, integer *k, doublereal *alpha, doublereal *a, integer *lda, 
+	doublereal *b, integer *ldb, doublereal *beta, doublereal *c__, 
+	integer *ldc)
+{
+    /* System generated locals */
+    integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2, 
+	    i__3;
+
+    /* Local variables */
+    integer i__, j, l, info;
+    logical nota, notb;
+    doublereal temp;
+    integer ncola;
+    extern logical lsame_(char *, char *);
+    integer nrowa, nrowb;
+    extern /* Subroutine */ int xerbla_(char *, integer *);
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+/*     .. Array Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*  DGEMM  performs one of the matrix-matrix operations */
+
+/*     C := alpha*op( A )*op( B ) + beta*C, */
+
+/*  where  op( X ) is one of */
+
+/*     op( X ) = X   or   op( X ) = X', */
+
+/*  alpha and beta are scalars, and A, B and C are matrices, with op( A ) */
+/*  an m by k matrix,  op( B )  a  k by n matrix and  C an m by n matrix. */
+
+/*  Arguments */
+/*  ========== */
+
+/*  TRANSA - CHARACTER*1. */
+/*           On entry, TRANSA specifies the form of op( A ) to be used in */
+/*           the matrix multiplication as follows: */
+
+/*              TRANSA = 'N' or 'n',  op( A ) = A. */
+
+/*              TRANSA = 'T' or 't',  op( A ) = A'. */
+
+/*              TRANSA = 'C' or 'c',  op( A ) = A'. */
+
+/*           Unchanged on exit. */
+
+/*  TRANSB - CHARACTER*1. */
+/*           On entry, TRANSB specifies the form of op( B ) to be used in */
+/*           the matrix multiplication as follows: */
+
+/*              TRANSB = 'N' or 'n',  op( B ) = B. */
+
+/*              TRANSB = 'T' or 't',  op( B ) = B'. */
+
+/*              TRANSB = 'C' or 'c',  op( B ) = B'. */
+
+/*           Unchanged on exit. */
+
+/*  M      - INTEGER. */
+/*           On entry,  M  specifies  the number  of rows  of the  matrix */
+/*           op( A )  and of the  matrix  C.  M  must  be at least  zero. */
+/*           Unchanged on exit. */
+
+/*  N      - INTEGER. */
+/*           On entry,  N  specifies the number  of columns of the matrix */
+/*           op( B ) and the number of columns of the matrix C. N must be */
+/*           at least zero. */
+/*           Unchanged on exit. */
+
+/*  K      - INTEGER. */
+/*           On entry,  K  specifies  the number of columns of the matrix */
+/*           op( A ) and the number of rows of the matrix op( B ). K must */
+/*           be at least  zero. */
+/*           Unchanged on exit. */
+
+/*  ALPHA  - DOUBLE PRECISION. */
+/*           On entry, ALPHA specifies the scalar alpha. */
+/*           Unchanged on exit. */
+
+/*  A      - DOUBLE PRECISION array of DIMENSION ( LDA, ka ), where ka is */
+/*           k  when  TRANSA = 'N' or 'n',  and is  m  otherwise. */
+/*           Before entry with  TRANSA = 'N' or 'n',  the leading  m by k */
+/*           part of the array  A  must contain the matrix  A,  otherwise */
+/*           the leading  k by m  part of the array  A  must contain  the */
+/*           matrix A. */
+/*           Unchanged on exit. */
+
+/*  LDA    - INTEGER. */
+/*           On entry, LDA specifies the first dimension of A as declared */
+/*           in the calling (sub) program. When  TRANSA = 'N' or 'n' then */
+/*           LDA must be at least  lmax( 1, m ), otherwise  LDA must be at */
+/*           least  lmax( 1, k ). */
+/*           Unchanged on exit. */
+
+/*  B      - DOUBLE PRECISION array of DIMENSION ( LDB, kb ), where kb is */
+/*           n  when  TRANSB = 'N' or 'n',  and is  k  otherwise. */
+/*           Before entry with  TRANSB = 'N' or 'n',  the leading  k by n */
+/*           part of the array  B  must contain the matrix  B,  otherwise */
+/*           the leading  n by k  part of the array  B  must contain  the */
+/*           matrix B. */
+/*           Unchanged on exit. */
+
+/*  LDB    - INTEGER. */
+/*           On entry, LDB specifies the first dimension of B as declared */
+/*           in the calling (sub) program. When  TRANSB = 'N' or 'n' then */
+/*           LDB must be at least  lmax( 1, k ), otherwise  LDB must be at */
+/*           least  lmax( 1, n ). */
+/*           Unchanged on exit. */
+
+/*  BETA   - DOUBLE PRECISION. */
+/*           On entry,  BETA  specifies the scalar  beta.  When  BETA  is */
+/*           supplied as zero then C need not be set on input. */
+/*           Unchanged on exit. */
+
+/*  C      - DOUBLE PRECISION array of DIMENSION ( LDC, n ). */
+/*           Before entry, the leading  m by n  part of the array  C must */
+/*           contain the matrix  C,  except when  beta  is zero, in which */
+/*           case C need not be set on entry. */
+/*           On exit, the array  C  is overwritten by the  m by n  matrix */
+/*           ( alpha*op( A )*op( B ) + beta*C ). */
+
+/*  LDC    - INTEGER. */
+/*           On entry, LDC specifies the first dimension of C as declared */
+/*           in  the  calling  (sub)  program.   LDC  must  be  at  least */
+/*           lmax( 1, m ). */
+/*           Unchanged on exit. */
+
+
+/*  Level 3 Blas routine. */
+
+/*  -- Written on 8-February-1989. */
+/*     Jack Dongarra, Argonne National Laboratory. */
+/*     Iain Duff, AERE Harwell. */
+/*     Jeremy Du Croz, Numerical Algorithms Group Ltd. */
+/*     Sven Hammarling, Numerical Algorithms Group Ltd. */
+
+
+/*     .. External Functions .. */
+/*     .. */
+/*     .. External Subroutines .. */
+/*     .. */
+/*     .. Intrinsic Functions .. */
+/*     .. */
+/*     .. Local Scalars .. */
+/*     .. */
+/*     .. Parameters .. */
+/*     .. */
+
+/*     Set  NOTA  and  NOTB  as  true if  A  and  B  respectively are not */
+/*     transposed and set  NROWA, NCOLA and  NROWB  as the number of rows */
+/*     and  columns of  A  and the  number of  rows  of  B  respectively. */
+
+    /* Parameter adjustments */
+    a_dim1 = *lda;
+    a_offset = 1 + a_dim1;
+    a -= a_offset;
+    b_dim1 = *ldb;
+    b_offset = 1 + b_dim1;
+    b -= b_offset;
+    c_dim1 = *ldc;
+    c_offset = 1 + c_dim1;
+    c__ -= c_offset;
+
+    /* Function Body */
+    nota = lsame_(transa, "N");
+    notb = lsame_(transb, "N");
+    if (nota) {
+	nrowa = *m;
+	ncola = *k;
+    } else {
+	nrowa = *k;
+	ncola = *m;
+    }
+    if (notb) {
+	nrowb = *k;
+    } else {
+	nrowb = *n;
+    }
+
+/*     Test the input parameters. */
+
+    info = 0;
+    if (! nota && ! lsame_(transa, "C") && ! lsame_(
+	    transa, "T")) {
+	info = 1;
+    } else if (! notb && ! lsame_(transb, "C") && ! 
+	    lsame_(transb, "T")) {
+	info = 2;
+    } else if (*m < 0) {
+	info = 3;
+    } else if (*n < 0) {
+	info = 4;
+    } else if (*k < 0) {
+	info = 5;
+    } else if (*lda < lmax(1,nrowa)) {
+	info = 8;
+    } else if (*ldb < lmax(1,nrowb)) {
+	info = 10;
+    } else if (*ldc < lmax(1,*m)) {
+	info = 13;
+    }
+    if (info != 0) {
+	xerbla_("DGEMM ", &info);
+	return 0;
+    }
+
+/*     Quick return if possible. */
+
+    if (*m == 0 || *n == 0 || (*alpha == 0. || *k == 0) && *beta == 1.) {
+	return 0;
+    }
+
+/*     And if  alpha.eq.zero. */
+
+    if (*alpha == 0.) {
+	if (*beta == 0.) {
+	    i__1 = *n;
+	    for (j = 1; j <= i__1; ++j) {
+		i__2 = *m;
+		for (i__ = 1; i__ <= i__2; ++i__) {
+		    c__[i__ + j * c_dim1] = 0.;
+/* L10: */
+		}
+/* L20: */
+	    }
+	} else {
+	    i__1 = *n;
+	    for (j = 1; j <= i__1; ++j) {
+		i__2 = *m;
+		for (i__ = 1; i__ <= i__2; ++i__) {
+		    c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
+/* L30: */
+		}
+/* L40: */
+	    }
+	}
+	return 0;
+    }
+
+/*     Start the operations. */
+
+    if (notb) {
+	if (nota) {
+
+/*           Form  C := alpha*A*B + beta*C. */
+
+	    i__1 = *n;
+	    for (j = 1; j <= i__1; ++j) {
+		if (*beta == 0.) {
+		    i__2 = *m;
+		    for (i__ = 1; i__ <= i__2; ++i__) {
+			c__[i__ + j * c_dim1] = 0.;
+/* L50: */
+		    }
+		} else if (*beta != 1.) {
+		    i__2 = *m;
+		    for (i__ = 1; i__ <= i__2; ++i__) {
+			c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
+/* L60: */
+		    }
+		}
+		i__2 = *k;
+		for (l = 1; l <= i__2; ++l) {
+		    if (b[l + j * b_dim1] != 0.) {
+			temp = *alpha * b[l + j * b_dim1];
+			i__3 = *m;
+			for (i__ = 1; i__ <= i__3; ++i__) {
+			    c__[i__ + j * c_dim1] += temp * a[i__ + l * 
+				    a_dim1];
+/* L70: */
+			}
+		    }
+/* L80: */
+		}
+/* L90: */
+	    }
+	} else {
+
+/*           Form  C := alpha*A'*B + beta*C */
+
+	    i__1 = *n;
+	    for (j = 1; j <= i__1; ++j) {
+		i__2 = *m;
+		for (i__ = 1; i__ <= i__2; ++i__) {
+		    temp = 0.;
+		    i__3 = *k;
+		    for (l = 1; l <= i__3; ++l) {
+			temp += a[l + i__ * a_dim1] * b[l + j * b_dim1];
+/* L100: */
+		    }
+		    if (*beta == 0.) {
+			c__[i__ + j * c_dim1] = *alpha * temp;
+		    } else {
+			c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
+				i__ + j * c_dim1];
+		    }
+/* L110: */
+		}
+/* L120: */
+	    }
+	}
+    } else {
+	if (nota) {
+
+/*           Form  C := alpha*A*B' + beta*C */
+
+	    i__1 = *n;
+	    for (j = 1; j <= i__1; ++j) {
+		if (*beta == 0.) {
+		    i__2 = *m;
+		    for (i__ = 1; i__ <= i__2; ++i__) {
+			c__[i__ + j * c_dim1] = 0.;
+/* L130: */
+		    }
+		} else if (*beta != 1.) {
+		    i__2 = *m;
+		    for (i__ = 1; i__ <= i__2; ++i__) {
+			c__[i__ + j * c_dim1] = *beta * c__[i__ + j * c_dim1];
+/* L140: */
+		    }
+		}
+		i__2 = *k;
+		for (l = 1; l <= i__2; ++l) {
+		    if (b[j + l * b_dim1] != 0.) {
+			temp = *alpha * b[j + l * b_dim1];
+			i__3 = *m;
+			for (i__ = 1; i__ <= i__3; ++i__) {
+			    c__[i__ + j * c_dim1] += temp * a[i__ + l * 
+				    a_dim1];
+/* L150: */
+			}
+		    }
+/* L160: */
+		}
+/* L170: */
+	    }
+	} else {
+
+/*           Form  C := alpha*A'*B' + beta*C */
+
+	    i__1 = *n;
+	    for (j = 1; j <= i__1; ++j) {
+		i__2 = *m;
+		for (i__ = 1; i__ <= i__2; ++i__) {
+		    temp = 0.;
+		    i__3 = *k;
+		    for (l = 1; l <= i__3; ++l) {
+			temp += a[l + i__ * a_dim1] * b[j + l * b_dim1];
+/* L180: */
+		    }
+		    if (*beta == 0.) {
+			c__[i__ + j * c_dim1] = *alpha * temp;
+		    } else {
+			c__[i__ + j * c_dim1] = *alpha * temp + *beta * c__[
+				i__ + j * c_dim1];
+		    }
+/* L190: */
+		}
+/* L200: */
+	    }
+	}
+    }
+
+    return 0;
+
+/*     End of DGEMM . */
+
+} /* dgemm_ */

+ 194 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dger.c

@@ -0,0 +1,194 @@
+/* dger.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+	on Microsoft Windows system, link with libf2c.lib;
+	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+	or, if you install libf2c.a in a standard place, with -lf2c -lm
+	-- in that order, at the end of the command line, as in
+		cc *.o -lf2c -lm
+	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+		http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+
+/* Subroutine */ int dger_(integer *m, integer *n, doublereal *alpha, 
+	doublereal *x, integer *incx, doublereal *y, integer *incy, 
+	doublereal *a, integer *lda)
+{
+    /* System generated locals */
+    integer a_dim1, a_offset, i__1, i__2;
+
+    /* Local variables */
+    integer i__, j, ix, jy, kx, info;
+    doublereal temp;
+    extern /* Subroutine */ int xerbla_(char *, integer *);
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+/*     .. Array Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*  DGER   performs the rank 1 operation */
+
+/*     A := alpha*x*y' + A, */
+
+/*  where alpha is a scalar, x is an m element vector, y is an n element */
+/*  vector and A is an m by n matrix. */
+
+/*  Arguments */
+/*  ========== */
+
+/*  M      - INTEGER. */
+/*           On entry, M specifies the number of rows of the matrix A. */
+/*           M must be at least zero. */
+/*           Unchanged on exit. */
+
+/*  N      - INTEGER. */
+/*           On entry, N specifies the number of columns of the matrix A. */
+/*           N must be at least zero. */
+/*           Unchanged on exit. */
+
+/*  ALPHA  - DOUBLE PRECISION. */
+/*           On entry, ALPHA specifies the scalar alpha. */
+/*           Unchanged on exit. */
+
+/*  X      - DOUBLE PRECISION array of dimension at least */
+/*           ( 1 + ( m - 1 )*abs( INCX ) ). */
+/*           Before entry, the incremented array X must contain the m */
+/*           element vector x. */
+/*           Unchanged on exit. */
+
+/*  INCX   - INTEGER. */
+/*           On entry, INCX specifies the increment for the elements of */
+/*           X. INCX must not be zero. */
+/*           Unchanged on exit. */
+
+/*  Y      - DOUBLE PRECISION array of dimension at least */
+/*           ( 1 + ( n - 1 )*abs( INCY ) ). */
+/*           Before entry, the incremented array Y must contain the n */
+/*           element vector y. */
+/*           Unchanged on exit. */
+
+/*  INCY   - INTEGER. */
+/*           On entry, INCY specifies the increment for the elements of */
+/*           Y. INCY must not be zero. */
+/*           Unchanged on exit. */
+
+/*  A      - DOUBLE PRECISION array of DIMENSION ( LDA, n ). */
+/*           Before entry, the leading m by n part of the array A must */
+/*           contain the matrix of coefficients. On exit, A is */
+/*           overwritten by the updated matrix. */
+
+/*  LDA    - INTEGER. */
+/*           On entry, LDA specifies the first dimension of A as declared */
+/*           in the calling (sub) program. LDA must be at least */
+/*           lmax( 1, m ). */
+/*           Unchanged on exit. */
+
+
+/*  Level 2 Blas routine. */
+
+/*  -- Written on 22-October-1986. */
+/*     Jack Dongarra, Argonne National Lab. */
+/*     Jeremy Du Croz, Nag Central Office. */
+/*     Sven Hammarling, Nag Central Office. */
+/*     Richard Hanson, Sandia National Labs. */
+
+
+/*     .. Parameters .. */
+/*     .. */
+/*     .. Local Scalars .. */
+/*     .. */
+/*     .. External Subroutines .. */
+/*     .. */
+/*     .. Intrinsic Functions .. */
+/*     .. */
+
+/*     Test the input parameters. */
+
+    /* Parameter adjustments */
+    --x;
+    --y;
+    a_dim1 = *lda;
+    a_offset = 1 + a_dim1;
+    a -= a_offset;
+
+    /* Function Body */
+    info = 0;
+    if (*m < 0) {
+	info = 1;
+    } else if (*n < 0) {
+	info = 2;
+    } else if (*incx == 0) {
+	info = 5;
+    } else if (*incy == 0) {
+	info = 7;
+    } else if (*lda < lmax(1,*m)) {
+	info = 9;
+    }
+    if (info != 0) {
+	xerbla_("DGER  ", &info);
+	return 0;
+    }
+
+/*     Quick return if possible. */
+
+    if (*m == 0 || *n == 0 || *alpha == 0.) {
+	return 0;
+    }
+
+/*     Start the operations. In this version the elements of A are */
+/*     accessed sequentially with one pass through A. */
+
+    if (*incy > 0) {
+	jy = 1;
+    } else {
+	jy = 1 - (*n - 1) * *incy;
+    }
+    if (*incx == 1) {
+	i__1 = *n;
+	for (j = 1; j <= i__1; ++j) {
+	    if (y[jy] != 0.) {
+		temp = *alpha * y[jy];
+		i__2 = *m;
+		for (i__ = 1; i__ <= i__2; ++i__) {
+		    a[i__ + j * a_dim1] += x[i__] * temp;
+/* L10: */
+		}
+	    }
+	    jy += *incy;
+/* L20: */
+	}
+    } else {
+	if (*incx > 0) {
+	    kx = 1;
+	} else {
+	    kx = 1 - (*m - 1) * *incx;
+	}
+	i__1 = *n;
+	for (j = 1; j <= i__1; ++j) {
+	    if (y[jy] != 0.) {
+		temp = *alpha * y[jy];
+		ix = kx;
+		i__2 = *m;
+		for (i__ = 1; i__ <= i__2; ++i__) {
+		    a[i__ + j * a_dim1] += x[ix] * temp;
+		    ix += *incx;
+/* L30: */
+		}
+	    }
+	    jy += *incy;
+/* L40: */
+	}
+    }
+
+    return 0;
+
+/*     End of DGER  . */
+
+} /* dger_ */

+ 138 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dgesv.c

@@ -0,0 +1,138 @@
+/* dgesv.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+	on Microsoft Windows system, link with libf2c.lib;
+	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+	or, if you install libf2c.a in a standard place, with -lf2c -lm
+	-- in that order, at the end of the command line, as in
+		cc *.o -lf2c -lm
+	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+		http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+
+/* Subroutine */ int dgesv_(integer *n, integer *nrhs, doublereal *a, integer 
+	*lda, integer *ipiv, doublereal *b, integer *ldb, integer *info)
+{
+    /* System generated locals */
+    integer a_dim1, a_offset, b_dim1, b_offset, i__1;
+
+    /* Local variables */
+    extern /* Subroutine */ int dgetrf_(integer *, integer *, doublereal *, 
+	    integer *, integer *, integer *), xerbla_(char *, integer *), dgetrs_(char *, integer *, integer *, doublereal *, 
+	    integer *, integer *, doublereal *, integer *, integer *);
+
+
+/*  -- LAPACK driver routine (version 3.2) -- */
+/*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
+/*     November 2006 */
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+/*     .. Array Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*  DGESV computes the solution to a real system of linear equations */
+/*     A * X = B, */
+/*  where A is an N-by-N matrix and X and B are N-by-NRHS matrices. */
+
+/*  The LU decomposition with partial pivoting and row interchanges is */
+/*  used to factor A as */
+/*     A = P * L * U, */
+/*  where P is a permutation matrix, L is unit lower triangular, and U is */
+/*  upper triangular.  The factored form of A is then used to solve the */
+/*  system of equations A * X = B. */
+
+/*  Arguments */
+/*  ========= */
+
+/*  N       (input) INTEGER */
+/*          The number of linear equations, i.e., the order of the */
+/*          matrix A.  N >= 0. */
+
+/*  NRHS    (input) INTEGER */
+/*          The number of right hand sides, i.e., the number of columns */
+/*          of the matrix B.  NRHS >= 0. */
+
+/*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
+/*          On entry, the N-by-N coefficient matrix A. */
+/*          On exit, the factors L and U from the factorization */
+/*          A = P*L*U; the unit diagonal elements of L are not stored. */
+
+/*  LDA     (input) INTEGER */
+/*          The leading dimension of the array A.  LDA >= lmax(1,N). */
+
+/*  IPIV    (output) INTEGER array, dimension (N) */
+/*          The pivot indices that define the permutation matrix P; */
+/*          row i of the matrix was interchanged with row IPIV(i). */
+
+/*  B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
+/*          On entry, the N-by-NRHS matrix of right hand side matrix B. */
+/*          On exit, if INFO = 0, the N-by-NRHS solution matrix X. */
+
+/*  LDB     (input) INTEGER */
+/*          The leading dimension of the array B.  LDB >= lmax(1,N). */
+
+/*  INFO    (output) INTEGER */
+/*          = 0:  successful exit */
+/*          < 0:  if INFO = -i, the i-th argument had an illegal value */
+/*          > 0:  if INFO = i, U(i,i) is exactly zero.  The factorization */
+/*                has been completed, but the factor U is exactly */
+/*                singular, so the solution could not be computed. */
+
+/*  ===================================================================== */
+
+/*     .. External Subroutines .. */
+/*     .. */
+/*     .. Intrinsic Functions .. */
+/*     .. */
+/*     .. Executable Statements .. */
+
+/*     Test the input parameters. */
+
+    /* Parameter adjustments */
+    a_dim1 = *lda;
+    a_offset = 1 + a_dim1;
+    a -= a_offset;
+    --ipiv;
+    b_dim1 = *ldb;
+    b_offset = 1 + b_dim1;
+    b -= b_offset;
+
+    /* Function Body */
+    *info = 0;
+    if (*n < 0) {
+	*info = -1;
+    } else if (*nrhs < 0) {
+	*info = -2;
+    } else if (*lda < lmax(1,*n)) {
+	*info = -4;
+    } else if (*ldb < lmax(1,*n)) {
+	*info = -7;
+    }
+    if (*info != 0) {
+	i__1 = -(*info);
+	xerbla_("DGESV ", &i__1);
+	return 0;
+    }
+
+/*     Compute the LU factorization of A. */
+
+    dgetrf_(n, n, &a[a_offset], lda, &ipiv[1], info);
+    if (*info == 0) {
+
+/*        Solve the system A*X = B, overwriting B with X. */
+
+	dgetrs_("No transpose", n, nrhs, &a[a_offset], lda, &ipiv[1], &b[
+		b_offset], ldb, info);
+    }
+    return 0;
+
+/*     End of DGESV */
+
+} /* dgesv_ */

+ 194 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dgetf2.c

@@ -0,0 +1,194 @@
+/* dgetf2.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+  on Microsoft Windows system, link with libf2c.lib;
+  on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+  or, if you install libf2c.a in a standard place, with -lf2c -lm
+  -- in that order, at the end of the command line, as in
+    cc *.o -lf2c -lm
+  Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+    http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+#include <math.h>
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static doublereal c_b8 = -1.;
+
+/* Subroutine */ int dgetf2_(integer *m, integer *n, doublereal *a, integer *
+  lda, integer *ipiv, integer *info)
+{
+    /* System generated locals */
+    integer a_dim1, a_offset, i__1, i__2, i__3;
+    doublereal d__1;
+
+    /* Local variables */
+    integer i__, j, jp;
+    extern /* Subroutine */ int dger_(integer *, integer *, doublereal *,
+      doublereal *, integer *, doublereal *, integer *, doublereal *,
+      integer *), dscal_(integer *, doublereal *, doublereal *, integer
+      *);
+    doublereal sfmin;
+    extern /* Subroutine */ int dswap_(integer *, doublereal *, integer *,
+      doublereal *, integer *);
+    extern doublereal dlamch_(char *);
+    extern integer idamax_(integer *, doublereal *, integer *);
+    extern /* Subroutine */ int xerbla_(char *, integer *);
+
+
+/*  -- LAPACK routine (version 3.2) -- */
+/*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
+/*     November 2006 */
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+/*     .. Array Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*  DGETF2 computes an LU factorization of a general m-by-n matrix A */
+/*  using partial pivoting with row interchanges. */
+
+/*  The factorization has the form */
+/*     A = P * L * U */
+/*  where P is a permutation matrix, L is lower triangular with unit */
+/*  diagonal elements (lower trapezoidal if m > n), and U is upper */
+/*  triangular (upper trapezoidal if m < n). */
+
+/*  This is the right-looking Level 2 BLAS version of the algorithm. */
+
+/*  Arguments */
+/*  ========= */
+
+/*  M       (input) INTEGER */
+/*          The number of rows of the matrix A.  M >= 0. */
+
+/*  N       (input) INTEGER */
+/*          The number of columns of the matrix A.  N >= 0. */
+
+/*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
+/*          On entry, the m by n matrix to be factored. */
+/*          On exit, the factors L and U from the factorization */
+/*          A = P*L*U; the unit diagonal elements of L are not stored. */
+
+/*  LDA     (input) INTEGER */
+/*          The leading dimension of the array A.  LDA >= lmax(1,M). */
+
+/*  IPIV    (output) INTEGER array, dimension (min(M,N)) */
+/*          The pivot indices; for 1 <= i <= lmin(M,N), row i of the */
+/*          matrix was interchanged with row IPIV(i). */
+
+/*  INFO    (output) INTEGER */
+/*          = 0: successful exit */
+/*          < 0: if INFO = -k, the k-th argument had an illegal value */
+/*          > 0: if INFO = k, U(k,k) is exactly zero. The factorization */
+/*               has been completed, but the factor U is exactly */
+/*               singular, and division by zero will occur if it is used */
+/*               to solve a system of equations. */
+
+/*  ===================================================================== */
+
+/*     .. Parameters .. */
+/*     .. */
+/*     .. Local Scalars .. */
+/*     .. */
+/*     .. External Functions .. */
+/*     .. */
+/*     .. External Subroutines .. */
+/*     .. */
+/*     .. Intrinsic Functions .. */
+/*     .. */
+/*     .. Executable Statements .. */
+
+/*     Test the input parameters. */
+
+    /* Parameter adjustments */
+    a_dim1 = *lda;
+    a_offset = 1 + a_dim1;
+    a -= a_offset;
+    --ipiv;
+
+    /* Function Body */
+    *info = 0;
+    if (*m < 0) {
+  *info = -1;
+    } else if (*n < 0) {
+  *info = -2;
+    } else if (*lda < lmax(1,*m)) {
+  *info = -4;
+    }
+    if (*info != 0) {
+  i__1 = -(*info);
+  xerbla_("DGETF2", &i__1);
+  return 0;
+    }
+
+/*     Quick return if possible */
+
+    if (*m == 0 || *n == 0) {
+  return 0;
+    }
+
+/*     Compute machine safe minimum */
+
+    sfmin = dlamch_("S");
+
+    i__1 = lmin(*m,*n);
+    for (j = 1; j <= i__1; ++j) {
+
+/*        Find pivot and test for singularity. */
+
+  i__2 = *m - j + 1;
+  jp = j - 1 + idamax_(&i__2, &a[j + j * a_dim1], &c__1);
+  ipiv[j] = jp;
+  if (a[jp + j * a_dim1] != 0.) {
+
+/*           Apply the interchange to columns 1:N. */
+
+      if (jp != j) {
+    dswap_(n, &a[j + a_dim1], lda, &a[jp + a_dim1], lda);
+      }
+
+/*           Compute elements J+1:M of J-th column. */
+
+      if (j < *m) {
+    if ((d__1 = a[j + j * a_dim1], fabs(d__1)) >= sfmin) {
+        i__2 = *m - j;
+        d__1 = 1. / a[j + j * a_dim1];
+        dscal_(&i__2, &d__1, &a[j + 1 + j * a_dim1], &c__1);
+    } else {
+        i__2 = *m - j;
+        for (i__ = 1; i__ <= i__2; ++i__) {
+      a[j + i__ + j * a_dim1] /= a[j + j * a_dim1];
+/* L20: */
+        }
+    }
+      }
+
+  } else if (*info == 0) {
+
+      *info = j;
+  }
+
+  if (j < lmin(*m,*n)) {
+
+/*           Update trailing submatrix. */
+
+      i__2 = *m - j;
+      i__3 = *n - j;
+      dger_(&i__2, &i__3, &c_b8, &a[j + 1 + j * a_dim1], &c__1, &a[j + (
+        j + 1) * a_dim1], lda, &a[j + 1 + (j + 1) * a_dim1], lda);
+  }
+/* L10: */
+    }
+    return 0;
+
+/*     End of DGETF2 */
+
+} /* dgetf2_ */

+ 219 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dgetrf.c

@@ -0,0 +1,219 @@
+/* dgetrf.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+	on Microsoft Windows system, link with libf2c.lib;
+	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+	or, if you install libf2c.a in a standard place, with -lf2c -lm
+	-- in that order, at the end of the command line, as in
+		cc *.o -lf2c -lm
+	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+		http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static integer c_n1 = -1;
+static doublereal c_b16 = 1.;
+static doublereal c_b19 = -1.;
+
+/* Subroutine */ int dgetrf_(integer *m, integer *n, doublereal *a, integer *
+	lda, integer *ipiv, integer *info)
+{
+    /* System generated locals */
+    integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
+
+    /* Local variables */
+    integer i__, j, jb, nb;
+    extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *, 
+	    integer *, doublereal *, doublereal *, integer *, doublereal *, 
+	    integer *, doublereal *, doublereal *, integer *);
+    integer iinfo;
+    extern /* Subroutine */ int dtrsm_(char *, char *, char *, char *, 
+	    integer *, integer *, doublereal *, doublereal *, integer *, 
+	    doublereal *, integer *), dgetf2_(
+	    integer *, integer *, doublereal *, integer *, integer *, integer 
+	    *), xerbla_(char *, integer *);
+    extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
+	    integer *, integer *);
+    extern /* Subroutine */ int dlaswp_(integer *, doublereal *, integer *, 
+	    integer *, integer *, integer *, integer *);
+
+
+/*  -- LAPACK routine (version 3.2) -- */
+/*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
+/*     November 2006 */
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+/*     .. Array Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*  DGETRF computes an LU factorization of a general M-by-N matrix A */
+/*  using partial pivoting with row interchanges. */
+
+/*  The factorization has the form */
+/*     A = P * L * U */
+/*  where P is a permutation matrix, L is lower triangular with unit */
+/*  diagonal elements (lower trapezoidal if m > n), and U is upper */
+/*  triangular (upper trapezoidal if m < n). */
+
+/*  This is the right-looking Level 3 BLAS version of the algorithm. */
+
+/*  Arguments */
+/*  ========= */
+
+/*  M       (input) INTEGER */
+/*          The number of rows of the matrix A.  M >= 0. */
+
+/*  N       (input) INTEGER */
+/*          The number of columns of the matrix A.  N >= 0. */
+
+/*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
+/*          On entry, the M-by-N matrix to be factored. */
+/*          On exit, the factors L and U from the factorization */
+/*          A = P*L*U; the unit diagonal elements of L are not stored. */
+
+/*  LDA     (input) INTEGER */
+/*          The leading dimension of the array A.  LDA >= lmax(1,M). */
+
+/*  IPIV    (output) INTEGER array, dimension (min(M,N)) */
+/*          The pivot indices; for 1 <= i <= lmin(M,N), row i of the */
+/*          matrix was interchanged with row IPIV(i). */
+
+/*  INFO    (output) INTEGER */
+/*          = 0:  successful exit */
+/*          < 0:  if INFO = -i, the i-th argument had an illegal value */
+/*          > 0:  if INFO = i, U(i,i) is exactly zero. The factorization */
+/*                has been completed, but the factor U is exactly */
+/*                singular, and division by zero will occur if it is used */
+/*                to solve a system of equations. */
+
+/*  ===================================================================== */
+
+/*     .. Parameters .. */
+/*     .. */
+/*     .. Local Scalars .. */
+/*     .. */
+/*     .. External Subroutines .. */
+/*     .. */
+/*     .. External Functions .. */
+/*     .. */
+/*     .. Intrinsic Functions .. */
+/*     .. */
+/*     .. Executable Statements .. */
+
+/*     Test the input parameters. */
+
+    /* Parameter adjustments */
+    a_dim1 = *lda;
+    a_offset = 1 + a_dim1;
+    a -= a_offset;
+    --ipiv;
+
+    /* Function Body */
+    *info = 0;
+    if (*m < 0) {
+	*info = -1;
+    } else if (*n < 0) {
+	*info = -2;
+    } else if (*lda < lmax(1,*m)) {
+	*info = -4;
+    }
+    if (*info != 0) {
+	i__1 = -(*info);
+	xerbla_("DGETRF", &i__1);
+	return 0;
+    }
+
+/*     Quick return if possible */
+
+    if (*m == 0 || *n == 0) {
+	return 0;
+    }
+
+/*     Determine the block size for this environment. */
+
+    nb = ilaenv_(&c__1, "DGETRF", " ", m, n, &c_n1, &c_n1);
+    if (nb <= 1 || nb >= lmin(*m,*n)) {
+
+/*        Use unblocked code. */
+
+	dgetf2_(m, n, &a[a_offset], lda, &ipiv[1], info);
+    } else {
+
+/*        Use blocked code. */
+
+	i__1 = lmin(*m,*n);
+	i__2 = nb;
+	for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
+/* Computing MIN */
+	    i__3 = lmin(*m,*n) - j + 1;
+	    jb = lmin(i__3,nb);
+
+/*           Factor diagonal and subdiagonal blocks and test for exact */
+/*           singularity. */
+
+	    i__3 = *m - j + 1;
+	    dgetf2_(&i__3, &jb, &a[j + j * a_dim1], lda, &ipiv[j], &iinfo);
+
+/*           Adjust INFO and the pivot indices. */
+
+	    if (*info == 0 && iinfo > 0) {
+		*info = iinfo + j - 1;
+	    }
+/* Computing MIN */
+	    i__4 = *m, i__5 = j + jb - 1;
+	    i__3 = lmin(i__4,i__5);
+	    for (i__ = j; i__ <= i__3; ++i__) {
+		ipiv[i__] = j - 1 + ipiv[i__];
+/* L10: */
+	    }
+
+/*           Apply interchanges to columns 1:J-1. */
+
+	    i__3 = j - 1;
+	    i__4 = j + jb - 1;
+	    dlaswp_(&i__3, &a[a_offset], lda, &j, &i__4, &ipiv[1], &c__1);
+
+	    if (j + jb <= *n) {
+
+/*              Apply interchanges to columns J+JB:N. */
+
+		i__3 = *n - j - jb + 1;
+		i__4 = j + jb - 1;
+		dlaswp_(&i__3, &a[(j + jb) * a_dim1 + 1], lda, &j, &i__4, &
+			ipiv[1], &c__1);
+
+/*              Compute block row of U. */
+
+		i__3 = *n - j - jb + 1;
+		dtrsm_("Left", "Lower", "No transpose", "Unit", &jb, &i__3, &
+			c_b16, &a[j + j * a_dim1], lda, &a[j + (j + jb) * 
+			a_dim1], lda);
+		if (j + jb <= *m) {
+
+/*                 Update trailing submatrix. */
+
+		    i__3 = *m - j - jb + 1;
+		    i__4 = *n - j - jb + 1;
+		    dgemm_("No transpose", "No transpose", &i__3, &i__4, &jb, 
+			    &c_b19, &a[j + jb + j * a_dim1], lda, &a[j + (j + 
+			    jb) * a_dim1], lda, &c_b16, &a[j + jb + (j + jb) *
+			     a_dim1], lda);
+		}
+	    }
+/* L20: */
+	}
+    }
+    return 0;
+
+/*     End of DGETRF */
+
+} /* dgetrf_ */

+ 186 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dgetrs.c

@@ -0,0 +1,186 @@
+/* dgetrs.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+	on Microsoft Windows system, link with libf2c.lib;
+	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+	or, if you install libf2c.a in a standard place, with -lf2c -lm
+	-- in that order, at the end of the command line, as in
+		cc *.o -lf2c -lm
+	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+		http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static doublereal c_b12 = 1.;
+static integer c_n1 = -1;
+
+/* Subroutine */ int dgetrs_(char *trans, integer *n, integer *nrhs, 
+	doublereal *a, integer *lda, integer *ipiv, doublereal *b, integer *
+	ldb, integer *info)
+{
+    /* System generated locals */
+    integer a_dim1, a_offset, b_dim1, b_offset, i__1;
+
+    /* Local variables */
+    extern logical lsame_(char *, char *);
+    extern /* Subroutine */ int dtrsm_(char *, char *, char *, char *, 
+	    integer *, integer *, doublereal *, doublereal *, integer *, 
+	    doublereal *, integer *), xerbla_(
+	    char *, integer *), dlaswp_(integer *, doublereal *, 
+	    integer *, integer *, integer *, integer *, integer *);
+    logical notran;
+
+
+/*  -- LAPACK routine (version 3.2) -- */
+/*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
+/*     November 2006 */
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+/*     .. Array Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*  DGETRS solves a system of linear equations */
+/*     A * X = B  or  A' * X = B */
+/*  with a general N-by-N matrix A using the LU factorization computed */
+/*  by DGETRF. */
+
+/*  Arguments */
+/*  ========= */
+
+/*  TRANS   (input) CHARACTER*1 */
+/*          Specifies the form of the system of equations: */
+/*          = 'N':  A * X = B  (No transpose) */
+/*          = 'T':  A'* X = B  (Transpose) */
+/*          = 'C':  A'* X = B  (Conjugate transpose = Transpose) */
+
+/*  N       (input) INTEGER */
+/*          The order of the matrix A.  N >= 0. */
+
+/*  NRHS    (input) INTEGER */
+/*          The number of right hand sides, i.e., the number of columns */
+/*          of the matrix B.  NRHS >= 0. */
+
+/*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
+/*          The factors L and U from the factorization A = P*L*U */
+/*          as computed by DGETRF. */
+
+/*  LDA     (input) INTEGER */
+/*          The leading dimension of the array A.  LDA >= lmax(1,N). */
+
+/*  IPIV    (input) INTEGER array, dimension (N) */
+/*          The pivot indices from DGETRF; for 1<=i<=N, row i of the */
+/*          matrix was interchanged with row IPIV(i). */
+
+/*  B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
+/*          On entry, the right hand side matrix B. */
+/*          On exit, the solution matrix X. */
+
+/*  LDB     (input) INTEGER */
+/*          The leading dimension of the array B.  LDB >= lmax(1,N). */
+
+/*  INFO    (output) INTEGER */
+/*          = 0:  successful exit */
+/*          < 0:  if INFO = -i, the i-th argument had an illegal value */
+
+/*  ===================================================================== */
+
+/*     .. Parameters .. */
+/*     .. */
+/*     .. Local Scalars .. */
+/*     .. */
+/*     .. External Functions .. */
+/*     .. */
+/*     .. External Subroutines .. */
+/*     .. */
+/*     .. Intrinsic Functions .. */
+/*     .. */
+/*     .. Executable Statements .. */
+
+/*     Test the input parameters. */
+
+    /* Parameter adjustments */
+    a_dim1 = *lda;
+    a_offset = 1 + a_dim1;
+    a -= a_offset;
+    --ipiv;
+    b_dim1 = *ldb;
+    b_offset = 1 + b_dim1;
+    b -= b_offset;
+
+    /* Function Body */
+    *info = 0;
+    notran = lsame_(trans, "N");
+    if (! notran && ! lsame_(trans, "T") && ! lsame_(
+	    trans, "C")) {
+	*info = -1;
+    } else if (*n < 0) {
+	*info = -2;
+    } else if (*nrhs < 0) {
+	*info = -3;
+    } else if (*lda < lmax(1,*n)) {
+	*info = -5;
+    } else if (*ldb < lmax(1,*n)) {
+	*info = -8;
+    }
+    if (*info != 0) {
+	i__1 = -(*info);
+	xerbla_("DGETRS", &i__1);
+	return 0;
+    }
+
+/*     Quick return if possible */
+
+    if (*n == 0 || *nrhs == 0) {
+	return 0;
+    }
+
+    if (notran) {
+
+/*        Solve A * X = B. */
+
+/*        Apply row interchanges to the right hand sides. */
+
+	dlaswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c__1);
+
+/*        Solve L*X = B, overwriting B with X. */
+
+	dtrsm_("Left", "Lower", "No transpose", "Unit", n, nrhs, &c_b12, &a[
+		a_offset], lda, &b[b_offset], ldb);
+
+/*        Solve U*X = B, overwriting B with X. */
+
+	dtrsm_("Left", "Upper", "No transpose", "Non-unit", n, nrhs, &c_b12, &
+		a[a_offset], lda, &b[b_offset], ldb);
+    } else {
+
+/*        Solve A' * X = B. */
+
+/*        Solve U'*X = B, overwriting B with X. */
+
+	dtrsm_("Left", "Upper", "Transpose", "Non-unit", n, nrhs, &c_b12, &a[
+		a_offset], lda, &b[b_offset], ldb);
+
+/*        Solve L'*X = B, overwriting B with X. */
+
+	dtrsm_("Left", "Lower", "Transpose", "Unit", n, nrhs, &c_b12, &a[
+		a_offset], lda, &b[b_offset], ldb);
+
+/*        Apply row interchanges to the solution vectors. */
+
+	dlaswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c_n1);
+    }
+
+    return 0;
+
+/*     End of DGETRS */
+
+} /* dgetrs_ */

File diff suppressed because it is too large
+ 1006 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dlamch.c


+ 158 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dlaswp.c

@@ -0,0 +1,158 @@
+/* dlaswp.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+	on Microsoft Windows system, link with libf2c.lib;
+	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+	or, if you install libf2c.a in a standard place, with -lf2c -lm
+	-- in that order, at the end of the command line, as in
+		cc *.o -lf2c -lm
+	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+		http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+
+/* Subroutine */ int dlaswp_(integer *n, doublereal *a, integer *lda, integer 
+	*k1, integer *k2, integer *ipiv, integer *incx)
+{
+    /* System generated locals */
+    integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
+
+    /* Local variables */
+    integer i__, j, k, i1, i2, n32, ip, ix, ix0, inc;
+    doublereal temp;
+
+
+/*  -- LAPACK auxiliary routine (version 3.2) -- */
+/*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
+/*     November 2006 */
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+/*     .. Array Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*  DLASWP performs a series of row interchanges on the matrix A. */
+/*  One row interchange is initiated for each of rows K1 through K2 of A. */
+
+/*  Arguments */
+/*  ========= */
+
+/*  N       (input) INTEGER */
+/*          The number of columns of the matrix A. */
+
+/*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
+/*          On entry, the matrix of column dimension N to which the row */
+/*          interchanges will be applied. */
+/*          On exit, the permuted matrix. */
+
+/*  LDA     (input) INTEGER */
+/*          The leading dimension of the array A. */
+
+/*  K1      (input) INTEGER */
+/*          The first element of IPIV for which a row interchange will */
+/*          be done. */
+
+/*  K2      (input) INTEGER */
+/*          The last element of IPIV for which a row interchange will */
+/*          be done. */
+
+/*  IPIV    (input) INTEGER array, dimension (K2*abs(INCX)) */
+/*          The vector of pivot indices.  Only the elements in positions */
+/*          K1 through K2 of IPIV are accessed. */
+/*          IPIV(K) = L implies rows K and L are to be interchanged. */
+
+/*  INCX    (input) INTEGER */
+/*          The increment between successive values of IPIV.  If IPIV */
+/*          is negative, the pivots are applied in reverse order. */
+
+/*  Further Details */
+/*  =============== */
+
+/*  Modified by */
+/*   R. C. Whaley, Computer Science Dept., Univ. of Tenn., Knoxville, USA */
+
+/* ===================================================================== */
+
+/*     .. Local Scalars .. */
+/*     .. */
+/*     .. Executable Statements .. */
+
+/*     Interchange row I with row IPIV(I) for each of rows K1 through K2. */
+
+    /* Parameter adjustments */
+    a_dim1 = *lda;
+    a_offset = 1 + a_dim1;
+    a -= a_offset;
+    --ipiv;
+
+    /* Function Body */
+    if (*incx > 0) {
+	ix0 = *k1;
+	i1 = *k1;
+	i2 = *k2;
+	inc = 1;
+    } else if (*incx < 0) {
+	ix0 = (1 - *k2) * *incx + 1;
+	i1 = *k2;
+	i2 = *k1;
+	inc = -1;
+    } else {
+	return 0;
+    }
+
+    n32 = *n / 32 << 5;
+    if (n32 != 0) {
+	i__1 = n32;
+	for (j = 1; j <= i__1; j += 32) {
+	    ix = ix0;
+	    i__2 = i2;
+	    i__3 = inc;
+	    for (i__ = i1; i__3 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__3) 
+		    {
+		ip = ipiv[ix];
+		if (ip != i__) {
+		    i__4 = j + 31;
+		    for (k = j; k <= i__4; ++k) {
+			temp = a[i__ + k * a_dim1];
+			a[i__ + k * a_dim1] = a[ip + k * a_dim1];
+			a[ip + k * a_dim1] = temp;
+/* L10: */
+		    }
+		}
+		ix += *incx;
+/* L20: */
+	    }
+/* L30: */
+	}
+    }
+    if (n32 != *n) {
+	++n32;
+	ix = ix0;
+	i__1 = i2;
+	i__3 = inc;
+	for (i__ = i1; i__3 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__3) {
+	    ip = ipiv[ix];
+	    if (ip != i__) {
+		i__2 = *n;
+		for (k = n32; k <= i__2; ++k) {
+		    temp = a[i__ + k * a_dim1];
+		    a[i__ + k * a_dim1] = a[ip + k * a_dim1];
+		    a[ip + k * a_dim1] = temp;
+/* L40: */
+		}
+	    }
+	    ix += *incx;
+/* L50: */
+	}
+    }
+
+    return 0;
+
+/*     End of DLASWP */
+
+} /* dlaswp_ */

+ 253 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dogleg_.c

@@ -0,0 +1,253 @@
+/* dogleg.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+
+/* Table of constant values */
+
+__minpack_attr__
+void __minpack_func__(dogleg)(const int *n, const real *r__, const int *lr, 
+	const real *diag, const real *qtb, const real *delta, real *x, 
+	real *wa1, real *wa2)
+{
+    /* System generated locals */
+    int i__1, i__2;
+    real d__1, d__2, d__3, d__4;
+
+    /* Local variables */
+    int i__, j, k, l, jj, jp1;
+    real sum, temp, alpha, bnorm;
+    real gnorm, qnorm, epsmch;
+    real sgnorm;
+    const int c__1 = 1;
+
+/*     ********** */
+
+/*     subroutine dogleg */
+
+/*     given an m by n matrix a, an n by n nonsingular diagonal */
+/*     matrix d, an m-vector b, and a positive number delta, the */
+/*     problem is to determine the convex combination x of the */
+/*     gauss-newton and scaled gradient directions that minimizes */
+/*     (a*x - b) in the least squares sense, subject to the */
+/*     restriction that the euclidean norm of d*x be at most delta. */
+
+/*     this subroutine completes the solution of the problem */
+/*     if it is provided with the necessary information from the */
+/*     qr factorization of a. that is, if a = q*r, where q has */
+/*     orthogonal columns and r is an upper triangular matrix, */
+/*     then dogleg expects the full upper triangle of r and */
+/*     the first n components of (q transpose)*b. */
+
+/*     the subroutine statement is */
+
+/*       subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2) */
+
+/*     where */
+
+/*       n is a positive integer input variable set to the order of r. */
+
+/*       r is an input array of length lr which must contain the upper */
+/*         triangular matrix r stored by rows. */
+
+/*       lr is a positive integer input variable not less than */
+/*         (n*(n+1))/2. */
+
+/*       diag is an input array of length n which must contain the */
+/*         diagonal elements of the matrix d. */
+
+/*       qtb is an input array of length n which must contain the first */
+/*         n elements of the vector (q transpose)*b. */
+
+/*       delta is a positive input variable which specifies an upper */
+/*         bound on the euclidean norm of d*x. */
+
+/*       x is an output array of length n which contains the desired */
+/*         convex combination of the gauss-newton direction and the */
+/*         scaled gradient direction. */
+
+/*       wa1 and wa2 are work arrays of length n. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... dpmpar,enorm */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa2;
+    --wa1;
+    --x;
+    --qtb;
+    --diag;
+    --r__;
+    (void)lr;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __minpack_func__(dpmpar)(&c__1);
+
+/*     first, calculate the gauss-newton direction. */
+
+    jj = *n * (*n + 1) / 2 + 1;
+    i__1 = *n;
+    for (k = 1; k <= i__1; ++k) {
+	j = *n - k + 1;
+	jp1 = j + 1;
+	jj -= k;
+	l = jj + 1;
+	sum = 0.;
+	if (*n < jp1) {
+	    goto L20;
+	}
+	i__2 = *n;
+	for (i__ = jp1; i__ <= i__2; ++i__) {
+	    sum += r__[l] * x[i__];
+	    ++l;
+/* L10: */
+	}
+L20:
+	temp = r__[jj];
+	if (temp != 0.) {
+	    goto L40;
+	}
+	l = j;
+	i__2 = j;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+/* Computing MAX */
+	    d__2 = temp, d__3 = fabs(r__[l]);
+	    temp = max(d__2,d__3);
+	    l = l + *n - i__;
+/* L30: */
+	}
+	temp = epsmch * temp;
+	if (temp == 0.) {
+	    temp = epsmch;
+	}
+L40:
+	x[j] = (qtb[j] - sum) / temp;
+/* L50: */
+    }
+
+/*     test whether the gauss-newton direction is acceptable. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa1[j] = 0.;
+	wa2[j] = diag[j] * x[j];
+/* L60: */
+    }
+    qnorm = __minpack_func__(enorm)(n, &wa2[1]);
+    if (qnorm <= *delta) {
+	/* goto L140; */
+        return;
+    }
+
+/*     the gauss-newton direction is not acceptable. */
+/*     next, calculate the scaled gradient direction. */
+
+    l = 1;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	temp = qtb[j];
+	i__2 = *n;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    wa1[i__] += r__[l] * temp;
+	    ++l;
+/* L70: */
+	}
+	wa1[j] /= diag[j];
+/* L80: */
+    }
+
+/*     calculate the norm of the scaled gradient and test for */
+/*     the special case in which the scaled gradient is zero. */
+
+    gnorm = __minpack_func__(enorm)(n, &wa1[1]);
+    sgnorm = 0.;
+    alpha = *delta / qnorm;
+    if (gnorm == 0.) {
+	goto L120;
+    }
+
+/*     calculate the point along the scaled gradient */
+/*     at which the quadratic is minimized. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa1[j] = wa1[j] / gnorm / diag[j];
+/* L90: */
+    }
+    l = 1;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	sum = 0.;
+	i__2 = *n;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    sum += r__[l] * wa1[i__];
+	    ++l;
+/* L100: */
+	}
+	wa2[j] = sum;
+/* L110: */
+    }
+    temp = __minpack_func__(enorm)(n, &wa2[1]);
+    sgnorm = gnorm / temp / temp;
+
+/*     test whether the scaled gradient direction is acceptable. */
+
+    alpha = 0.;
+    if (sgnorm >= *delta) {
+	goto L120;
+    }
+
+/*     the scaled gradient direction is not acceptable. */
+/*     finally, calculate the point along the dogleg */
+/*     at which the quadratic is minimized. */
+
+    bnorm = __minpack_func__(enorm)(n, &qtb[1]);
+    temp = bnorm / gnorm * (bnorm / qnorm) * (sgnorm / *delta);
+/* Computing 2nd power */
+    d__1 = sgnorm / *delta;
+/* Computing 2nd power */
+    d__2 = temp - *delta / qnorm;
+/* Computing 2nd power */
+    d__3 = *delta / qnorm;
+/* Computing 2nd power */
+    d__4 = sgnorm / *delta;
+    temp = temp - *delta / qnorm * (d__1 * d__1) + sqrt(d__2 * d__2 + (1. - 
+	    d__3 * d__3) * (1. - d__4 * d__4));
+/* Computing 2nd power */
+    d__1 = sgnorm / *delta;
+    alpha = *delta / qnorm * (1. - d__1 * d__1) / temp;
+L120:
+
+/*     form appropriate convex combination of the gauss-newton */
+/*     direction and the scaled gradient direction. */
+
+    temp = (1. - alpha) * min(sgnorm,*delta);
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	x[j] = temp * wa1[j] + alpha * x[j];
+/* L130: */
+    }
+/* L140: */
+    return;
+
+/*     last card of subroutine dogleg. */
+
+} /* dogleg_ */
+

+ 207 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dpmpar_.c

@@ -0,0 +1,207 @@
+/* dpmpar.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <float.h>
+#define real __minpack_real__
+
+#define double_EPSILON DBL_EPSILON
+#define double_MIN DBL_MIN
+#define double_MAX DBL_MAX
+#define float_EPSILON FLT_EPSILON
+#define float_MIN FLT_MIN
+#define float_MAX FLT_MAX
+#define half_EPSILON HALF_EPSILON
+#define half_MIN HALF_NRM_MIN
+#define half_MAX HALF_MAX
+
+#define DPMPAR(type,X) _DPMPAR(type,X)
+#define _DPMPAR(type,X) type ## _ ## X
+
+__minpack_attr__
+real __minpack_func__(dpmpar)(const int *i)
+{
+/*     ********** */
+
+/*     Function dpmpar */
+
+/*     This function provides double precision machine parameters */
+/*     when the appropriate set of data statements is activated (by */
+/*     removing the c from column 1) and all other data statements are */
+/*     rendered inactive. Most of the parameter values were obtained */
+/*     from the corresponding Bell Laboratories Port Library function. */
+
+/*     The function statement is */
+
+/*       double precision function dpmpar(i) */
+
+/*     where */
+
+/*       i is an integer input variable set to 1, 2, or 3 which */
+/*         selects the desired machine parameter. If the machine has */
+/*         t base b digits and its smallest and largest exponents are */
+/*         emin and emax, respectively, then these parameters are */
+
+/*         dpmpar(1) = b**(1 - t), the machine precision, */
+
+/*         dpmpar(2) = b**(emin - 1), the smallest magnitude, */
+
+/*         dpmpar(3) = b**emax*(1 - b**(-t)), the largest magnitude. */
+
+/*     Argonne National Laboratory. MINPACK Project. November 1996. */
+/*     Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More' */
+
+/*     ********** */
+
+/*     Machine constants for the IBM 360/370 series, */
+/*     the Amdahl 470/V6, the ICL 2900, the Itel AS/6, */
+/*     the Xerox Sigma 5/7/9 and the Sel systems 85/86. */
+
+/*     data mcheps(1),mcheps(2) / z34100000, z00000000 / */
+/*     data minmag(1),minmag(2) / z00100000, z00000000 / */
+/*     data maxmag(1),maxmag(2) / z7fffffff, zffffffff / */
+
+/*     Machine constants for the Honeywell 600/6000 series. */
+
+/*     data mcheps(1),mcheps(2) / o606400000000, o000000000000 / */
+/*     data minmag(1),minmag(2) / o402400000000, o000000000000 / */
+/*     data maxmag(1),maxmag(2) / o376777777777, o777777777777 / */
+
+/*     Machine constants for the CDC 6000/7000 series. */
+
+/*     data mcheps(1) / 15614000000000000000b / */
+/*     data mcheps(2) / 15010000000000000000b / */
+
+/*     data minmag(1) / 00604000000000000000b / */
+/*     data minmag(2) / 00000000000000000000b / */
+
+/*     data maxmag(1) / 37767777777777777777b / */
+/*     data maxmag(2) / 37167777777777777777b / */
+
+/*     Machine constants for the PDP-10 (KA processor). */
+
+/*     data mcheps(1),mcheps(2) / "114400000000, "000000000000 / */
+/*     data minmag(1),minmag(2) / "033400000000, "000000000000 / */
+/*     data maxmag(1),maxmag(2) / "377777777777, "344777777777 / */
+
+/*     Machine constants for the PDP-10 (KI processor). */
+
+/*     data mcheps(1),mcheps(2) / "104400000000, "000000000000 / */
+/*     data minmag(1),minmag(2) / "000400000000, "000000000000 / */
+/*     data maxmag(1),maxmag(2) / "377777777777, "377777777777 / */
+
+/*     Machine constants for the PDP-11. */
+
+/*     data mcheps(1),mcheps(2) /   9472,      0 / */
+/*     data mcheps(3),mcheps(4) /      0,      0 / */
+
+/*     data minmag(1),minmag(2) /    128,      0 / */
+/*     data minmag(3),minmag(4) /      0,      0 / */
+
+/*     data maxmag(1),maxmag(2) /  32767,     -1 / */
+/*     data maxmag(3),maxmag(4) /     -1,     -1 / */
+
+/*     Machine constants for the Burroughs 6700/7700 systems. */
+
+/*     data mcheps(1) / o1451000000000000 / */
+/*     data mcheps(2) / o0000000000000000 / */
+
+/*     data minmag(1) / o1771000000000000 / */
+/*     data minmag(2) / o7770000000000000 / */
+
+/*     data maxmag(1) / o0777777777777777 / */
+/*     data maxmag(2) / o7777777777777777 / */
+
+/*     Machine constants for the Burroughs 5700 system. */
+
+/*     data mcheps(1) / o1451000000000000 / */
+/*     data mcheps(2) / o0000000000000000 / */
+
+/*     data minmag(1) / o1771000000000000 / */
+/*     data minmag(2) / o0000000000000000 / */
+
+/*     data maxmag(1) / o0777777777777777 / */
+/*     data maxmag(2) / o0007777777777777 / */
+
+/*     Machine constants for the Burroughs 1700 system. */
+
+/*     data mcheps(1) / zcc6800000 / */
+/*     data mcheps(2) / z000000000 / */
+
+/*     data minmag(1) / zc00800000 / */
+/*     data minmag(2) / z000000000 / */
+
+/*     data maxmag(1) / zdffffffff / */
+/*     data maxmag(2) / zfffffffff / */
+
+/*     Machine constants for the Univac 1100 series. */
+
+/*     data mcheps(1),mcheps(2) / o170640000000, o000000000000 / */
+/*     data minmag(1),minmag(2) / o000040000000, o000000000000 / */
+/*     data maxmag(1),maxmag(2) / o377777777777, o777777777777 / */
+
+/*     Machine constants for the Data General Eclipse S/200. */
+
+/*     Note - it may be appropriate to include the following card - */
+/*     static dmach(3) */
+
+/*     data minmag/20k,3*0/,maxmag/77777k,3*177777k/ */
+/*     data mcheps/32020k,3*0/ */
+
+/*     Machine constants for the Harris 220. */
+
+/*     data mcheps(1),mcheps(2) / '20000000, '00000334 / */
+/*     data minmag(1),minmag(2) / '20000000, '00000201 / */
+/*     data maxmag(1),maxmag(2) / '37777777, '37777577 / */
+
+/*     Machine constants for the Cray-1. */
+
+/*     data mcheps(1) / 0376424000000000000000b / */
+/*     data mcheps(2) / 0000000000000000000000b / */
+
+/*     data minmag(1) / 0200034000000000000000b / */
+/*     data minmag(2) / 0000000000000000000000b / */
+
+/*     data maxmag(1) / 0577777777777777777777b / */
+/*     data maxmag(2) / 0000007777777777777776b / */
+
+/*     Machine constants for the Prime 400. */
+
+/*     data mcheps(1),mcheps(2) / :10000000000, :00000000123 / */
+/*     data minmag(1),minmag(2) / :10000000000, :00000100000 / */
+/*     data maxmag(1),maxmag(2) / :17777777777, :37777677776 / */
+
+/*     Machine constants for the VAX-11. */
+
+/*     data mcheps(1),mcheps(2) /   9472,  0 / */
+/*     data minmag(1),minmag(2) /    128,  0 / */
+/*     data maxmag(1),maxmag(2) / -32769, -1 / */
+
+/*     Machine constants for IEEE machines. */
+
+/*    data dmach(1) /2.22044604926d-16/ */
+/*    data dmach(2) /2.22507385852d-308/ */
+/*    data dmach(3) /1.79769313485d+308/ */
+
+
+    switch(*i) {
+        case 1:
+            return DPMPAR(real,EPSILON); /* 2.2204460492503131e-16 | 1.19209290e-07F */
+        case 2:
+            return DPMPAR(real,MIN);    /* 2.2250738585072014e-308 | 1.17549435e-38F */
+        default:
+            return DPMPAR(real,MAX);    /* 1.7976931348623157e+308 | 3.40282347e+38F */
+    }
+
+/*     Last card of function dpmpar. */
+
+} /* dpmpar_ */
+
+#undef mcheps
+#undef maxmag
+#undef minmag
+#undef dmach
+
+

+ 96 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dscal.c

@@ -0,0 +1,96 @@
+/* dscal.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+	on Microsoft Windows system, link with libf2c.lib;
+	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+	or, if you install libf2c.a in a standard place, with -lf2c -lm
+	-- in that order, at the end of the command line, as in
+		cc *.o -lf2c -lm
+	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+		http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+
+/* Subroutine */ int dscal_(integer *n, doublereal *da, doublereal *dx, 
+	integer *incx)
+{
+    /* System generated locals */
+    integer i__1, i__2;
+
+    /* Local variables */
+    integer i__, m, mp1, nincx;
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+/*     .. Array Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+/* * */
+/*     scales a vector by a constant. */
+/*     uses unrolled loops for increment equal to one. */
+/*     jack dongarra, linpack, 3/11/78. */
+/*     modified 3/93 to return if incx .le. 0. */
+/*     modified 12/3/93, array(1) declarations changed to array(*) */
+
+
+/*     .. Local Scalars .. */
+/*     .. */
+/*     .. Intrinsic Functions .. */
+/*     .. */
+    /* Parameter adjustments */
+    --dx;
+
+    /* Function Body */
+    if (*n <= 0 || *incx <= 0) {
+	return 0;
+    }
+    if (*incx == 1) {
+	goto L20;
+    }
+
+/*        code for increment not equal to 1 */
+
+    nincx = *n * *incx;
+    i__1 = nincx;
+    i__2 = *incx;
+    for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
+	dx[i__] = *da * dx[i__];
+/* L10: */
+    }
+    return 0;
+
+/*        code for increment equal to 1 */
+
+
+/*        clean-up loop */
+
+L20:
+    m = *n % 5;
+    if (m == 0) {
+	goto L40;
+    }
+    i__2 = m;
+    for (i__ = 1; i__ <= i__2; ++i__) {
+	dx[i__] = *da * dx[i__];
+/* L30: */
+    }
+    if (*n < 5) {
+	return 0;
+    }
+L40:
+    mp1 = m + 1;
+    i__2 = *n;
+    for (i__ = mp1; i__ <= i__2; i__ += 5) {
+	dx[i__] = *da * dx[i__];
+	dx[i__ + 1] = *da * dx[i__ + 1];
+	dx[i__ + 2] = *da * dx[i__ + 2];
+	dx[i__ + 3] = *da * dx[i__ + 3];
+	dx[i__ + 4] = *da * dx[i__ + 4];
+/* L50: */
+    }
+    return 0;
+} /* dscal_ */

+ 114 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dswap.c

@@ -0,0 +1,114 @@
+/* dswap.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+	on Microsoft Windows system, link with libf2c.lib;
+	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+	or, if you install libf2c.a in a standard place, with -lf2c -lm
+	-- in that order, at the end of the command line, as in
+		cc *.o -lf2c -lm
+	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+		http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+
+/* Subroutine */ int dswap_(integer *n, doublereal *dx, integer *incx, 
+	doublereal *dy, integer *incy)
+{
+    /* System generated locals */
+    integer i__1;
+
+    /* Local variables */
+    integer i__, m, ix, iy, mp1;
+    doublereal dtemp;
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+/*     .. Array Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*     interchanges two vectors. */
+/*     uses unrolled loops for increments equal one. */
+/*     jack dongarra, linpack, 3/11/78. */
+/*     modified 12/3/93, array(1) declarations changed to array(*) */
+
+
+/*     .. Local Scalars .. */
+/*     .. */
+/*     .. Intrinsic Functions .. */
+/*     .. */
+    /* Parameter adjustments */
+    --dy;
+    --dx;
+
+    /* Function Body */
+    if (*n <= 0) {
+	return 0;
+    }
+    if (*incx == 1 && *incy == 1) {
+	goto L20;
+    }
+
+/*       code for unequal increments or equal increments not equal */
+/*         to 1 */
+
+    ix = 1;
+    iy = 1;
+    if (*incx < 0) {
+	ix = (-(*n) + 1) * *incx + 1;
+    }
+    if (*incy < 0) {
+	iy = (-(*n) + 1) * *incy + 1;
+    }
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	dtemp = dx[ix];
+	dx[ix] = dy[iy];
+	dy[iy] = dtemp;
+	ix += *incx;
+	iy += *incy;
+/* L10: */
+    }
+    return 0;
+
+/*       code for both increments equal to 1 */
+
+
+/*       clean-up loop */
+
+L20:
+    m = *n % 3;
+    if (m == 0) {
+	goto L40;
+    }
+    i__1 = m;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	dtemp = dx[i__];
+	dx[i__] = dy[i__];
+	dy[i__] = dtemp;
+/* L30: */
+    }
+    if (*n < 3) {
+	return 0;
+    }
+L40:
+    mp1 = m + 1;
+    i__1 = *n;
+    for (i__ = mp1; i__ <= i__1; i__ += 3) {
+	dtemp = dx[i__];
+	dx[i__] = dy[i__];
+	dy[i__] = dtemp;
+	dtemp = dx[i__ + 1];
+	dx[i__ + 1] = dy[i__ + 1];
+	dy[i__ + 1] = dtemp;
+	dtemp = dx[i__ + 2];
+	dx[i__ + 2] = dy[i__ + 2];
+	dy[i__ + 2] = dtemp;
+/* L50: */
+    }
+    return 0;
+} /* dswap_ */

+ 490 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/dtrsm.c

@@ -0,0 +1,490 @@
+/* dtrsm.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+	on Microsoft Windows system, link with libf2c.lib;
+	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+	or, if you install libf2c.a in a standard place, with -lf2c -lm
+	-- in that order, at the end of the command line, as in
+		cc *.o -lf2c -lm
+	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+		http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+
+/* Subroutine */ int dtrsm_(char *side, char *uplo, char *transa, char *diag, 
+	integer *m, integer *n, doublereal *alpha, doublereal *a, integer *
+	lda, doublereal *b, integer *ldb)
+{
+    /* System generated locals */
+    integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2, i__3;
+
+    /* Local variables */
+    integer i__, j, k, info;
+    doublereal temp;
+    logical lside;
+    extern logical lsame_(char *, char *);
+    integer nrowa;
+    logical upper;
+    extern /* Subroutine */ int xerbla_(char *, integer *);
+    logical nounit;
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+/*     .. Array Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*  DTRSM  solves one of the matrix equations */
+
+/*     op( A )*X = alpha*B,   or   X*op( A ) = alpha*B, */
+
+/*  where alpha is a scalar, X and B are m by n matrices, A is a unit, or */
+/*  non-unit,  upper or lower triangular matrix  and  op( A )  is one  of */
+
+/*     op( A ) = A   or   op( A ) = A'. */
+
+/*  The matrix X is overwritten on B. */
+
+/*  Arguments */
+/*  ========== */
+
+/*  SIDE   - CHARACTER*1. */
+/*           On entry, SIDE specifies whether op( A ) appears on the left */
+/*           or right of X as follows: */
+
+/*              SIDE = 'L' or 'l'   op( A )*X = alpha*B. */
+
+/*              SIDE = 'R' or 'r'   X*op( A ) = alpha*B. */
+
+/*           Unchanged on exit. */
+
+/*  UPLO   - CHARACTER*1. */
+/*           On entry, UPLO specifies whether the matrix A is an upper or */
+/*           lower triangular matrix as follows: */
+
+/*              UPLO = 'U' or 'u'   A is an upper triangular matrix. */
+
+/*              UPLO = 'L' or 'l'   A is a lower triangular matrix. */
+
+/*           Unchanged on exit. */
+
+/*  TRANSA - CHARACTER*1. */
+/*           On entry, TRANSA specifies the form of op( A ) to be used in */
+/*           the matrix multiplication as follows: */
+
+/*              TRANSA = 'N' or 'n'   op( A ) = A. */
+
+/*              TRANSA = 'T' or 't'   op( A ) = A'. */
+
+/*              TRANSA = 'C' or 'c'   op( A ) = A'. */
+
+/*           Unchanged on exit. */
+
+/*  DIAG   - CHARACTER*1. */
+/*           On entry, DIAG specifies whether or not A is unit triangular */
+/*           as follows: */
+
+/*              DIAG = 'U' or 'u'   A is assumed to be unit triangular. */
+
+/*              DIAG = 'N' or 'n'   A is not assumed to be unit */
+/*                                  triangular. */
+
+/*           Unchanged on exit. */
+
+/*  M      - INTEGER. */
+/*           On entry, M specifies the number of rows of B. M must be at */
+/*           least zero. */
+/*           Unchanged on exit. */
+
+/*  N      - INTEGER. */
+/*           On entry, N specifies the number of columns of B.  N must be */
+/*           at least zero. */
+/*           Unchanged on exit. */
+
+/*  ALPHA  - DOUBLE PRECISION. */
+/*           On entry,  ALPHA specifies the scalar  alpha. When  alpha is */
+/*           zero then  A is not referenced and  B need not be set before */
+/*           entry. */
+/*           Unchanged on exit. */
+
+/*  A      - DOUBLE PRECISION array of DIMENSION ( LDA, k ), where k is m */
+/*           when  SIDE = 'L' or 'l'  and is  n  when  SIDE = 'R' or 'r'. */
+/*           Before entry  with  UPLO = 'U' or 'u',  the  leading  k by k */
+/*           upper triangular part of the array  A must contain the upper */
+/*           triangular matrix  and the strictly lower triangular part of */
+/*           A is not referenced. */
+/*           Before entry  with  UPLO = 'L' or 'l',  the  leading  k by k */
+/*           lower triangular part of the array  A must contain the lower */
+/*           triangular matrix  and the strictly upper triangular part of */
+/*           A is not referenced. */
+/*           Note that when  DIAG = 'U' or 'u',  the diagonal elements of */
+/*           A  are not referenced either,  but are assumed to be  unity. */
+/*           Unchanged on exit. */
+
+/*  LDA    - INTEGER. */
+/*           On entry, LDA specifies the first dimension of A as declared */
+/*           in the calling (sub) program.  When  SIDE = 'L' or 'l'  then */
+/*           LDA  must be at least  lmax( 1, m ),  when  SIDE = 'R' or 'r' */
+/*           then LDA must be at least lmax( 1, n ). */
+/*           Unchanged on exit. */
+
+/*  B      - DOUBLE PRECISION array of DIMENSION ( LDB, n ). */
+/*           Before entry,  the leading  m by n part of the array  B must */
+/*           contain  the  right-hand  side  matrix  B,  and  on exit  is */
+/*           overwritten by the solution matrix  X. */
+
+/*  LDB    - INTEGER. */
+/*           On entry, LDB specifies the first dimension of B as declared */
+/*           in  the  calling  (sub)  program.   LDB  must  be  at  least */
+/*           lmax( 1, m ). */
+/*           Unchanged on exit. */
+
+
+/*  Level 3 Blas routine. */
+
+
+/*  -- Written on 8-February-1989. */
+/*     Jack Dongarra, Argonne National Laboratory. */
+/*     Iain Duff, AERE Harwell. */
+/*     Jeremy Du Croz, Numerical Algorithms Group Ltd. */
+/*     Sven Hammarling, Numerical Algorithms Group Ltd. */
+
+
+/*     .. External Functions .. */
+/*     .. */
+/*     .. External Subroutines .. */
+/*     .. */
+/*     .. Intrinsic Functions .. */
+/*     .. */
+/*     .. Local Scalars .. */
+/*     .. */
+/*     .. Parameters .. */
+/*     .. */
+
+/*     Test the input parameters. */
+
+    /* Parameter adjustments */
+    a_dim1 = *lda;
+    a_offset = 1 + a_dim1;
+    a -= a_offset;
+    b_dim1 = *ldb;
+    b_offset = 1 + b_dim1;
+    b -= b_offset;
+
+    /* Function Body */
+    lside = lsame_(side, "L");
+    if (lside) {
+	nrowa = *m;
+    } else {
+	nrowa = *n;
+    }
+    nounit = lsame_(diag, "N");
+    upper = lsame_(uplo, "U");
+
+    info = 0;
+    if (! lside && ! lsame_(side, "R")) {
+	info = 1;
+    } else if (! upper && ! lsame_(uplo, "L")) {
+	info = 2;
+    } else if (! lsame_(transa, "N") && ! lsame_(transa, 
+	     "T") && ! lsame_(transa, "C")) {
+	info = 3;
+    } else if (! lsame_(diag, "U") && ! lsame_(diag, 
+	    "N")) {
+	info = 4;
+    } else if (*m < 0) {
+	info = 5;
+    } else if (*n < 0) {
+	info = 6;
+    } else if (*lda < lmax(1,nrowa)) {
+	info = 9;
+    } else if (*ldb < lmax(1,*m)) {
+	info = 11;
+    }
+    if (info != 0) {
+	xerbla_("DTRSM ", &info);
+	return 0;
+    }
+
+/*     Quick return if possible. */
+
+    if (*m == 0 || *n == 0) {
+	return 0;
+    }
+
+/*     And when  alpha.eq.zero. */
+
+    if (*alpha == 0.) {
+	i__1 = *n;
+	for (j = 1; j <= i__1; ++j) {
+	    i__2 = *m;
+	    for (i__ = 1; i__ <= i__2; ++i__) {
+		b[i__ + j * b_dim1] = 0.;
+/* L10: */
+	    }
+/* L20: */
+	}
+	return 0;
+    }
+
+/*     Start the operations. */
+
+    if (lside) {
+	if (lsame_(transa, "N")) {
+
+/*           Form  B := alpha*inv( A )*B. */
+
+	    if (upper) {
+		i__1 = *n;
+		for (j = 1; j <= i__1; ++j) {
+		    if (*alpha != 1.) {
+			i__2 = *m;
+			for (i__ = 1; i__ <= i__2; ++i__) {
+			    b[i__ + j * b_dim1] = *alpha * b[i__ + j * b_dim1]
+				    ;
+/* L30: */
+			}
+		    }
+		    for (k = *m; k >= 1; --k) {
+			if (b[k + j * b_dim1] != 0.) {
+			    if (nounit) {
+				b[k + j * b_dim1] /= a[k + k * a_dim1];
+			    }
+			    i__2 = k - 1;
+			    for (i__ = 1; i__ <= i__2; ++i__) {
+				b[i__ + j * b_dim1] -= b[k + j * b_dim1] * a[
+					i__ + k * a_dim1];
+/* L40: */
+			    }
+			}
+/* L50: */
+		    }
+/* L60: */
+		}
+	    } else {
+		i__1 = *n;
+		for (j = 1; j <= i__1; ++j) {
+		    if (*alpha != 1.) {
+			i__2 = *m;
+			for (i__ = 1; i__ <= i__2; ++i__) {
+			    b[i__ + j * b_dim1] = *alpha * b[i__ + j * b_dim1]
+				    ;
+/* L70: */
+			}
+		    }
+		    i__2 = *m;
+		    for (k = 1; k <= i__2; ++k) {
+			if (b[k + j * b_dim1] != 0.) {
+			    if (nounit) {
+				b[k + j * b_dim1] /= a[k + k * a_dim1];
+			    }
+			    i__3 = *m;
+			    for (i__ = k + 1; i__ <= i__3; ++i__) {
+				b[i__ + j * b_dim1] -= b[k + j * b_dim1] * a[
+					i__ + k * a_dim1];
+/* L80: */
+			    }
+			}
+/* L90: */
+		    }
+/* L100: */
+		}
+	    }
+	} else {
+
+/*           Form  B := alpha*inv( A' )*B. */
+
+	    if (upper) {
+		i__1 = *n;
+		for (j = 1; j <= i__1; ++j) {
+		    i__2 = *m;
+		    for (i__ = 1; i__ <= i__2; ++i__) {
+			temp = *alpha * b[i__ + j * b_dim1];
+			i__3 = i__ - 1;
+			for (k = 1; k <= i__3; ++k) {
+			    temp -= a[k + i__ * a_dim1] * b[k + j * b_dim1];
+/* L110: */
+			}
+			if (nounit) {
+			    temp /= a[i__ + i__ * a_dim1];
+			}
+			b[i__ + j * b_dim1] = temp;
+/* L120: */
+		    }
+/* L130: */
+		}
+	    } else {
+		i__1 = *n;
+		for (j = 1; j <= i__1; ++j) {
+		    for (i__ = *m; i__ >= 1; --i__) {
+			temp = *alpha * b[i__ + j * b_dim1];
+			i__2 = *m;
+			for (k = i__ + 1; k <= i__2; ++k) {
+			    temp -= a[k + i__ * a_dim1] * b[k + j * b_dim1];
+/* L140: */
+			}
+			if (nounit) {
+			    temp /= a[i__ + i__ * a_dim1];
+			}
+			b[i__ + j * b_dim1] = temp;
+/* L150: */
+		    }
+/* L160: */
+		}
+	    }
+	}
+    } else {
+	if (lsame_(transa, "N")) {
+
+/*           Form  B := alpha*B*inv( A ). */
+
+	    if (upper) {
+		i__1 = *n;
+		for (j = 1; j <= i__1; ++j) {
+		    if (*alpha != 1.) {
+			i__2 = *m;
+			for (i__ = 1; i__ <= i__2; ++i__) {
+			    b[i__ + j * b_dim1] = *alpha * b[i__ + j * b_dim1]
+				    ;
+/* L170: */
+			}
+		    }
+		    i__2 = j - 1;
+		    for (k = 1; k <= i__2; ++k) {
+			if (a[k + j * a_dim1] != 0.) {
+			    i__3 = *m;
+			    for (i__ = 1; i__ <= i__3; ++i__) {
+				b[i__ + j * b_dim1] -= a[k + j * a_dim1] * b[
+					i__ + k * b_dim1];
+/* L180: */
+			    }
+			}
+/* L190: */
+		    }
+		    if (nounit) {
+			temp = 1. / a[j + j * a_dim1];
+			i__2 = *m;
+			for (i__ = 1; i__ <= i__2; ++i__) {
+			    b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
+/* L200: */
+			}
+		    }
+/* L210: */
+		}
+	    } else {
+		for (j = *n; j >= 1; --j) {
+		    if (*alpha != 1.) {
+			i__1 = *m;
+			for (i__ = 1; i__ <= i__1; ++i__) {
+			    b[i__ + j * b_dim1] = *alpha * b[i__ + j * b_dim1]
+				    ;
+/* L220: */
+			}
+		    }
+		    i__1 = *n;
+		    for (k = j + 1; k <= i__1; ++k) {
+			if (a[k + j * a_dim1] != 0.) {
+			    i__2 = *m;
+			    for (i__ = 1; i__ <= i__2; ++i__) {
+				b[i__ + j * b_dim1] -= a[k + j * a_dim1] * b[
+					i__ + k * b_dim1];
+/* L230: */
+			    }
+			}
+/* L240: */
+		    }
+		    if (nounit) {
+			temp = 1. / a[j + j * a_dim1];
+			i__1 = *m;
+			for (i__ = 1; i__ <= i__1; ++i__) {
+			    b[i__ + j * b_dim1] = temp * b[i__ + j * b_dim1];
+/* L250: */
+			}
+		    }
+/* L260: */
+		}
+	    }
+	} else {
+
+/*           Form  B := alpha*B*inv( A' ). */
+
+	    if (upper) {
+		for (k = *n; k >= 1; --k) {
+		    if (nounit) {
+			temp = 1. / a[k + k * a_dim1];
+			i__1 = *m;
+			for (i__ = 1; i__ <= i__1; ++i__) {
+			    b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
+/* L270: */
+			}
+		    }
+		    i__1 = k - 1;
+		    for (j = 1; j <= i__1; ++j) {
+			if (a[j + k * a_dim1] != 0.) {
+			    temp = a[j + k * a_dim1];
+			    i__2 = *m;
+			    for (i__ = 1; i__ <= i__2; ++i__) {
+				b[i__ + j * b_dim1] -= temp * b[i__ + k * 
+					b_dim1];
+/* L280: */
+			    }
+			}
+/* L290: */
+		    }
+		    if (*alpha != 1.) {
+			i__1 = *m;
+			for (i__ = 1; i__ <= i__1; ++i__) {
+			    b[i__ + k * b_dim1] = *alpha * b[i__ + k * b_dim1]
+				    ;
+/* L300: */
+			}
+		    }
+/* L310: */
+		}
+	    } else {
+		i__1 = *n;
+		for (k = 1; k <= i__1; ++k) {
+		    if (nounit) {
+			temp = 1. / a[k + k * a_dim1];
+			i__2 = *m;
+			for (i__ = 1; i__ <= i__2; ++i__) {
+			    b[i__ + k * b_dim1] = temp * b[i__ + k * b_dim1];
+/* L320: */
+			}
+		    }
+		    i__2 = *n;
+		    for (j = k + 1; j <= i__2; ++j) {
+			if (a[j + k * a_dim1] != 0.) {
+			    temp = a[j + k * a_dim1];
+			    i__3 = *m;
+			    for (i__ = 1; i__ <= i__3; ++i__) {
+				b[i__ + j * b_dim1] -= temp * b[i__ + k * 
+					b_dim1];
+/* L330: */
+			    }
+			}
+/* L340: */
+		    }
+		    if (*alpha != 1.) {
+			i__2 = *m;
+			for (i__ = 1; i__ <= i__2; ++i__) {
+			    b[i__ + k * b_dim1] = *alpha * b[i__ + k * b_dim1]
+				    ;
+/* L350: */
+			}
+		    }
+/* L360: */
+		}
+	    }
+	}
+    }
+
+    return 0;
+
+/*     End of DTRSM . */
+
+} /* dtrsm_ */

+ 196 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/enorm_.c

@@ -0,0 +1,196 @@
+/* enorm.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+/*
+  About the values for rdwarf and rgiant.
+
+  The original values, both in single-precision FORTRAN source code and in double-precision code were:
+#define rdwarf 3.834e-20
+#define rgiant 1.304e19
+  See for example:
+    http://www.netlib.org/slatec/src/denorm.f
+    http://www.netlib.org/slatec/src/enorm.f
+  However, rdwarf is smaller than sqrt(FLT_MIN) = 1.0842021724855044e-19, so that rdwarf**2 will
+  underflow. This contradicts the constraints expressed in the comments below.
+
+  We changed these constants to those proposed by the
+  implementation found in MPFIT http://cow.physics.wisc.edu/~craigm/idl/fitting.html
+
+ cmpfit-1.2 proposes the following definitions:
+  rdwarf = sqrt(dpmpar(2)*1.5) * 10
+  rgiant = sqrt(dpmpar(3)) * 0.1
+
+ The half version does not really worked that way, so we use for half:
+  rdwarf = sqrt(dpmpar(2)) * 2
+  rgiant = sqrt(dpmpar(3)) * 0.5
+ Any suggestion is welcome. Half CMINPACK is really only a
+ proof-of-concept anyway.
+
+ See the example/tenorm*c, which computes these values 
+*/
+#define double_dwarf (1.82691291192569e-153)
+#define double_giant (1.34078079299426e+153)
+#define float_dwarf (1.327871072777421e-18f)
+#define float_giant (1.844674297419792e+18f)
+#define half_dwarf (0.015625f)
+#define half_giant (127.9375f)
+
+#define dwarf(type) _dwarf(type)
+#define _dwarf(type) type ## _dwarf
+#define giant(type) _giant(type)
+#define _giant(type) type ## _giant
+
+#define rdwarf dwarf(real)
+#define rgiant giant(real)
+
+__minpack_attr__
+real __minpack_func__(enorm)(const int *n, const real *x)
+{
+    /* System generated locals */
+    int i__1;
+    real ret_val, d__1;
+
+    /* Local variables */
+    int i__;
+    real s1, s2, s3, xabs, x1max, x3max, agiant, floatn;
+
+/*     ********** */
+
+/*     function enorm */
+
+/*     given an n-vector x, this function calculates the */
+/*     euclidean norm of x. */
+
+/*     the euclidean norm is computed by accumulating the sum of */
+/*     squares in three different sums. the sums of squares for the */
+/*     small and large components are scaled so that no overflows */
+/*     occur. non-destructive underflows are permitted. underflows */
+/*     and overflows do not occur in the computation of the unscaled */
+/*     sum of squares for the intermediate components. */
+/*     the definitions of small, intermediate and large components */
+/*     depend on two constants, rdwarf and rgiant. the main */
+/*     restrictions on these constants are that rdwarf**2 not */
+/*     underflow and rgiant**2 not overflow. the constants */
+/*     given here are suitable for every known computer. */
+
+/*     the function statement is */
+
+/*       double precision function enorm(n,x) */
+
+/*     where */
+
+/*       n is a positive integer input variable. */
+
+/*       x is an input array of length n. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... dabs,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --x;
+
+    /* Function Body */
+    s1 = 0.;
+    s2 = 0.;
+    s3 = 0.;
+    x1max = 0.;
+    x3max = 0.;
+    floatn = (real) (*n);
+    agiant = rgiant / floatn;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	xabs = fabs(x[i__]);
+	if (xabs > rdwarf && xabs < agiant) {
+	    goto L70;
+	}
+	if (xabs <= rdwarf) {
+	    goto L30;
+	}
+
+/*              sum for large components. */
+
+	if (xabs <= x1max) {
+	    goto L10;
+	}
+/* Computing 2nd power */
+	d__1 = x1max / xabs;
+	s1 = 1. + s1 * (d__1 * d__1);
+	x1max = xabs;
+	goto L20;
+L10:
+/* Computing 2nd power */
+	d__1 = xabs / x1max;
+	s1 += d__1 * d__1;
+L20:
+	goto L60;
+L30:
+
+/*              sum for small components. */
+
+	if (xabs <= x3max) {
+	    goto L40;
+	}
+/* Computing 2nd power */
+	d__1 = x3max / xabs;
+	s3 = 1. + s3 * (d__1 * d__1);
+	x3max = xabs;
+	goto L50;
+L40:
+	if (xabs != 0.) {
+/* Computing 2nd power */
+	    d__1 = xabs / x3max;
+	    s3 += d__1 * d__1;
+	}
+L50:
+L60:
+	goto L80;
+L70:
+
+/*           sum for intermediate components. */
+
+/* Computing 2nd power */
+	d__1 = xabs;
+	s2 += d__1 * d__1;
+L80:
+/* L90: */
+	;
+    }
+
+/*     calculation of norm. */
+
+    if (s1 == 0.) {
+	goto L100;
+    }
+    ret_val = x1max * sqrt(s1 + s2 / x1max / x1max);
+    goto L130;
+L100:
+    if (s2 == 0.) {
+	goto L110;
+    }
+    if (s2 >= x3max) {
+	ret_val = sqrt(s2 * (1. + x3max / s2 * (x3max * s3)));
+    } else {
+	ret_val = sqrt(x3max * (s2 / x3max + x3max * s3));
+    }
+    goto L120;
+L110:
+    ret_val = x3max * sqrt(s3);
+L120:
+L130:
+    return ret_val;
+
+/*     last card of function enorm. */
+
+} /* enorm_ */
+

+ 225 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/f2c.h

@@ -0,0 +1,225 @@
+/* f2c.h  --  Standard Fortran to C header file */
+
+/**  barf  [ba:rf]  2.  "He suggested using FORTRAN, and everybody barfed."
+
+  - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
+
+#ifndef F2C_INCLUDE
+#define F2C_INCLUDE
+
+#if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
+typedef int integer;
+typedef unsigned int uinteger;
+#else
+typedef long int integer;
+typedef unsigned long int uinteger;
+#endif
+typedef char *address;
+typedef short int shortint;
+typedef float real;
+typedef double doublereal;
+typedef struct { real r, i; } complex;
+typedef struct { doublereal r, i; } doublecomplex;
+typedef long int logical;
+typedef short int shortlogical;
+typedef char logical1;
+typedef char integer1;
+#ifdef INTEGER_STAR_8 /* Adjust for integer*8. */
+typedef long long longint;    /* system-dependent */
+typedef unsigned long long ulongint;  /* system-dependent */
+#define qbit_clear(a,b) ((a) & ~((ulongint)1 << (b)))
+#define qbit_set(a,b) ((a) |  ((ulongint)1 << (b)))
+#endif
+
+#define TRUE_ (1)
+#define FALSE_ (0)
+
+/* Extern is for use with -E */
+#ifndef Extern
+#define Extern extern
+#endif
+
+/* I/O stuff */
+
+#ifdef f2c_i2
+/* for -i2 */
+typedef short flag;
+typedef short ftnlen;
+typedef short ftnint;
+#else
+typedef long int flag;
+typedef long int ftnlen;
+typedef long int ftnint;
+#endif
+
+/*external read, write*/
+typedef struct
+{ flag cierr;
+  ftnint ciunit;
+  flag ciend;
+  char *cifmt;
+  ftnint cirec;
+} cilist;
+
+/*internal read, write*/
+typedef struct
+{ flag icierr;
+  char *iciunit;
+  flag iciend;
+  char *icifmt;
+  ftnint icirlen;
+  ftnint icirnum;
+} icilist;
+
+/*open*/
+typedef struct
+{ flag oerr;
+  ftnint ounit;
+  char *ofnm;
+  ftnlen ofnmlen;
+  char *osta;
+  char *oacc;
+  char *ofm;
+  ftnint orl;
+  char *oblnk;
+} olist;
+
+/*close*/
+typedef struct
+{ flag cerr;
+  ftnint cunit;
+  char *csta;
+} cllist;
+
+/*rewind, backspace, endfile*/
+typedef struct
+{ flag aerr;
+  ftnint aunit;
+} alist;
+
+/* inquire */
+typedef struct
+{ flag inerr;
+  ftnint inunit;
+  char *infile;
+  ftnlen infilen;
+  ftnint  *inex;  /*parameters in standard's order*/
+  ftnint  *inopen;
+  ftnint  *innum;
+  ftnint  *innamed;
+  char  *inname;
+  ftnlen  innamlen;
+  char  *inacc;
+  ftnlen  inacclen;
+  char  *inseq;
+  ftnlen  inseqlen;
+  char  *indir;
+  ftnlen  indirlen;
+  char  *infmt;
+  ftnlen  infmtlen;
+  char  *inform;
+  ftnint  informlen;
+  char  *inunf;
+  ftnlen  inunflen;
+  ftnint  *inrecl;
+  ftnint  *innrec;
+  char  *inblank;
+  ftnlen  inblanklen;
+} inlist;
+
+#define VOID void
+
+union Multitype { /* for multiple entry points */
+  integer1 g;
+  shortint h;
+  integer i;
+  /* longint j; */
+  real r;
+  doublereal d;
+  complex c;
+  doublecomplex z;
+  };
+
+typedef union Multitype Multitype;
+
+/*typedef long int Long;*/  /* No longer used; formerly in Namelist */
+
+struct Vardesc {  /* for Namelist */
+  char *name;
+  char *addr;
+  ftnlen *dims;
+  int  type;
+  };
+typedef struct Vardesc Vardesc;
+
+struct Namelist {
+  char *name;
+  Vardesc **vars;
+  int nvars;
+  };
+typedef struct Namelist Namelist;
+
+#include <math.h>
+static integer lmin(long a, long b) {return ((a) <= (b) ? (a) : (b));}
+static integer lmax(long a, long b) {return ((a) >= (b) ? (a) : (b));}
+#define bit_test(a,b) ((a) >> (b) & 1)
+#define bit_clear(a,b)  ((a) & ~((uinteger)1 << (b)))
+#define bit_set(a,b)  ((a) |  ((uinteger)1 << (b)))
+
+/* procedure parameter types for -A and -C++ */
+
+#define F2C_proc_par_types 1
+#ifdef __cplusplus
+typedef int /* Unknown procedure type */ (*U_fp)(...);
+typedef shortint (*J_fp)(...);
+typedef integer (*I_fp)(...);
+typedef real (*R_fp)(...);
+typedef doublereal (*D_fp)(...), (*E_fp)(...);
+typedef /* Complex */ VOID (*C_fp)(...);
+typedef /* Double Complex */ VOID (*Z_fp)(...);
+typedef logical (*L_fp)(...);
+typedef shortlogical (*K_fp)(...);
+typedef /* Character */ VOID (*H_fp)(...);
+typedef /* Subroutine */ int (*S_fp)(...);
+#else
+typedef int /* Unknown procedure type */ (*U_fp)();
+typedef shortint (*J_fp)();
+typedef integer (*I_fp)();
+typedef real (*R_fp)();
+typedef doublereal (*D_fp)(), (*E_fp)();
+typedef /* Complex */ VOID (*C_fp)();
+typedef /* Double Complex */ VOID (*Z_fp)();
+typedef logical (*L_fp)();
+typedef shortlogical (*K_fp)();
+typedef /* Character */ VOID (*H_fp)();
+typedef /* Subroutine */ int (*S_fp)();
+#endif
+/* E_fp is for real functions when -R is not specified */
+typedef VOID C_f; /* complex function */
+typedef VOID H_f; /* character function */
+typedef VOID Z_f; /* double complex function */
+typedef doublereal E_f; /* real function with -R not specified */
+
+/* undef any lower-case symbols that your C compiler predefines, e.g.: */
+
+#ifndef Skip_f2c_Undefs
+#undef cray
+#undef gcos
+#undef mc68010
+#undef mc68020
+#undef mips
+#undef pdp11
+#undef sgi
+#undef sparc
+#undef sun
+#undef sun2
+#undef sun3
+#undef sun4
+#undef u370
+#undef u3b
+#undef u3b2
+#undef u3b5
+#undef unix
+#undef vax
+#endif
+#endif

+ 612 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/hybrj_.c

@@ -0,0 +1,612 @@
+/* hybrj.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+#define TRUE_ (1)
+#define FALSE_ (0)
+
+__minpack_attr__
+void __minpack_func__(hybrj)(__minpack_decl_fcnder_nn__  const int *n, real *x, real *
+	fvec, real *fjac, const int *ldfjac, const real *xtol, const int *
+	maxfev, real *diag, const int *mode, const real *factor, const int *
+	nprint, int *info, int *nfev, int *njev, real *r__, 
+	const int *lr, real *qtf, real *wa1, real *wa2, 
+	real *wa3, real *wa4, void* user_data)
+{
+    /* Initialized data */
+
+#define p1 .1
+#define p5 .5
+#define p001 .001
+#define p0001 1e-4
+    const int c_false = FALSE_;
+    const int c__1 = 1;
+
+    /* System generated locals */
+    int fjac_dim1, fjac_offset, i__1, i__2;
+    real d__1, d__2;
+
+    /* Local variables */
+    int i__, j, l, jm1, iwa[1];
+    real sum;
+    int sing;
+    int iter;
+    real temp;
+    int iflag;
+    real delta;
+    int jeval;
+    int ncsuc;
+    real ratio;
+    real fnorm;
+    real pnorm, xnorm = 0, fnorm1;
+    int nslow1, nslow2;
+    int ncfail;
+    real actred, epsmch, prered;
+
+/*     ********** */
+
+/*     subroutine hybrj */
+
+/*     the purpose of hybrj is to find a zero of a system of */
+/*     n nonlinear functions in n variables by a modification */
+/*     of the powell hybrid method. the user must provide a */
+/*     subroutine which calculates the functions and the jacobian. */
+
+/*     the subroutine statement is */
+
+/*       subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag, */
+/*                        mode,factor,nprint,info,nfev,njev,r,lr,qtf, */
+/*                        wa1,wa2,wa3,wa4) */
+
+/*     where */
+
+/*       fcn is the name of the user-supplied subroutine which */
+/*         calculates the functions and the jacobian. fcn must */
+/*         be declared in an external statement in the user */
+/*         calling program, and should be written as follows. */
+
+/*         subroutine fcn(n,x,fvec,fjac,ldfjac,iflag) */
+/*         integer n,ldfjac,iflag */
+/*         double precision x(n),fvec(n),fjac(ldfjac,n) */
+/*         ---------- */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/*         --------- */
+/*         return */
+/*         end */
+
+/*         the value of iflag should not be changed by fcn unless */
+/*         the user wants to terminate execution of hybrj. */
+/*         in this case set iflag to a negative integer. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of functions and variables. */
+
+/*       x is an array of length n. on input x must contain */
+/*         an initial estimate of the solution vector. on output x */
+/*         contains the final estimate of the solution vector. */
+
+/*       fvec is an output array of length n which contains */
+/*         the functions evaluated at the output x. */
+
+/*       fjac is an output n by n array which contains the */
+/*         orthogonal matrix q produced by the qr factorization */
+/*         of the final approximate jacobian. */
+
+/*       ldfjac is a positive integer input variable not less than n */
+/*         which specifies the leading dimension of the array fjac. */
+
+/*       xtol is a nonnegative input variable. termination */
+/*         occurs when the relative error between two consecutive */
+/*         iterates is at most xtol. */
+
+/*       maxfev is a positive integer input variable. termination */
+/*         occurs when the number of calls to fcn with iflag = 1 */
+/*         has reached maxfev. */
+
+/*       diag is an array of length n. if mode = 1 (see */
+/*         below), diag is internally set. if mode = 2, diag */
+/*         must contain positive entries that serve as */
+/*         multiplicative scale factors for the variables. */
+
+/*       mode is an integer input variable. if mode = 1, the */
+/*         variables will be scaled internally. if mode = 2, */
+/*         the scaling is specified by the input diag. other */
+/*         values of mode are equivalent to mode = 1. */
+
+/*       factor is a positive input variable used in determining the */
+/*         initial step bound. this bound is set to the product of */
+/*         factor and the euclidean norm of diag*x if nonzero, or else */
+/*         to factor itself. in most cases factor should lie in the */
+/*         interval (.1,100.). 100. is a generally recommended value. */
+
+/*       nprint is an integer input variable that enables controlled */
+/*         printing of iterates if it is positive. in this case, */
+/*         fcn is called with iflag = 0 at the beginning of the first */
+/*         iteration and every nprint iterations thereafter and */
+/*         immediately prior to return, with x and fvec available */
+/*         for printing. fvec and fjac should not be altered. */
+/*         if nprint is not positive, no special calls of fcn */
+/*         with iflag = 0 are made. */
+
+/*       info is an integer output variable. if the user has */
+/*         terminated execution, info is set to the (negative) */
+/*         value of iflag. see description of fcn. otherwise, */
+/*         info is set as follows. */
+
+/*         info = 0   improper input parameters. */
+
+/*         info = 1   relative error between two consecutive iterates */
+/*                    is at most xtol. */
+
+/*         info = 2   number of calls to fcn with iflag = 1 has */
+/*                    reached maxfev. */
+
+/*         info = 3   xtol is too small. no further improvement in */
+/*                    the approximate solution x is possible. */
+
+/*         info = 4   iteration is not making good progress, as */
+/*                    measured by the improvement from the last */
+/*                    five jacobian evaluations. */
+
+/*         info = 5   iteration is not making good progress, as */
+/*                    measured by the improvement from the last */
+/*                    ten iterations. */
+
+/*       nfev is an integer output variable set to the number of */
+/*         calls to fcn with iflag = 1. */
+
+/*       njev is an integer output variable set to the number of */
+/*         calls to fcn with iflag = 2. */
+
+/*       r is an output array of length lr which contains the */
+/*         upper triangular matrix produced by the qr factorization */
+/*         of the final approximate jacobian, stored rowwise. */
+
+/*       lr is a positive integer input variable not less than */
+/*         (n*(n+1))/2. */
+
+/*       qtf is an output array of length n which contains */
+/*         the vector (q transpose)*fvec. */
+
+/*       wa1, wa2, wa3, and wa4 are work arrays of length n. */
+
+/*     subprograms called */
+
+/*       user-supplied ...... fcn */
+
+/*       minpack-supplied ... dogleg,dpmpar,enorm, */
+/*                            qform,qrfac,r1mpyq,r1updt */
+
+/*       fortran-supplied ... dabs,dmax1,dmin1,mod */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa4;
+    --wa3;
+    --wa2;
+    --wa1;
+    --qtf;
+    --diag;
+    --fvec;
+    --x;
+    fjac_dim1 = *ldfjac;
+    fjac_offset = 1 + fjac_dim1 * 1;
+    fjac -= fjac_offset;
+    --r__;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __minpack_func__(dpmpar)(&c__1);
+
+    *info = 0;
+    iflag = 0;
+    *nfev = 0;
+    *njev = 0;
+
+/*     check the input parameters for errors. */
+
+    if (*n <= 0 || *ldfjac < *n || *xtol < 0. || *maxfev <= 0 || *factor <= 
+	    0. || *lr < *n * (*n + 1) / 2) {
+	goto L300;
+    }
+    if (*mode != 2) {
+	goto L20;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	if (diag[j] <= 0.) {
+	    goto L300;
+	}
+/* L10: */
+    }
+L20:
+
+/*     evaluate the function at the starting point */
+/*     and calculate its norm. */
+
+    iflag = 1;
+    fcnder_nn(n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag, user_data);
+    *nfev = 1;
+    if (iflag < 0) {
+	goto L300;
+    }
+    fnorm = __minpack_func__(enorm)(n, &fvec[1]);
+
+/*     initialize iteration counter and monitors. */
+
+    iter = 1;
+    ncsuc = 0;
+    ncfail = 0;
+    nslow1 = 0;
+    nslow2 = 0;
+
+/*     beginning of the outer loop. */
+
+L30:
+    jeval = TRUE_;
+
+/*        calculate the jacobian matrix. */
+
+    iflag = 2;
+    fcnder_nn(n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag, user_data);
+    ++(*njev);
+    if (iflag < 0) {
+	goto L300;
+    }
+
+/*        compute the qr factorization of the jacobian. */
+
+    __minpack_func__(qrfac)(n, n, &fjac[fjac_offset], ldfjac, &c_false, iwa, &c__1, &wa1[1], &
+	    wa2[1], &wa3[1]);
+
+/*        on the first iteration and if mode is 1, scale according */
+/*        to the norms of the columns of the initial jacobian. */
+
+    if (iter != 1) {
+	goto L70;
+    }
+    if (*mode == 2) {
+	goto L50;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	diag[j] = wa2[j];
+	if (wa2[j] == 0.) {
+	    diag[j] = 1.;
+	}
+/* L40: */
+    }
+L50:
+
+/*        on the first iteration, calculate the norm of the scaled x */
+/*        and initialize the step bound delta. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa3[j] = diag[j] * x[j];
+/* L60: */
+    }
+    xnorm = __minpack_func__(enorm)(n, &wa3[1]);
+    delta = *factor * xnorm;
+    if (delta == 0.) {
+	delta = *factor;
+    }
+L70:
+
+/*        form (q transpose)*fvec and store in qtf. */
+
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	qtf[i__] = fvec[i__];
+/* L80: */
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	if (fjac[j + j * fjac_dim1] == 0.) {
+	    goto L110;
+	}
+	sum = 0.;
+	i__2 = *n;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    sum += fjac[i__ + j * fjac_dim1] * qtf[i__];
+/* L90: */
+	}
+	temp = -sum / fjac[j + j * fjac_dim1];
+	i__2 = *n;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    qtf[i__] += fjac[i__ + j * fjac_dim1] * temp;
+/* L100: */
+	}
+L110:
+/* L120: */
+	;
+    }
+
+/*        copy the triangular factor of the qr factorization into r. */
+
+    sing = FALSE_;
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	l = j;
+	jm1 = j - 1;
+	if (jm1 < 1) {
+	    goto L140;
+	}
+	i__2 = jm1;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    r__[l] = fjac[i__ + j * fjac_dim1];
+	    l = l + *n - i__;
+/* L130: */
+	}
+L140:
+	r__[l] = wa1[j];
+	if (wa1[j] == 0.) {
+	    sing = TRUE_;
+	}
+/* L150: */
+    }
+
+/*        accumulate the orthogonal factor in fjac. */
+
+    __minpack_func__(qform)(n, n, &fjac[fjac_offset], ldfjac, &wa1[1]);
+
+/*        rescale if necessary. */
+
+    if (*mode == 2) {
+	goto L170;
+    }
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+/* Computing MAX */
+	d__1 = diag[j], d__2 = wa2[j];
+	diag[j] = max(d__1,d__2);
+/* L160: */
+    }
+L170:
+
+/*        beginning of the inner loop. */
+
+L180:
+
+/*           if requested, call fcn to enable printing of iterates. */
+
+    if (*nprint <= 0) {
+	goto L190;
+    }
+    iflag = 0;
+    if ((iter - 1) % *nprint == 0) {
+	fcnder_nn(n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag, user_data);
+    }
+    if (iflag < 0) {
+	goto L300;
+    }
+L190:
+
+/*           determine the direction p. */
+
+    __minpack_func__(dogleg)(n, &r__[1], lr, &diag[1], &qtf[1], &delta, &wa1[1], &wa2[1], &wa3[
+	    1]);
+
+/*           store the direction p and x + p. calculate the norm of p. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	wa1[j] = -wa1[j];
+	wa2[j] = x[j] + wa1[j];
+	wa3[j] = diag[j] * wa1[j];
+/* L200: */
+    }
+    pnorm = __minpack_func__(enorm)(n, &wa3[1]);
+
+/*           on the first iteration, adjust the initial step bound. */
+
+    if (iter == 1) {
+	delta = min(delta,pnorm);
+    }
+
+/*           evaluate the function at x + p and calculate its norm. */
+
+    iflag = 1;
+    fcnder_nn(n, &wa2[1], &wa4[1], &fjac[fjac_offset], ldfjac, &iflag, user_data);
+    ++(*nfev);
+    if (iflag < 0) {
+	goto L300;
+    }
+    fnorm1 = __minpack_func__(enorm)(n, &wa4[1]);
+
+/*           compute the scaled actual reduction. */
+
+    actred = -1.;
+    if (fnorm1 < fnorm) {
+/* Computing 2nd power */
+	d__1 = fnorm1 / fnorm;
+	actred = 1. - d__1 * d__1;
+    }
+
+/*           compute the scaled predicted reduction. */
+
+    l = 1;
+    i__1 = *n;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	sum = 0.;
+	i__2 = *n;
+	for (j = i__; j <= i__2; ++j) {
+	    sum += r__[l] * wa1[j];
+	    ++l;
+/* L210: */
+	}
+	wa3[i__] = qtf[i__] + sum;
+/* L220: */
+    }
+    temp = __minpack_func__(enorm)(n, &wa3[1]);
+    prered = 0.;
+    if (temp < fnorm) {
+/* Computing 2nd power */
+	d__1 = temp / fnorm;
+	prered = 1. - d__1 * d__1;
+    }
+
+/*           compute the ratio of the actual to the predicted */
+/*           reduction. */
+
+    ratio = 0.;
+    if (prered > 0.) {
+	ratio = actred / prered;
+    }
+
+/*           update the step bound. */
+
+    if (ratio >= p1) {
+	goto L230;
+    }
+    ncsuc = 0;
+    ++ncfail;
+    delta = p5 * delta;
+    goto L240;
+L230:
+    ncfail = 0;
+    ++ncsuc;
+    if (ratio >= p5 || ncsuc > 1) {
+/* Computing MAX */
+	d__1 = delta, d__2 = pnorm / p5;
+	delta = max(d__1,d__2);
+    }
+    if (fabs(ratio - 1.) <= p1) {
+	delta = pnorm / p5;
+    }
+L240:
+
+/*           test for successful iteration. */
+
+    if (ratio < p0001) {
+	goto L260;
+    }
+
+/*           successful iteration. update x, fvec, and their norms. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	x[j] = wa2[j];
+	wa2[j] = diag[j] * x[j];
+	fvec[j] = wa4[j];
+/* L250: */
+    }
+    xnorm = __minpack_func__(enorm)(n, &wa2[1]);
+    fnorm = fnorm1;
+    ++iter;
+L260:
+
+/*           determine the progress of the iteration. */
+
+    ++nslow1;
+    if (actred >= p001) {
+	nslow1 = 0;
+    }
+    if (jeval) {
+	++nslow2;
+    }
+    if (actred >= p1) {
+	nslow2 = 0;
+    }
+
+/*           test for convergence. */
+
+    if (delta <= *xtol * xnorm || fnorm == 0.) {
+	*info = 1;
+    }
+    if (*info != 0) {
+	goto L300;
+    }
+
+/*           tests for termination and stringent tolerances. */
+
+    if (*nfev >= *maxfev) {
+	*info = 2;
+    }
+/* Computing MAX */
+    d__1 = p1 * delta;
+    if (p1 * max(d__1,pnorm) <= epsmch * xnorm) {
+	*info = 3;
+    }
+    if (nslow2 == 5) {
+	*info = 4;
+    }
+    if (nslow1 == 10) {
+	*info = 5;
+    }
+    if (*info != 0) {
+	goto L300;
+    }
+
+/*           criterion for recalculating jacobian. */
+
+    if (ncfail == 2) {
+	goto L290;
+    }
+
+/*           calculate the rank one modification to the jacobian */
+/*           and update qtf if necessary. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	sum = 0.;
+	i__2 = *n;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    sum += fjac[i__ + j * fjac_dim1] * wa4[i__];
+/* L270: */
+	}
+	wa2[j] = (sum - wa3[j]) / pnorm;
+	wa1[j] = diag[j] * (diag[j] * wa1[j] / pnorm);
+	if (ratio >= p0001) {
+	    qtf[j] = sum;
+	}
+/* L280: */
+    }
+
+/*           compute the qr factorization of the updated jacobian. */
+
+    __minpack_func__(r1updt)(n, n, &r__[1], lr, &wa1[1], &wa2[1], &wa3[1], &sing);
+    __minpack_func__(r1mpyq)(n, n, &fjac[fjac_offset], ldfjac, &wa2[1], &wa3[1]);
+    __minpack_func__(r1mpyq)(&c__1, n, &qtf[1], &c__1, &wa2[1], &wa3[1]);
+
+/*           end of the inner loop. */
+
+    jeval = FALSE_;
+    goto L180;
+L290:
+
+/*        end of the outer loop. */
+
+    goto L30;
+L300:
+
+/*     termination, either normal or user imposed. */
+
+    if (iflag < 0) {
+	*info = iflag;
+    }
+    iflag = 0;
+    if (*nprint > 0) {
+	fcnder_nn(n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, &iflag, user_data);
+    }
+    return;
+
+/*     last card of subroutine hybrj. */
+
+} /* hybrj_ */
+

+ 19 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/i_nint.c

@@ -0,0 +1,19 @@
+#include "f2c.h"
+
+#ifdef KR_headers
+double floor();
+integer i_nint(x) real *x;
+#else
+#undef abs
+#include "math.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+integer i_nint(real *x)
+#endif
+{
+return (integer)(*x >= 0 ? floor(*x + .5) : -floor(.5 - *x));
+}
+#ifdef __cplusplus
+}
+#endif

+ 93 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/idamax.c

@@ -0,0 +1,93 @@
+/* idamax.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+  on Microsoft Windows system, link with libf2c.lib;
+  on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+  or, if you install libf2c.a in a standard place, with -lf2c -lm
+  -- in that order, at the end of the command line, as in
+    cc *.o -lf2c -lm
+  Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+    http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+
+integer idamax_(integer *n, doublereal *dx, integer *incx)
+{
+    /* System generated locals */
+    integer ret_val, i__1;
+    doublereal d__1;
+
+    /* Local variables */
+    integer i__, ix;
+    doublereal dmax__;
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+/*     .. Array Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*     finds the index of element having max. absolute value. */
+/*     jack dongarra, linpack, 3/11/78. */
+/*     modified 3/93 to return if incx .le. 0. */
+/*     modified 12/3/93, array(1) declarations changed to array(*) */
+
+
+/*     .. Local Scalars .. */
+/*     .. */
+/*     .. Intrinsic Functions .. */
+/*     .. */
+    /* Parameter adjustments */
+    --dx;
+
+    /* Function Body */
+    ret_val = 0;
+    if (*n < 1 || *incx <= 0) {
+  return ret_val;
+    }
+    ret_val = 1;
+    if (*n == 1) {
+  return ret_val;
+    }
+    if (*incx == 1) {
+  goto L20;
+    }
+
+/*        code for increment not equal to 1 */
+
+    ix = 1;
+    dmax__ = fabs(dx[1]);
+    ix += *incx;
+    i__1 = *n;
+    for (i__ = 2; i__ <= i__1; ++i__) {
+  if ((d__1 = dx[ix], fabs(d__1)) <= dmax__) {
+      goto L5;
+  }
+  ret_val = i__;
+  dmax__ = (d__1 = dx[ix], fabs(d__1));
+L5:
+  ix += *incx;
+/* L10: */
+    }
+    return ret_val;
+
+/*        code for increment equal to 1 */
+
+L20:
+    dmax__ = fabs(dx[1]);
+    i__1 = *n;
+    for (i__ = 2; i__ <= i__1; ++i__) {
+  if ((d__1 = dx[i__], fabs(d__1)) <= dmax__) {
+      goto L30;
+  }
+  ret_val = i__;
+  dmax__ = (d__1 = dx[i__], fabs(d__1));
+L30:
+  ;
+    }
+    return ret_val;
+} /* idamax_ */

+ 166 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/ieeeck.c

@@ -0,0 +1,166 @@
+/* ieeeck.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+	on Microsoft Windows system, link with libf2c.lib;
+	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+	or, if you install libf2c.a in a standard place, with -lf2c -lm
+	-- in that order, at the end of the command line, as in
+		cc *.o -lf2c -lm
+	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+		http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+
+integer ieeeck_(integer *ispec, real *zero, real *one)
+{
+    /* System generated locals */
+    integer ret_val;
+
+    /* Local variables */
+    real nan1, nan2, nan3, nan4, nan5, nan6, neginf, posinf, negzro, newzro;
+
+
+/*  -- LAPACK auxiliary routine (version 3.2) -- */
+/*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
+/*     November 2006 */
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*  IEEECK is called from the ILAENV to verify that Infinity and */
+/*  possibly NaN arithmetic is safe (i.e. will not trap). */
+
+/*  Arguments */
+/*  ========= */
+
+/*  ISPEC   (input) INTEGER */
+/*          Specifies whether to test just for inifinity arithmetic */
+/*          or whether to test for infinity and NaN arithmetic. */
+/*          = 0: Verify infinity arithmetic only. */
+/*          = 1: Verify infinity and NaN arithmetic. */
+
+/*  ZERO    (input) REAL */
+/*          Must contain the value 0.0 */
+/*          This is passed to prevent the compiler from optimizing */
+/*          away this code. */
+
+/*  ONE     (input) REAL */
+/*          Must contain the value 1.0 */
+/*          This is passed to prevent the compiler from optimizing */
+/*          away this code. */
+
+/*  RETURN VALUE:  INTEGER */
+/*          = 0:  Arithmetic failed to produce the correct answers */
+/*          = 1:  Arithmetic produced the correct answers */
+
+/*     .. Local Scalars .. */
+/*     .. */
+/*     .. Executable Statements .. */
+    ret_val = 1;
+
+    posinf = *one / *zero;
+    if (posinf <= *one) {
+	ret_val = 0;
+	return ret_val;
+    }
+
+    neginf = -(*one) / *zero;
+    if (neginf >= *zero) {
+	ret_val = 0;
+	return ret_val;
+    }
+
+    negzro = *one / (neginf + *one);
+    if (negzro != *zero) {
+	ret_val = 0;
+	return ret_val;
+    }
+
+    neginf = *one / negzro;
+    if (neginf >= *zero) {
+	ret_val = 0;
+	return ret_val;
+    }
+
+    newzro = negzro + *zero;
+    if (newzro != *zero) {
+	ret_val = 0;
+	return ret_val;
+    }
+
+    posinf = *one / newzro;
+    if (posinf <= *one) {
+	ret_val = 0;
+	return ret_val;
+    }
+
+    neginf *= posinf;
+    if (neginf >= *zero) {
+	ret_val = 0;
+	return ret_val;
+    }
+
+    posinf *= posinf;
+    if (posinf <= *one) {
+	ret_val = 0;
+	return ret_val;
+    }
+
+
+
+
+/*     Return if we were only asked to check infinity arithmetic */
+
+    if (*ispec == 0) {
+	return ret_val;
+    }
+
+    nan1 = posinf + neginf;
+
+    nan2 = posinf / neginf;
+
+    nan3 = posinf / posinf;
+
+    nan4 = posinf * *zero;
+
+    nan5 = neginf * negzro;
+
+    nan6 = nan5 * 0.f;
+
+    if (nan1 == nan1) {
+	ret_val = 0;
+	return ret_val;
+    }
+
+    if (nan2 == nan2) {
+	ret_val = 0;
+	return ret_val;
+    }
+
+    if (nan3 == nan3) {
+	ret_val = 0;
+	return ret_val;
+    }
+
+    if (nan4 == nan4) {
+	ret_val = 0;
+	return ret_val;
+    }
+
+    if (nan5 == nan5) {
+	ret_val = 0;
+	return ret_val;
+    }
+
+    if (nan6 == nan6) {
+	ret_val = 0;
+	return ret_val;
+    }
+
+    return ret_val;
+} /* ieeeck_ */

+ 654 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/ilaenv.c

@@ -0,0 +1,654 @@
+/* ilaenv.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+	on Microsoft Windows system, link with libf2c.lib;
+	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+	or, if you install libf2c.a in a standard place, with -lf2c -lm
+	-- in that order, at the end of the command line, as in
+		cc *.o -lf2c -lm
+	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+		http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+#include "string.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+static real c_b163 = 0.f;
+static real c_b164 = 1.f;
+static integer c__0 = 0;
+
+integer ilaenv_(integer *ispec, char *name__, char *opts, integer *n1, 
+	integer *n2, integer *n3, integer *n4)
+{
+    /* System generated locals */
+    integer ret_val;
+
+    /* Builtin functions */
+    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+    integer s_cmp(char *, char *, ftnlen, ftnlen);
+
+    /* Local variables */
+    integer i__;
+    char c1[1], c2[1], c3[1], c4[1];
+    integer ic, nb, iz, nx;
+    logical cname;
+    integer nbmin;
+    logical sname;
+    extern integer ieeeck_(integer *, real *, real *);
+    char subnam[1];
+    extern integer iparmq_(integer *, char *, char *, integer *, integer *, 
+	    integer *, integer *);
+
+    ftnlen name_len, opts_len;
+
+    name_len = strlen (name__);
+    opts_len = strlen (opts);
+
+/*  -- LAPACK auxiliary routine (version 3.2) -- */
+/*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
+/*     January 2007 */
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*  ILAENV is called from the LAPACK routines to choose problem-dependent */
+/*  parameters for the local environment.  See ISPEC for a description of */
+/*  the parameters. */
+
+/*  ILAENV returns an INTEGER */
+/*  if ILAENV >= 0: ILAENV returns the value of the parameter specified by ISPEC */
+/*  if ILAENV < 0:  if ILAENV = -k, the k-th argument had an illegal value. */
+
+/*  This version provides a set of parameters which should give good, */
+/*  but not optimal, performance on many of the currently available */
+/*  computers.  Users are encouraged to modify this subroutine to set */
+/*  the tuning parameters for their particular machine using the option */
+/*  and problem size information in the arguments. */
+
+/*  This routine will not function correctly if it is converted to all */
+/*  lower case.  Converting it to all upper case is allowed. */
+
+/*  Arguments */
+/*  ========= */
+
+/*  ISPEC   (input) INTEGER */
+/*          Specifies the parameter to be returned as the value of */
+/*          ILAENV. */
+/*          = 1: the optimal blocksize; if this value is 1, an unblocked */
+/*               algorithm will give the best performance. */
+/*          = 2: the minimum block size for which the block routine */
+/*               should be used; if the usable block size is less than */
+/*               this value, an unblocked routine should be used. */
+/*          = 3: the crossover point (in a block routine, for N less */
+/*               than this value, an unblocked routine should be used) */
+/*          = 4: the number of shifts, used in the nonsymmetric */
+/*               eigenvalue routines (DEPRECATED) */
+/*          = 5: the minimum column dimension for blocking to be used; */
+/*               rectangular blocks must have dimension at least k by m, */
+/*               where k is given by ILAENV(2,...) and m by ILAENV(5,...) */
+/*          = 6: the crossover point for the SVD (when reducing an m by n */
+/*               matrix to bidiagonal form, if lmax(m,n)/min(m,n) exceeds */
+/*               this value, a QR factorization is used first to reduce */
+/*               the matrix to a triangular form.) */
+/*          = 7: the number of processors */
+/*          = 8: the crossover point for the multishift QR method */
+/*               for nonsymmetric eigenvalue problems (DEPRECATED) */
+/*          = 9: maximum size of the subproblems at the bottom of the */
+/*               computation tree in the divide-and-conquer algorithm */
+/*               (used by xGELSD and xGESDD) */
+/*          =10: ieee NaN arithmetic can be trusted not to trap */
+/*          =11: infinity arithmetic can be trusted not to trap */
+/*          12 <= ISPEC <= 16: */
+/*               xHSEQR or one of its subroutines, */
+/*               see IPARMQ for detailed explanation */
+
+/*  NAME    (input) CHARACTER*(*) */
+/*          The name of the calling subroutine, in either upper case or */
+/*          lower case. */
+
+/*  OPTS    (input) CHARACTER*(*) */
+/*          The character options to the subroutine NAME, concatenated */
+/*          into a single character string.  For example, UPLO = 'U', */
+/*          TRANS = 'T', and DIAG = 'N' for a triangular routine would */
+/*          be specified as OPTS = 'UTN'. */
+
+/*  N1      (input) INTEGER */
+/*  N2      (input) INTEGER */
+/*  N3      (input) INTEGER */
+/*  N4      (input) INTEGER */
+/*          Problem dimensions for the subroutine NAME; these may not all */
+/*          be required. */
+
+/*  Further Details */
+/*  =============== */
+
+/*  The following conventions have been used when calling ILAENV from the */
+/*  LAPACK routines: */
+/*  1)  OPTS is a concatenation of all of the character options to */
+/*      subroutine NAME, in the same order that they appear in the */
+/*      argument list for NAME, even if they are not used in determining */
+/*      the value of the parameter specified by ISPEC. */
+/*  2)  The problem dimensions N1, N2, N3, N4 are specified in the order */
+/*      that they appear in the argument list for NAME.  N1 is used */
+/*      first, N2 second, and so on, and unused problem dimensions are */
+/*      passed a value of -1. */
+/*  3)  The parameter value returned by ILAENV is checked for validity in */
+/*      the calling subroutine.  For example, ILAENV is used to retrieve */
+/*      the optimal blocksize for STRTRI as follows: */
+
+/*      NB = ILAENV( 1, 'STRTRI', UPLO // DIAG, N, -1, -1, -1 ) */
+/*      IF( NB.LE.1 ) NB = MAX( 1, N ) */
+
+/*  ===================================================================== */
+
+/*     .. Local Scalars .. */
+/*     .. */
+/*     .. Intrinsic Functions .. */
+/*     .. */
+/*     .. External Functions .. */
+/*     .. */
+/*     .. Executable Statements .. */
+
+    switch (*ispec) {
+	case 1:  goto L10;
+	case 2:  goto L10;
+	case 3:  goto L10;
+	case 4:  goto L80;
+	case 5:  goto L90;
+	case 6:  goto L100;
+	case 7:  goto L110;
+	case 8:  goto L120;
+	case 9:  goto L130;
+	case 10:  goto L140;
+	case 11:  goto L150;
+	case 12:  goto L160;
+	case 13:  goto L160;
+	case 14:  goto L160;
+	case 15:  goto L160;
+	case 16:  goto L160;
+    }
+
+/*     Invalid value for ISPEC */
+
+    ret_val = -1;
+    return ret_val;
+
+L10:
+
+/*     Convert NAME to upper case if the first character is lower case. */
+
+    ret_val = 1;
+    s_copy(subnam, name__, (ftnlen)1, name_len);
+    ic = *(unsigned char *)subnam;
+    iz = 'Z';
+    if (iz == 90 || iz == 122) {
+
+/*        ASCII character set */
+
+	if (ic >= 97 && ic <= 122) {
+	    *(unsigned char *)subnam = (char) (ic - 32);
+	    for (i__ = 2; i__ <= 6; ++i__) {
+		ic = *(unsigned char *)&subnam[i__ - 1];
+		if (ic >= 97 && ic <= 122) {
+		    *(unsigned char *)&subnam[i__ - 1] = (char) (ic - 32);
+		}
+/* L20: */
+	    }
+	}
+
+    } else if (iz == 233 || iz == 169) {
+
+/*        EBCDIC character set */
+
+	if (ic >= 129 && ic <= 137 || ic >= 145 && ic <= 153 || ic >= 162 && 
+		ic <= 169) {
+	    *(unsigned char *)subnam = (char) (ic + 64);
+	    for (i__ = 2; i__ <= 6; ++i__) {
+		ic = *(unsigned char *)&subnam[i__ - 1];
+		if (ic >= 129 && ic <= 137 || ic >= 145 && ic <= 153 || ic >= 
+			162 && ic <= 169) {
+		    *(unsigned char *)&subnam[i__ - 1] = (char) (ic + 64);
+		}
+/* L30: */
+	    }
+	}
+
+    } else if (iz == 218 || iz == 250) {
+
+/*        Prime machines:  ASCII+128 */
+
+	if (ic >= 225 && ic <= 250) {
+	    *(unsigned char *)subnam = (char) (ic - 32);
+	    for (i__ = 2; i__ <= 6; ++i__) {
+		ic = *(unsigned char *)&subnam[i__ - 1];
+		if (ic >= 225 && ic <= 250) {
+		    *(unsigned char *)&subnam[i__ - 1] = (char) (ic - 32);
+		}
+/* L40: */
+	    }
+	}
+    }
+
+    *(unsigned char *)c1 = *(unsigned char *)subnam;
+    sname = *(unsigned char *)c1 == 'S' || *(unsigned char *)c1 == 'D';
+    cname = *(unsigned char *)c1 == 'C' || *(unsigned char *)c1 == 'Z';
+    if (! (cname || sname)) {
+	return ret_val;
+    }
+    s_copy(c2, subnam + 1, (ftnlen)1, (ftnlen)2);
+    s_copy(c3, subnam + 3, (ftnlen)1, (ftnlen)3);
+    s_copy(c4, c3 + 1, (ftnlen)1, (ftnlen)2);
+
+    switch (*ispec) {
+	case 1:  goto L50;
+	case 2:  goto L60;
+	case 3:  goto L70;
+    }
+
+L50:
+
+/*     ISPEC = 1:  block size */
+
+/*     In these examples, separate code is provided for setting NB for */
+/*     real and complex.  We assume that NB will take the same value in */
+/*     single or double precision. */
+
+    nb = 1;
+
+    if (s_cmp(c2, "GE", (ftnlen)1, (ftnlen)2) == 0) {
+	if (s_cmp(c3, "TRF", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		nb = 64;
+	    } else {
+		nb = 64;
+	    }
+	} else if (s_cmp(c3, "QRF", (ftnlen)1, (ftnlen)3) == 0 || s_cmp(c3, 
+		"RQF", (ftnlen)1, (ftnlen)3) == 0 || s_cmp(c3, "LQF", (ftnlen)
+		1, (ftnlen)3) == 0 || s_cmp(c3, "QLF", (ftnlen)1, (ftnlen)3) 
+		== 0) {
+	    if (sname) {
+		nb = 32;
+	    } else {
+		nb = 32;
+	    }
+	} else if (s_cmp(c3, "HRD", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		nb = 32;
+	    } else {
+		nb = 32;
+	    }
+	} else if (s_cmp(c3, "BRD", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		nb = 32;
+	    } else {
+		nb = 32;
+	    }
+	} else if (s_cmp(c3, "TRI", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		nb = 64;
+	    } else {
+		nb = 64;
+	    }
+	}
+    } else if (s_cmp(c2, "PO", (ftnlen)1, (ftnlen)2) == 0) {
+	if (s_cmp(c3, "TRF", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		nb = 64;
+	    } else {
+		nb = 64;
+	    }
+	}
+    } else if (s_cmp(c2, "SY", (ftnlen)1, (ftnlen)2) == 0) {
+	if (s_cmp(c3, "TRF", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		nb = 64;
+	    } else {
+		nb = 64;
+	    }
+	} else if (sname && s_cmp(c3, "TRD", (ftnlen)1, (ftnlen)3) == 0) {
+	    nb = 32;
+	} else if (sname && s_cmp(c3, "GST", (ftnlen)1, (ftnlen)3) == 0) {
+	    nb = 64;
+	}
+    } else if (cname && s_cmp(c2, "HE", (ftnlen)1, (ftnlen)2) == 0) {
+	if (s_cmp(c3, "TRF", (ftnlen)1, (ftnlen)3) == 0) {
+	    nb = 64;
+	} else if (s_cmp(c3, "TRD", (ftnlen)1, (ftnlen)3) == 0) {
+	    nb = 32;
+	} else if (s_cmp(c3, "GST", (ftnlen)1, (ftnlen)3) == 0) {
+	    nb = 64;
+	}
+    } else if (sname && s_cmp(c2, "OR", (ftnlen)1, (ftnlen)2) == 0) {
+	if (*(unsigned char *)c3 == 'G') {
+	    if (s_cmp(c4, "QR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "RQ", 
+		    (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "LQ", (ftnlen)1, (
+		    ftnlen)2) == 0 || s_cmp(c4, "QL", (ftnlen)1, (ftnlen)2) ==
+		     0 || s_cmp(c4, "HR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(
+		    c4, "TR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "BR", (
+		    ftnlen)1, (ftnlen)2) == 0) {
+		nb = 32;
+	    }
+	} else if (*(unsigned char *)c3 == 'M') {
+	    if (s_cmp(c4, "QR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "RQ", 
+		    (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "LQ", (ftnlen)1, (
+		    ftnlen)2) == 0 || s_cmp(c4, "QL", (ftnlen)1, (ftnlen)2) ==
+		     0 || s_cmp(c4, "HR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(
+		    c4, "TR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "BR", (
+		    ftnlen)1, (ftnlen)2) == 0) {
+		nb = 32;
+	    }
+	}
+    } else if (cname && s_cmp(c2, "UN", (ftnlen)1, (ftnlen)2) == 0) {
+	if (*(unsigned char *)c3 == 'G') {
+	    if (s_cmp(c4, "QR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "RQ", 
+		    (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "LQ", (ftnlen)1, (
+		    ftnlen)2) == 0 || s_cmp(c4, "QL", (ftnlen)1, (ftnlen)2) ==
+		     0 || s_cmp(c4, "HR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(
+		    c4, "TR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "BR", (
+		    ftnlen)1, (ftnlen)2) == 0) {
+		nb = 32;
+	    }
+	} else if (*(unsigned char *)c3 == 'M') {
+	    if (s_cmp(c4, "QR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "RQ", 
+		    (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "LQ", (ftnlen)1, (
+		    ftnlen)2) == 0 || s_cmp(c4, "QL", (ftnlen)1, (ftnlen)2) ==
+		     0 || s_cmp(c4, "HR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(
+		    c4, "TR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "BR", (
+		    ftnlen)1, (ftnlen)2) == 0) {
+		nb = 32;
+	    }
+	}
+    } else if (s_cmp(c2, "GB", (ftnlen)1, (ftnlen)2) == 0) {
+	if (s_cmp(c3, "TRF", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		if (*n4 <= 64) {
+		    nb = 1;
+		} else {
+		    nb = 32;
+		}
+	    } else {
+		if (*n4 <= 64) {
+		    nb = 1;
+		} else {
+		    nb = 32;
+		}
+	    }
+	}
+    } else if (s_cmp(c2, "PB", (ftnlen)1, (ftnlen)2) == 0) {
+	if (s_cmp(c3, "TRF", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		if (*n2 <= 64) {
+		    nb = 1;
+		} else {
+		    nb = 32;
+		}
+	    } else {
+		if (*n2 <= 64) {
+		    nb = 1;
+		} else {
+		    nb = 32;
+		}
+	    }
+	}
+    } else if (s_cmp(c2, "TR", (ftnlen)1, (ftnlen)2) == 0) {
+	if (s_cmp(c3, "TRI", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		nb = 64;
+	    } else {
+		nb = 64;
+	    }
+	}
+    } else if (s_cmp(c2, "LA", (ftnlen)1, (ftnlen)2) == 0) {
+	if (s_cmp(c3, "UUM", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		nb = 64;
+	    } else {
+		nb = 64;
+	    }
+	}
+    } else if (sname && s_cmp(c2, "ST", (ftnlen)1, (ftnlen)2) == 0) {
+	if (s_cmp(c3, "EBZ", (ftnlen)1, (ftnlen)3) == 0) {
+	    nb = 1;
+	}
+    }
+    ret_val = nb;
+    return ret_val;
+
+L60:
+
+/*     ISPEC = 2:  minimum block size */
+
+    nbmin = 2;
+    if (s_cmp(c2, "GE", (ftnlen)1, (ftnlen)2) == 0) {
+	if (s_cmp(c3, "QRF", (ftnlen)1, (ftnlen)3) == 0 || s_cmp(c3, "RQF", (
+		ftnlen)1, (ftnlen)3) == 0 || s_cmp(c3, "LQF", (ftnlen)1, (
+		ftnlen)3) == 0 || s_cmp(c3, "QLF", (ftnlen)1, (ftnlen)3) == 0)
+		 {
+	    if (sname) {
+		nbmin = 2;
+	    } else {
+		nbmin = 2;
+	    }
+	} else if (s_cmp(c3, "HRD", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		nbmin = 2;
+	    } else {
+		nbmin = 2;
+	    }
+	} else if (s_cmp(c3, "BRD", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		nbmin = 2;
+	    } else {
+		nbmin = 2;
+	    }
+	} else if (s_cmp(c3, "TRI", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		nbmin = 2;
+	    } else {
+		nbmin = 2;
+	    }
+	}
+    } else if (s_cmp(c2, "SY", (ftnlen)1, (ftnlen)2) == 0) {
+	if (s_cmp(c3, "TRF", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		nbmin = 8;
+	    } else {
+		nbmin = 8;
+	    }
+	} else if (sname && s_cmp(c3, "TRD", (ftnlen)1, (ftnlen)3) == 0) {
+	    nbmin = 2;
+	}
+    } else if (cname && s_cmp(c2, "HE", (ftnlen)1, (ftnlen)2) == 0) {
+	if (s_cmp(c3, "TRD", (ftnlen)1, (ftnlen)3) == 0) {
+	    nbmin = 2;
+	}
+    } else if (sname && s_cmp(c2, "OR", (ftnlen)1, (ftnlen)2) == 0) {
+	if (*(unsigned char *)c3 == 'G') {
+	    if (s_cmp(c4, "QR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "RQ", 
+		    (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "LQ", (ftnlen)1, (
+		    ftnlen)2) == 0 || s_cmp(c4, "QL", (ftnlen)1, (ftnlen)2) ==
+		     0 || s_cmp(c4, "HR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(
+		    c4, "TR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "BR", (
+		    ftnlen)1, (ftnlen)2) == 0) {
+		nbmin = 2;
+	    }
+	} else if (*(unsigned char *)c3 == 'M') {
+	    if (s_cmp(c4, "QR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "RQ", 
+		    (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "LQ", (ftnlen)1, (
+		    ftnlen)2) == 0 || s_cmp(c4, "QL", (ftnlen)1, (ftnlen)2) ==
+		     0 || s_cmp(c4, "HR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(
+		    c4, "TR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "BR", (
+		    ftnlen)1, (ftnlen)2) == 0) {
+		nbmin = 2;
+	    }
+	}
+    } else if (cname && s_cmp(c2, "UN", (ftnlen)1, (ftnlen)2) == 0) {
+	if (*(unsigned char *)c3 == 'G') {
+	    if (s_cmp(c4, "QR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "RQ", 
+		    (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "LQ", (ftnlen)1, (
+		    ftnlen)2) == 0 || s_cmp(c4, "QL", (ftnlen)1, (ftnlen)2) ==
+		     0 || s_cmp(c4, "HR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(
+		    c4, "TR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "BR", (
+		    ftnlen)1, (ftnlen)2) == 0) {
+		nbmin = 2;
+	    }
+	} else if (*(unsigned char *)c3 == 'M') {
+	    if (s_cmp(c4, "QR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "RQ", 
+		    (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "LQ", (ftnlen)1, (
+		    ftnlen)2) == 0 || s_cmp(c4, "QL", (ftnlen)1, (ftnlen)2) ==
+		     0 || s_cmp(c4, "HR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(
+		    c4, "TR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "BR", (
+		    ftnlen)1, (ftnlen)2) == 0) {
+		nbmin = 2;
+	    }
+	}
+    }
+    ret_val = nbmin;
+    return ret_val;
+
+L70:
+
+/*     ISPEC = 3:  crossover point */
+
+    nx = 0;
+    if (s_cmp(c2, "GE", (ftnlen)1, (ftnlen)2) == 0) {
+	if (s_cmp(c3, "QRF", (ftnlen)1, (ftnlen)3) == 0 || s_cmp(c3, "RQF", (
+		ftnlen)1, (ftnlen)3) == 0 || s_cmp(c3, "LQF", (ftnlen)1, (
+		ftnlen)3) == 0 || s_cmp(c3, "QLF", (ftnlen)1, (ftnlen)3) == 0)
+		 {
+	    if (sname) {
+		nx = 128;
+	    } else {
+		nx = 128;
+	    }
+	} else if (s_cmp(c3, "HRD", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		nx = 128;
+	    } else {
+		nx = 128;
+	    }
+	} else if (s_cmp(c3, "BRD", (ftnlen)1, (ftnlen)3) == 0) {
+	    if (sname) {
+		nx = 128;
+	    } else {
+		nx = 128;
+	    }
+	}
+    } else if (s_cmp(c2, "SY", (ftnlen)1, (ftnlen)2) == 0) {
+	if (sname && s_cmp(c3, "TRD", (ftnlen)1, (ftnlen)3) == 0) {
+	    nx = 32;
+	}
+    } else if (cname && s_cmp(c2, "HE", (ftnlen)1, (ftnlen)2) == 0) {
+	if (s_cmp(c3, "TRD", (ftnlen)1, (ftnlen)3) == 0) {
+	    nx = 32;
+	}
+    } else if (sname && s_cmp(c2, "OR", (ftnlen)1, (ftnlen)2) == 0) {
+	if (*(unsigned char *)c3 == 'G') {
+	    if (s_cmp(c4, "QR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "RQ", 
+		    (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "LQ", (ftnlen)1, (
+		    ftnlen)2) == 0 || s_cmp(c4, "QL", (ftnlen)1, (ftnlen)2) ==
+		     0 || s_cmp(c4, "HR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(
+		    c4, "TR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "BR", (
+		    ftnlen)1, (ftnlen)2) == 0) {
+		nx = 128;
+	    }
+	}
+    } else if (cname && s_cmp(c2, "UN", (ftnlen)1, (ftnlen)2) == 0) {
+	if (*(unsigned char *)c3 == 'G') {
+	    if (s_cmp(c4, "QR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "RQ", 
+		    (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "LQ", (ftnlen)1, (
+		    ftnlen)2) == 0 || s_cmp(c4, "QL", (ftnlen)1, (ftnlen)2) ==
+		     0 || s_cmp(c4, "HR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(
+		    c4, "TR", (ftnlen)1, (ftnlen)2) == 0 || s_cmp(c4, "BR", (
+		    ftnlen)1, (ftnlen)2) == 0) {
+		nx = 128;
+	    }
+	}
+    }
+    ret_val = nx;
+    return ret_val;
+
+L80:
+
+/*     ISPEC = 4:  number of shifts (used by xHSEQR) */
+
+    ret_val = 6;
+    return ret_val;
+
+L90:
+
+/*     ISPEC = 5:  minimum column dimension (not used) */
+
+    ret_val = 2;
+    return ret_val;
+
+L100:
+
+/*     ISPEC = 6:  crossover point for SVD (used by xGELSS and xGESVD) */
+
+    ret_val = (integer) ((real) lmin(*n1,*n2) * 1.6f);
+    return ret_val;
+
+L110:
+
+/*     ISPEC = 7:  number of processors (not used) */
+
+    ret_val = 1;
+    return ret_val;
+
+L120:
+
+/*     ISPEC = 8:  crossover point for multishift (used by xHSEQR) */
+
+    ret_val = 50;
+    return ret_val;
+
+L130:
+
+/*     ISPEC = 9:  maximum size of the subproblems at the bottom of the */
+/*                 computation tree in the divide-and-conquer algorithm */
+/*                 (used by xGELSD and xGESDD) */
+
+    ret_val = 25;
+    return ret_val;
+
+L140:
+
+/*     ISPEC = 10: ieee NaN arithmetic can be trusted not to trap */
+
+/*     ILAENV = 0 */
+    ret_val = 1;
+    if (ret_val == 1) {
+	ret_val = ieeeck_(&c__1, &c_b163, &c_b164);
+    }
+    return ret_val;
+
+L150:
+
+/*     ISPEC = 11: infinity arithmetic can be trusted not to trap */
+
+/*     ILAENV = 0 */
+    ret_val = 1;
+    if (ret_val == 1) {
+	ret_val = ieeeck_(&c__0, &c_b163, &c_b164);
+    }
+    return ret_val;
+
+L160:
+
+/*     12 <= ISPEC <= 16: xHSEQR or one of its subroutines. */
+
+    ret_val = iparmq_(ispec, name__, opts, n1, n2, n3, n4)
+	    ;
+    return ret_val;
+
+/*     End of ILAENV */
+
+} /* ilaenv_ */

+ 282 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/iparmq.c

@@ -0,0 +1,282 @@
+/* iparmq.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+	on Microsoft Windows system, link with libf2c.lib;
+	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+	or, if you install libf2c.a in a standard place, with -lf2c -lm
+	-- in that order, at the end of the command line, as in
+		cc *.o -lf2c -lm
+	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+		http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+
+integer iparmq_(integer *ispec, char *name__, char *opts, integer *n, integer 
+	*ilo, integer *ihi, integer *lwork)
+{
+    /* System generated locals */
+    integer ret_val, i__1, i__2;
+    real r__1;
+
+    /* Builtin functions */
+    double log(doublereal);
+    integer i_nint(real *);
+
+    /* Local variables */
+    integer nh, ns;
+
+
+/*  -- LAPACK auxiliary routine (version 3.2) -- */
+/*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
+/*     November 2006 */
+
+/*     .. Scalar Arguments .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*       This program sets problem and machine dependent parameters */
+/*       useful for xHSEQR and its subroutines. It is called whenever */
+/*       ILAENV is called with 12 <= ISPEC <= 16 */
+
+/*  Arguments */
+/*  ========= */
+
+/*       ISPEC  (input) integer scalar */
+/*              ISPEC specifies which tunable parameter IPARMQ should */
+/*              return. */
+
+/*              ISPEC=12: (INMIN)  Matrices of order nmin or less */
+/*                        are sent directly to xLAHQR, the implicit */
+/*                        double shift QR algorithm.  NMIN must be */
+/*                        at least 11. */
+
+/*              ISPEC=13: (INWIN)  Size of the deflation window. */
+/*                        This is best set greater than or equal to */
+/*                        the number of simultaneous shifts NS. */
+/*                        Larger matrices benefit from larger deflation */
+/*                        windows. */
+
+/*              ISPEC=14: (INIBL) Determines when to stop nibbling and */
+/*                        invest in an (expensive) multi-shift QR sweep. */
+/*                        If the aggressive early deflation subroutine */
+/*                        finds LD converged eigenvalues from an order */
+/*                        NW deflation window and LD.GT.(NW*NIBBLE)/100, */
+/*                        then the next QR sweep is skipped and early */
+/*                        deflation is applied immediately to the */
+/*                        remaining active diagonal block.  Setting */
+/*                        IPARMQ(ISPEC=14) = 0 causes TTQRE to skip a */
+/*                        multi-shift QR sweep whenever early deflation */
+/*                        finds a converged eigenvalue.  Setting */
+/*                        IPARMQ(ISPEC=14) greater than or equal to 100 */
+/*                        prevents TTQRE from skipping a multi-shift */
+/*                        QR sweep. */
+
+/*              ISPEC=15: (NSHFTS) The number of simultaneous shifts in */
+/*                        a multi-shift QR iteration. */
+
+/*              ISPEC=16: (IACC22) IPARMQ is set to 0, 1 or 2 with the */
+/*                        following meanings. */
+/*                        0:  During the multi-shift QR sweep, */
+/*                            xLAQR5 does not accumulate reflections and */
+/*                            does not use matrix-matrix multiply to */
+/*                            update the far-from-diagonal matrix */
+/*                            entries. */
+/*                        1:  During the multi-shift QR sweep, */
+/*                            xLAQR5 and/or xLAQRaccumulates reflections and uses */
+/*                            matrix-matrix multiply to update the */
+/*                            far-from-diagonal matrix entries. */
+/*                        2:  During the multi-shift QR sweep. */
+/*                            xLAQR5 accumulates reflections and takes */
+/*                            advantage of 2-by-2 block structure during */
+/*                            matrix-matrix multiplies. */
+/*                        (If xTRMM is slower than xGEMM, then */
+/*                        IPARMQ(ISPEC=16)=1 may be more efficient than */
+/*                        IPARMQ(ISPEC=16)=2 despite the greater level of */
+/*                        arithmetic work implied by the latter choice.) */
+
+/*       NAME    (input) character string */
+/*               Name of the calling subroutine */
+
+/*       OPTS    (input) character string */
+/*               This is a concatenation of the string arguments to */
+/*               TTQRE. */
+
+/*       N       (input) integer scalar */
+/*               N is the order of the Hessenberg matrix H. */
+
+/*       ILO     (input) INTEGER */
+/*       IHI     (input) INTEGER */
+/*               It is assumed that H is already upper triangular */
+/*               in rows and columns 1:ILO-1 and IHI+1:N. */
+
+/*       LWORK   (input) integer scalar */
+/*               The amount of workspace available. */
+
+/*  Further Details */
+/*  =============== */
+
+/*       Little is known about how best to choose these parameters. */
+/*       It is possible to use different values of the parameters */
+/*       for each of CHSEQR, DHSEQR, SHSEQR and ZHSEQR. */
+
+/*       It is probably best to choose different parameters for */
+/*       different matrices and different parameters at different */
+/*       times during the iteration, but this has not been */
+/*       implemented --- yet. */
+
+
+/*       The best choices of most of the parameters depend */
+/*       in an ill-understood way on the relative execution */
+/*       rate of xLAQR3 and xLAQR5 and on the nature of each */
+/*       particular eigenvalue problem.  Experiment may be the */
+/*       only practical way to determine which choices are most */
+/*       effective. */
+
+/*       Following is a list of default values supplied by IPARMQ. */
+/*       These defaults may be adjusted in order to attain better */
+/*       performance in any particular computational environment. */
+
+/*       IPARMQ(ISPEC=12) The xLAHQR vs xLAQR0 crossover point. */
+/*                        Default: 75. (Must be at least 11.) */
+
+/*       IPARMQ(ISPEC=13) Recommended deflation window size. */
+/*                        This depends on ILO, IHI and NS, the */
+/*                        number of simultaneous shifts returned */
+/*                        by IPARMQ(ISPEC=15).  The default for */
+/*                        (IHI-ILO+1).LE.500 is NS.  The default */
+/*                        for (IHI-ILO+1).GT.500 is 3*NS/2. */
+
+/*       IPARMQ(ISPEC=14) Nibble crossover point.  Default: 14. */
+
+/*       IPARMQ(ISPEC=15) Number of simultaneous shifts, NS. */
+/*                        a multi-shift QR iteration. */
+
+/*                        If IHI-ILO+1 is ... */
+
+/*                        greater than      ...but less    ... the */
+/*                        or equal to ...      than        default is */
+
+/*                                0               30       NS =   2+ */
+/*                               30               60       NS =   4+ */
+/*                               60              150       NS =  10 */
+/*                              150              590       NS =  ** */
+/*                              590             3000       NS =  64 */
+/*                             3000             6000       NS = 128 */
+/*                             6000             infinity   NS = 256 */
+
+/*                    (+)  By default matrices of this order are */
+/*                         passed to the implicit double shift routine */
+/*                         xLAHQR.  See IPARMQ(ISPEC=12) above.   These */
+/*                         values of NS are used only in case of a rare */
+/*                         xLAHQR failure. */
+
+/*                    (**) The asterisks (**) indicate an ad-hoc */
+/*                         function increasing from 10 to 64. */
+
+/*       IPARMQ(ISPEC=16) Select structured matrix multiply. */
+/*                        (See ISPEC=16 above for details.) */
+/*                        Default: 3. */
+
+/*     ================================================================ */
+/*     .. Parameters .. */
+/*     .. */
+/*     .. Local Scalars .. */
+/*     .. */
+/*     .. Intrinsic Functions .. */
+/*     .. */
+/*     .. Executable Statements .. */
+    if (*ispec == 15 || *ispec == 13 || *ispec == 16) {
+
+/*        ==== Set the number simultaneous shifts ==== */
+
+	nh = *ihi - *ilo + 1;
+	ns = 2;
+	if (nh >= 30) {
+	    ns = 4;
+	}
+	if (nh >= 60) {
+	    ns = 10;
+	}
+	if (nh >= 150) {
+/* Computing MAX */
+	    r__1 = log((real) nh) / log(2.f);
+	    i__1 = 10, i__2 = nh / i_nint(&r__1);
+	    ns = lmax(i__1,i__2);
+	}
+	if (nh >= 590) {
+	    ns = 64;
+	}
+	if (nh >= 3000) {
+	    ns = 128;
+	}
+	if (nh >= 6000) {
+	    ns = 256;
+	}
+/* Computing MAX */
+	i__1 = 2, i__2 = ns - ns % 2;
+	ns = lmax(i__1,i__2);
+    }
+
+    if (*ispec == 12) {
+
+
+/*        ===== Matrices of order smaller than NMIN get sent */
+/*        .     to xLAHQR, the classic double shift algorithm. */
+/*        .     This must be at least 11. ==== */
+
+	ret_val = 75;
+
+    } else if (*ispec == 14) {
+
+/*        ==== INIBL: skip a multi-shift qr iteration and */
+/*        .    whenever aggressive early deflation finds */
+/*        .    at least (NIBBLE*(window size)/100) deflations. ==== */
+
+	ret_val = 14;
+
+    } else if (*ispec == 15) {
+
+/*        ==== NSHFTS: The number of simultaneous shifts ===== */
+
+	ret_val = ns;
+
+    } else if (*ispec == 13) {
+
+/*        ==== NW: deflation window size.  ==== */
+
+	if (nh <= 500) {
+	    ret_val = ns;
+	} else {
+	    ret_val = ns * 3 / 2;
+	}
+
+    } else if (*ispec == 16) {
+
+/*        ==== IACC22: Whether to accumulate reflections */
+/*        .     before updating the far-from-diagonal elements */
+/*        .     and whether to use 2-by-2 block structure while */
+/*        .     doing it.  A small amount of work could be saved */
+/*        .     by making this choice dependent also upon the */
+/*        .     NH=IHI-ILO+1. */
+
+	ret_val = 0;
+	if (ns >= 14) {
+	    ret_val = 1;
+	}
+	if (ns >= 14) {
+	    ret_val = 2;
+	}
+
+    } else {
+/*        ===== invalid value of ispec ===== */
+	ret_val = -1;
+
+    }
+
+/*     ==== End of IPARMQ ==== */
+
+    return ret_val;
+} /* iparmq_ */

+ 117 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/lsame.c

@@ -0,0 +1,117 @@
+/* lsame.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+	on Microsoft Windows system, link with libf2c.lib;
+	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+	or, if you install libf2c.a in a standard place, with -lf2c -lm
+	-- in that order, at the end of the command line, as in
+		cc *.o -lf2c -lm
+	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+		http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+
+logical lsame_(char *ca, char *cb)
+{
+    /* System generated locals */
+    logical ret_val;
+
+    /* Local variables */
+    integer inta, intb, zcode;
+
+
+/*  -- LAPACK auxiliary routine (version 3.1) -- */
+/*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
+/*     November 2006 */
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*  LSAME returns .TRUE. if CA is the same letter as CB regardless of */
+/*  case. */
+
+/*  Arguments */
+/*  ========= */
+
+/*  CA      (input) CHARACTER*1 */
+
+/*  CB      (input) CHARACTER*1 */
+/*          CA and CB specify the single characters to be compared. */
+
+/* ===================================================================== */
+
+/*     .. Intrinsic Functions .. */
+/*     .. */
+/*     .. Local Scalars .. */
+/*     .. */
+
+/*     Test if the characters are equal */
+
+    ret_val = *(unsigned char *)ca == *(unsigned char *)cb;
+    if (ret_val) {
+	return ret_val;
+    }
+
+/*     Now test for equivalence if both characters are alphabetic. */
+
+    zcode = 'Z';
+
+/*     Use 'Z' rather than 'A' so that ASCII can be detected on Prime */
+/*     machines, on which ICHAR returns a value with bit 8 set. */
+/*     ICHAR('A') on Prime machines returns 193 which is the same as */
+/*     ICHAR('A') on an EBCDIC machine. */
+
+    inta = *(unsigned char *)ca;
+    intb = *(unsigned char *)cb;
+
+    if (zcode == 90 || zcode == 122) {
+
+/*        ASCII is assumed - ZCODE is the ASCII code of either lower or */
+/*        upper case 'Z'. */
+
+	if (inta >= 97 && inta <= 122) {
+	    inta += -32;
+	}
+	if (intb >= 97 && intb <= 122) {
+	    intb += -32;
+	}
+
+    } else if (zcode == 233 || zcode == 169) {
+
+/*        EBCDIC is assumed - ZCODE is the EBCDIC code of either lower or */
+/*        upper case 'Z'. */
+
+	if (inta >= 129 && inta <= 137 || inta >= 145 && inta <= 153 || inta 
+		>= 162 && inta <= 169) {
+	    inta += 64;
+	}
+	if (intb >= 129 && intb <= 137 || intb >= 145 && intb <= 153 || intb 
+		>= 162 && intb <= 169) {
+	    intb += 64;
+	}
+
+    } else if (zcode == 218 || zcode == 250) {
+
+/*        ASCII is assumed, on Prime machines - ZCODE is the ASCII code */
+/*        plus 128 of either lower or upper case 'Z'. */
+
+	if (inta >= 225 && inta <= 250) {
+	    inta += -32;
+	}
+	if (intb >= 225 && intb <= 250) {
+	    intb += -32;
+	}
+    }
+    ret_val = inta == intb;
+
+/*     RETURN */
+
+/*     End of LSAME */
+
+    return ret_val;
+} /* lsame_ */

+ 301 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/minpack.h

@@ -0,0 +1,301 @@
+#ifndef __MINPACK_H__
+#define __MINPACK_H__
+
+#include "cminpack.h"
+
+/* The default floating-point type is "double" for C/C++ and "float" for CUDA,
+   but you can change this by defining one of the following symbols when
+   compiling the library, and before including cminpack.h when using it:
+   __cminpack_double__ for double
+   __cminpack_float__ for float
+   __cminpack_half__ for half from the OpenEXR library (in this case, you must
+                     compile cminpack with a C++ compiler)
+*/
+#ifdef __cminpack_double__
+#define __minpack_func__(func) func ## _
+#endif
+
+#ifdef __cminpack_float__
+#define __minpack_func__(func) s ## func ## _
+#endif
+
+#ifdef __cminpack_half__
+#define __minpack_func__(func) h ## func ## _
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define MINPACK_EXPORT CMINPACK_EXPORT
+
+#define __minpack_real__  __cminpack_real__
+#define __minpack_attr__  __cminpack_attr__
+#if defined(__CUDA_ARCH__) || defined(__CUDACC__)
+#define __minpack_type_fcn_nn__        __minpack_attr__ void fcn_nn
+#define __minpack_type_fcnder_nn__     __minpack_attr__ void fcnder_nn
+#define __minpack_type_fcn_mn__        __minpack_attr__ void fcn_mn
+#define __minpack_type_fcnder_mn__     __minpack_attr__ void fcnder_mn
+#define __minpack_type_fcnderstr_mn__  __minpack_attr__ void fcnderstr_mn
+#define __minpack_decl_fcn_nn__
+#define __minpack_decl_fcnder_nn__
+#define __minpack_decl_fcn_mn__
+#define __minpack_decl_fcnder_mn__
+#define __minpack_decl_fcnderstr_mn__
+#define __minpack_param_fcn_nn__
+#define __minpack_param_fcnder_nn__
+#define __minpack_param_fcn_mn__
+#define __minpack_param_fcnder_mn__
+#define __minpack_param_fcnderstr_mn__
+#else
+#define __minpack_type_fcn_nn__        typedef void (*minpack_func_nn)
+#define __minpack_type_fcnder_nn__     typedef void (*minpack_funcder_nn)
+#define __minpack_type_fcn_mn__        typedef void (*minpack_func_mn)
+#define __minpack_type_fcnder_mn__     typedef void (*minpack_funcder_mn)
+#define __minpack_type_fcnderstr_mn__  typedef void (*minpack_funcderstr_mn)
+#define __minpack_decl_fcn_nn__        minpack_func_nn fcn_nn,
+#define __minpack_decl_fcnder_nn__     minpack_funcder_nn fcnder_nn,
+#define __minpack_decl_fcn_mn__        minpack_func_mn fcn_mn,
+#define __minpack_decl_fcnder_mn__     minpack_funcder_mn fcnder_mn,
+#define __minpack_decl_fcnderstr_mn__  minpack_funcderstr_mn fcnderstr_mn,
+#define __minpack_param_fcn_nn__       fcn_nn,
+#define __minpack_param_fcnder_nn__    fcnder_nn,
+#define __minpack_param_fcn_mn__       fcn_mn,
+#define __minpack_param_fcnder_mn__    fcnder_mn,
+#define __minpack_param_fcnderstr_mn__ fcnderstr_mn,
+#endif
+#undef __cminpack_type_fcn_nn__
+#undef __cminpack_type_fcnder_nn__
+#undef __cminpack_type_fcn_mn__
+#undef __cminpack_type_fcnder_mn__
+#undef __cminpack_type_fcnderstr_mn__
+#undef __cminpack_decl_fcn_nn__
+#undef __cminpack_decl_fcnder_nn__
+#undef __cminpack_decl_fcn_mn__
+#undef __cminpack_decl_fcnder_mn__
+#undef __cminpack_decl_fcnderstr_mn__
+#undef __cminpack_param_fcn_nn__
+#undef __cminpack_param_fcnder_nn__
+#undef __cminpack_param_fcn_mn__
+#undef __cminpack_param_fcnder_mn__
+#undef __cminpack_param_fcnderstr_mn__
+
+/* Declarations for minpack */
+
+/* Function types: */
+/* the iflag parameter is input-only (with respect to the FORTRAN */
+/*  version), the output iflag value is the return value of the function. */
+/* If iflag=0, the function shoulkd just print the current values (see */
+/* the nprint parameters below). */
+  
+/* for hybrd1 and hybrd: */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/* return a negative value to terminate hybrd1/hybrd */
+__minpack_type_fcn_nn__(const int *n, const __minpack_real__ *x, __minpack_real__ *fvec, int *iflag );
+
+/* for hybrj1 and hybrj */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/* return a negative value to terminate hybrj1/hybrj */
+__minpack_type_fcnder_nn__(const int *n, const __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac,
+                                  const int *ldfjac, int *iflag, void *user_data );
+
+/* for lmdif1 and lmdif */
+/*         calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         if iflag = 1 the result is used to compute the residuals. */
+/*         if iflag = 2 the result is used to compute the Jacobian by finite differences. */
+/*         Jacobian computation requires exactly n function calls with iflag = 2. */
+/* return a negative value to terminate lmdif1/lmdif */
+__minpack_type_fcn_mn__(const int *m, const int *n, const __minpack_real__ *x, __minpack_real__ *fvec,
+                               int *iflag );
+
+/* for lmder1 and lmder */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. do not alter fjac. */
+/*         if iflag = 2 calculate the jacobian at x and */
+/*         return this matrix in fjac. do not alter fvec. */
+/* return a negative value to terminate lmder1/lmder */
+__minpack_type_fcnder_mn__(const int *m, const int *n, const __minpack_real__ *x, __minpack_real__ *fvec,
+                                  __minpack_real__ *fjac, const int *ldfjac, int *iflag );
+
+/* for lmstr1 and lmstr */
+/*         if iflag = 1 calculate the functions at x and */
+/*         return this vector in fvec. */
+/*         if iflag = i calculate the (i-1)-st row of the */
+/*         jacobian at x and return this vector in fjrow. */
+/* return a negative value to terminate lmstr1/lmstr */
+__minpack_type_fcnderstr_mn__(const int *m, const int *n, const __minpack_real__ *x, __minpack_real__ *fvec,
+                                     __minpack_real__ *fjrow, int *iflag );
+
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (Jacobian calculated by
+   a forward-difference approximation) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(hybrd1)(  __minpack_decl_fcn_nn__
+	       const int *n, __minpack_real__ *x, __minpack_real__ *fvec, const __minpack_real__ *tol, int *info,
+	       __minpack_real__ *wa, const int *lwa );
+
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (Jacobian calculated by
+   a forward-difference approximation, more general). */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(hybrd)( __minpack_decl_fcn_nn__
+	      const int *n, __minpack_real__ *x, __minpack_real__ *fvec, const __minpack_real__ *xtol, const int *maxfev,
+	      const int *ml, const int *mu, const __minpack_real__ *epsfcn, __minpack_real__ *diag, const int *mode,
+	      const __minpack_real__ *factor, const int *nprint, int *info, int *nfev,
+	      __minpack_real__ *fjac, const int *ldfjac, __minpack_real__ *r, const int *lr, __minpack_real__ *qtf,
+	      __minpack_real__ *wa1, __minpack_real__ *wa2, __minpack_real__ *wa3, __minpack_real__ *wa4);
+  
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (user-supplied Jacobian) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(hybrj1)( __minpack_decl_fcnder_nn__ const int *n, __minpack_real__ *x,
+	       __minpack_real__ *fvec, __minpack_real__ *fjec, const int *ldfjac, const __minpack_real__ *tol,
+	       int *info, __minpack_real__ *wa, const int *lwa, void *user_data );
+          
+/* find a zero of a system of N nonlinear functions in N variables by
+   a modification of the Powell hybrid method (user-supplied Jacobian,
+   more general) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(hybrj)( __minpack_decl_fcnder_nn__ const int *n, __minpack_real__ *x,
+	      __minpack_real__ *fvec, __minpack_real__ *fjec, const int *ldfjac, const __minpack_real__ *xtol,
+	      const int *maxfev, __minpack_real__ *diag, const int *mode, const __minpack_real__ *factor,
+	      const int *nprint, int *info, int *nfev, int *njev, __minpack_real__ *r,
+	      const int *lr, __minpack_real__ *qtf, __minpack_real__ *wa1, __minpack_real__ *wa2,
+	      __minpack_real__ *wa3, __minpack_real__ *wa4, void *user_data );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (Jacobian calculated by a forward-difference approximation) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(lmdif1)( __minpack_decl_fcn_mn__
+	       const int *m, const int *n, __minpack_real__ *x, __minpack_real__ *fvec, const __minpack_real__ *tol,
+	       int *info, int *iwa, __minpack_real__ *wa, const int *lwa );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (Jacobian calculated by a forward-difference approximation, more
+   general) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(lmdif)( __minpack_decl_fcn_mn__
+	      const int *m, const int *n, __minpack_real__ *x, __minpack_real__ *fvec, const __minpack_real__ *ftol,
+	      const __minpack_real__ *xtol, const __minpack_real__ *gtol, const int *maxfev, const __minpack_real__ *epsfcn,
+	      __minpack_real__ *diag, const int *mode, const __minpack_real__ *factor, const int *nprint,
+	      int *info, int *nfev, __minpack_real__ *fjac, const int *ldfjac, int *ipvt,
+	      __minpack_real__ *qtf, __minpack_real__ *wa1, __minpack_real__ *wa2, __minpack_real__ *wa3,
+	      __minpack_real__ *wa4 );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(lmder1)( __minpack_decl_fcnder_mn__
+	       const int *m, const int *n, __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac,
+	       const int *ldfjac, const __minpack_real__ *tol, int *info, int *ipvt,
+	       __minpack_real__ *wa, const int *lwa );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian, more general) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(lmder)( __minpack_decl_fcnder_mn__
+	      const int *m, const int *n, __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac,
+	      const int *ldfjac, const __minpack_real__ *ftol, const __minpack_real__ *xtol, const __minpack_real__ *gtol,
+	      const int *maxfev, __minpack_real__ *diag, const int *mode, const __minpack_real__ *factor,
+	      const int *nprint, int *info, int *nfev, int *njev, int *ipvt,
+	      __minpack_real__ *qtf, __minpack_real__ *wa1, __minpack_real__ *wa2, __minpack_real__ *wa3,
+	      __minpack_real__ *wa4 );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian, minimal storage) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(lmstr1)( __minpack_decl_fcnderstr_mn__ const int *m, const int *n,
+	       __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac, const int *ldfjac,
+	       const __minpack_real__ *tol, int *info, int *ipvt, __minpack_real__ *wa, const int *lwa );
+
+/* minimize the sum of the squares of nonlinear functions in N
+   variables by a modification of the Levenberg-Marquardt algorithm
+   (user-supplied Jacobian, minimal storage, more general) */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(lmstr)( __minpack_decl_fcnderstr_mn__ const int *m,
+	      const int *n, __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjac,
+	      const int *ldfjac, const __minpack_real__ *ftol, const __minpack_real__ *xtol, const __minpack_real__ *gtol,
+	      const int *maxfev, __minpack_real__ *diag, const int *mode, const __minpack_real__ *factor,
+	      const int *nprint, int *info, int *nfev, int *njev, int *ipvt,
+	      __minpack_real__ *qtf, __minpack_real__ *wa1, __minpack_real__ *wa2, __minpack_real__ *wa3,
+	      __minpack_real__ *wa4 );
+ 
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(chkder)( const int *m, const int *n, const __minpack_real__ *x, __minpack_real__ *fvec, __minpack_real__ *fjec,
+	       const int *ldfjac, __minpack_real__ *xp, __minpack_real__ *fvecp, const int *mode,
+	       __minpack_real__ *err  );
+
+__minpack_attr__
+__minpack_real__ MINPACK_EXPORT __minpack_func__(dpmpar)( const int *i );
+
+__minpack_attr__
+__minpack_real__ MINPACK_EXPORT __minpack_func__(enorm)( const int *n, const __minpack_real__ *x );
+
+/* compute a forward-difference approximation to the m by n jacobian
+   matrix associated with a specified problem of m functions in n
+   variables. */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(fdjac2)(__minpack_decl_fcn_mn__
+	     const int *m, const int *n, __minpack_real__ *x, const __minpack_real__ *fvec, __minpack_real__ *fjac,
+	     const int *ldfjac, int *iflag, const __minpack_real__ *epsfcn, __minpack_real__ *wa);
+
+/* compute a forward-difference approximation to the n by n jacobian
+   matrix associated with a specified problem of n functions in n
+   variables. if the jacobian has a banded form, then function
+   evaluations are saved by only approximating the nonzero terms. */
+__minpack_attr__
+void MINPACK_EXPORT __minpack_func__(fdjac1)(__minpack_decl_fcn_nn__
+	     const int *n, __minpack_real__ *x, const __minpack_real__ *fvec, __minpack_real__ *fjac, const int *ldfjac,
+	     int *iflag, const int *ml, const int *mu, const __minpack_real__ *epsfcn, __minpack_real__ *wa1,
+	     __minpack_real__ *wa2);
+
+/* internal MINPACK subroutines */
+__minpack_attr__
+void __minpack_func__(dogleg)(const int *n, const __minpack_real__ *r, const int *lr, 
+             const __minpack_real__ *diag, const __minpack_real__ *qtb, const __minpack_real__ *delta, __minpack_real__ *x, 
+             __minpack_real__ *wa1, __minpack_real__ *wa2);
+__minpack_attr__
+void __minpack_func__(qrfac)(const int *m, const int *n, __minpack_real__ *a, const int *
+            lda, const int *pivot, int *ipvt, const int *lipvt, __minpack_real__ *rdiag,
+            __minpack_real__ *acnorm, __minpack_real__ *wa);
+__minpack_attr__
+void __minpack_func__(qrsolv)(const int *n, __minpack_real__ *r, const int *ldr, 
+             const int *ipvt, const __minpack_real__ *diag, const __minpack_real__ *qtb, __minpack_real__ *x, 
+             __minpack_real__ *sdiag, __minpack_real__ *wa);
+__minpack_attr__
+void __minpack_func__(qform)(const int *m, const int *n, __minpack_real__ *q, const int *
+            ldq, __minpack_real__ *wa);
+__minpack_attr__
+void __minpack_func__(r1updt)(const int *m, const int *n, __minpack_real__ *s, const int *
+             ls, const __minpack_real__ *u, __minpack_real__ *v, __minpack_real__ *w, int *sing);
+__minpack_attr__
+void __minpack_func__(r1mpyq)(const int *m, const int *n, __minpack_real__ *a, const int *
+             lda, const __minpack_real__ *v, const __minpack_real__ *w);
+__minpack_attr__
+void __minpack_func__(lmpar)(const int *n, __minpack_real__ *r, const int *ldr, 
+            const int *ipvt, const __minpack_real__ *diag, const __minpack_real__ *qtb, const __minpack_real__ *delta, 
+            __minpack_real__ *par, __minpack_real__ *x, __minpack_real__ *sdiag, __minpack_real__ *wa1, 
+            __minpack_real__ *wa2);
+__minpack_attr__
+void __minpack_func__(rwupdt)(const int *n, __minpack_real__ *r, const int *ldr, 
+             const __minpack_real__ *w, __minpack_real__ *b, __minpack_real__ *alpha, __minpack_real__ *cos, 
+             __minpack_real__ *sin);
+__minpack_attr__
+void __minpack_func__(covar)(const int *n, __minpack_real__ *r, const int *ldr, 
+           const int *ipvt, const __minpack_real__ *tol, __minpack_real__ *wa);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __MINPACK_H__ */

+ 41 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/pow_di.c

@@ -0,0 +1,41 @@
+#include "f2c.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef KR_headers
+double pow_di(ap, bp) doublereal *ap; integer *bp;
+#else
+double pow_di(doublereal *ap, integer *bp)
+#endif
+{
+double pow, x;
+integer n;
+unsigned long u;
+
+pow = 1;
+x = *ap;
+n = *bp;
+
+if(n != 0)
+	{
+	if(n < 0)
+		{
+		n = -n;
+		x = 1/x;
+		}
+	for(u = n; ; )
+		{
+		if(u & 01)
+			pow *= x;
+		if(u >>= 1)
+			x *= x;
+		else
+			break;
+		}
+	}
+return(pow);
+}
+#ifdef __cplusplus
+}
+#endif

+ 145 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/qform_.c

@@ -0,0 +1,145 @@
+/* qform.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+
+__minpack_attr__
+void __minpack_func__(qform)(const int *m, const int *n, real *q, const int *
+	ldq, real *wa)
+{
+    /* System generated locals */
+    int q_dim1, q_offset, i__1, i__2, i__3;
+
+    /* Local variables */
+    int i__, j, k, l, jm1, np1;
+    real sum, temp;
+    int minmn;
+
+/*     ********** */
+
+/*     subroutine qform */
+
+/*     this subroutine proceeds from the computed qr factorization of */
+/*     an m by n matrix a to accumulate the m by m orthogonal matrix */
+/*     q from its factored form. */
+
+/*     the subroutine statement is */
+
+/*       subroutine qform(m,n,q,ldq,wa) */
+
+/*     where */
+
+/*       m is a positive integer input variable set to the number */
+/*         of rows of a and the order of q. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of columns of a. */
+
+/*       q is an m by m array. on input the full lower trapezoid in */
+/*         the first min(m,n) columns of q contains the factored form. */
+/*         on output q has been accumulated into a square matrix. */
+
+/*       ldq is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array q. */
+
+/*       wa is a work array of length m. */
+
+/*     subprograms called */
+
+/*       fortran-supplied ... min0 */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa;
+    q_dim1 = *ldq;
+    q_offset = 1 + q_dim1 * 1;
+    q -= q_offset;
+
+    /* Function Body */
+
+/*     zero out upper triangle of q in the first min(m,n) columns. */
+
+    minmn = min(*m,*n);
+    if (minmn < 2) {
+	goto L30;
+    }
+    i__1 = minmn;
+    for (j = 2; j <= i__1; ++j) {
+	jm1 = j - 1;
+	i__2 = jm1;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    q[i__ + j * q_dim1] = 0.;
+/* L10: */
+	}
+/* L20: */
+    }
+L30:
+
+/*     initialize remaining columns to those of the identity matrix. */
+
+    np1 = *n + 1;
+    if (*m < np1) {
+	goto L60;
+    }
+    i__1 = *m;
+    for (j = np1; j <= i__1; ++j) {
+	i__2 = *m;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    q[i__ + j * q_dim1] = 0.;
+/* L40: */
+	}
+	q[j + j * q_dim1] = 1.;
+/* L50: */
+    }
+L60:
+
+/*     accumulate q from its factored form. */
+
+    i__1 = minmn;
+    for (l = 1; l <= i__1; ++l) {
+	k = minmn - l + 1;
+	i__2 = *m;
+	for (i__ = k; i__ <= i__2; ++i__) {
+	    wa[i__] = q[i__ + k * q_dim1];
+	    q[i__ + k * q_dim1] = 0.;
+/* L70: */
+	}
+	q[k + k * q_dim1] = 1.;
+	if (wa[k] == 0.) {
+	    goto L110;
+	}
+	i__2 = *m;
+	for (j = k; j <= i__2; ++j) {
+	    sum = 0.;
+	    i__3 = *m;
+	    for (i__ = k; i__ <= i__3; ++i__) {
+		sum += q[i__ + j * q_dim1] * wa[i__];
+/* L80: */
+	    }
+	    temp = sum / wa[k];
+	    i__3 = *m;
+	    for (i__ = k; i__ <= i__3; ++i__) {
+		q[i__ + j * q_dim1] -= temp * wa[i__];
+/* L90: */
+	    }
+/* L100: */
+	}
+L110:
+/* L120: */
+	;
+    }
+    return;
+
+/*     last card of subroutine qform. */
+
+} /* qform_ */
+

+ 245 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/qrfac_.c

@@ -0,0 +1,245 @@
+/* qrfac.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define min(a,b) ((a) <= (b) ? (a) : (b))
+#define max(a,b) ((a) >= (b) ? (a) : (b))
+
+__minpack_attr__
+void __minpack_func__(qrfac)(const int *m, const int *n, real *a, const int *
+	lda, const int *pivot, int *ipvt, const int *lipvt, real *rdiag,
+	 real *acnorm, real *wa)
+{
+    /* Initialized data */
+
+#define p05 .05
+    const int c__1 = 1;
+
+    /* System generated locals */
+    int a_dim1, a_offset, i__1, i__2, i__3;
+    real d__1, d__2, d__3;
+
+    /* Local variables */
+    int i__, j, k, jp1;
+    real sum;
+    int kmax;
+    real temp;
+    int minmn;
+    real epsmch;
+    real ajnorm;
+
+/*     ********** */
+
+/*     subroutine qrfac */
+
+/*     this subroutine uses householder transformations with column */
+/*     pivoting (optional) to compute a qr factorization of the */
+/*     m by n matrix a. that is, qrfac determines an orthogonal */
+/*     matrix q, a permutation matrix p, and an upper trapezoidal */
+/*     matrix r with diagonal elements of nonincreasing magnitude, */
+/*     such that a*p = q*r. the householder transformation for */
+/*     column k, k = 1,2,...,min(m,n), is of the form */
+
+/*                           t */
+/*           i - (1/u(k))*u*u */
+
+/*     where u has zeros in the first k-1 positions. the form of */
+/*     this transformation and the method of pivoting first */
+/*     appeared in the corresponding linpack subroutine. */
+
+/*     the subroutine statement is */
+
+/*       subroutine qrfac(m,n,a,lda,pivot,ipvt,lipvt,rdiag,acnorm,wa) */
+
+/*     where */
+
+/*       m is a positive integer input variable set to the number */
+/*         of rows of a. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of columns of a. */
+
+/*       a is an m by n array. on input a contains the matrix for */
+/*         which the qr factorization is to be computed. on output */
+/*         the strict upper trapezoidal part of a contains the strict */
+/*         upper trapezoidal part of r, and the lower trapezoidal */
+/*         part of a contains a factored form of q (the non-trivial */
+/*         elements of the u vectors described above). */
+
+/*       lda is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array a. */
+
+/*       pivot is a logical input variable. if pivot is set true, */
+/*         then column pivoting is enforced. if pivot is set false, */
+/*         then no column pivoting is done. */
+
+/*       ipvt is an integer output array of length lipvt. ipvt */
+/*         defines the permutation matrix p such that a*p = q*r. */
+/*         column j of p is column ipvt(j) of the identity matrix. */
+/*         if pivot is false, ipvt is not referenced. */
+
+/*       lipvt is a positive integer input variable. if pivot is false, */
+/*         then lipvt may be as small as 1. if pivot is true, then */
+/*         lipvt must be at least n. */
+
+/*       rdiag is an output array of length n which contains the */
+/*         diagonal elements of r. */
+
+/*       acnorm is an output array of length n which contains the */
+/*         norms of the corresponding columns of the input matrix a. */
+/*         if this information is not needed, then acnorm can coincide */
+/*         with rdiag. */
+
+/*       wa is a work array of length n. if pivot is false, then wa */
+/*         can coincide with rdiag. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... dpmpar,enorm */
+
+/*       fortran-supplied ... dmax1,dsqrt,min0 */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --wa;
+    --acnorm;
+    --rdiag;
+    a_dim1 = *lda;
+    a_offset = 1 + a_dim1 * 1;
+    a -= a_offset;
+    --ipvt;
+    (void)lipvt;
+
+    /* Function Body */
+
+/*     epsmch is the machine precision. */
+
+    epsmch = __minpack_func__(dpmpar)(&c__1);
+
+/*     compute the initial column norms and initialize several arrays. */
+
+    i__1 = *n;
+    for (j = 1; j <= i__1; ++j) {
+	acnorm[j] = __minpack_func__(enorm)(m, &a[j * a_dim1 + 1]);
+	rdiag[j] = acnorm[j];
+	wa[j] = rdiag[j];
+	if (*pivot) {
+	    ipvt[j] = j;
+	}
+/* L10: */
+    }
+
+/*     reduce a to r with householder transformations. */
+
+    minmn = min(*m,*n);
+    i__1 = minmn;
+    for (j = 1; j <= i__1; ++j) {
+	if (! (*pivot)) {
+	    goto L40;
+	}
+
+/*        bring the column of largest norm into the pivot position. */
+
+	kmax = j;
+	i__2 = *n;
+	for (k = j; k <= i__2; ++k) {
+	    if (rdiag[k] > rdiag[kmax]) {
+		kmax = k;
+	    }
+/* L20: */
+	}
+	if (kmax == j) {
+	    goto L40;
+	}
+	i__2 = *m;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    temp = a[i__ + j * a_dim1];
+	    a[i__ + j * a_dim1] = a[i__ + kmax * a_dim1];
+	    a[i__ + kmax * a_dim1] = temp;
+/* L30: */
+	}
+	rdiag[kmax] = rdiag[j];
+	wa[kmax] = wa[j];
+	k = ipvt[j];
+	ipvt[j] = ipvt[kmax];
+	ipvt[kmax] = k;
+L40:
+
+/*        compute the householder transformation to reduce the */
+/*        j-th column of a to a multiple of the j-th unit vector. */
+
+	i__2 = *m - j + 1;
+	ajnorm = __minpack_func__(enorm)(&i__2, &a[j + j * a_dim1]);
+	if (ajnorm == 0.) {
+	    goto L100;
+	}
+	if (a[j + j * a_dim1] < 0.) {
+	    ajnorm = -ajnorm;
+	}
+	i__2 = *m;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    a[i__ + j * a_dim1] /= ajnorm;
+/* L50: */
+	}
+	a[j + j * a_dim1] += 1.;
+
+/*        apply the transformation to the remaining columns */
+/*        and update the norms. */
+
+	jp1 = j + 1;
+	if (*n < jp1) {
+	    goto L100;
+	}
+	i__2 = *n;
+	for (k = jp1; k <= i__2; ++k) {
+	    sum = 0.;
+	    i__3 = *m;
+	    for (i__ = j; i__ <= i__3; ++i__) {
+		sum += a[i__ + j * a_dim1] * a[i__ + k * a_dim1];
+/* L60: */
+	    }
+	    temp = sum / a[j + j * a_dim1];
+	    i__3 = *m;
+	    for (i__ = j; i__ <= i__3; ++i__) {
+		a[i__ + k * a_dim1] -= temp * a[i__ + j * a_dim1];
+/* L70: */
+	    }
+	    if (! (*pivot) || rdiag[k] == 0.) {
+		goto L80;
+	    }
+	    temp = a[j + k * a_dim1] / rdiag[k];
+/* Computing MAX */
+/* Computing 2nd power */
+	    d__3 = temp;
+	    d__1 = 0., d__2 = 1. - d__3 * d__3;
+	    rdiag[k] *= sqrt((max(d__1,d__2)));
+/* Computing 2nd power */
+	    d__1 = rdiag[k] / wa[k];
+	    if (p05 * (d__1 * d__1) > epsmch) {
+		goto L80;
+	    }
+	    i__3 = *m - j;
+	    rdiag[k] = __minpack_func__(enorm)(&i__3, &a[jp1 + k * a_dim1]);
+	    wa[k] = rdiag[k];
+L80:
+/* L90: */
+	    ;
+	}
+L100:
+	rdiag[j] = -ajnorm;
+/* L110: */
+    }
+    return;
+
+/*     last card of subroutine qrfac. */
+
+} /* qrfac_ */
+

+ 145 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/r1mpyq_.c

@@ -0,0 +1,145 @@
+/* r1mpyq.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define abs(x) ((x) >= 0 ? (x) : -(x))
+
+__minpack_attr__
+void __minpack_func__(r1mpyq)(const int *m, const int *n, real *a, const int *
+	lda, const real *v, const real *w)
+{
+    /* System generated locals */
+    int a_dim1, a_offset, i__1, i__2;
+    real d__1, d__2;
+
+    /* Local variables */
+    int i__, j, nm1, nmj;
+    real cos__, sin__, temp;
+
+/*     ********** */
+
+/*     subroutine r1mpyq */
+
+/*     given an m by n matrix a, this subroutine computes a*q where */
+/*     q is the product of 2*(n - 1) transformations */
+
+/*           gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1) */
+
+/*     and gv(i), gw(i) are givens rotations in the (i,n) plane which */
+/*     eliminate elements in the i-th and n-th planes, respectively. */
+/*     q itself is not given, rather the information to recover the */
+/*     gv, gw rotations is supplied. */
+
+/*     the subroutine statement is */
+
+/*       subroutine r1mpyq(m,n,a,lda,v,w) */
+
+/*     where */
+
+/*       m is a positive integer input variable set to the number */
+/*         of rows of a. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of columns of a. */
+
+/*       a is an m by n array. on input a must contain the matrix */
+/*         to be postmultiplied by the orthogonal matrix q */
+/*         described above. on output a*q has replaced a. */
+
+/*       lda is a positive integer input variable not less than m */
+/*         which specifies the leading dimension of the array a. */
+
+/*       v is an input array of length n. v(i) must contain the */
+/*         information necessary to recover the givens rotation gv(i) */
+/*         described above. */
+
+/*       w is an input array of length n. w(i) must contain the */
+/*         information necessary to recover the givens rotation gw(i) */
+/*         described above. */
+
+/*     subroutines called */
+
+/*       fortran-supplied ... dabs,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --w;
+    --v;
+    a_dim1 = *lda;
+    a_offset = 1 + a_dim1 * 1;
+    a -= a_offset;
+
+    /* Function Body */
+
+/*     apply the first set of givens rotations to a. */
+
+    nm1 = *n - 1;
+    if (nm1 < 1) {
+	/* goto L50; */
+        return;
+    }
+    i__1 = nm1;
+    for (nmj = 1; nmj <= i__1; ++nmj) {
+	j = *n - nmj;
+	if ((d__1 = v[j], abs(d__1)) > 1.) {
+	    cos__ = 1. / v[j];
+/* Computing 2nd power */
+	    d__2 = cos__;
+	    sin__ = sqrt(1. - d__2 * d__2);
+	} else {
+	    sin__ = v[j];
+/* Computing 2nd power */
+	    d__2 = sin__;
+	    cos__ = sqrt(1. - d__2 * d__2);
+	}
+	i__2 = *m;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    temp = cos__ * a[i__ + j * a_dim1] - sin__ * a[i__ + *n * a_dim1];
+	    a[i__ + *n * a_dim1] = sin__ * a[i__ + j * a_dim1] + cos__ * a[
+		    i__ + *n * a_dim1];
+	    a[i__ + j * a_dim1] = temp;
+/* L10: */
+	}
+/* L20: */
+    }
+
+/*     apply the second set of givens rotations to a. */
+
+    i__1 = nm1;
+    for (j = 1; j <= i__1; ++j) {
+	if ((d__1 = w[j], abs(d__1)) > 1.) {
+	    cos__ = 1. / w[j];
+/* Computing 2nd power */
+	    d__2 = cos__;
+	    sin__ = sqrt(1. - d__2 * d__2);
+	} else {
+	    sin__ = w[j];
+/* Computing 2nd power */
+	    d__2 = sin__;
+	    cos__ = sqrt(1. - d__2 * d__2);
+	}
+	i__2 = *m;
+	for (i__ = 1; i__ <= i__2; ++i__) {
+	    temp = cos__ * a[i__ + j * a_dim1] + sin__ * a[i__ + *n * a_dim1];
+	    a[i__ + *n * a_dim1] = -sin__ * a[i__ + j * a_dim1] + cos__ * a[
+		    i__ + *n * a_dim1];
+	    a[i__ + j * a_dim1] = temp;
+/* L30: */
+	}
+/* L40: */
+    }
+/* L50: */
+    return;
+
+/*     last card of subroutine r1mpyq. */
+
+} /* r1mpyq_ */
+

+ 283 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/r1updt_.c

@@ -0,0 +1,283 @@
+/* r1updt.f -- translated by f2c (version 20020621).
+   You must link the resulting object file with the libraries:
+	-lf2c -lm   (in that order)
+*/
+
+#include "minpack.h"
+#include <math.h>
+#define real __minpack_real__
+
+#define abs(x) ((x) >= 0 ? (x) : -(x))
+#define TRUE_ (1)
+#define FALSE_ (0)
+
+__minpack_attr__
+void __minpack_func__(r1updt)(const int *m, const int *n, real *s, const int *
+	ls, const real *u, real *v, real *w, int *sing)
+{
+    /* Initialized data */
+
+#define p5 .5
+#define p25 .25
+    const int c__3 = 3;
+
+    /* System generated locals */
+    int i__1, i__2;
+    real d__1, d__2;
+
+    /* Local variables */
+    int i__, j, l, jj, nm1;
+    real tan__;
+    int nmj;
+    real cos__, sin__, tau, temp, giant, cotan;
+
+/*     ********** */
+
+/*     subroutine r1updt */
+
+/*     given an m by n lower trapezoidal matrix s, an m-vector u, */
+/*     and an n-vector v, the problem is to determine an */
+/*     orthogonal matrix q such that */
+
+/*                   t */
+/*           (s + u*v )*q */
+
+/*     is again lower trapezoidal. */
+
+/*     this subroutine determines q as the product of 2*(n - 1) */
+/*     transformations */
+
+/*           gv(n-1)*...*gv(1)*gw(1)*...*gw(n-1) */
+
+/*     where gv(i), gw(i) are givens rotations in the (i,n) plane */
+/*     which eliminate elements in the i-th and n-th planes, */
+/*     respectively. q itself is not accumulated, rather the */
+/*     information to recover the gv, gw rotations is returned. */
+
+/*     the subroutine statement is */
+
+/*       subroutine r1updt(m,n,s,ls,u,v,w,sing) */
+
+/*     where */
+
+/*       m is a positive integer input variable set to the number */
+/*         of rows of s. */
+
+/*       n is a positive integer input variable set to the number */
+/*         of columns of s. n must not exceed m. */
+
+/*       s is an array of length ls. on input s must contain the lower */
+/*         trapezoidal matrix s stored by columns. on output s contains */
+/*         the lower trapezoidal matrix produced as described above. */
+
+/*       ls is a positive integer input variable not less than */
+/*         (n*(2*m-n+1))/2. */
+
+/*       u is an input array of length m which must contain the */
+/*         vector u. */
+
+/*       v is an array of length n. on input v must contain the vector */
+/*         v. on output v(i) contains the information necessary to */
+/*         recover the givens rotation gv(i) described above. */
+
+/*       w is an output array of length m. w(i) contains information */
+/*         necessary to recover the givens rotation gw(i) described */
+/*         above. */
+
+/*       sing is a logical output variable. sing is set true if any */
+/*         of the diagonal elements of the output s are zero. otherwise */
+/*         sing is set false. */
+
+/*     subprograms called */
+
+/*       minpack-supplied ... dpmpar */
+
+/*       fortran-supplied ... dabs,dsqrt */
+
+/*     argonne national laboratory. minpack project. march 1980. */
+/*     burton s. garbow, kenneth e. hillstrom, jorge j. more, */
+/*     john l. nazareth */
+
+/*     ********** */
+    /* Parameter adjustments */
+    --w;
+    --u;
+    --v;
+    --s;
+    (void)ls;
+
+    /* Function Body */
+
+/*     giant is the largest magnitude. */
+
+    giant = __minpack_func__(dpmpar)(&c__3);
+
+/*     initialize the diagonal element pointer. */
+
+    jj = *n * ((*m << 1) - *n + 1) / 2 - (*m - *n);
+
+/*     move the nontrivial part of the last column of s into w. */
+
+    l = jj;
+    i__1 = *m;
+    for (i__ = *n; i__ <= i__1; ++i__) {
+	w[i__] = s[l];
+	++l;
+/* L10: */
+    }
+
+/*     rotate the vector v into a multiple of the n-th unit vector */
+/*     in such a way that a spike is introduced into w. */
+
+    nm1 = *n - 1;
+    if (nm1 < 1) {
+	goto L70;
+    }
+    i__1 = nm1;
+    for (nmj = 1; nmj <= i__1; ++nmj) {
+	j = *n - nmj;
+	jj -= *m - j + 1;
+	w[j] = 0.;
+	if (v[j] == 0.) {
+	    goto L50;
+	}
+
+/*        determine a givens rotation which eliminates the */
+/*        j-th element of v. */
+
+	if ((d__1 = v[*n], abs(d__1)) >= (d__2 = v[j], abs(d__2))) {
+	    goto L20;
+	}
+	cotan = v[*n] / v[j];
+/* Computing 2nd power */
+	d__1 = cotan;
+	sin__ = p5 / sqrt(p25 + p25 * (d__1 * d__1));
+	cos__ = sin__ * cotan;
+	tau = 1.;
+	if (abs(cos__) * giant > 1.) {
+	    tau = 1. / cos__;
+	}
+	goto L30;
+L20:
+	tan__ = v[j] / v[*n];
+/* Computing 2nd power */
+	d__1 = tan__;
+	cos__ = p5 / sqrt(p25 + p25 * (d__1 * d__1));
+	sin__ = cos__ * tan__;
+	tau = sin__;
+L30:
+
+/*        apply the transformation to v and store the information */
+/*        necessary to recover the givens rotation. */
+
+	v[*n] = sin__ * v[j] + cos__ * v[*n];
+	v[j] = tau;
+
+/*        apply the transformation to s and extend the spike in w. */
+
+	l = jj;
+	i__2 = *m;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    temp = cos__ * s[l] - sin__ * w[i__];
+	    w[i__] = sin__ * s[l] + cos__ * w[i__];
+	    s[l] = temp;
+	    ++l;
+/* L40: */
+	}
+L50:
+/* L60: */
+	;
+    }
+L70:
+
+/*     add the spike from the rank 1 update to w. */
+
+    i__1 = *m;
+    for (i__ = 1; i__ <= i__1; ++i__) {
+	w[i__] += v[*n] * u[i__];
+/* L80: */
+    }
+
+/*     eliminate the spike. */
+
+    *sing = FALSE_;
+    if (nm1 < 1) {
+	goto L140;
+    }
+    i__1 = nm1;
+    for (j = 1; j <= i__1; ++j) {
+	if (w[j] == 0.) {
+	    goto L120;
+	}
+
+/*        determine a givens rotation which eliminates the */
+/*        j-th element of the spike. */
+
+	if ((d__1 = s[jj], abs(d__1)) >= (d__2 = w[j], abs(d__2))) {
+	    goto L90;
+	}
+	cotan = s[jj] / w[j];
+/* Computing 2nd power */
+	d__1 = cotan;
+	sin__ = p5 / sqrt(p25 + p25 * (d__1 * d__1));
+	cos__ = sin__ * cotan;
+	tau = 1.;
+	if (abs(cos__) * giant > 1.) {
+	    tau = 1. / cos__;
+	}
+	goto L100;
+L90:
+	tan__ = w[j] / s[jj];
+/* Computing 2nd power */
+	d__1 = tan__;
+	cos__ = p5 / sqrt(p25 + p25 * (d__1 * d__1));
+	sin__ = cos__ * tan__;
+	tau = sin__;
+L100:
+
+/*        apply the transformation to s and reduce the spike in w. */
+
+	l = jj;
+	i__2 = *m;
+	for (i__ = j; i__ <= i__2; ++i__) {
+	    temp = cos__ * s[l] + sin__ * w[i__];
+	    w[i__] = -sin__ * s[l] + cos__ * w[i__];
+	    s[l] = temp;
+	    ++l;
+/* L110: */
+	}
+
+/*        store the information necessary to recover the */
+/*        givens rotation. */
+
+	w[j] = tau;
+L120:
+
+/*        test for zero diagonal elements in the output s. */
+
+	if (s[jj] == 0.) {
+	    *sing = TRUE_;
+	}
+	jj += *m - j + 1;
+/* L130: */
+    }
+L140:
+
+/*     move w back into the last column of the output s. */
+
+    l = jj;
+    i__1 = *m;
+    for (i__ = *n; i__ <= i__1; ++i__) {
+	s[l] = w[i__];
+	++l;
+/* L150: */
+    }
+    if (s[jj] == 0.) {
+	*sing = TRUE_;
+    }
+    return;
+
+/*     last card of subroutine r1updt. */
+
+} /* r1updt_ */
+

+ 50 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/s_cmp.c

@@ -0,0 +1,50 @@
+#include "f2c.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* compare two strings */
+
+#ifdef KR_headers
+integer s_cmp(a0, b0, la, lb) char *a0, *b0; ftnlen la, lb;
+#else
+integer s_cmp(char *a0, char *b0, ftnlen la, ftnlen lb)
+#endif
+{
+register unsigned char *a, *aend, *b, *bend;
+a = (unsigned char *)a0;
+b = (unsigned char *)b0;
+aend = a + la;
+bend = b + lb;
+
+if(la <= lb)
+	{
+	while(a < aend)
+		if(*a != *b)
+			return( *a - *b );
+		else
+			{ ++a; ++b; }
+
+	while(b < bend)
+		if(*b != ' ')
+			return( ' ' - *b );
+		else	++b;
+	}
+
+else
+	{
+	while(b < bend)
+		if(*a == *b)
+			{ ++a; ++b; }
+		else
+			return( *a - *b );
+	while(a < aend)
+		if(*a != ' ')
+			return(*a - ' ');
+		else	++a;
+	}
+return(0);
+}
+#ifdef __cplusplus
+}
+#endif

+ 57 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/s_copy.c

@@ -0,0 +1,57 @@
+/* Unless compiled with -DNO_OVERWRITE, this variant of s_copy allows the
+ * target of an assignment to appear on its right-hand side (contrary
+ * to the Fortran 77 Standard, but in accordance with Fortran 90),
+ * as in  a(2:5) = a(4:7) .
+ */
+
+#include "f2c.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* assign strings:  a = b */
+
+#ifdef KR_headers
+VOID s_copy(a, b, la, lb) register char *a, *b; ftnlen la, lb;
+#else
+void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb)
+#endif
+{
+	register char *aend, *bend;
+
+	aend = a + la;
+
+	if(la <= lb)
+#ifndef NO_OVERWRITE
+		if (a <= b || a >= b + la)
+#endif
+			while(a < aend)
+				*a++ = *b++;
+#ifndef NO_OVERWRITE
+		else
+			for(b += la; a < aend; )
+				*--aend = *--b;
+#endif
+
+	else {
+		bend = b + lb;
+#ifndef NO_OVERWRITE
+		if (a <= b || a >= bend)
+#endif
+			while(b < bend)
+				*a++ = *b++;
+#ifndef NO_OVERWRITE
+		else {
+			a += lb;
+			while(b < bend)
+				*--a = *--bend;
+			a += lb;
+			}
+#endif
+		while(a < aend)
+			*a++ = ' ';
+		}
+	}
+#ifdef __cplusplus
+}
+#endif

+ 65 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/external_solvers/xerbla.c

@@ -0,0 +1,65 @@
+/* xerbla.f -- translated by f2c (version 20061008).
+   You must link the resulting object file with libf2c:
+  on Microsoft Windows system, link with libf2c.lib;
+  on Linux or Unix systems, link with .../path/to/libf2c.a -lm
+  or, if you install libf2c.a in a standard place, with -lf2c -lm
+  -- in that order, at the end of the command line, as in
+    cc *.o -lf2c -lm
+  Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
+
+    http://www.netlib.org/f2c/libf2c.zip
+*/
+
+#include "f2c.h"
+#include "blaswrap.h"
+#include "stdio.h"
+
+/* Table of constant values */
+
+static integer c__1 = 1;
+
+/* Subroutine */ int xerbla_(char *srname, integer *info)
+{
+
+
+/*  -- LAPACK auxiliary routine (version 3.2) -- */
+/*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
+/*     November 2006 */
+
+/*     .. Scalar Arguments .. */
+/*     .. */
+
+/*  Purpose */
+/*  ======= */
+
+/*  XERBLA  is an error handler for the LAPACK routines. */
+/*  It is called by an LAPACK routine if an input parameter has an */
+/*  invalid value.  A message is printed and execution stops. */
+
+/*  Installers may consider modifying the STOP statement in order to */
+/*  call system-specific exception-handling facilities. */
+
+/*  Arguments */
+/*  ========= */
+
+/*  SRNAME  (input) CHARACTER*(*) */
+/*          The name of the routine which called XERBLA. */
+
+/*  INFO    (input) INTEGER */
+/*          The position of the invalid parameter in the parameter list */
+/*          of the calling routine. */
+
+/* ===================================================================== */
+
+/*     .. Intrinsic Functions .. */
+/*     .. */
+/*     .. Executable Statements .. */
+
+    printf("** On entry to %6s, parameter number %2i had an illegal value\n",
+    srname, (int) *info);
+
+
+/*     End of XERBLA */
+
+    return 0;
+} /* xerbla_ */

+ 292 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi1/fmiModelFunctions.h

@@ -0,0 +1,292 @@
+#ifndef fmiModelFunctions_h
+#define fmiModelFunctions_h
+
+/* This header file must be utilized when compiling a model.
+   It defines all functions of the Model Execution Interface.
+   In order to have unique function names even if several models
+   are compiled together (e.g. for embedded systems), every "real" function name
+   is constructed by prepending the function name by
+   "MODEL_IDENTIFIER" + "_" where "MODEL_IDENTIFIER" is the short name
+   of the model used as the name of the zip-file where the model is stored.
+   Therefore, the typical usage is:
+
+      #define MODEL_IDENTIFIER MyModel
+      #include "fmiModelFunctions.h"
+
+   As a result, a function that is defined as "fmiGetDerivatives" in this header file,
+   is actually getting the name "MyModel_fmiGetDerivatives".
+
+   Revisions:
+   - Jan. 20, 2010: stateValueReferencesChanged added to struct fmiEventInfo (ticket #27)
+                    (by M. Otter, DLR)
+                    Added WIN32 pragma to define the struct layout (ticket #34)
+                    (by J. Mauss, QTronic)
+   - Jan.  4, 2010: Removed argument intermediateResults from fmiInitialize
+                    Renamed macro fmiGetModelFunctionsVersion to fmiGetVersion
+                    Renamed macro fmiModelFunctionsVersion to fmiVersion
+                    Replaced fmiModel by fmiComponent in decl of fmiInstantiateModel
+                    (by J. Mauss, QTronic)
+   - Dec. 17, 2009: Changed extension "me" to "fmi" (by Martin Otter, DLR).
+   - Dez. 14, 2009: Added eventInfo to meInitialize and added
+                    meGetNominalContinuousStates (by Martin Otter, DLR)
+   - Sept. 9, 2009: Added DllExport (according to Peter Nilsson's suggestion)
+                    (by A. Junghanns, QTronic)
+   - Sept. 9, 2009: Changes according to FMI-meeting on July 21:
+                    meInquireModelTypesVersion     -> meGetModelTypesPlatform
+                    meInquireModelFunctionsVersion -> meGetModelFunctionsVersion
+                    meSetStates                    -> meSetContinuousStates
+                    meGetStates                    -> meGetContinuousStates
+                    removal of meInitializeModelClass
+                    removal of meGetTime
+                    change of arguments of meInstantiateModel
+                    change of arguments of meCompletedIntegratorStep
+                    (by Martin Otter, DLR):
+   - July 19, 2009: Added "me" as prefix to file names (by Martin Otter, DLR).
+   - March 2, 2009: Changed function definitions according to the last design
+                    meeting with additional improvements (by Martin Otter, DLR).
+   - Dec. 3 , 2008: First version by Martin Otter (DLR) and Hans Olsson (Dynasim).
+
+
+   Copyright (C) 2008-2009, MODELISAR consortium. All rights reserved.
+   This file is licensed by the copyright holders under the BSD License
+   (http://www.opensource.org/licenses/bsd-license.html):
+
+   ----------------------------------------------------------------------------
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+
+   - Redistributions of source code must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   - Redistributions in binary form must reproduce the above copyright notice,
+     this list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+   - Neither the name of the copyright holders nor the names of its
+     contributors may be used to endorse or promote products derived
+     from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+   ----------------------------------------------------------------------------
+
+   with the extension:
+
+   You may distribute or publicly perform any modification only under the
+   terms of this license.
+*/
+
+#include "fmiModelTypes.h"
+#include <stdlib.h>
+
+/* Export fmi functions on Windows */
+#if defined(_MSC_VER) || defined(__MINGW32__)
+#define DllExport __declspec( dllexport )
+#else
+#define DllExport
+#endif
+
+/* Macros to construct the real function name
+   (prepend function name by MODEL_IDENTIFIER + "_") */
+
+#define fmiPaste(a,b)     a ## b
+#define fmiPasteB(a,b)    fmiPaste(a,b)
+#define fmiFullName(name) fmiPasteB(MODEL_IDENTIFIER, name)
+
+#define fmiGetModelTypesPlatform      fmiFullName(_fmiGetModelTypesPlatform)
+#define fmiGetTypesPlatform           fmiFullName(_fmiGetTypesPlatform)
+#define fmiGetVersion                 fmiFullName(_fmiGetVersion)
+#define fmiInstantiateModel           fmiFullName(_fmiInstantiateModel)
+#define fmiFreeModelInstance          fmiFullName(_fmiFreeModelInstance)
+#define fmiSetDebugLogging            fmiFullName(_fmiSetDebugLogging)
+#define fmiSetTime                    fmiFullName(_fmiSetTime)
+#define fmiSetContinuousStates        fmiFullName(_fmiSetContinuousStates)
+#define fmiCompletedIntegratorStep    fmiFullName(_fmiCompletedIntegratorStep)
+#define fmiSetReal                    fmiFullName(_fmiSetReal)
+#define fmiSetInteger                 fmiFullName(_fmiSetInteger)
+#define fmiSetBoolean                 fmiFullName(_fmiSetBoolean)
+#define fmiSetString                  fmiFullName(_fmiSetString)
+#define fmiInitialize                 fmiFullName(_fmiInitialize)
+#define fmiGetDerivatives             fmiFullName(_fmiGetDerivatives)
+#define fmiGetEventIndicators         fmiFullName(_fmiGetEventIndicators)
+#define fmiGetReal                    fmiFullName(_fmiGetReal)
+#define fmiGetInteger                 fmiFullName(_fmiGetInteger)
+#define fmiGetBoolean                 fmiFullName(_fmiGetBoolean)
+#define fmiGetString                  fmiFullName(_fmiGetString)
+#define fmiEventUpdate                fmiFullName(_fmiEventUpdate)
+#define fmiGetContinuousStates        fmiFullName(_fmiGetContinuousStates)
+#define fmiGetNominalContinuousStates fmiFullName(_fmiGetNominalContinuousStates)
+#define fmiGetStateValueReferences    fmiFullName(_fmiGetStateValueReferences)
+#define fmiTerminate                  fmiFullName(_fmiTerminate)
+#define fmiSetExternalFunction        fmiFullName(_fmiSetExternalFunction)
+
+/***************************************************
+Functions for FMI for Co-Simulation
+****************************************************/
+#define fmiInstantiateSlave         fmiFullName(_fmiInstantiateSlave)
+#define fmiInitializeSlave          fmiFullName(_fmiInitializeSlave)
+#define fmiTerminateSlave           fmiFullName(_fmiTerminateSlave)
+#define fmiResetSlave               fmiFullName(_fmiResetSlave)
+#define fmiFreeSlaveInstance        fmiFullName(_fmiFreeSlaveInstance)
+#define fmiSetRealInputDerivatives  fmiFullName(_fmiSetRealInputDerivatives)
+#define fmiGetRealOutputDerivatives fmiFullName(_fmiGetRealOutputDerivatives)
+#define fmiDoStep                   fmiFullName(_fmiDoStep)
+#define fmiCancelStep               fmiFullName(_fmiCancelStep)
+#define fmiGetStatus                fmiFullName(_fmiGetStatus)
+#define fmiGetRealStatus            fmiFullName(_fmiGetRealStatus)
+#define fmiGetIntegerStatus         fmiFullName(_fmiGetIntegerStatus)
+#define fmiGetBooleanStatus         fmiFullName(_fmiGetBooleanStatus)
+#define fmiGetStringStatus          fmiFullName(_fmiGetStringStatus)
+
+/* Version number */
+#define fmiVersion "1.0"
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* Inquire version numbers of header files */
+   DllExport const char* fmiGetModelTypesPlatform();
+   DllExport const char* fmiGetTypesPlatform();
+   DllExport const char* fmiGetVersion();
+
+/* make sure all compiler use the same alignment policies for structures */
+#ifdef WIN32
+#pragma pack(push,8)
+#endif
+
+/* Type definitions */
+   typedef enum  {fmiOK,
+                  fmiWarning,
+                  fmiDiscard,
+                  fmiError,
+                  fmiFatal,
+                  fmiPending} fmiStatus;
+
+   typedef void  (*fmiCallbackLogger)        (fmiComponent c, fmiString instanceName, fmiStatus status,
+                                              fmiString category, fmiString message, ...);
+   typedef void* (*fmiCallbackAllocateMemory)(size_t nobj, size_t size);
+   typedef void  (*fmiCallbackFreeMemory)    (void* obj);
+   typedef void  (*fmiStepFinished)          (fmiComponent c, fmiStatus status);
+
+   typedef struct {
+     fmiCallbackLogger         logger;
+     fmiCallbackAllocateMemory allocateMemory;
+     fmiCallbackFreeMemory     freeMemory;
+     fmiStepFinished           stepFinished;
+   } fmiCallbackFunctions;
+
+   typedef struct {
+      fmiBoolean iterationConverged;
+      fmiBoolean stateValueReferencesChanged;
+      fmiBoolean stateValuesChanged;
+      fmiBoolean terminateSimulation;
+      fmiBoolean upcomingTimeEvent;
+      fmiReal    nextEventTime;
+   } fmiEventInfo;
+
+/* reset alignment policy to the one set before reading this file */
+#ifdef WIN32
+#pragma pack(pop)
+#endif
+
+/* Creation and destruction of model instances and setting debug status */
+   DllExport fmiComponent fmiInstantiateModel (fmiString            instanceName,
+                                               fmiString            GUID,
+                                               fmiCallbackFunctions functions,
+                                               fmiBoolean           loggingOn);
+   DllExport void      fmiFreeModelInstance(fmiComponent c);
+   DllExport fmiStatus fmiSetDebugLogging  (fmiComponent c, fmiBoolean loggingOn);
+
+
+/* Providing independent variables and re-initialization of caching */
+   DllExport fmiStatus fmiSetTime                (fmiComponent c, fmiReal t);
+   DllExport fmiStatus fmiSetContinuousStates    (fmiComponent c, const fmiReal x[], size_t nx);
+   DllExport fmiStatus fmiCompletedIntegratorStep(fmiComponent c, fmiBoolean* callEventUpdate);
+   DllExport fmiStatus fmiSetReal                (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal    value[]);
+   DllExport fmiStatus fmiSetInteger             (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[]);
+   DllExport fmiStatus fmiSetBoolean             (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[]);
+   DllExport fmiStatus fmiSetString              (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString  value[]);
+
+
+/* Evaluation of the model equations */
+   DllExport fmiStatus fmiInitialize(fmiComponent c, fmiBoolean toleranceControlled,
+                                     fmiReal relativeTolerance, fmiEventInfo* eventInfo);
+
+   DllExport fmiStatus fmiGetDerivatives    (fmiComponent c, fmiReal derivatives[]    , size_t nx);
+   DllExport fmiStatus fmiGetEventIndicators(fmiComponent c, fmiReal eventIndicators[], size_t ni);
+
+   DllExport fmiStatus fmiGetReal   (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal    value[]);
+   DllExport fmiStatus fmiGetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[]);
+   DllExport fmiStatus fmiGetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[]);
+   DllExport fmiStatus fmiGetString (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString  value[]);
+
+   DllExport fmiStatus fmiEventUpdate               (fmiComponent c, fmiBoolean intermediateResults, fmiEventInfo* eventInfo);
+   DllExport fmiStatus fmiGetContinuousStates       (fmiComponent c, fmiReal states[], size_t nx);
+   DllExport fmiStatus fmiGetNominalContinuousStates(fmiComponent c, fmiReal x_nominal[], size_t nx);
+   DllExport fmiStatus fmiGetStateValueReferences   (fmiComponent c, fmiValueReference vrx[], size_t nx);
+   DllExport fmiStatus fmiTerminate                 (fmiComponent c);
+   DllExport fmiStatus fmiSetExternalFunction       (fmiComponent c, fmiValueReference vr[], size_t nvr, const void* value[]);
+
+/***************************************************
+Functions for FMI for Co-Simulation
+****************************************************/
+
+/* Creation and destruction of slave instances and setting debug status */
+   DllExport fmiComponent fmiInstantiateSlave(fmiString  instanceName,
+                                              fmiString  fmuGUID,
+                                              fmiString  fmuLocation,
+                                              fmiString  mimeType,
+                                              fmiReal    timeout,
+                                              fmiBoolean visible,
+                                              fmiBoolean interactive,
+                                              fmiCallbackFunctions functions,
+                                              fmiBoolean loggingOn);
+
+   DllExport fmiStatus fmiInitializeSlave(fmiComponent c,
+                                          fmiReal      tStart,
+                                          fmiBoolean   StopTimeDefined,
+                                          fmiReal      tStop);
+
+   DllExport fmiStatus fmiTerminateSlave   (fmiComponent c);
+   DllExport fmiStatus fmiResetSlave       (fmiComponent c);
+   DllExport void      fmiFreeSlaveInstance(fmiComponent c);
+
+   DllExport fmiStatus fmiSetRealInputDerivatives(fmiComponent c,
+                                                  const  fmiValueReference vr[],
+                                                  size_t nvr,
+                                                  const  fmiInteger order[],
+                                                  const  fmiReal value[]);
+
+   DllExport fmiStatus fmiGetRealOutputDerivatives(fmiComponent c,
+                                                   const   fmiValueReference vr[],
+                                                   size_t  nvr,
+                                                   const   fmiInteger order[],
+                                                   fmiReal value[]);
+
+   DllExport fmiStatus fmiCancelStep(fmiComponent c);
+   DllExport fmiStatus fmiDoStep    (fmiComponent c,
+                                     fmiReal      currentCommunicationPoint,
+                                     fmiReal      communicationStepSize,
+                                     fmiBoolean   newStep);
+
+
+   typedef enum {fmiDoStepStatus,
+                 fmiPendingStatus,
+                 fmiLastSuccessfulTime} fmiStatusKind;
+
+   DllExport fmiStatus fmiGetStatus       (fmiComponent c, const fmiStatusKind s, fmiStatus*  value);
+   DllExport fmiStatus fmiGetRealStatus   (fmiComponent c, const fmiStatusKind s, fmiReal*    value);
+   DllExport fmiStatus fmiGetIntegerStatus(fmiComponent c, const fmiStatusKind s, fmiInteger* value);
+   DllExport fmiStatus fmiGetBooleanStatus(fmiComponent c, const fmiStatusKind s, fmiBoolean* value);
+   DllExport fmiStatus fmiGetStringStatus (fmiComponent c, const fmiStatusKind s, fmiString*  value);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* fmiModelFunctions_h */

+ 92 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi1/fmiModelTypes.h

@@ -0,0 +1,92 @@
+#ifndef fmiModelTypes_h
+#define fmiModelTypes_h
+
+/* Standard header file to define the argument types of the
+   functions of the Model Execution Interface.
+   This header file must be utilized both by the model and
+   by the simulation engine.
+
+   Revisions:
+   - Jan.  4, 2010: Renamed meModelTypes_h to fmiModelTypes_h (by Mauss, QTronic)
+   - Dec. 21, 2009: Changed "me" to "fmi" and "meModel" to "fmiComponent"
+                    according to meeting on Dec. 18 (by Martin Otter, DLR)
+   - Dec.  6, 2009: Added meUndefinedValueReference (by Martin Otter, DLR)
+   - Sept. 9, 2009: Changes according to FMI-meeting on July 21:
+                    Changed "version" to "platform", "standard" to "standard32",
+                    Added a precise definition of "standard32" as comment
+                    (by Martin Otter, DLR)
+   - July 19, 2009: Added "me" as prefix to file names, added meTrue/meFalse,
+                    and changed meValueReferenced from int to unsigned int
+                    (by Martin Otter, DLR).
+   - March 2, 2009: Moved enums and function pointer definitions to
+                    ModelFunctions.h (by Martin Otter, DLR).
+   - Dec. 3, 2008 : First version by Martin Otter (DLR) and
+                    Hans Olsson (Dynasim).
+
+
+   Copyright (C) 2008-2010, MODELISAR consortium. All rights reserved.
+   This file is licensed by the copyright holders under the BSD License
+   (http://www.opensource.org/licenses/bsd-license.html)
+
+   ----------------------------------------------------------------------------
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+
+   - Redistributions of source code must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   - Redistributions in binary form must reproduce the above copyright notice,
+     this list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+   - Neither the name of the copyright holders nor the names of its
+     contributors may be used to endorse or promote products derived
+     from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+   ----------------------------------------------------------------------------
+
+   with the extension:
+
+   You may distribute or publicly perform any modification only under the
+   terms of this license.
+*/
+
+/* Platform (combination of machine, compiler, operating system) */
+#define fmiModelTypesPlatform "standard32"
+#define fmiPlatform "standard32"
+
+/* Type definitions of variables passed as arguments
+   Version "standard32" means:
+
+   fmiComponent     : 32 bit pointer
+   fmiValueReference: 32 bit
+   fmiReal          : 64 bit
+   fmiInteger       : 32 bit
+   fmiBoolean       :  8 bit
+   fmiString        : 32 bit pointer
+
+*/
+   typedef void*        fmiComponent;
+   typedef unsigned int fmiValueReference;
+   typedef double       fmiReal   ;
+   typedef int          fmiInteger;
+   typedef char         fmiBoolean;
+   typedef const char*  fmiString ;
+
+/* Values for fmiBoolean  */
+#define fmiTrue  1
+#define fmiFalse 0
+
+/* Undefined value for fmiValueReference (largest unsigned int value) */
+#define fmiUndefinedValueReference (fmiValueReference)(-1)
+
+#endif

+ 968 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi1/fmu1_model_interface.c

@@ -0,0 +1,968 @@
+/*
+ * This file is part of OpenModelica.
+ *
+ * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
+ * c/o Linköpings universitet, Department of Computer and Information Science,
+ * SE-58183 Linköping, Sweden.
+ *
+ * All rights reserved.
+ *
+ * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
+ * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
+ * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
+ * OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
+ *
+ * The OpenModelica software and the Open Source Modelica
+ * Consortium (OSMC) Public License (OSMC-PL) are obtained
+ * from OSMC, either from the above address,
+ * from the URLs: http://www.ida.liu.se/projects/OpenModelica or
+ * http://www.openmodelica.org, and in the OpenModelica distribution.
+ * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without
+ * even the implied warranty of  MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
+ * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
+ *
+ * See the full OSMC Public License conditions for more details.
+ *
+ */
+
+#include "simulation_data.h"
+#include "simulation/solver/stateset.h"
+#include "simulation/solver/model_help.h"
+#include "simulation/solver/nonlinearSystem.h"
+#include "simulation/solver/linearSystem.h"
+#include "simulation/solver/mixedSystem.h"
+#include "simulation/solver/delay.h"
+#include "simulation/simulation_info_json.h"
+#include "simulation/simulation_input_xml.h"
+
+/*
+DLLExport pthread_key_t fmu1_thread_data_key;
+*/
+
+// array of value references of states
+#if NUMBER_OF_STATES>0
+fmiValueReference vrStates[NUMBER_OF_STATES] = STATES;
+fmiValueReference vrStatesDerivatives[NUMBER_OF_STATES] = STATESDERIVATIVES;
+#endif
+
+static fmiBoolean invalidNumber(ModelInstance* comp, const char* f, const char* arg, int n, int nExpected)
+{
+  if (n != nExpected)
+  {
+    comp->state = modelError;
+    comp->functions.logger(comp, comp->instanceName, fmiError, "error",
+        "%s: Invalid argument %s = %d. Expected %d.", f, arg, n, nExpected);
+    return fmiTrue;
+  }
+  return fmiFalse;
+}
+
+static fmiBoolean invalidState(ModelInstance* comp, const char* f, int statesExpected)
+{
+  if (!comp)
+    return fmiTrue;
+  if (!(comp->state & statesExpected))
+  {
+    comp->state = modelError;
+    comp->functions.logger(comp, comp->instanceName, fmiError, "error",
+        "%s: Illegal call sequence. Expected State: %d.", f, statesExpected);
+    return fmiTrue;
+  }
+  return fmiFalse;
+}
+
+static fmiBoolean nullPointer(ModelInstance* comp, const char* f, const char* arg, const void* p)
+{
+  if (!p)
+  {
+    comp->state = modelError;
+    comp->functions.logger(comp, comp->instanceName, fmiError, "error",
+        "%s: Invalid argument %s = NULL.", f, arg);
+    return fmiTrue;
+  }
+  return fmiFalse;
+}
+
+static fmiBoolean vrOutOfRange(ModelInstance* comp, const char* f, fmiValueReference vr, unsigned int end)
+{
+  if (vr >= end)
+  {
+    comp->functions.logger(comp, comp->instanceName, fmiError, "error",
+        "%s: Illegal value reference %u.", f, vr);
+    comp->state = modelError;
+    return fmiTrue;
+  }
+  return fmiFalse;
+}
+
+// ---------------------------------------------------------------------------
+// FMI functions: class methods not depending of a specific model instance
+// ---------------------------------------------------------------------------
+/***************************************************
+Common Functions
+****************************************************/
+const char* fmiGetModelTypesPlatform()
+{
+  return fmiModelTypesPlatform;
+}
+
+const char* fmiGetTypesPlatform()
+{
+  return fmiPlatform;
+}
+
+const char* fmiGetVersion()
+{
+  return fmiVersion;
+}
+
+/***************************************************
+Functions for FMI for Model Exchange
+****************************************************/
+fmiComponent fmiInstantiateModel(fmiString instanceName, fmiString GUID, fmiCallbackFunctions functions, fmiBoolean loggingOn)
+{
+  ModelInstance* comp;
+  if (!functions.logger)
+    return NULL;
+  if (!functions.allocateMemory || !functions.freeMemory){
+    functions.logger(NULL, instanceName, fmiError, "error",
+        "fmiInstantiateModel: Missing callback function.");
+    return NULL;
+  }
+  if (!instanceName || strlen(instanceName)==0) {
+    functions.logger(NULL, instanceName, fmiWarning, "Warning",
+        "fmiInstantiateModel: Missing instance name.");
+  }
+  if (strcmp(GUID, MODEL_GUID) != 0) {
+    functions.logger(NULL, instanceName, fmiError, "error",
+        "fmiInstantiateModel: Wrong GUID %s. Expected %s.", GUID, MODEL_GUID);
+    return NULL;
+  }
+  comp = (ModelInstance *)functions.allocateMemory(1, sizeof(ModelInstance));
+  if (comp) {
+    DATA* fmudata = NULL;
+	MODEL_DATA* modelData = NULL;
+	SIMULATION_INFO* simInfo = NULL;
+	threadData_t *threadData = NULL;
+
+    comp->functions = functions;
+    comp->loggingOn = loggingOn;
+    comp->state = modelInstantiated;
+    comp->instanceName = functions.allocateMemory(1 + strlen(instanceName), sizeof(char));
+    comp->GUID = functions.allocateMemory(1 + strlen(GUID), sizeof(char));
+    /* Cannot use functions.allocateMemory since the pointer might not be stored on the stack of the parent */
+    fmudata = (DATA *)functions.allocateMemory(1, sizeof(DATA));
+    modelData = (MODEL_DATA *)functions.allocateMemory(1, sizeof(MODEL_DATA));
+    simInfo = (SIMULATION_INFO *)functions.allocateMemory(1, sizeof(SIMULATION_INFO));
+    fmudata->modelData = modelData;
+    fmudata->simulationInfo = simInfo;
+
+
+    threadData = (threadData_t *)functions.allocateMemory(1, sizeof(threadData_t));
+    memset(threadData, 0, sizeof(threadData_t));
+    /*
+    pthread_key_create(&fmu1_thread_data_key,NULL);
+    pthread_setspecific(fmu1_thread_data_key, threadData);
+    */
+
+    comp->threadData = threadData;
+    comp->fmuData = fmudata;
+
+    if (!comp->fmuData) {
+      functions.logger(NULL, instanceName, fmiError, "error",
+          "fmiInstantiateModel: Error: Could not initialize the global data structure file.");
+      return NULL;
+    }
+  }
+  if (!comp || !comp->instanceName || !comp->GUID) {
+    functions.logger(NULL, instanceName, fmiError, "error", "fmiInstantiateModel: Out of memory.");
+    return NULL;
+  }
+  /* intialize modelData */
+  fmu1_model_interface_setupDataStruc(comp->fmuData);
+  useStream[LOG_STDOUT] = 1;
+  useStream[LOG_ASSERT] = 1;
+  initializeDataStruc(comp->fmuData, comp->threadData);
+  /* setup model data with default start data */
+  setDefaultStartValues(comp);
+  setAllVarsToStart(comp->fmuData);
+  setAllParamsToStart(comp->fmuData);
+  comp->fmuData->callback->read_input_fmu(comp->fmuData->modelData, comp->fmuData->simulationInfo);
+  modelInfoInit(&(comp->fmuData->modelData->modelDataXml));
+
+  strcpy((char*)comp->instanceName, (const char*)instanceName);
+  strcpy((char*)comp->GUID, (const char*)GUID);
+
+  /* read input vars */
+  //input_function(comp->fmuData);
+  /* initial sample and delay before initial the system */
+  comp->fmuData->callback->callExternalObjectConstructors(comp->fmuData, comp->threadData);
+  /* allocate memory for non-linear system solvers */
+  initializeNonlinearSystems(comp->fmuData, comp->threadData);
+  /* allocate memory for non-linear system solvers */
+  initializeLinearSystems(comp->fmuData, comp->threadData);
+  /* allocate memory for mixed system solvers */
+  initializeMixedSystems(comp->fmuData, comp->threadData);
+  /* allocate memory for state selection */
+  initializeStateSetJacobians(comp->fmuData, comp->threadData);
+
+  return comp;
+}
+
+fmiStatus fmiSetDebugLogging(fmiComponent c, fmiBoolean loggingOn)
+{
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiSetDebugLogging", not_modelError))
+    return fmiError;
+  comp->loggingOn = loggingOn;
+  if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+      "fmiSetDebugLogging: loggingOn=%d", loggingOn);
+  return fmiOK;
+}
+
+void fmiFreeModelInstance(fmiComponent c)
+{
+  ModelInstance* comp = (ModelInstance *)c;
+  if (!comp) return;
+  if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+      "fmiFreeModelInstance");
+
+  /* free instanceName & GUID */
+  if (comp->instanceName) comp->functions.freeMemory((void*)comp->instanceName);
+  if (comp->GUID) comp->functions.freeMemory((void*)comp->GUID);
+
+  /* free comp */
+  comp->functions.freeMemory(comp);
+}
+
+// ---------------------------------------------------------------------------
+// FMI functions: set variable values in the FMU
+// ---------------------------------------------------------------------------
+
+fmiStatus fmiSetReal(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal value[])
+{
+  unsigned int i=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiSetReal", modelInstantiated|modelInitialized))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiSetReal", "vr[]", vr))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiSetReal", "value[]", value))
+    return fmiError;
+  if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+      "fmiSetReal: nvr = %d", nvr);
+  // no check wether setting the value is allowed in the current state
+  for (i=0; i<nvr; i++) {
+    if (vrOutOfRange(comp, "fmiSetReal", vr[i], NUMBER_OF_REALS+NUMBER_OF_STATES))
+      return fmiError;
+    if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+        "fmiSetReal: #r%d# = %.16g", vr[i], value[i]);
+    if (setReal(comp, vr[i],value[i]) != fmiOK) // to be implemented by the includer of this file
+      return fmiError;
+  }
+
+  return fmiOK;
+}
+
+fmiStatus fmiSetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[])
+{
+  unsigned int i=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiSetInteger", modelInstantiated|modelInitialized))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiSetInteger", "vr[]", vr))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiSetInteger", "value[]", value))
+    return fmiError;
+  if (comp->loggingOn)
+    comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiSetInteger: nvr = %d",  nvr);
+  for (i=0; i<nvr; i++) {
+    if (vrOutOfRange(comp, "fmiSetInteger", vr[i], NUMBER_OF_INTEGERS))
+      return fmiError;
+    if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+        "fmiSetInteger: #i%d# = %d", vr[i], value[i]);
+    if (setInteger(comp, vr[i],value[i]) != fmiOK) // to be implemented by the includer of this file
+      return fmiError;
+  }
+
+  return fmiOK;
+}
+
+fmiStatus fmiSetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[])
+{
+  unsigned int i=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiSetBoolean", modelInstantiated|modelInitialized))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiSetBoolean", "vr[]", vr))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiSetBoolean", "value[]", value))
+    return fmiError;
+  if (comp->loggingOn)
+    comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiSetBoolean: nvr = %d",  nvr);
+  for (i=0; i<nvr; i++) {
+    if (vrOutOfRange(comp, "fmiSetBoolean", vr[i], NUMBER_OF_BOOLEANS))
+      return fmiError;
+    if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+        "fmiSetBoolean: #b%d# = %s", vr[i], value[i] ? "true" : "false");
+    if (setBoolean(comp, vr[i],value[i]) != fmiOK) // to be implemented by the includer of this file
+      return fmiError;
+  }
+
+  return fmiOK;
+}
+
+fmiStatus fmiSetString(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString value[])
+{
+  unsigned int i=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiSetString", modelInstantiated|modelInitialized))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiSetString", "vr[]", vr))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiSetString", "value[]", value))
+    return fmiError;
+  if (comp->loggingOn)
+    comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiSetString: nvr = %d",  nvr);
+  for (i=0; i<nvr; i++) {
+    if (vrOutOfRange(comp, "fmiSetString", vr[i], NUMBER_OF_STRINGS))
+      return fmiError;
+    if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+        "fmiSetString: #s%d# = '%s'", vr[i], value[i]);
+    if (setString(comp, vr[i],value[i]) != fmiOK) // to be implemented by the includer of this file
+      return fmiError;
+  }
+  return fmiOK;
+}
+
+fmiStatus fmiSetTime(fmiComponent c, fmiReal t)
+{
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiSetTime", modelInstantiated|modelInitialized))
+    return fmiError;
+  if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+      "fmiSetTime: time=%.16g", t);
+  comp->fmuData->localData[0]->timeValue = t;
+  return fmiOK;
+}
+
+fmiStatus fmiSetContinuousStates(fmiComponent c, const fmiReal x[], size_t nx)
+{
+  ModelInstance* comp = (ModelInstance *)c;
+  unsigned int i=0;
+  if (invalidState(comp, "fmiSetContinuousStates", modelInitialized))
+    return fmiError;
+  if (invalidNumber(comp, "fmiSetContinuousStates", "nx", nx, NUMBER_OF_STATES))
+    return fmiError;
+#if NUMBER_OF_STATES>0
+  if (nullPointer(comp, "fmiSetContinuousStates", "x[]", x))
+    return fmiError;
+  for (i=0; i<nx; i++) {
+    fmiValueReference vr = vrStates[i];
+    if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+        "fmiSetContinuousStates: #r%d#=%.16g", vr, x[i]);
+    if (vr<0 || vr>=NUMBER_OF_REALS || setReal(comp, vr, x[i]) != fmiOK) { // to be implemented by the includer of this file
+      return fmiError;
+    }
+  }
+#endif
+  return fmiOK;
+}
+
+// ---------------------------------------------------------------------------
+// FMI functions: get variable values from the FMU
+// ---------------------------------------------------------------------------
+
+fmiStatus fmiGetReal(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal value[])
+{
+  unsigned int i=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiGetReal", not_modelError))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiGetReal", "vr[]", vr))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiGetReal", "value[]", value))
+    return fmiError;
+#if NUMBER_OF_REALS>0
+  for (i=0; i<nvr; i++) {
+    if (vrOutOfRange(comp, "fmiGetReal", vr[i], NUMBER_OF_REALS+NUMBER_OF_STATES))
+      return fmiError;
+    value[i] = getReal(comp, vr[i]);
+    if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+        "fmiGetReal: #r%u# = %.16g", vr[i], value[i]);
+  }
+  return fmiOK;
+#else
+  return fmiOK;
+#endif
+}
+
+fmiStatus fmiGetInteger(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[])
+{
+  unsigned int i=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiGetInteger", not_modelError))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiGetInteger", "vr[]", vr))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiGetInteger", "value[]", value))
+    return fmiError;
+#if NUMBER_OF_INTEGERS>0
+  for (i=0; i<nvr; i++) {
+    if (vrOutOfRange(comp, "fmiGetInteger", vr[i], NUMBER_OF_INTEGERS))
+      return fmiError;
+    value[i] = getInteger(comp, vr[i]); // to be implemented by the includer of this file
+    if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+        "fmiGetInteger: #i%u# = %d", vr[i], value[i]);
+  }
+  return fmiOK;
+#else
+  return fmiOK;
+#endif
+}
+
+fmiStatus fmiGetBoolean(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[])
+{
+  unsigned int i=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiGetBoolean", not_modelError))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiGetBoolean", "vr[]", vr))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiGetBoolean", "value[]", value))
+    return fmiError;
+#if NUMBER_OF_BOOLEANS>0
+  for (i=0; i<nvr; i++) {
+    if (vrOutOfRange(comp, "fmiGetBoolean", vr[i], NUMBER_OF_BOOLEANS))
+      return fmiError;
+    value[i] = getBoolean(comp, vr[i]); // to be implemented by the includer of this file
+    if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+        "fmiGetBoolean: #b%u# = %s", vr[i], value[i]? "true" : "false");
+  }
+  return fmiOK;
+#else
+  return fmiOK;
+#endif
+}
+
+fmiStatus fmiGetString(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString  value[])
+{
+  unsigned int i=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiGetString", not_modelError))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiGetString", "vr[]", vr))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiGetString", "value[]", value))
+    return fmiError;
+#if NUMBER_OF_STRINGS>0
+  for (i=0; i<nvr; i++) {
+    if (vrOutOfRange(comp, "fmiGetString", vr[i], NUMBER_OF_STRINGS))
+      return fmiError;
+    value[i] = getString(comp, vr[i]); // to be implemented by the includer of this file
+    if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+        "fmiGetString: #s%u# = '%s'", vr[i], value[i]);
+  }
+  return fmiOK;
+#else
+  return fmiOK;
+#endif
+}
+
+fmiStatus fmiGetStateValueReferences(fmiComponent c, fmiValueReference vrx[], size_t nx)
+{
+  unsigned int i=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiGetStateValueReferences", not_modelError))
+    return fmiError;
+  if (invalidNumber(comp, "fmiGetStateValueReferences", "nx", nx, NUMBER_OF_STATES))
+    return fmiError;
+  if (nullPointer(comp, "fmiGetStateValueReferences", "vrx[]", vrx))
+    return fmiError;
+#if NUMBER_OF_STATES>0
+  for (i=0; i<nx; i++) {
+    vrx[i] = vrStates[i];
+    if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+        "fmiGetStateValueReferences: vrx[%d] = %d", i, vrx[i]);
+  }
+#endif
+  return fmiOK;
+}
+
+fmiStatus fmiGetContinuousStates(fmiComponent c, fmiReal states[], size_t nx)
+{
+  unsigned int i=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiGetContinuousStates", not_modelError))
+    return fmiError;
+#if NUMBER_OF_STATES>0
+  if (invalidNumber(comp, "fmiGetContinuousStates", "nx", nx, NUMBER_OF_STATES))
+    return fmiError;
+  if (nullPointer(comp, "fmiGetContinuousStates", "states[]", states))
+    return fmiError;
+  for (i=0; i<nx; i++) {
+    fmiValueReference vr = vrStates[i];
+    states[i] = getReal(comp, vr); // to be implemented by the includer of this file
+    if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+        "fmiGetContinuousStates: #r%u# = %.16g", vr, states[i]);
+  }
+#endif
+  return fmiOK;
+}
+
+fmiStatus fmiGetNominalContinuousStates(fmiComponent c, fmiReal x_nominal[], size_t nx)
+{
+  unsigned int i=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiGetNominalContinuousStates", not_modelError))
+    return fmiError;
+  if (invalidNumber(comp, "fmiGetNominalContinuousStates", "nx", nx, NUMBER_OF_STATES))
+    return fmiError;
+  if (nullPointer(comp, "fmiGetNominalContinuousStates", "x_nominal[]", x_nominal))
+    return fmiError;
+  x_nominal[0] = 1;
+  if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+      "fmiGetNominalContinuousStates: x_nominal[0..%d] = 1.0", nx-1);
+  for (i=0; i<nx; i++)
+    x_nominal[i] = 1;
+  return fmiOK;
+}
+
+fmiStatus fmiGetDerivatives(fmiComponent c, fmiReal derivatives[], size_t nx)
+{
+  unsigned int i=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  threadData_t *threadData = comp->threadData;
+  if (invalidState(comp, "fmiGetDerivatives", not_modelError))
+    return fmiError;
+  if (invalidNumber(comp, "fmiGetDerivatives", "nx", nx, NUMBER_OF_STATES))
+    return fmiError;
+  if (nullPointer(comp, "fmiGetDerivatives", "derivatives[]", derivatives))
+    return fmiError;
+
+  /* try */
+  MMC_TRY_INTERNAL(simulationJumpBuffer)
+
+    comp->fmuData->callback->functionODE(comp->fmuData, comp->threadData);
+  #if (NUMBER_OF_STATES>0)
+    for (i=0; i<nx; i++) {
+      fmiValueReference vr = vrStatesDerivatives[i];
+      derivatives[i] = getReal(comp, vr); // to be implemented by the includer of this file
+      if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+          "fmiGetDerivatives: #r%d# = %.16g", vr, derivatives[i]);
+    }
+  #endif
+    return fmiOK;
+
+  /* catch */
+  MMC_CATCH_INTERNAL(simulationJumpBuffer)
+
+    comp->functions.logger(c, comp->instanceName, fmiError, "error", "fmiGetDerivatives: terminated by an assertion.");
+    return fmiError;
+}
+
+fmiStatus fmiGetEventIndicators(fmiComponent c, fmiReal eventIndicators[], size_t ni)
+{
+  unsigned int i=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  threadData_t *threadData = comp->threadData;
+
+  if (invalidState(comp, "fmiGetEventIndicators", not_modelError))
+    return fmiError;
+  if (invalidNumber(comp, "fmiGetEventIndicators", "ni", ni, NUMBER_OF_EVENT_INDICATORS))
+    return fmiError;
+
+  /* try */
+  MMC_TRY_INTERNAL(simulationJumpBuffer)
+
+#if NUMBER_OF_EVENT_INDICATORS>0
+    /* eval needed equations*/
+    comp->fmuData->callback->function_ZeroCrossingsEquations(comp->fmuData, comp->threadData);
+    comp->fmuData->callback->function_ZeroCrossings(comp->fmuData, comp->threadData, comp->fmuData->simulationInfo->zeroCrossings);
+    for (i=0; i<ni; i++) {
+      /* retVal = getEventIndicator(comp, i, eventIndicators[i]); // to be implemented by the includer of this file
+       * getEventIndicator(comp, eventIndicators); // to be implemented by the includer of this file */
+      eventIndicators[i] = comp->fmuData->simulationInfo->zeroCrossings[i];
+      if (comp->loggingOn){
+        comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+            "fmiGetEventIndicators: z%d = %.16g", i, eventIndicators[i]);
+      }
+    }
+#endif
+    return fmiOK;
+
+  /* catch */
+  MMC_CATCH_INTERNAL(simulationJumpBuffer)
+
+    comp->functions.logger(c, comp->instanceName, fmiError, "error", "fmiGetEventIndicators: terminated by an assertion.");
+    return fmiError;
+}
+
+// ---------------------------------------------------------------------------
+// FMI functions: initialization, event handling, stepping and termination
+// ---------------------------------------------------------------------------
+
+fmiStatus fmiInitialize(fmiComponent c, fmiBoolean toleranceControlled, fmiReal relativeTolerance, fmiEventInfo* eventInfo)
+{
+  double nextSampleEvent=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  threadData_t *threadData = comp->threadData;
+  threadData->currentErrorStage = ERROR_SIMULATION;
+
+  if (invalidState(comp, "fmiInitialize", modelInstantiated))
+    return fmiError;
+  if (nullPointer(comp, "fmiInitialize", "eventInfo", eventInfo))
+    return fmiError;
+  if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+      "fmiInitialize: toleranceControlled=%d relativeTolerance=%g",
+      toleranceControlled, relativeTolerance);
+
+  /* set zero-crossing tolerance */
+  setZCtol(relativeTolerance);
+
+  setStartValues(comp);
+  copyStartValuestoInitValues(comp->fmuData);
+
+  /* try */
+  MMC_TRY_INTERNAL(simulationJumpBuffer)
+
+    if(initialization(comp->fmuData, comp->threadData, "", "", 0.0, 5))
+    {
+      comp->state = modelError;
+      if(comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+          "fmiInitialization: failed");
+    }
+    else
+    {
+      comp->state = modelInitialized;
+      if(comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+          "fmiInitialization: succeed");
+    }
+
+    /*TODO: Simulation stop time is need to calculate in before hand all sample events
+            We shouldn't generate them all in beforehand */
+    initSample(comp->fmuData, comp->threadData, comp->fmuData->localData[0]->timeValue, 100 /*should be stopTime*/);
+    initDelay(comp->fmuData, comp->fmuData->localData[0]->timeValue);
+
+    /* due to an event overwrite old values */
+    overwriteOldSimulationData(comp->fmuData);
+
+    eventInfo->iterationConverged = fmiTrue;
+    eventInfo->stateValueReferencesChanged = fmiFalse;
+    eventInfo->stateValuesChanged = fmiTrue;
+    eventInfo->terminateSimulation = fmiFalse;
+
+    /* Get next event time (sample calls)*/
+    nextSampleEvent = getNextSampleTimeFMU(comp->fmuData);
+    if (nextSampleEvent == -1){
+      eventInfo->upcomingTimeEvent = fmiFalse;
+    }else{
+      eventInfo->upcomingTimeEvent = fmiTrue;
+      eventInfo->nextEventTime = nextSampleEvent;
+      fmiEventUpdate(comp, fmiFalse, eventInfo);
+    }
+
+    return fmiOK;
+
+  /* catch */
+  MMC_CATCH_INTERNAL(simulationJumpBuffer)
+
+    comp->functions.logger(c, comp->instanceName, fmiError, "error", "fmiInitialize: terminated by an assertion.");
+    return fmiError;
+}
+
+fmiStatus fmiEventUpdate(fmiComponent c, fmiBoolean intermediateResults, fmiEventInfo* eventInfo)
+{
+  int i;
+  ModelInstance* comp = (ModelInstance *)c;
+  threadData_t *threadData = comp->threadData;
+  if (invalidState(comp, "fmiEventUpdate", modelInitialized))
+    return fmiError;
+  if (nullPointer(comp, "fmiEventUpdate", "eventInfo", eventInfo))
+    return fmiError;
+  eventInfo->stateValuesChanged = fmiFalse;
+
+  if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+      "fmiEventUpdate: Start Event Update! Next Sample Event %g", eventInfo->nextEventTime);
+
+  /* try */
+  MMC_TRY_INTERNAL(simulationJumpBuffer)
+
+    if (stateSelection(comp->fmuData, threadData, 1, 1))
+    {
+      if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+          "fmiEventUpdate: Need to iterate state values changed!");
+      /* if new set is calculated reinit the solver */
+      eventInfo->stateValuesChanged = fmiTrue;
+    }
+
+    storePreValues(comp->fmuData);
+
+    /* activate sample event */
+    for(i=0; i<comp->fmuData->modelData->nSamples; ++i)
+    {
+      if(comp->fmuData->simulationInfo->nextSampleTimes[i] <= comp->fmuData->localData[0]->timeValue)
+      {
+        comp->fmuData->simulationInfo->samples[i] = 1;
+        infoStreamPrint(LOG_EVENTS, 0, "[%ld] sample(%g, %g)", comp->fmuData->modelData->samplesInfo[i].index, comp->fmuData->modelData->samplesInfo[i].start, comp->fmuData->modelData->samplesInfo[i].interval);
+      }
+    }
+
+    comp->fmuData->callback->functionDAE(comp->fmuData, threadData);
+
+    /* deactivate sample events */
+    for(i=0; i<comp->fmuData->modelData->nSamples; ++i)
+    {
+      if(comp->fmuData->simulationInfo->samples[i])
+      {
+        comp->fmuData->simulationInfo->samples[i] = 0;
+        comp->fmuData->simulationInfo->nextSampleTimes[i] += comp->fmuData->modelData->samplesInfo[i].interval;
+      }
+    }
+
+    for(i=0; i<comp->fmuData->modelData->nSamples; ++i)
+      if((i == 0) || (comp->fmuData->simulationInfo->nextSampleTimes[i] < comp->fmuData->simulationInfo->nextSampleEvent))
+        comp->fmuData->simulationInfo->nextSampleEvent = comp->fmuData->simulationInfo->nextSampleTimes[i];
+
+    if(comp->fmuData->callback->checkForDiscreteChanges(comp->fmuData, threadData) || comp->fmuData->simulationInfo->needToIterate || checkRelations(comp->fmuData) || eventInfo->stateValuesChanged)
+    {
+      intermediateResults = fmiTrue;
+      if (comp->loggingOn)
+        comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiEventUpdate: Need to iterate(discrete changes)!");
+      eventInfo->iterationConverged  = fmiTrue;
+      eventInfo->stateValueReferencesChanged = fmiFalse;
+      eventInfo->stateValuesChanged  = fmiTrue;
+      eventInfo->terminateSimulation = fmiFalse;
+    }
+    else
+    {
+      intermediateResults = fmiFalse;
+      eventInfo->iterationConverged  = fmiTrue;
+      eventInfo->stateValueReferencesChanged = fmiFalse;
+      eventInfo->terminateSimulation = fmiFalse;
+    }
+
+    /* due to an event overwrite old values */
+    overwriteOldSimulationData(comp->fmuData);
+
+    /* TODO: check the event iteration for relation
+     * in fmi import and export. This is an workaround,
+     * since the iteration seem not starting.
+     */
+    storePreValues(comp->fmuData);
+    updateRelationsPre(comp->fmuData);
+
+    if (comp->loggingOn)
+      comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiEventUpdate: intermediateResults = %d", intermediateResults);
+
+    //Get Next Event Time
+    double nextSampleEvent=0;
+    nextSampleEvent = getNextSampleTimeFMU(comp->fmuData);
+    if (nextSampleEvent == -1)
+    {
+      eventInfo->upcomingTimeEvent = fmiFalse;
+    }
+    else
+    {
+      eventInfo->upcomingTimeEvent = fmiTrue;
+      eventInfo->nextEventTime = nextSampleEvent;
+    }
+    if (comp->loggingOn)
+      comp->functions.logger(c, comp->instanceName, fmiOK, "log", "fmiEventUpdate: Checked for Sample Events! Next Sample Event %g",eventInfo->nextEventTime);
+
+    return fmiOK;
+
+  /* catch */
+  MMC_CATCH_INTERNAL(simulationJumpBuffer)
+
+  comp->functions.logger(c, comp->instanceName, fmiError, "error", "fmiEventUpdate: terminated by an assertion.");
+  return fmiError;
+}
+
+fmiStatus fmiCompletedIntegratorStep(fmiComponent c, fmiBoolean* callEventUpdate)
+{
+  ModelInstance* comp = (ModelInstance *)c;
+  threadData_t *threadData = comp->threadData;
+  if (invalidState(comp, "fmiCompletedIntegratorStep", modelInitialized))
+    return fmiError;
+  if (nullPointer(comp, "fmiCompletedIntegratorStep", "callEventUpdate", callEventUpdate))
+    return fmiError;
+  if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+      "fmiCompletedIntegratorStep");
+
+  /* try */
+  MMC_TRY_INTERNAL(simulationJumpBuffer)
+
+    comp->fmuData->callback->functionAlgebraics(comp->fmuData, comp->threadData);
+    comp->fmuData->callback->output_function(comp->fmuData, comp->threadData);
+    comp->fmuData->callback->function_storeDelayed(comp->fmuData, comp->threadData);
+    storePreValues(comp->fmuData);
+    *callEventUpdate  = fmiFalse;
+    /******** check state selection ********/
+    if (stateSelection(comp->fmuData, comp->threadData, 1, 0))
+    {
+      if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+          "fmiEventUpdate: Need to iterate state values changed!");
+      /* if new set is calculated reinit the solver */
+      *callEventUpdate = fmiTrue;
+    }
+    /* TODO: fix the extrapolation in non-linear system
+     *       then we can stop to save all variables in
+     *       in the whole ringbuffer
+     */
+    overwriteOldSimulationData(comp->fmuData);
+    return fmiOK;
+  /* catch */
+  MMC_CATCH_INTERNAL(simulationJumpBuffer)
+
+  comp->functions.logger(c, comp->instanceName, fmiError, "error", "fmiCompletedIntegratorStep: terminated by an assertion.");
+  return fmiError;
+}
+
+fmiStatus fmiTerminate(fmiComponent c)
+{
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiTerminate", modelInitialized))
+    return fmiError;
+  if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+      "fmiTerminate");
+
+  comp->state = modelTerminated;
+  /* free nonlinear system data */
+  freeNonlinearSystems(comp->fmuData, comp->threadData);
+  /* free mixed system data */
+  freeMixedSystems(comp->fmuData, comp->threadData);
+  /* free linear system data */
+  freeLinearSystems(comp->fmuData, comp->threadData);
+
+  /* call external objects destructors */
+  comp->fmuData->callback->callExternalObjectDestructors(comp->fmuData, comp->threadData);
+  /* free stateset data */
+  freeStateSetData(comp->fmuData);
+  deInitializeDataStruc(comp->fmuData);
+  /* free simuation data */
+  comp->functions.freeMemory(comp->fmuData->modelData);
+  comp->functions.freeMemory(comp->fmuData->simulationInfo);
+
+  comp->functions.freeMemory(comp->threadData);
+  comp->functions.freeMemory(comp->fmuData);
+
+  comp->state = modelTerminated;
+  return fmiOK;
+}
+
+/***************************************************
+Functions for FMI for Co-Simulation
+****************************************************/
+fmiComponent fmiInstantiateSlave(fmiString instanceName, fmiString fmuGUID, fmiString fmuLocation, fmiString mimeType, fmiReal timeout, fmiBoolean visible,
+                                 fmiBoolean interactive, fmiCallbackFunctions functions, fmiBoolean loggingOn)
+{
+  // TODO Write code here
+  return 0;
+}
+
+fmiStatus fmiInitializeSlave(fmiComponent c, fmiReal tStart, fmiBoolean StopTimeDefined, fmiReal tStop)
+{
+  // TODO Write code here
+  return fmiOK;
+}
+
+fmiStatus fmiTerminateSlave(fmiComponent c)
+{
+  // TODO Write code here
+  return fmiOK;
+}
+
+fmiStatus fmiResetSlave(fmiComponent c)
+{
+  // TODO Write code here
+  return fmiOK;
+}
+
+void fmiFreeSlaveInstance(fmiComponent c)
+{
+  // TODO Write code here
+}
+
+fmiStatus fmiSetRealInputDerivatives(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger order[], const fmiReal value[])
+{
+  // TODO Write code here
+  return fmiOK;
+}
+
+fmiStatus fmiGetRealOutputDerivatives(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger order[], fmiReal value[])
+{
+  // TODO Write code here
+  return fmiOK;
+}
+
+fmiStatus fmiCancelStep(fmiComponent c)
+{
+  // TODO Write code here
+  return fmiOK;
+}
+
+fmiStatus fmiDoStep(fmiComponent c, fmiReal currentCommunicationPoint, fmiReal communicationStepSize, fmiBoolean newStep)
+{
+  // TODO Write code here
+  return fmiOK;
+}
+
+fmiStatus fmiGetStatus(fmiComponent c, const fmiStatusKind s, fmiStatus* value)
+{
+  // TODO Write code here
+  return fmiOK;
+}
+
+fmiStatus fmiGetRealStatus(fmiComponent c, const fmiStatusKind s, fmiReal* value)
+{
+  // TODO Write code here
+  return fmiOK;
+}
+
+fmiStatus fmiGetIntegerStatus(fmiComponent c, const fmiStatusKind s, fmiInteger* value)
+{
+  // TODO Write code here
+  return fmiOK;
+}
+
+fmiStatus fmiGetBooleanStatus(fmiComponent c, const fmiStatusKind s, fmiBoolean* value)
+{
+  // TODO Write code here
+  return fmiOK;
+}
+
+fmiStatus fmiGetStringStatus(fmiComponent c, const fmiStatusKind s, fmiString* value)
+{
+  // TODO Write code here
+  return fmiOK;
+}
+
+// ---------------------------------------------------------------------------
+// FMI functions: set external functions
+// ---------------------------------------------------------------------------
+
+fmiStatus fmiSetExternalFunction(fmiComponent c, fmiValueReference vr[], size_t nvr, const void* value[])
+{
+  unsigned int i=0;
+  ModelInstance* comp = (ModelInstance *)c;
+  if (invalidState(comp, "fmiTerminate", modelInstantiated))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiSetExternalFunction", "vr[]", vr))
+    return fmiError;
+  if (nvr>0 && nullPointer(comp, "fmiSetExternalFunction", "value[]", value))
+    return fmiError;
+  if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
+      "fmiSetExternalFunction");
+  // no check wether setting the value is allowed in the current state
+  for (i=0; i<nvr; i++) {
+    if (vrOutOfRange(comp, "fmiSetExternalFunction", vr[i], NUMBER_OF_EXTERNALFUNCTIONS))
+      return fmiError;
+    if (setExternalFunction(comp, vr[i],value[i]) != fmiOK) // to be implemented by the includer of this file
+      return fmiError;
+  }
+  return fmiOK;
+}

+ 69 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi1/fmu1_model_interface.h

@@ -0,0 +1,69 @@
+/*
+ * This file is part of OpenModelica.
+ *
+ * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
+ * c/o Linköpings universitet, Department of Computer and Information Science,
+ * SE-58183 Linköping, Sweden.
+ *
+ * All rights reserved.
+ *
+ * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
+ * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
+ * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
+ * OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
+ *
+ * The OpenModelica software and the Open Source Modelica
+ * Consortium (OSMC) Public License (OSMC-PL) are obtained
+ * from OSMC, either from the above address,
+ * from the URLs: http://www.ida.liu.se/projects/OpenModelica or
+ * http://www.openmodelica.org, and in the OpenModelica distribution.
+ * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without
+ * even the implied warranty of  MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
+ * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
+ *
+ * See the full OSMC Public License conditions for more details.
+ *
+ */
+
+#ifndef __FMU1_MODEL_INTERFACE_H__
+#define __FMU1_MODEL_INTERFACE_H__
+
+#include "fmiModelFunctions.h"
+#include "simulation_data.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// macros used to define variables
+#define pos(z) comp->isPositive[z]
+#define copy(vr, value) setString(comp, vr, value)
+
+#define not_modelError (modelInstantiated|modelInitialized|modelTerminated)
+
+typedef enum {
+  modelInstantiated = 1<<0,
+  modelInitialized  = 1<<1,
+  modelTerminated   = 1<<2,
+  modelError        = 1<<3
+} ModelState;
+
+typedef struct {
+  fmiString instanceName;
+  fmiString GUID;
+  fmiCallbackFunctions functions;
+  fmiBoolean loggingOn;
+  fmiEventInfo eventInfo;
+  ModelState state;
+  DATA* fmuData;
+  threadData_t *threadData;
+} ModelInstance;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

+ 247 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi2/fmi2FunctionTypes.h

@@ -0,0 +1,247 @@
+#ifndef fmi2FunctionTypes_h
+#define fmi2FunctionTypes_h
+
+#include "fmi2TypesPlatform.h"
+
+/* This header file must be utilized when compiling an FMU or an FMI master.
+   It declares data and function types for FMI 2.0
+
+   Revisions:
+   - Apr.  9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8)
+   - Apr.  3, 2014: Added #include <stddef.h> for size_t definition
+   - Mar. 27, 2014: Added #include "fmiTypesPlatform.h" (#179)
+   - Mar. 26, 2014: Introduced function argument "void" for the functions (#171)
+                      fmiGetTypesPlatformTYPE and fmiGetVersionTYPE
+   - Oct. 11, 2013: Functions of ModelExchange and CoSimulation merged:
+                      fmiInstantiateModelTYPE , fmiInstantiateSlaveTYPE  -> fmiInstantiateTYPE
+                      fmiFreeModelInstanceTYPE, fmiFreeSlaveInstanceTYPE -> fmiFreeInstanceTYPE
+                      fmiEnterModelInitializationModeTYPE, fmiEnterSlaveInitializationModeTYPE -> fmiEnterInitializationModeTYPE
+                      fmiExitModelInitializationModeTYPE , fmiExitSlaveInitializationModeTYPE  -> fmiExitInitializationModeTYPE
+                      fmiTerminateModelTYPE , fmiTerminateSlaveTYPE  -> fmiTerminate
+                      fmiResetSlave -> fmiReset (now also for ModelExchange and not only for CoSimulation)
+                    Functions renamed
+                      fmiUpdateDiscreteStatesTYPE -> fmiNewDiscreteStatesTYPE
+                    Renamed elements of the enumeration fmiEventInfo
+                      upcomingTimeEvent             -> nextEventTimeDefined // due to generic naming scheme: varDefined + var
+                      newUpdateDiscreteStatesNeeded -> newDiscreteStatesNeeded;
+   - June 13, 2013: Changed type fmiEventInfo
+                    Functions removed:
+                       fmiInitializeModelTYPE
+                       fmiEventUpdateTYPE
+                       fmiCompletedEventIterationTYPE
+                       fmiInitializeSlaveTYPE
+                    Functions added:
+                       fmiEnterModelInitializationModeTYPE
+                       fmiExitModelInitializationModeTYPE
+                       fmiEnterEventModeTYPE
+                       fmiUpdateDiscreteStatesTYPE
+                       fmiEnterContinuousTimeModeTYPE
+                       fmiEnterSlaveInitializationModeTYPE;
+                       fmiExitSlaveInitializationModeTYPE;
+   - Feb. 17, 2013: Added third argument to fmiCompletedIntegratorStepTYPE
+                    Changed function name "fmiTerminateType" to "fmiTerminateModelType" (due to #113)
+                    Changed function name "fmiGetNominalContinuousStateTYPE" to
+                                          "fmiGetNominalsOfContinuousStatesTYPE"
+                    Removed fmiGetStateValueReferencesTYPE.
+   - Nov. 14, 2011: First public Version
+
+
+   Copyright (C) 2011 MODELISAR consortium,
+               2012-2013 Modelica Association Project "FMI"
+               All rights reserved.
+   This file is licensed by the copyright holders under the BSD 2-Clause License
+   (http://www.opensource.org/licenses/bsd-license.html):
+
+   ----------------------------------------------------------------------------
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+
+   - Redistributions of source code must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   - Redistributions in binary form must reproduce the above copyright notice,
+     this list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+   - Neither the name of the copyright holders nor the names of its
+     contributors may be used to endorse or promote products derived
+     from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+   ----------------------------------------------------------------------------
+
+   with the extension:
+
+   You may distribute or publicly perform any modification only under the
+   terms of this license.
+   (Note, this means that if you distribute a modified file,
+    the modified file must also be provided under this license).
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* make sure all compiler use the same alignment policies for structures */
+#if defined _MSC_VER || defined __GNUC__
+#pragma pack(push,8)
+#endif
+
+/* Include stddef.h, in order that size_t etc. is defined */
+#include <stddef.h>
+
+
+/* Type definitions */
+typedef enum {
+    fmi2OK,
+    fmi2Warning,
+    fmi2Discard,
+    fmi2Error,
+    fmi2Fatal,
+    fmi2Pending
+} fmi2Status;
+
+typedef enum {
+    fmi2ModelExchange,
+    fmi2CoSimulation
+} fmi2Type;
+
+typedef enum {
+    fmi2DoStepStatus,
+    fmi2PendingStatus,
+    fmi2LastSuccessfulTime,
+    fmi2Terminated
+} fmi2StatusKind;
+
+typedef void      (*fmi2CallbackLogger)        (fmi2ComponentEnvironment, fmi2String, fmi2Status, fmi2String, fmi2String, ...);
+typedef void*     (*fmi2CallbackAllocateMemory)(size_t, size_t);
+typedef void      (*fmi2CallbackFreeMemory)    (void*);
+typedef void      (*fmi2StepFinished)          (fmi2ComponentEnvironment, fmi2Status);
+
+typedef struct {
+   const fmi2CallbackLogger         logger;
+   const fmi2CallbackAllocateMemory allocateMemory;
+   const fmi2CallbackFreeMemory     freeMemory;
+   const fmi2StepFinished           stepFinished;
+   const fmi2ComponentEnvironment   componentEnvironment;
+} fmi2CallbackFunctions;
+
+typedef struct {
+   fmi2Boolean newDiscreteStatesNeeded;
+   fmi2Boolean terminateSimulation;
+   fmi2Boolean nominalsOfContinuousStatesChanged;
+   fmi2Boolean valuesOfContinuousStatesChanged;
+   fmi2Boolean nextEventTimeDefined;
+   fmi2Real    nextEventTime;
+} fmi2EventInfo;
+
+
+/* reset alignment policy to the one set before reading this file */
+#if defined _MSC_VER || defined __GNUC__
+#pragma pack(pop)
+#endif
+
+
+/* Define fmi2 function pointer types to simplify dynamic loading */
+
+/***************************************************
+Types for Common Functions
+****************************************************/
+
+/* Inquire version numbers of header files and setting logging status */
+   typedef const char* fmi2GetTypesPlatformTYPE(void);
+   typedef const char* fmi2GetVersionTYPE(void);
+   typedef fmi2Status  fmi2SetDebugLoggingTYPE(fmi2Component, fmi2Boolean, size_t, const fmi2String[]);
+
+/* Creation and destruction of FMU instances and setting debug status */
+   typedef fmi2Component fmi2InstantiateTYPE (fmi2String, fmi2Type, fmi2String, fmi2String, const fmi2CallbackFunctions*, fmi2Boolean, fmi2Boolean);
+   typedef void          fmi2FreeInstanceTYPE(fmi2Component);
+
+/* Enter and exit initialization mode, terminate and reset */
+   typedef fmi2Status fmi2SetupExperimentTYPE        (fmi2Component, fmi2Boolean, fmi2Real, fmi2Real, fmi2Boolean, fmi2Real);
+   typedef fmi2Status fmi2EnterInitializationModeTYPE(fmi2Component);
+   typedef fmi2Status fmi2ExitInitializationModeTYPE (fmi2Component);
+   typedef fmi2Status fmi2TerminateTYPE              (fmi2Component);
+   typedef fmi2Status fmi2ResetTYPE                  (fmi2Component);
+
+/* Getting and setting variable values */
+   typedef fmi2Status fmi2GetRealTYPE   (fmi2Component, const fmi2ValueReference[], size_t, fmi2Real   []);
+   typedef fmi2Status fmi2GetIntegerTYPE(fmi2Component, const fmi2ValueReference[], size_t, fmi2Integer[]);
+   typedef fmi2Status fmi2GetBooleanTYPE(fmi2Component, const fmi2ValueReference[], size_t, fmi2Boolean[]);
+   typedef fmi2Status fmi2GetStringTYPE (fmi2Component, const fmi2ValueReference[], size_t, fmi2String []);
+
+   typedef fmi2Status fmi2SetRealTYPE   (fmi2Component, const fmi2ValueReference[], size_t, const fmi2Real   []);
+   typedef fmi2Status fmi2SetIntegerTYPE(fmi2Component, const fmi2ValueReference[], size_t, const fmi2Integer[]);
+   typedef fmi2Status fmi2SetBooleanTYPE(fmi2Component, const fmi2ValueReference[], size_t, const fmi2Boolean[]);
+   typedef fmi2Status fmi2SetStringTYPE (fmi2Component, const fmi2ValueReference[], size_t, const fmi2String []);
+
+/* Getting and setting the internal FMU state */
+   typedef fmi2Status fmi2GetFMUstateTYPE           (fmi2Component, fmi2FMUstate*);
+   typedef fmi2Status fmi2SetFMUstateTYPE           (fmi2Component, fmi2FMUstate);
+   typedef fmi2Status fmi2FreeFMUstateTYPE          (fmi2Component, fmi2FMUstate*);
+   typedef fmi2Status fmi2SerializedFMUstateSizeTYPE(fmi2Component, fmi2FMUstate, size_t*);
+   typedef fmi2Status fmi2SerializeFMUstateTYPE     (fmi2Component, fmi2FMUstate, fmi2Byte[], size_t);
+   typedef fmi2Status fmi2DeSerializeFMUstateTYPE   (fmi2Component, const fmi2Byte[], size_t, fmi2FMUstate*);
+
+/* Getting partial derivatives */
+   typedef fmi2Status fmi2GetDirectionalDerivativeTYPE(fmi2Component, const fmi2ValueReference[], size_t,
+                                                                   const fmi2ValueReference[], size_t,
+                                                                   const fmi2Real[], fmi2Real[]);
+
+/***************************************************
+Types for Functions for FMI2 for Model Exchange
+****************************************************/
+
+/* Enter and exit the different modes */
+   typedef fmi2Status fmi2EnterEventModeTYPE         (fmi2Component);
+   typedef fmi2Status fmi2NewDiscreteStatesTYPE      (fmi2Component, fmi2EventInfo*);
+   typedef fmi2Status fmi2EnterContinuousTimeModeTYPE(fmi2Component);
+   typedef fmi2Status fmi2CompletedIntegratorStepTYPE(fmi2Component, fmi2Boolean, fmi2Boolean*, fmi2Boolean*);
+
+/* Providing independent variables and re-initialization of caching */
+   typedef fmi2Status fmi2SetTimeTYPE            (fmi2Component, fmi2Real);
+   typedef fmi2Status fmi2SetContinuousStatesTYPE(fmi2Component, const fmi2Real[], size_t);
+
+/* Evaluation of the model equations */
+   typedef fmi2Status fmi2GetDerivativesTYPE               (fmi2Component, fmi2Real[], size_t);
+#ifdef FMU_EXPERIMENTAL
+   typedef fmi2Status fmi2GetSpecificDerivativesTYPE       (fmi2Component, fmi2Real[], const fmi2ValueReference [], size_t);
+#endif
+
+   typedef fmi2Status fmi2GetEventIndicatorsTYPE           (fmi2Component, fmi2Real[], size_t);
+   typedef fmi2Status fmi2GetContinuousStatesTYPE          (fmi2Component, fmi2Real[], size_t);
+   typedef fmi2Status fmi2GetNominalsOfContinuousStatesTYPE(fmi2Component, fmi2Real[], size_t);
+
+
+/***************************************************
+Types for Functions for FMI2 for Co-Simulation
+****************************************************/
+
+/* Simulating the slave */
+   typedef fmi2Status fmi2SetRealInputDerivativesTYPE (fmi2Component, const fmi2ValueReference [], size_t, const fmi2Integer [], const fmi2Real []);
+   typedef fmi2Status fmi2GetRealOutputDerivativesTYPE(fmi2Component, const fmi2ValueReference [], size_t, const fmi2Integer [], fmi2Real []);
+
+   typedef fmi2Status fmi2DoStepTYPE     (fmi2Component, fmi2Real, fmi2Real, fmi2Boolean);
+   typedef fmi2Status fmi2CancelStepTYPE (fmi2Component);
+
+/* Inquire slave status */
+   typedef fmi2Status fmi2GetStatusTYPE       (fmi2Component, const fmi2StatusKind, fmi2Status* );
+   typedef fmi2Status fmi2GetRealStatusTYPE   (fmi2Component, const fmi2StatusKind, fmi2Real*   );
+   typedef fmi2Status fmi2GetIntegerStatusTYPE(fmi2Component, const fmi2StatusKind, fmi2Integer*);
+   typedef fmi2Status fmi2GetBooleanStatusTYPE(fmi2Component, const fmi2StatusKind, fmi2Boolean*);
+   typedef fmi2Status fmi2GetStringStatusTYPE (fmi2Component, const fmi2StatusKind, fmi2String* );
+
+
+#ifdef __cplusplus
+}  /* end of extern "C" { */
+#endif
+
+#endif /* fmi2FunctionTypes_h */

+ 339 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi2/fmi2Functions.h

@@ -0,0 +1,339 @@
+#ifndef fmi2Functions_h
+#define fmi2Functions_h
+
+/* This header file must be utilized when compiling a FMU.
+   It defines all functions of the
+         FMI 2.0 Model Exchange and Co-Simulation Interface.
+
+   In order to have unique function names even if several FMUs
+   are compiled together (e.g. for embedded systems), every "real" function name
+   is constructed by prepending the function name by "FMI2_FUNCTION_PREFIX".
+   Therefore, the typical usage is:
+
+      #define FMI2_FUNCTION_PREFIX MyModel_
+      #include "fmi2Functions.h"
+
+   As a result, a function that is defined as "fmi2GetDerivatives" in this header file,
+   is actually getting the name "MyModel_fmi2GetDerivatives".
+
+   This only holds if the FMU is shipped in C source code, or is compiled in a
+   static link library. For FMUs compiled in a DLL/sharedObject, the "actual" function
+   names are used and "FMI2_FUNCTION_PREFIX" must not be defined.
+
+   Revisions:
+   - Apr.  9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8)
+   - Mar. 26, 2014: FMI_Export set to empty value if FMI_Export and FMI_FUNCTION_PREFIX
+                    are not defined (#173)
+   - Oct. 11, 2013: Functions of ModelExchange and CoSimulation merged:
+                      fmiInstantiateModel , fmiInstantiateSlave  -> fmiInstantiate
+                      fmiFreeModelInstance, fmiFreeSlaveInstance -> fmiFreeInstance
+                      fmiEnterModelInitializationMode, fmiEnterSlaveInitializationMode -> fmiEnterInitializationMode
+                      fmiExitModelInitializationMode , fmiExitSlaveInitializationMode  -> fmiExitInitializationMode
+                      fmiTerminateModel, fmiTerminateSlave  -> fmiTerminate
+                      fmiResetSlave -> fmiReset (now also for ModelExchange and not only for CoSimulation)
+                    Functions renamed:
+                      fmiUpdateDiscreteStates -> fmiNewDiscreteStates
+   - June 13, 2013: Functions removed:
+                       fmiInitializeModel
+                       fmiEventUpdate
+                       fmiCompletedEventIteration
+                       fmiInitializeSlave
+                    Functions added:
+                       fmiEnterModelInitializationMode
+                       fmiExitModelInitializationMode
+                       fmiEnterEventMode
+                       fmiUpdateDiscreteStates
+                       fmiEnterContinuousTimeMode
+                       fmiEnterSlaveInitializationMode;
+                       fmiExitSlaveInitializationMode;
+   - Feb. 17, 2013: Portability improvements:
+                       o DllExport changed to FMI_Export
+                       o FUNCTION_PREFIX changed to FMI_FUNCTION_PREFIX
+                       o Allow undefined FMI_FUNCTION_PREFIX (meaning no prefix is used)
+                    Changed function name "fmiTerminate" to "fmiTerminateModel" (due to #113)
+                    Changed function name "fmiGetNominalContinuousState" to
+                                          "fmiGetNominalsOfContinuousStates"
+                    Removed fmiGetStateValueReferences.
+   - Nov. 14, 2011: Adapted to FMI 2.0:
+                       o Split into two files (fmiFunctions.h, fmiTypes.h) in order
+                         that code that dynamically loads an FMU can directly
+                         utilize the header files).
+                       o Added C++ encapsulation of C-part, in order that the header
+                         file can be directly utilized in C++ code.
+                       o fmiCallbackFunctions is passed as pointer to fmiInstantiateXXX
+                       o stepFinished within fmiCallbackFunctions has as first
+                         argument "fmiComponentEnvironment" and not "fmiComponent".
+                       o New functions to get and set the complete FMU state
+                         and to compute partial derivatives.
+   - Nov.  4, 2010: Adapted to specification text:
+                       o fmiGetModelTypesPlatform renamed to fmiGetTypesPlatform
+                       o fmiInstantiateSlave: Argument GUID     replaced by fmuGUID
+                                              Argument mimetype replaced by mimeType
+                       o tabs replaced by spaces
+   - Oct. 16, 2010: Functions for FMI for Co-simulation added
+   - Jan. 20, 2010: stateValueReferencesChanged added to struct fmiEventInfo (ticket #27)
+                    (by M. Otter, DLR)
+                    Added WIN32 pragma to define the struct layout (ticket #34)
+                    (by J. Mauss, QTronic)
+   - Jan.  4, 2010: Removed argument intermediateResults from fmiInitialize
+                    Renamed macro fmiGetModelFunctionsVersion to fmiGetVersion
+                    Renamed macro fmiModelFunctionsVersion to fmiVersion
+                    Replaced fmiModel by fmiComponent in decl of fmiInstantiateModel
+                    (by J. Mauss, QTronic)
+   - Dec. 17, 2009: Changed extension "me" to "fmi" (by Martin Otter, DLR).
+   - Dez. 14, 2009: Added eventInfo to meInitialize and added
+                    meGetNominalContinuousStates (by Martin Otter, DLR)
+   - Sept. 9, 2009: Added DllExport (according to Peter Nilsson's suggestion)
+                    (by A. Junghanns, QTronic)
+   - Sept. 9, 2009: Changes according to FMI-meeting on July 21:
+                    meInquireModelTypesVersion     -> meGetModelTypesPlatform
+                    meInquireModelFunctionsVersion -> meGetModelFunctionsVersion
+                    meSetStates                    -> meSetContinuousStates
+                    meGetStates                    -> meGetContinuousStates
+                    removal of meInitializeModelClass
+                    removal of meGetTime
+                    change of arguments of meInstantiateModel
+                    change of arguments of meCompletedIntegratorStep
+                    (by Martin Otter, DLR):
+   - July 19, 2009: Added "me" as prefix to file names (by Martin Otter, DLR).
+   - March 2, 2009: Changed function definitions according to the last design
+                    meeting with additional improvements (by Martin Otter, DLR).
+   - Dec. 3 , 2008: First version by Martin Otter (DLR) and Hans Olsson (Dynasim).
+
+   Copyright (C) 2008-2011 MODELISAR consortium,
+               2012-2013 Modelica Association Project "FMI"
+               All rights reserved.
+   This file is licensed by the copyright holders under the BSD 2-Clause License
+   (http://www.opensource.org/licenses/bsd-license.html):
+
+   ----------------------------------------------------------------------------
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+
+   - Redistributions of source code must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   - Redistributions in binary form must reproduce the above copyright notice,
+     this list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+   - Neither the name of the copyright holders nor the names of its
+     contributors may be used to endorse or promote products derived
+     from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+   ----------------------------------------------------------------------------
+
+   with the extension:
+
+   You may distribute or publicly perform any modification only under the
+   terms of this license.
+   (Note, this means that if you distribute a modified file,
+    the modified file must also be provided under this license).
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "fmi2TypesPlatform.h"
+#include "fmi2FunctionTypes.h"
+#include <stdlib.h>
+
+
+/*
+  Export FMI2 API functions on Windows and under GCC.
+  If custom linking is desired then the FMI2_Export must be
+  defined before including this file. For instance,
+  it may be set to __declspec(dllimport).
+*/
+#if !defined(FMI2_Export)
+  #if !defined(FMI2_FUNCTION_PREFIX)
+    #if defined _WIN32 || defined __CYGWIN__
+     /* Note: both gcc & MSVC on Windows support this syntax. */
+        #define FMI2_Export __declspec(dllexport)
+    #else
+      #if __GNUC__ >= 4
+        #define FMI2_Export __attribute__ ((visibility ("default")))
+      #else
+        #define FMI2_Export
+      #endif
+    #endif
+  #else
+    #define FMI2_Export
+  #endif
+#endif
+
+/* Macros to construct the real function name
+   (prepend function name by FMI2_FUNCTION_PREFIX) */
+#if defined(FMI2_FUNCTION_PREFIX)
+  #define fmi2Paste(a,b)     a ## b
+  #define fmi2PasteB(a,b)    fmi2Paste(a,b)
+  #define fmi2FullName(name) fmi2PasteB(FMI2_FUNCTION_PREFIX, name)
+#else
+  #define fmi2FullName(name) name
+#endif
+
+/***************************************************
+Common Functions
+****************************************************/
+#define fmi2GetTypesPlatform         fmi2FullName(fmi2GetTypesPlatform)
+#define fmi2GetVersion               fmi2FullName(fmi2GetVersion)
+#define fmi2SetDebugLogging          fmi2FullName(fmi2SetDebugLogging)
+#define fmi2Instantiate              fmi2FullName(fmi2Instantiate)
+#define fmi2FreeInstance             fmi2FullName(fmi2FreeInstance)
+#define fmi2SetupExperiment          fmi2FullName(fmi2SetupExperiment)
+#define fmi2EnterInitializationMode  fmi2FullName(fmi2EnterInitializationMode)
+#define fmi2ExitInitializationMode   fmi2FullName(fmi2ExitInitializationMode)
+#define fmi2Terminate                fmi2FullName(fmi2Terminate)
+#define fmi2Reset                    fmi2FullName(fmi2Reset)
+#define fmi2GetReal                  fmi2FullName(fmi2GetReal)
+#define fmi2GetInteger               fmi2FullName(fmi2GetInteger)
+#define fmi2GetBoolean               fmi2FullName(fmi2GetBoolean)
+#define fmi2GetString                fmi2FullName(fmi2GetString)
+#define fmi2SetReal                  fmi2FullName(fmi2SetReal)
+#define fmi2SetInteger               fmi2FullName(fmi2SetInteger)
+#define fmi2SetBoolean               fmi2FullName(fmi2SetBoolean)
+#define fmi2SetString                fmi2FullName(fmi2SetString)
+#define fmi2GetFMUstate              fmi2FullName(fmi2GetFMUstate)
+#define fmi2SetFMUstate              fmi2FullName(fmi2SetFMUstate)
+#define fmi2FreeFMUstate             fmi2FullName(fmi2FreeFMUstate)
+#define fmi2SerializedFMUstateSize   fmi2FullName(fmi2SerializedFMUstateSize)
+#define fmi2SerializeFMUstate        fmi2FullName(fmi2SerializeFMUstate)
+#define fmi2DeSerializeFMUstate      fmi2FullName(fmi2DeSerializeFMUstate)
+#define fmi2GetDirectionalDerivative fmi2FullName(fmi2GetDirectionalDerivative)
+
+
+/***************************************************
+Functions for FMI2 for Model Exchange
+****************************************************/
+#define fmi2EnterEventMode                fmi2FullName(fmi2EnterEventMode)
+#define fmi2NewDiscreteStates             fmi2FullName(fmi2NewDiscreteStates)
+#define fmi2EnterContinuousTimeMode       fmi2FullName(fmi2EnterContinuousTimeMode)
+#define fmi2CompletedIntegratorStep       fmi2FullName(fmi2CompletedIntegratorStep)
+#define fmi2SetTime                       fmi2FullName(fmi2SetTime)
+#define fmi2SetContinuousStates           fmi2FullName(fmi2SetContinuousStates)
+#define fmi2GetDerivatives                fmi2FullName(fmi2GetDerivatives)
+#ifdef FMU_EXPERIMENTAL
+#define fmi2GetSpecificDerivatives        fmi2FullName(fmi2GetSpecificDerivatives)
+#endif
+#define fmi2GetEventIndicators            fmi2FullName(fmi2GetEventIndicators)
+#define fmi2GetContinuousStates           fmi2FullName(fmi2GetContinuousStates)
+#define fmi2GetNominalsOfContinuousStates fmi2FullName(fmi2GetNominalsOfContinuousStates)
+
+
+/***************************************************
+Functions for FMI2 for Co-Simulation
+****************************************************/
+#define fmi2SetRealInputDerivatives      fmi2FullName(fmi2SetRealInputDerivatives)
+#define fmi2GetRealOutputDerivatives     fmi2FullName(fmi2GetRealOutputDerivatives)
+#define fmi2DoStep                       fmi2FullName(fmi2DoStep)
+#define fmi2CancelStep                   fmi2FullName(fmi2CancelStep)
+#define fmi2GetStatus                    fmi2FullName(fmi2GetStatus)
+#define fmi2GetRealStatus                fmi2FullName(fmi2GetRealStatus)
+#define fmi2GetIntegerStatus             fmi2FullName(fmi2GetIntegerStatus)
+#define fmi2GetBooleanStatus             fmi2FullName(fmi2GetBooleanStatus)
+#define fmi2GetStringStatus              fmi2FullName(fmi2GetStringStatus)
+
+/* Version number */
+#define fmi2Version "2.0"
+
+
+/***************************************************
+Common Functions
+****************************************************/
+
+/* Inquire version numbers of header files */
+   FMI2_Export fmi2GetTypesPlatformTYPE fmi2GetTypesPlatform;
+   FMI2_Export fmi2GetVersionTYPE       fmi2GetVersion;
+   FMI2_Export fmi2SetDebugLoggingTYPE  fmi2SetDebugLogging;
+
+/* Creation and destruction of FMU instances */
+   FMI2_Export fmi2InstantiateTYPE  fmi2Instantiate;
+   FMI2_Export fmi2FreeInstanceTYPE fmi2FreeInstance;
+
+/* Enter and exit initialization mode, terminate and reset */
+   FMI2_Export fmi2SetupExperimentTYPE         fmi2SetupExperiment;
+   FMI2_Export fmi2EnterInitializationModeTYPE fmi2EnterInitializationMode;
+   FMI2_Export fmi2ExitInitializationModeTYPE  fmi2ExitInitializationMode;
+   FMI2_Export fmi2TerminateTYPE               fmi2Terminate;
+   FMI2_Export fmi2ResetTYPE                   fmi2Reset;
+
+/* Getting and setting variables values */
+   FMI2_Export fmi2GetRealTYPE    fmi2GetReal;
+   FMI2_Export fmi2GetIntegerTYPE fmi2GetInteger;
+   FMI2_Export fmi2GetBooleanTYPE fmi2GetBoolean;
+   FMI2_Export fmi2GetStringTYPE  fmi2GetString;
+
+   FMI2_Export fmi2SetRealTYPE    fmi2SetReal;
+   FMI2_Export fmi2SetIntegerTYPE fmi2SetInteger;
+   FMI2_Export fmi2SetBooleanTYPE fmi2SetBoolean;
+   FMI2_Export fmi2SetStringTYPE  fmi2SetString;
+
+/* Getting and setting the internal FMU state */
+   FMI2_Export fmi2GetFMUstateTYPE            fmi2GetFMUstate;
+   FMI2_Export fmi2SetFMUstateTYPE            fmi2SetFMUstate;
+   FMI2_Export fmi2FreeFMUstateTYPE           fmi2FreeFMUstate;
+   FMI2_Export fmi2SerializedFMUstateSizeTYPE fmi2SerializedFMUstateSize;
+   FMI2_Export fmi2SerializeFMUstateTYPE      fmi2SerializeFMUstate;
+   FMI2_Export fmi2DeSerializeFMUstateTYPE    fmi2DeSerializeFMUstate;
+
+/* Getting partial derivatives */
+   FMI2_Export fmi2GetDirectionalDerivativeTYPE fmi2GetDirectionalDerivative;
+
+
+/***************************************************
+Functions for FMI2 for Model Exchange
+****************************************************/
+
+/* Enter and exit the different modes */
+   FMI2_Export fmi2EnterEventModeTYPE               fmi2EnterEventMode;
+   FMI2_Export fmi2NewDiscreteStatesTYPE            fmi2NewDiscreteStates;
+   FMI2_Export fmi2EnterContinuousTimeModeTYPE      fmi2EnterContinuousTimeMode;
+   FMI2_Export fmi2CompletedIntegratorStepTYPE      fmi2CompletedIntegratorStep;
+
+/* Providing independent variables and re-initialization of caching */
+   FMI2_Export fmi2SetTimeTYPE             fmi2SetTime;
+   FMI2_Export fmi2SetContinuousStatesTYPE fmi2SetContinuousStates;
+
+/* Evaluation of the model equations */
+   FMI2_Export fmi2GetDerivativesTYPE                fmi2GetDerivatives;
+#ifdef FMU_EXPERIMENTAL
+   FMI2_Export fmi2GetSpecificDerivativesTYPE        fmi2GetSpecificDerivatives;
+#endif
+   FMI2_Export fmi2GetEventIndicatorsTYPE            fmi2GetEventIndicators;
+   FMI2_Export fmi2GetContinuousStatesTYPE           fmi2GetContinuousStates;
+   FMI2_Export fmi2GetNominalsOfContinuousStatesTYPE fmi2GetNominalsOfContinuousStates;
+
+
+/***************************************************
+Functions for FMI2 for Co-Simulation
+****************************************************/
+
+/* Simulating the slave */
+   FMI2_Export fmi2SetRealInputDerivativesTYPE  fmi2SetRealInputDerivatives;
+   FMI2_Export fmi2GetRealOutputDerivativesTYPE fmi2GetRealOutputDerivatives;
+
+   FMI2_Export fmi2DoStepTYPE     fmi2DoStep;
+   FMI2_Export fmi2CancelStepTYPE fmi2CancelStep;
+
+/* Inquire slave status */
+   FMI2_Export fmi2GetStatusTYPE        fmi2GetStatus;
+   FMI2_Export fmi2GetRealStatusTYPE    fmi2GetRealStatus;
+   FMI2_Export fmi2GetIntegerStatusTYPE fmi2GetIntegerStatus;
+   FMI2_Export fmi2GetBooleanStatusTYPE fmi2GetBooleanStatus;
+   FMI2_Export fmi2GetStringStatusTYPE  fmi2GetStringStatus;
+
+#ifdef __cplusplus
+}  /* end of extern "C" { */
+#endif
+
+#endif /* fmi2Functions_h */

+ 115 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi2/fmi2TypesPlatform.h

@@ -0,0 +1,115 @@
+#ifndef fmi2TypesPlatform_h
+#define fmi2TypesPlatform_h
+
+/* Standard header file to define the argument types of the
+   functions of the Functional Mock-up Interface 2.0.
+   This header file must be utilized both by the model and
+   by the simulation engine.
+
+   Revisions:
+   - Apr.  9, 2014: all prefixes "fmi" renamed to "fmi2" (decision from April 8)
+   - Mar   31, 2014: New datatype fmiChar introduced.
+   - Feb.  17, 2013: Changed fmiTypesPlatform from "standard32" to "default".
+                     Removed fmiUndefinedValueReference since no longer needed
+                     (because every state is defined in ScalarVariables).
+   - March 20, 2012: Renamed from fmiPlatformTypes.h to fmiTypesPlatform.h
+   - Nov.  14, 2011: Use the header file "fmiPlatformTypes.h" for FMI 2.0
+                     both for "FMI for model exchange" and for "FMI for co-simulation"
+                     New types "fmiComponentEnvironment", "fmiState", and "fmiByte".
+                     The implementation of "fmiBoolean" is change from "char" to "int".
+                     The #define "fmiPlatform" changed to "fmiTypesPlatform"
+                     (in order that #define and function call are consistent)
+   - Oct.   4, 2010: Renamed header file from "fmiModelTypes.h" to fmiPlatformTypes.h"
+                     for the co-simulation interface
+   - Jan.   4, 2010: Renamed meModelTypes_h to fmiModelTypes_h (by Mauss, QTronic)
+   - Dec.  21, 2009: Changed "me" to "fmi" and "meModel" to "fmiComponent"
+                     according to meeting on Dec. 18 (by Martin Otter, DLR)
+   - Dec.   6, 2009: Added meUndefinedValueReference (by Martin Otter, DLR)
+   - Sept.  9, 2009: Changes according to FMI-meeting on July 21:
+                     Changed "version" to "platform", "standard" to "standard32",
+                     Added a precise definition of "standard32" as comment
+                     (by Martin Otter, DLR)
+   - July  19, 2009: Added "me" as prefix to file names, added meTrue/meFalse,
+                     and changed meValueReferenced from int to unsigned int
+                     (by Martin Otter, DLR).
+   - March  2, 2009: Moved enums and function pointer definitions to
+                     ModelFunctions.h (by Martin Otter, DLR).
+   - Dec.  3, 2008 : First version by Martin Otter (DLR) and
+                     Hans Olsson (Dynasim).
+
+
+   Copyright (C) 2008-2011 MODELISAR consortium,
+               2012-2013 Modelica Association Project "FMI"
+               All rights reserved.
+   This file is licensed by the copyright holders under the BSD 2-Clause License
+   (http://www.opensource.org/licenses/bsd-license.html):
+
+   ----------------------------------------------------------------------------
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+
+   - Redistributions of source code must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   - Redistributions in binary form must reproduce the above copyright notice,
+     this list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+   - Neither the name of the copyright holders nor the names of its
+     contributors may be used to endorse or promote products derived
+     from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+   ----------------------------------------------------------------------------
+
+   with the extension:
+
+   You may distribute or publicly perform any modification only under the
+   terms of this license.
+   (Note, this means that if you distribute a modified file,
+    the modified file must also be provided under this license).
+*/
+
+/* Platform (unique identification of this header file) */
+#define fmi2TypesPlatform "default"
+
+/* Type definitions of variables passed as arguments
+   Version "default" means:
+
+   fmi2Component           : an opaque object pointer
+   fmi2ComponentEnvironment: an opaque object pointer
+   fmi2FMUstate            : an opaque object pointer
+   fmi2ValueReference      : handle to the value of a variable
+   fmi2Real                : double precision floating-point data type
+   fmi2Integer             : basic signed integer data type
+   fmi2Boolean             : basic signed integer data type
+   fmi2Char                : character data type
+   fmi2String              : a pointer to a vector of fmi2Char characters
+                             ('\0' terminated, UTF8 encoded)
+   fmi2Byte                : smallest addressable unit of the machine, typically one byte.
+*/
+   typedef void*           fmi2Component;               /* Pointer to FMU instance       */
+   typedef void*           fmi2ComponentEnvironment;    /* Pointer to FMU environment    */
+   typedef void*           fmi2FMUstate;                /* Pointer to internal FMU state */
+   typedef unsigned int    fmi2ValueReference;
+   typedef double          fmi2Real   ;
+   typedef int             fmi2Integer;
+   typedef int             fmi2Boolean;
+   typedef char            fmi2Char;
+   typedef const fmi2Char* fmi2String;
+   typedef char            fmi2Byte;
+
+/* Values for fmi2Boolean  */
+#define fmi2True  1
+#define fmi2False 0
+
+
+#endif /* fmi2TypesPlatform_h */

File diff suppressed because it is too large
+ 1285 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi2/fmu2_model_interface.c


+ 95 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/fmi2/fmu2_model_interface.h

@@ -0,0 +1,95 @@
+/*
+ * This file is part of OpenModelica.
+ *
+ * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
+ * c/o Linköpings universitet, Department of Computer and Information Science,
+ * SE-58183 Linköping, Sweden.
+ *
+ * All rights reserved.
+ *
+ * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
+ * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
+ * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
+ * OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
+ *
+ * The OpenModelica software and the Open Source Modelica
+ * Consortium (OSMC) Public License (OSMC-PL) are obtained
+ * from OSMC, either from the above address,
+ * from the URLs: http://www.ida.liu.se/projects/OpenModelica or
+ * http://www.openmodelica.org, and in the OpenModelica distribution.
+ * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without
+ * even the implied warranty of  MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
+ * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
+ *
+ * See the full OSMC Public License conditions for more details.
+ *
+ */
+
+#ifndef __FMU2_MODEL_INTERFACE_H__
+#define __FMU2_MODEL_INTERFACE_H__
+
+#include "fmi2Functions.h"
+#include "simulation_data.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// categories of logging supported by model.
+// Value is the index in logCategories of a ModelInstance.
+#define LOG_EVENTS                      0
+#define LOG_SINGULARLINEARSYSTEMS       1
+#define LOG_NONLINEARSYSTEMS            2
+#define LOG_DYNAMICSTATESELECTION       3
+#define LOG_STATUSWARNING               4
+#define LOG_STATUSDISCARD               5
+#define LOG_STATUSERROR                 6
+#define LOG_STATUSFATAL                 7
+#define LOG_STATUSPENDING               8
+#define LOG_ALL                         9
+#define LOG_FMI2_CALL                   10
+
+#define NUMBER_OF_CATEGORIES 11
+
+typedef enum {
+  modelInstantiated       = 1<<0,
+  modelInitializationMode = 1<<1,
+  modelEventMode          = 1<<2,
+  modelContinuousTimeMode = 1<<3,
+  modelTerminated         = 1<<4,
+  modelError              = 1<<5
+} ModelState;
+
+typedef struct {
+  fmi2String instanceName;
+  fmi2Type type;
+  fmi2String GUID;
+  const fmi2CallbackFunctions *functions;
+  fmi2Boolean loggingOn;
+  fmi2Boolean logCategories[NUMBER_OF_CATEGORIES];
+  fmi2ComponentEnvironment componentEnvironment;
+  ModelState state;
+  fmi2EventInfo eventInfo;
+
+  DATA* fmuData;
+  threadData_t *threadData;
+  fmi2Boolean toleranceDefined;
+  fmi2Real tolerance;
+  fmi2Real startTime;
+  fmi2Boolean stopTimeDefined;
+  fmi2Real stopTime;
+
+  int _need_update;
+#ifdef FMU_EXPERIMENTAL
+  int _has_jacobian;
+#endif
+} ModelInstance;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

File diff suppressed because it is too large
+ 1942 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/gc.h


+ 267 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/gc/memory_pool.c

@@ -0,0 +1,267 @@
+/*
+ * This file is part of OpenModelica.
+ *
+ * Copyright (c) 1998-2014, Open Source Modelica Consortium (OSMC),
+ * c/o Linköpings universitet, Department of Computer and Information Science,
+ * SE-58183 Linköping, Sweden.
+ *
+ * All rights reserved.
+ *
+ * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE
+ * GPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
+ * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
+ * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
+ * ACCORDING TO RECIPIENTS CHOICE.
+ *
+ * The OpenModelica software and the OSMC (Open Source Modelica Consortium)
+ * Public License (OSMC-PL) are obtained from OSMC, either from the above
+ * address, from the URLs: http://www.openmodelica.org or
+ * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica
+ * distribution. GNU version 3 is obtained from:
+ * http://www.gnu.org/copyleft/gpl.html. The New BSD License is obtained from:
+ * http://www.opensource.org/licenses/BSD-3-Clause.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS
+ * EXPRESSLY SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE
+ * CONDITIONS OF OSMC-PL.
+ *
+ */
+
+
+#if defined(OMC_MINIMAL_RUNTIME) || defined(OMC_FMI_RUNTIME)
+#define OMC_NO_GC_MAPPING
+#endif
+#include "gc/omc_gc.h"
+#include <string.h>
+#if !defined(OMC_NO_THREADS)
+#include <pthread.h>
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+static int GC_collect_a_little_or_not(void)
+{
+  return 0;
+}
+
+typedef struct list_s {
+  void *memory;
+  size_t used;
+  size_t size;
+  struct list_s *next;
+} list;
+
+#if !defined(OMC_NO_THREADS)
+static pthread_mutex_t memory_pool_mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
+static list *memory_pools = NULL;
+
+static void pool_init(void)
+{
+  memory_pools = (list*) malloc(sizeof(list));
+  memory_pools->used = 0;
+  memory_pools->size = 2*1024*1024; /* 2MB pool by default */
+  memory_pools->memory = malloc(memory_pools->size);
+  memory_pools->next = NULL;
+}
+
+static unsigned long upper_power_of_two(unsigned long v)
+{
+  v--;
+  v |= v >> 1;
+  v |= v >> 2;
+  v |= v >> 4;
+  v |= v >> 8;
+  v |= v >> 16;
+  v++;
+  return v;
+}
+
+static inline size_t round_up(size_t num, size_t factor)
+{
+  return num + factor - 1 - (num - 1) % factor;
+}
+
+static inline void pool_expand(size_t len)
+{
+  list *newlist = NULL;
+  /* Check if we have enough memory already */
+  if (memory_pools->size - memory_pools->used >= len) {
+    return;
+  }
+  newlist = (list*) malloc(sizeof(list));
+  newlist->next = memory_pools;
+  memory_pools = newlist;
+  memory_pools->used = 0;
+  memory_pools->size = upper_power_of_two(3*memory_pools->next->size/2 + len); /* expand by 1.5x the old memory pool. More if we request a very large array. */
+  memory_pools->memory = malloc(memory_pools->size);
+}
+
+static void* pool_malloc(size_t sz)
+{
+  void *res;
+  sz = round_up(sz,8);
+#if !defined(OMC_NO_THREADS)
+  pthread_mutex_lock(&memory_pool_mutex);
+#endif
+  pool_expand(sz);
+  res = (void*)((char*)memory_pools->memory + memory_pools->used);
+  memory_pools->used += sz;
+#if !defined(OMC_NO_THREADS)
+  pthread_mutex_unlock(&memory_pool_mutex);
+#endif
+  memset(res,0,sz);
+  return res;
+}
+
+static int pool_free(void)
+{
+  list *freelist = memory_pools->next;
+  while (freelist) {
+    list *next = freelist->next;
+    free(freelist->memory);
+    free(freelist);
+    freelist = next;
+  }
+  memory_pools->used = 0;
+  memory_pools->next = 0;
+  return 0;
+}
+
+static void nofree(void* ptr)
+{
+}
+
+static void* malloc_zero(size_t sz) {
+  return calloc(1, sz);
+}
+
+omc_alloc_interface_t omc_alloc_interface_pooled = {
+  pool_init,
+  pool_malloc,
+  pool_malloc,
+  (char*(*)(size_t)) malloc,
+  strdup,
+  pool_free,
+  malloc_zero,
+  free,
+  malloc,
+  free
+};
+
+#if defined(OMC_RECORD_ALLOC_WORDS)
+#include "gc/omc_gc.h"
+
+static void* OMC_record_malloc(size_t sz)
+{
+  mmc_record_alloc_words(sz);
+  return GC_malloc(sz);
+}
+
+static void* OMC_record_malloc_uncollectable(size_t sz)
+{
+  mmc_record_alloc_words(sz);
+  return GC_malloc_uncollectable(sz);
+}
+
+static void* OMC_record_malloc_atomic(size_t sz)
+{
+  mmc_record_alloc_words(sz);
+  return GC_malloc_atomic(sz);
+}
+
+static void* OMC_record_strdup(const char *str)
+{
+  mmc_record_alloc_words(strlen(str)+1);
+  return GC_strdup(str);
+}
+
+#endif
+
+omc_alloc_interface_t omc_alloc_interface = {
+#if !defined(OMC_MINIMAL_RUNTIME)
+#if !defined(OMC_RECORD_ALLOC_WORDS)
+  GC_init,
+  GC_malloc,
+  GC_malloc_atomic,
+  (char*(*)(size_t)) GC_malloc_atomic,
+  GC_strdup,
+  GC_collect_a_little_or_not,
+  GC_malloc_uncollectable,
+  GC_free,
+  GC_malloc_atomic,
+  nofree
+#else
+  GC_init,
+  OMC_record_malloc,
+  OMC_record_malloc_atomic,
+  (char*(*)(size_t)) OMC_record_malloc_atomic,
+  OMC_record_strdup,
+  GC_collect_a_little_or_not,
+  OMC_record_malloc_uncollectable,
+  GC_free,
+  OMC_record_malloc_atomic,
+  nofree
+#endif
+#else
+  pool_init,
+  pool_malloc,
+  pool_malloc,
+  (char*(*)(size_t)) malloc,
+  strdup,
+  pool_free,
+  malloc_zero /* calloc, but with malloc interface */,
+  free,
+  malloc,
+  free
+#endif
+};
+
+/* allocates n reals in the real_buffer */
+m_real* real_alloc(int n)
+{
+  return (m_real*) omc_alloc_interface.malloc_atomic(n*sizeof(m_real));
+}
+
+/* allocates n integers in the integer_buffer */
+m_integer* integer_alloc(int n)
+{
+  return (m_integer*) omc_alloc_interface.malloc_atomic(n*sizeof(m_integer));
+}
+
+/* allocates n strings in the string_buffer */
+m_string* string_alloc(int n)
+{
+  return (m_string*) omc_alloc_interface.malloc(n*sizeof(m_string));
+}
+
+/* allocates n booleans in the boolean_buffer */
+m_boolean* boolean_alloc(int n)
+{
+  return (m_boolean*) omc_alloc_interface.malloc_atomic(n*sizeof(m_boolean));
+}
+
+_index_t* size_alloc(int n)
+{
+  return (_index_t*) omc_alloc_interface.malloc(n*sizeof(_index_t));
+}
+
+_index_t** index_alloc(int n)
+{
+  return (_index_t**) omc_alloc_interface.malloc(n*sizeof(_index_t*));
+}
+
+/* allocates n elements of size sze */
+void* generic_alloc(int n, size_t sze)
+{
+  return (void*) omc_alloc_interface.malloc(n*sze);
+}
+
+
+#if defined(__cplusplus)
+} /* end extern "C" */
+#endif
+

+ 55 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/gc/memory_pool.h

@@ -0,0 +1,55 @@
+/*
+ * This file is part of OpenModelica.
+ *
+ * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
+ * c/o Linköpings universitet, Department of Computer and Information Science,
+ * SE-58183 Linköping, Sweden.
+ *
+ * All rights reserved.
+ *
+ * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE
+ * GPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
+ * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
+ * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
+ * ACCORDING TO RECIPIENTS CHOICE.
+ *
+ * The OpenModelica software and the OSMC (Open Source Modelica Consortium)
+ * Public License (OSMC-PL) are obtained from OSMC, either from the above
+ * address, from the URLs: http://www.openmodelica.org or
+ * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica
+ * distribution. GNU version 3 is obtained from:
+ * http://www.gnu.org/copyleft/gpl.html. The New BSD License is obtained from:
+ * http://www.opensource.org/licenses/BSD-3-Clause.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS
+ * EXPRESSLY SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE
+ * CONDITIONS OF OSMC-PL.
+ *
+ */
+
+#ifndef MEMORY_POOL_H_
+#define MEMORY_POOL_H_
+
+#include <stdlib.h>
+#include "openmodelica.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Allocation functions */
+extern m_real* real_alloc(int n);
+extern m_integer* integer_alloc(int n);
+extern m_string* string_alloc(int n);
+extern m_boolean* boolean_alloc(int n);
+extern _index_t* size_alloc(int n);
+extern _index_t** index_alloc(int n);
+
+void* generic_alloc(int n, size_t sze);
+
+#if defined(__cplusplus)
+} /* end extern "C" */
+#endif
+
+#endif

+ 245 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/gc/omc_gc.h

@@ -0,0 +1,245 @@
+/*
+ * This file is part of OpenModelica.
+ *
+ * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
+ * c/o Linköpings universitet, Department of Computer and Information Science,
+ * SE-58183 Linköping, Sweden.
+ *
+ * All rights reserved.
+ *
+ * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE
+ * GPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
+ * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
+ * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
+ * ACCORDING TO RECIPIENTS CHOICE.
+ *
+ * The OpenModelica software and the OSMC (Open Source Modelica Consortium)
+ * Public License (OSMC-PL) are obtained from OSMC, either from the above
+ * address, from the URLs: http://www.openmodelica.org or
+ * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica
+ * distribution. GNU version 3 is obtained from:
+ * http://www.gnu.org/copyleft/gpl.html. The New BSD License is obtained from:
+ * http://www.opensource.org/licenses/BSD-3-Clause.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS
+ * EXPRESSLY SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE
+ * CONDITIONS OF OSMC-PL.
+ *
+ */
+
+/*
+ * Adrian Pop [Adrian.Pop@liu.se]
+ * This file defines the MetaModelica garbage collector (GC) interface
+ * We use Boehm GC mark-and-sweep collector.
+ *
+ *
+ */
+
+#ifndef OMC_GC_H_
+#define OMC_GC_H_
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#include <stdlib.h>
+#if !defined(OMC_NO_THREADS)
+#include <pthread.h>
+#endif
+#include <setjmp.h>
+
+#if defined(_MSC_VER)
+#include "omc_inline.h"
+#endif
+
+typedef struct {
+  void (*init)(void);
+  void* (*malloc)(size_t);
+  void* (*malloc_atomic)(size_t);
+  char* (*malloc_string)(size_t);
+  char* (*malloc_strdup)(const char*);
+  int (*collect_a_little)(void);
+  void* (*malloc_uncollectable)(size_t);
+  void (*free_uncollectable)(void*);
+  void* (*malloc_string_persist)(size_t);
+  void (*free_string_persist)(void*);
+} omc_alloc_interface_t;
+
+extern omc_alloc_interface_t omc_alloc_interface;
+extern omc_alloc_interface_t omc_alloc_interface_pooled;
+
+/*
+ * ERROR_STAGE defines different
+ * stages where an assertion can be triggered.
+ *
+ */
+typedef enum {
+  ERROR_UNKOWN = 0,
+  ERROR_SIMULATION,
+  ERROR_INTEGRATOR,
+  ERROR_NONLINEARSOLVER,
+  ERROR_EVENTSEARCH,
+  ERROR_EVENTHANDLING,
+  ERROR_OPTIMIZE,
+  ERROR_MAX
+} errorStage;
+
+typedef void (*PlotCallback)(void*, int externalWindow, const char* filename, const char* title, const char* grid, const char* plotType, const char* logX,
+    const char* logY, const char* xLabel, const char* yLabel, const char* x1, const char* x2, const char* y1, const char* y2,
+    const char* curveWidth, const char* curveStyle, const char* legendPosition, const char* footer, const char* autoScale,
+    const char* variables);
+
+/* Thread-specific data passed around in most functions.
+ * It is also possible to fetch it using pthread_getspecific (mostly for external functions that were not passed the pointer) */
+enum {
+  LOCAL_ROOT_USER_DEFINED_0,
+  LOCAL_ROOT_USER_DEFINED_1,
+  LOCAL_ROOT_USER_DEFINED_2,
+  LOCAL_ROOT_USER_DEFINED_3,
+  LOCAL_ROOT_USER_DEFINED_4,
+  LOCAL_ROOT_USER_DEFINED_5,
+  LOCAL_ROOT_USER_DEFINED_6,
+  LOCAL_ROOT_USER_DEFINED_7,
+  LOCAL_ROOT_USER_DEFINED_8,
+  LOCAL_ROOT_ERROR_MO,
+  LOCAL_ROOT_PRINT_MO,
+  LOCAL_ROOT_SYSTEM_MO,
+  LOCAL_ROOT_STACK_OVERFLOW,
+  MAX_LOCAL_ROOTS
+};
+#define MAX_LOCAL_ROOTS 16
+
+typedef struct threadData_s {
+  jmp_buf *mmc_jumper;
+  jmp_buf *mmc_stack_overflow_jumper;
+  jmp_buf *mmc_thread_work_exit;
+  void *localRoots[MAX_LOCAL_ROOTS];
+/*
+ * simulationJumpBufer:
+ *  Jump-buffer to handle simulation error
+ *  like asserts or divisions by zero.
+ *
+ * currentJumpStage:
+ *   define which simulation jump buffer
+ *   is currently used.
+ */
+  jmp_buf *globalJumpBuffer;
+  jmp_buf *simulationJumpBuffer;
+  errorStage currentErrorStage;
+  struct threadData_s *parent;
+#if !defined(OMC_NO_THREADS)
+  pthread_mutex_t parentMutex; /* Prevent children from all manipulating the parent at the same time */
+#endif
+  void *plotClassPointer;
+  PlotCallback plotCB;
+  void *stackBottom; /* Actually offset 64 kB from bottom, just to never reach the bottom */
+} threadData_t;
+
+typedef threadData_t* OpenModelica_threadData_ThreadData;
+
+#if (defined(OMC_MINIMAL_RUNTIME) || defined(OMC_FMI_RUNTIME))
+
+#if !defined(OMC_NO_GC_MAPPING)
+#define GC_init                           omc_alloc_interface_pooled.init
+#define GC_malloc                         omc_alloc_interface_pooled.malloc
+#define GC_malloc_atomic                  omc_alloc_interface_pooled.malloc_atomic
+#define GC_strdup                         omc_alloc_interface_pooled.malloc_strdup
+#define GC_collect_a_little_or_not        omc_alloc_interface_pooled.collect_a_little
+#define GC_malloc_uncollectable           omc_alloc_interface_pooled.malloc_uncollectable
+#define GC_free                           omc_alloc_interface_pooled.free_uncollectable
+#define nofree                            omc_alloc_interface_pooled.free_string_persist
+#define GC_malloc_atomic_ignore_off_page  omc_alloc_interface_pooled.malloc_atomic
+#define GC_register_displacement          /* nothing */
+#define GC_set_force_unmap_on_gcollect    /* nothing */
+#endif
+
+#else /* #if (defined(OMC_MINIMAL_RUNTIME) || defined(OMC_FMI_RUNTIME)) */
+
+#include <gc.h>
+/* gc.h doesn't include this by default; and the actual header redirects dlopen, which does not have an implementation */
+int GC_pthread_create(pthread_t *,const pthread_attr_t *,void *(*)(void *), void *);
+int GC_pthread_join(pthread_t, void **);
+
+#endif /* #if (defined(OMC_MINIMAL_RUNTIME) || defined(OMC_FMI_RUNTIME)) */
+
+#include "openmodelica_types.h"
+
+/* global roots size */
+#define MMC_GC_GLOBAL_ROOTS_SIZE 1024
+
+struct mmc_GC_state_type /* the structure of GC state */
+{
+  modelica_metatype       global_roots[MMC_GC_GLOBAL_ROOTS_SIZE]; /* the global roots ! */
+};
+typedef struct mmc_GC_state_type mmc_GC_state_type;
+extern mmc_GC_state_type* mmc_GC_state;
+
+/* tag the free reqion as a free object with 250 ctor*/
+#define MMC_FREE_OBJECT_CTOR           200
+#define MMC_TAG_AS_FREE_OBJECT(p, sz)  (((struct mmc_header*)p)->header = MMC_STRUCTHDR(sz, MMC_FREE_OBJECT_CTOR))
+
+#if !defined(OMC_NO_GC_MAPPING)
+static inline void mmc_GC_init(void)
+{
+  GC_init();
+  GC_register_displacement(0);
+#ifdef RML_STYLE_TAGPTR
+  GC_register_displacement(3);
+#endif
+  GC_set_force_unmap_on_gcollect(1);
+}
+
+static inline void mmc_GC_init_default(void)
+{
+  mmc_GC_init();
+}
+
+#define mmc_GC_clear(void)
+#define mmc_GC_collect(local_GC_state)
+
+#if defined(OMC_RECORD_ALLOC_WORDS)
+void mmc_record_alloc_words(size_t n);
+void mmc_set_current_pos(const char *str);
+#endif
+
+static inline void* mmc_alloc_words_atomic(unsigned int nwords) {
+#if defined(OMC_RECORD_ALLOC_WORDS)
+  mmc_record_alloc_words((nwords) * sizeof(void*));
+#endif
+  return GC_malloc_atomic((nwords) * sizeof(void*));
+}
+
+static inline void* mmc_alloc_words(unsigned int nwords) {
+#if defined(OMC_RECORD_ALLOC_WORDS)
+  mmc_record_alloc_words((nwords) * sizeof(void*));
+#endif
+  return GC_malloc((nwords) * sizeof(void*));
+}
+
+/* for arrays only */
+static inline void* mmc_alloc_words_atomic_ignore_off_page(unsigned int nwords) {
+#if defined(OMC_RECORD_ALLOC_WORDS)
+  mmc_record_alloc_words((nwords) * sizeof(void*));
+#endif
+  return GC_malloc_atomic_ignore_off_page((nwords) * sizeof(void*));
+}
+
+/* for arrays only */
+static inline void* mmc_alloc_words_ignore_off_page(unsigned int nwords) {
+#if defined(OMC_RECORD_ALLOC_WORDS)
+  mmc_record_alloc_words((nwords) * sizeof(void*));
+#endif
+  return GC_malloc_atomic_ignore_off_page((nwords) * sizeof(void*));
+}
+#endif
+
+
+#include "memory_pool.h"
+
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* #define OMC_GC_H_ */

+ 390 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/gc_config_macros.h

@@ -0,0 +1,390 @@
+/*
+ * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.
+ * Copyright (c) 1996 by Silicon Graphics.  All rights reserved.
+ * Copyright (c) 1998 by Fergus Henderson.  All rights reserved.
+ * Copyright (c) 2000-2009 by Hewlett-Packard Development Company.
+ * All rights reserved.
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose,  provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+/* This should never be included directly; it is included only from gc.h. */
+/* We separate it only to make gc.h more suitable as documentation.       */
+#if defined(GC_H)
+
+/* Some tests for old macros.  These violate our namespace rules and    */
+/* will disappear shortly.  Use the GC_ names.                          */
+#if defined(SOLARIS_THREADS) || defined(_SOLARIS_THREADS) \
+    || defined(_SOLARIS_PTHREADS) || defined(GC_SOLARIS_PTHREADS)
+  /* We no longer support old style Solaris threads.            */
+  /* GC_SOLARIS_THREADS now means pthreads.                     */
+# ifndef GC_SOLARIS_THREADS
+#   define GC_SOLARIS_THREADS
+# endif
+#endif
+#if defined(IRIX_THREADS)
+# define GC_IRIX_THREADS
+#endif
+#if defined(DGUX_THREADS) && !defined(GC_DGUX386_THREADS)
+# define GC_DGUX386_THREADS
+#endif
+#if defined(AIX_THREADS)
+# define GC_AIX_THREADS
+#endif
+#if defined(HPUX_THREADS)
+# define GC_HPUX_THREADS
+#endif
+#if defined(OSF1_THREADS)
+# define GC_OSF1_THREADS
+#endif
+#if defined(LINUX_THREADS)
+# define GC_LINUX_THREADS
+#endif
+#if defined(WIN32_THREADS)
+# define GC_WIN32_THREADS
+#endif
+#if defined(RTEMS_THREADS)
+# define GC_RTEMS_PTHREADS
+#endif
+#if defined(USE_LD_WRAP)
+# define GC_USE_LD_WRAP
+#endif
+
+#if defined(GC_WIN32_PTHREADS) && !defined(GC_WIN32_THREADS)
+  /* Using pthreads-win32 library (or other Win32 implementation).  */
+# define GC_WIN32_THREADS
+#endif
+
+#if defined(GC_AIX_THREADS) || defined(GC_DARWIN_THREADS) \
+    || defined(GC_DGUX386_THREADS) || defined(GC_FREEBSD_THREADS) \
+    || defined(GC_GNU_THREADS) || defined(GC_HPUX_THREADS) \
+    || defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) \
+    || defined(GC_NETBSD_THREADS) || defined(GC_OPENBSD_THREADS) \
+    || defined(GC_OSF1_THREADS) || defined(GC_SOLARIS_THREADS) \
+    || defined(GC_WIN32_THREADS) || defined(GC_RTEMS_PTHREADS)
+# ifndef GC_THREADS
+#   define GC_THREADS
+# endif
+#elif defined(GC_THREADS)
+# if defined(__linux__)
+#   define GC_LINUX_THREADS
+# endif
+# if !defined(__linux__) && (defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
+                             || defined(hppa) || defined(__HPPA)) \
+     || (defined(__ia64) && defined(_HPUX_SOURCE))
+#   define GC_HPUX_THREADS
+# endif
+# if !defined(__linux__) && (defined(__alpha) || defined(__alpha__))
+#   define GC_OSF1_THREADS
+# endif
+# if defined(__mips) && !defined(__linux__)
+#   define GC_IRIX_THREADS
+# endif
+# if defined(__sparc) && !defined(__linux__) \
+     || defined(sun) && (defined(i386) || defined(__i386__) \
+                         || defined(__amd64__))
+#   define GC_SOLARIS_THREADS
+# elif defined(__APPLE__) && defined(__MACH__)
+#   define GC_DARWIN_THREADS
+# elif defined(__OpenBSD__)
+#   define GC_OPENBSD_THREADS
+# elif !defined(GC_LINUX_THREADS) && !defined(GC_HPUX_THREADS) \
+       && !defined(GC_OSF1_THREADS) && !defined(GC_IRIX_THREADS)
+    /* FIXME: Should we really need for FreeBSD and NetBSD to check     */
+    /* that no other GC_xxx_THREADS macro is set?                       */
+#   if defined(__FreeBSD__) || defined(__DragonFly__)
+#     define GC_FREEBSD_THREADS
+#   elif defined(__NetBSD__)
+#     define GC_NETBSD_THREADS
+#   endif
+# endif
+# if defined(DGUX) && (defined(i386) || defined(__i386__))
+#   define GC_DGUX386_THREADS
+# endif
+# if defined(_AIX)
+#   define GC_AIX_THREADS
+# endif
+# if (defined(_WIN32) || defined(_MSC_VER) || defined(__BORLANDC__) \
+      || defined(__CYGWIN32__) || defined(__CYGWIN__) || defined(__CEGCC__) \
+      || defined(_WIN32_WCE) || defined(__MINGW32__)) \
+     && !defined(GC_WIN32_THREADS)
+    /* Either posix or native Win32 threads. */
+#   define GC_WIN32_THREADS
+# endif
+# if defined(__rtems__) && (defined(i386) || defined(__i386__))
+#   define GC_RTEMS_PTHREADS
+# endif
+#endif /* GC_THREADS */
+
+#undef GC_PTHREADS
+#if (!defined(GC_WIN32_THREADS) || defined(GC_WIN32_PTHREADS) \
+     || defined(__CYGWIN32__) || defined(__CYGWIN__)) && defined(GC_THREADS)
+  /* Posix threads. */
+# define GC_PTHREADS
+#endif
+
+#if !defined(_PTHREADS) && defined(GC_NETBSD_THREADS)
+# define _PTHREADS
+#endif
+
+#if defined(GC_DGUX386_THREADS) && !defined(_POSIX4A_DRAFT10_SOURCE)
+# define _POSIX4A_DRAFT10_SOURCE 1
+#endif
+
+#if !defined(_REENTRANT) && defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
+  /* Better late than never.  This fails if system headers that depend  */
+  /* on this were previously included.                                  */
+# define _REENTRANT
+#endif
+
+#define __GC
+#if !defined(_WIN32_WCE) || defined(__GNUC__)
+# include <stddef.h>
+# if defined(__MINGW32__) && !defined(_WIN32_WCE)
+#   include <stdint.h>
+    /* We mention uintptr_t.                                            */
+    /* Perhaps this should be included in pure msft environments        */
+    /* as well?                                                         */
+# endif
+#else /* _WIN32_WCE */
+  /* Yet more kludges for WinCE.        */
+# include <stdlib.h> /* size_t is defined here */
+# ifndef _PTRDIFF_T_DEFINED
+    /* ptrdiff_t is not defined */
+#   define _PTRDIFF_T_DEFINED
+    typedef long ptrdiff_t;
+# endif
+#endif /* _WIN32_WCE */
+
+#if !defined(GC_NOT_DLL) && !defined(GC_DLL) \
+    && ((defined(_DLL) && !defined(__GNUC__)) \
+        || (defined(DLL_EXPORT) && defined(GC_BUILD)))
+# define GC_DLL
+#endif
+
+#if defined(GC_DLL) && !defined(GC_API)
+
+# if defined(__MINGW32__) || defined(__CEGCC__)
+#   if defined(GC_BUILD) || defined(__MINGW32_DELAY_LOAD__)
+#     define GC_API __declspec(dllexport)
+#   else
+#     define GC_API __declspec(dllimport)
+#   endif
+
+# elif defined(_MSC_VER) || defined(__DMC__) || defined(__BORLANDC__) \
+        || defined(__CYGWIN__)
+#   ifdef GC_BUILD
+#     define GC_API extern __declspec(dllexport)
+#   else
+#     define GC_API __declspec(dllimport)
+#   endif
+
+# elif defined(__WATCOMC__)
+#   ifdef GC_BUILD
+#     define GC_API extern __declspec(dllexport)
+#   else
+#     define GC_API extern __declspec(dllimport)
+#   endif
+
+# elif defined(__SYMBIAN32__)
+#   ifdef GC_BUILD
+#     define GC_API extern EXPORT_C
+#   else
+#     define GC_API extern IMPORT_C
+#   endif
+
+# elif defined(__GNUC__)
+    /* Only matters if used in conjunction with -fvisibility=hidden option. */
+#   if defined(GC_BUILD) && !defined(GC_NO_VISIBILITY) \
+            && (__GNUC__ >= 4 || defined(GC_VISIBILITY_HIDDEN_SET))
+#     define GC_API extern __attribute__((__visibility__("default")))
+#   endif
+# endif
+#endif /* GC_DLL */
+
+#ifndef GC_API
+# define GC_API extern
+#endif
+
+#ifndef GC_CALL
+# define GC_CALL
+#endif
+
+#ifndef GC_CALLBACK
+# define GC_CALLBACK GC_CALL
+#endif
+
+#ifndef GC_ATTR_MALLOC
+  /* 'malloc' attribute should be used for all malloc-like functions    */
+  /* (to tell the compiler that a function may be treated as if any     */
+  /* non-NULL pointer it returns cannot alias any other pointer valid   */
+  /* when the function returns).  If the client code violates this rule */
+  /* by using custom GC_oom_func then define GC_OOM_FUNC_RETURNS_ALIAS. */
+# ifdef GC_OOM_FUNC_RETURNS_ALIAS
+#   define GC_ATTR_MALLOC /* empty */
+# elif defined(__GNUC__) && (__GNUC__ > 3 \
+                             || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
+#   define GC_ATTR_MALLOC __attribute__((__malloc__))
+# elif defined(_MSC_VER) && _MSC_VER >= 14
+#   define GC_ATTR_MALLOC __declspec(noalias) __declspec(restrict)
+# else
+#   define GC_ATTR_MALLOC
+# endif
+#endif
+
+#ifndef GC_ATTR_ALLOC_SIZE
+  /* 'alloc_size' attribute improves __builtin_object_size correctness. */
+  /* Only single-argument form of 'alloc_size' attribute is used.       */
+# ifdef __clang__
+#   if __has_attribute(__alloc_size__)
+#     define GC_ATTR_ALLOC_SIZE(argnum) __attribute__((__alloc_size__(argnum)))
+#   else
+#     define GC_ATTR_ALLOC_SIZE(argnum) /* empty */
+#   endif
+# elif __GNUC__ > 4 \
+       || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 && !defined(__ICC))
+#   define GC_ATTR_ALLOC_SIZE(argnum) __attribute__((__alloc_size__(argnum)))
+# else
+#   define GC_ATTR_ALLOC_SIZE(argnum) /* empty */
+# endif
+#endif
+
+#ifndef GC_ATTR_NONNULL
+# if defined(__GNUC__) && __GNUC__ >= 4
+#   define GC_ATTR_NONNULL(argnum) __attribute__((__nonnull__(argnum)))
+# else
+#   define GC_ATTR_NONNULL(argnum) /* empty */
+# endif
+#endif
+
+#ifndef GC_ATTR_DEPRECATED
+# ifdef GC_BUILD
+#   undef GC_ATTR_DEPRECATED
+#   define GC_ATTR_DEPRECATED /* empty */
+# elif defined(__GNUC__) && __GNUC__ >= 4
+#   define GC_ATTR_DEPRECATED __attribute__((__deprecated__))
+# elif defined(_MSC_VER) && _MSC_VER >= 12
+#   define GC_ATTR_DEPRECATED __declspec(deprecated)
+# else
+#   define GC_ATTR_DEPRECATED /* empty */
+# endif
+#endif
+
+#if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION >= 720
+# define GC_ADD_CALLER
+# define GC_RETURN_ADDR (GC_word)__return_address
+#endif
+
+#if defined(__linux__) || defined(__GLIBC__)
+# if !defined(__native_client__)
+#   include <features.h>
+# endif
+# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
+        && !defined(__ia64__) && !defined(__UCLIBC__) \
+        && !defined(GC_HAVE_BUILTIN_BACKTRACE)
+#   define GC_HAVE_BUILTIN_BACKTRACE
+# endif
+# if defined(__i386__) || defined(__amd64__) || defined(__x86_64__)
+#   define GC_CAN_SAVE_CALL_STACKS
+# endif
+#endif /* GLIBC */
+
+#if defined(_MSC_VER) && _MSC_VER >= 1200 /* version 12.0+ (MSVC 6.0+) */ \
+        && !defined(_AMD64_) && !defined(_M_X64) && !defined(_WIN32_WCE) \
+        && !defined(GC_HAVE_NO_BUILTIN_BACKTRACE) \
+        && !defined(GC_HAVE_BUILTIN_BACKTRACE)
+# define GC_HAVE_BUILTIN_BACKTRACE
+#endif
+
+#if defined(GC_HAVE_BUILTIN_BACKTRACE) && !defined(GC_CAN_SAVE_CALL_STACKS)
+# define GC_CAN_SAVE_CALL_STACKS
+#endif
+
+#if defined(__sparc__)
+# define GC_CAN_SAVE_CALL_STACKS
+#endif
+
+/* If we're on a platform on which we can't save call stacks, but       */
+/* gcc is normally used, we go ahead and define GC_ADD_CALLER.          */
+/* We make this decision independent of whether gcc is actually being   */
+/* used, in order to keep the interface consistent, and allow mixing    */
+/* of compilers.                                                        */
+/* This may also be desirable if it is possible but expensive to        */
+/* retrieve the call chain.                                             */
+#if (defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) \
+     || defined(__FreeBSD__) || defined(__DragonFly__) \
+     || defined(PLATFORM_ANDROID) || defined(__ANDROID__)) \
+    && !defined(GC_CAN_SAVE_CALL_STACKS)
+# define GC_ADD_CALLER
+# if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
+    /* gcc knows how to retrieve return address, but we don't know      */
+    /* how to generate call stacks.                                     */
+#   define GC_RETURN_ADDR (GC_word)__builtin_return_address(0)
+#   if (__GNUC__ >= 4) && (defined(__i386__) || defined(__amd64__) \
+        || defined(__x86_64__) /* and probably others... */)
+#     define GC_RETURN_ADDR_PARENT \
+        (GC_word)__builtin_extract_return_addr(__builtin_return_address(1))
+#   endif
+# else
+    /* Just pass 0 for gcc compatibility.       */
+#   define GC_RETURN_ADDR 0
+# endif
+#endif /* !GC_CAN_SAVE_CALL_STACKS */
+
+#ifdef GC_PTHREADS
+
+# if (defined(GC_DARWIN_THREADS) || defined(GC_WIN32_PTHREADS) \
+      || defined(__native_client__) || defined(GC_RTEMS_PTHREADS)) \
+      && !defined(GC_NO_DLOPEN)
+    /* Either there is no dlopen() or we do not need to intercept it.   */
+#   define GC_NO_DLOPEN
+# endif
+
+# if (defined(GC_DARWIN_THREADS) || defined(GC_WIN32_PTHREADS) \
+      || defined(GC_OPENBSD_THREADS) || defined(__native_client__)) \
+     && !defined(GC_NO_PTHREAD_SIGMASK)
+    /* Either there is no pthread_sigmask() or no need to intercept it. */
+#   define GC_NO_PTHREAD_SIGMASK
+# endif
+
+# if defined(__native_client__)
+    /* At present, NaCl pthread_create() prototype does not have        */
+    /* "const" for its "attr" argument; also, NaCl pthread_exit() one   */
+    /* does not have "noreturn" attribute.                              */
+#   ifndef GC_PTHREAD_CREATE_CONST
+#     define GC_PTHREAD_CREATE_CONST /* empty */
+#   endif
+#   ifndef GC_PTHREAD_EXIT_ATTRIBUTE
+#     define GC_PTHREAD_EXIT_ATTRIBUTE /* empty */
+#   endif
+# endif
+
+# if !defined(GC_PTHREAD_EXIT_ATTRIBUTE) \
+     && !defined(PLATFORM_ANDROID) && !defined(__ANDROID__) \
+     && (defined(GC_LINUX_THREADS) || defined(GC_SOLARIS_THREADS))
+    /* Intercept pthread_exit on Linux and Solaris.     */
+#   if defined(__GNUC__) /* since GCC v2.7 */
+#     define GC_PTHREAD_EXIT_ATTRIBUTE __attribute__((__noreturn__))
+#   elif defined(__NORETURN) /* used in Solaris */
+#     define GC_PTHREAD_EXIT_ATTRIBUTE __NORETURN
+#   else
+#     define GC_PTHREAD_EXIT_ATTRIBUTE /* empty */
+#   endif
+# endif
+
+# if (!defined(GC_PTHREAD_EXIT_ATTRIBUTE) || defined(__native_client__)) \
+     && !defined(GC_NO_PTHREAD_CANCEL)
+    /* Either there is no pthread_cancel() or no need to intercept it.  */
+#   define GC_NO_PTHREAD_CANCEL
+# endif
+
+#endif /* GC_PTHREADS */
+
+#endif

+ 101 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/gc_pthread_redirects.h

@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.
+ * Copyright (c) 1996 by Silicon Graphics.  All rights reserved.
+ * Copyright (c) 1998 by Fergus Henderson.  All rights reserved.
+ * Copyright (c) 2000-2010 by Hewlett-Packard Development Company.
+ * All rights reserved.
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose,  provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+/* Our pthread support normally needs to intercept a number of thread   */
+/* calls.  We arrange to do that here, if appropriate.                  */
+
+/* Included from gc.h only.  Included only if GC_PTHREADS.              */
+#if defined(GC_H) && defined(GC_PTHREADS)
+
+/* We need to intercept calls to many of the threads primitives, so     */
+/* that we can locate thread stacks and stop the world.                 */
+/* Note also that the collector cannot always see thread specific data. */
+/* Thread specific data should generally consist of pointers to         */
+/* uncollectible objects (allocated with GC_malloc_uncollectable,       */
+/* not the system malloc), which are deallocated using the destructor   */
+/* facility in thr_keycreate.  Alternatively, keep a redundant pointer  */
+/* to thread specific data on the thread stack.                         */
+
+#ifndef GC_PTHREAD_REDIRECTS_ONLY
+# include <pthread.h>
+
+# ifndef GC_SUSPEND_THREAD_ID
+#   define GC_SUSPEND_THREAD_ID pthread_t
+# endif
+
+# ifndef GC_NO_DLOPEN
+#   include <dlfcn.h>
+    GC_API void *GC_dlopen(const char * /* path */, int /* mode */);
+# endif /* !GC_NO_DLOPEN */
+
+# ifndef GC_NO_PTHREAD_SIGMASK
+#   include <signal.h>
+    GC_API int GC_pthread_sigmask(int /* how */, const sigset_t *,
+                                  sigset_t * /* oset */);
+# endif /* !GC_NO_PTHREAD_SIGMASK */
+
+# ifndef GC_PTHREAD_CREATE_CONST
+    /* This is used for pthread_create() only.    */
+#   define GC_PTHREAD_CREATE_CONST const
+# endif
+
+  GC_API int GC_pthread_create(pthread_t *,
+                               GC_PTHREAD_CREATE_CONST pthread_attr_t *,
+                               void *(*)(void *), void * /* arg */);
+  GC_API int GC_pthread_join(pthread_t, void ** /* retval */);
+  GC_API int GC_pthread_detach(pthread_t);
+
+# ifndef GC_NO_PTHREAD_CANCEL
+    GC_API int GC_pthread_cancel(pthread_t);
+# endif
+
+# if defined(GC_PTHREAD_EXIT_ATTRIBUTE) && !defined(GC_PTHREAD_EXIT_DECLARED)
+#   define GC_PTHREAD_EXIT_DECLARED
+    GC_API void GC_pthread_exit(void *) GC_PTHREAD_EXIT_ATTRIBUTE;
+# endif
+#endif /* !GC_PTHREAD_REDIRECTS_ONLY */
+
+#if !defined(GC_NO_THREAD_REDIRECTS) && !defined(GC_USE_LD_WRAP)
+  /* Unless the compiler supports #pragma extern_prefix, the Tru64      */
+  /* UNIX <pthread.h> redefines some POSIX thread functions to use      */
+  /* mangled names.  Anyway, it's safe to undef them before redefining. */
+# undef pthread_create
+# undef pthread_join
+# undef pthread_detach
+# define pthread_create GC_pthread_create
+# define pthread_join GC_pthread_join
+# define pthread_detach GC_pthread_detach
+
+# ifndef GC_NO_PTHREAD_SIGMASK
+#   undef pthread_sigmask
+#   define pthread_sigmask GC_pthread_sigmask
+# endif
+# ifndef GC_NO_DLOPEN
+#   undef dlopen
+#   define dlopen GC_dlopen
+# endif
+# ifndef GC_NO_PTHREAD_CANCEL
+#   undef pthread_cancel
+#   define pthread_cancel GC_pthread_cancel
+# endif
+# ifdef GC_PTHREAD_EXIT_ATTRIBUTE
+#   undef pthread_exit
+#   define pthread_exit GC_pthread_exit
+# endif
+#endif /* !GC_NO_THREAD_REDIRECTS */
+
+#endif /* GC_PTHREADS */

+ 47 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/gc_version.h

@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.
+ * Copyright (c) 1996 by Silicon Graphics.  All rights reserved.
+ * Copyright (c) 1998 by Fergus Henderson.  All rights reserved.
+ * Copyright (c) 2000-2009 by Hewlett-Packard Development Company.
+ * All rights reserved.
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose,  provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+/* This should never be included directly; it is included only from gc.h. */
+#if defined(GC_H)
+
+/* The policy regarding version numbers: development code has odd       */
+/* "minor" number (and "micro" part is 0); when development is finished */
+/* and a release is prepared, "minor" number is incremented (keeping    */
+/* "micro" number still zero), whenever a defect is fixed a new release */
+/* is prepared incrementing "micro" part to odd value (the most stable  */
+/* release has the biggest "micro" number).                             */
+
+/* The version here should match that in configure/configure.ac */
+/* Eventually this one may become unnecessary.  For now we need */
+/* it to keep the old-style build process working.              */
+#define GC_TMP_VERSION_MAJOR 7
+#define GC_TMP_VERSION_MINOR 5
+#define GC_TMP_VERSION_MICRO 0 /* 7.5.0 */
+
+#ifdef GC_VERSION_MAJOR
+# if GC_TMP_VERSION_MAJOR != GC_VERSION_MAJOR \
+     || GC_TMP_VERSION_MINOR != GC_VERSION_MINOR \
+     || GC_TMP_VERSION_MICRO != GC_VERSION_MICRO
+#   error Inconsistent version info.  Check README.md, include/gc_version.h and configure.ac.
+# endif
+#else
+# define GC_VERSION_MAJOR GC_TMP_VERSION_MAJOR
+# define GC_VERSION_MINOR GC_TMP_VERSION_MINOR
+# define GC_VERSION_MICRO GC_TMP_VERSION_MICRO
+#endif /* !GC_VERSION_MAJOR */
+
+#endif

+ 55 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/linearization/linearize.h

@@ -0,0 +1,55 @@
+/*
+ * This file is part of OpenModelica.
+ *
+ * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
+ * c/o Linköpings universitet, Department of Computer and Information Science,
+ * SE-58183 Linköping, Sweden.
+ *
+ * All rights reserved.
+ *
+ * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE
+ * GPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
+ * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
+ * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
+ * ACCORDING TO RECIPIENTS CHOICE.
+ *
+ * The OpenModelica software and the OSMC (Open Source Modelica Consortium)
+ * Public License (OSMC-PL) are obtained from OSMC, either from the above
+ * address, from the URLs: http://www.openmodelica.org or
+ * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica
+ * distribution. GNU version 3 is obtained from:
+ * http://www.gnu.org/copyleft/gpl.html. The New BSD License is obtained from:
+ * http://www.opensource.org/licenses/BSD-3-Clause.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS
+ * EXPRESSLY SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE
+ * CONDITIONS OF OSMC-PL.
+ *
+ */
+
+#ifndef _LINEARIZE
+#define _LINEARIZE
+
+#include "simulation_data.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int linearize(DATA* data, threadData_t *threadData);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*int argc, char** argv, string method, double start,
+//double stop, double stepSize , long outputSteps, double tolerance);
+
+// dummy
+//int linear_model_frame(string& out, string A, string x_startvalues, string u_startvalues);
+//{
+//  return 0;
+//}
+*/
+#endif

+ 140 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/math-support/pivot.c

@@ -0,0 +1,140 @@
+/* pivot.c
+ provides a simple function to do a full pivot search while doing an LU factorization
+*/
+
+#include <math.h>
+#include <assert.h>
+#include "openmodelica.h"
+
+/* Matrixes using column major order (as in Fortran) */
+#ifndef set_matrix_elt
+#define set_matrix_elt(A,r,c,n_rows,value) A[r + n_rows * c] = value
+#endif
+
+#ifndef get_matrix_elt
+#define get_matrix_elt(A,r,c,n_rows) A[r + n_rows * c]
+#endif
+
+
+/* Matrixes using column major order (as in Fortran) */
+/* colInd, rowInd, n_rows is added implicitly, makes code easier to read but may be considered bad programming style! */
+#define set_pivot_matrix_elt(A,r,c,value) set_matrix_elt(A,rowInd[r],colInd[c],n_rows,value)
+/* #define set_pivot_matrix_elt(A,r,c,value) set_matrix_elt(A,colInd[c],rowInd[r],n_cols,value) */
+#define get_pivot_matrix_elt(A,r,c) get_matrix_elt(A,rowInd[r],colInd[c],n_rows)
+/* #define get_pivot_matrix_elt(A,r,c) get_matrix_elt(A,colInd[c],rowInd[r],n_cols) */
+#define swap(a,b) { modelica_integer _swap=a; a=b; b=_swap; }
+
+#ifndef min
+#define min(a,b) ((a > b) ? (b) : (a))
+#endif
+
+/*
+find the maximum element below (and including) line/row start
+*/
+int maxsearch( double *A, modelica_integer start, modelica_integer n_rows, modelica_integer n_cols, modelica_integer *rowInd, modelica_integer *colInd, modelica_integer *maxrow, modelica_integer *maxcol, double *maxabsval)
+{
+  /* temporary variables */
+  modelica_integer row;
+  modelica_integer col;
+
+  /* Initialization */
+  modelica_integer mrow = -1;
+  modelica_integer mcol = -1;
+  double mabsval = 0.0;
+
+  /* go through all rows and columns */
+  for(row=start; row<n_rows; row++)
+  {
+    for(col=start; col<n_cols; col++)
+    {
+      double tmp = fabs(get_pivot_matrix_elt(A,row,col));
+      /* Compare element to current maximum */
+      if (tmp > mabsval)
+      {
+        mrow = row;
+        mcol = col;
+        mabsval = tmp;
+      }
+    }
+  }
+
+  /* assert that the matrix is not identical to zero */
+  if ((mrow < 0) || (mcol < 0)) return -1;
+
+  /* return result */
+  *maxrow = mrow;
+  *maxcol = mcol;
+  *maxabsval = mabsval;
+  return 0;
+}
+
+
+
+/*
+pivot performs a full pivotization of a rectangular matrix A of dimension n_cols x n_rows
+rowInd and colInd are vectors of length nrwos and n_cols respectively.
+They hold the old (and new) pivoting information, such that
+  A_pivoted[i,j] = A[rowInd[i], colInd[j]]
+*/
+int pivot( double *A, modelica_integer n_rows, modelica_integer n_cols, modelica_integer *rowInd, modelica_integer *colInd )
+{
+  /* parameter, determines how much larger an element should be before rows and columns are interchanged */
+  const double fac = 1.125; /* approved by dymola ;) */
+
+  /* temporary variables */
+  modelica_integer row;
+  modelica_integer i,j;
+  modelica_integer maxrow;
+  modelica_integer maxcol;
+  double maxabsval;
+  double pivot;
+
+  /* go over all pivot elements */
+  for(row=0; row<min(n_rows,n_cols); row++)
+  {
+    /* get current pivot */
+    pivot = fabs(get_pivot_matrix_elt(A,row,row));
+
+    /* find the maximum element in matrix
+       result is stored in maxrow, maxcol and maxabsval */
+    if (maxsearch(A, row, n_rows, n_cols, rowInd, colInd, &maxrow, &maxcol, &maxabsval) != 0) return -1;
+
+
+    /* compare max element and pivot (scaled by fac) */
+    if (maxabsval > (fac*pivot))
+    {
+      /* row interchange */
+      swap(rowInd[row], rowInd[maxrow]);
+      /* column interchange */
+      swap(colInd[row], colInd[maxcol]);
+    }
+
+    /* get pivot (without abs, may have changed because of row/column interchange */
+    pivot = get_pivot_matrix_elt(A,row,row);
+    /* internal error, pivot element should never be zero if maxsearch succeeded */
+    assert(pivot != 0);
+
+    /* perform one step of Gaussian Elimination */
+    for(i=row+1;i<n_rows;i++)
+    {
+      double leader = get_pivot_matrix_elt(A,i,row);
+      if (leader != 0.0)
+      {
+        double scale = -leader/pivot;
+        /* set leader to zero */
+        set_pivot_matrix_elt(A,i,row, 0.0);
+        /* subtract scaled equation from pivot row from current row */
+        for(j=row+1;j<n_cols;j++)
+        {
+          double t1 = get_pivot_matrix_elt(A,i,j);
+          double t2 = get_pivot_matrix_elt(A,row,j);
+          double tmp = t1 + scale*t2;
+          set_pivot_matrix_elt(A,i,j, tmp);
+        }
+      }
+    }
+  }
+  /* all fine */
+  return 0;
+}
+

+ 0 - 0
SemanticAdaptationForFMI/Experiments/power_window_case_study/fmu20/fmu/cs/StategraphSample/sources/include/meta/meta_modelica.h


Some files were not shown because too many files changed in this diff