Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 4
Functions: -% 0 / 1 / 1
Branches: 0.0% 0 / 0 / 10

OMCompiler/SimulationRuntime/c/moo/strategies.h
Line Branch Exec Source
1 /*
2 * This file belongs to the OpenModelica Run-Time System
3 *
4 * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), c/o Linköpings
5 * universitet, Department of Computer and Information Science, SE-58183 Linköping, Sweden. All rights
6 * reserved.
7 *
8 * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE
9 * AGPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. ANY
10 * USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
11 * ACCEPTANCE OF THE BSD NEW LICENSE OR THE OSMC PUBLIC LICENSE OR THE AGPL
12 * VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
13 *
14 * The OpenModelica software and the OSMC (Open Source Modelica Consortium) Public License
15 * (OSMC-PL) are obtained from OSMC, either from the above address, from the URLs:
16 * http://www.openmodelica.org or https://github.com/OpenModelica/ or
17 * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica distribution. GNU
18 * AGPL version 3 is obtained from: https://www.gnu.org/licenses/licenses.html#GPL. The BSD NEW
19 * License is obtained from: http://www.opensource.org/licenses/BSD-3-Clause.
20 *
21 * This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY
23 * SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF
24 * OSMC-PL.
25 *
26 */
27
28 #ifndef MOO_OM_STRATEGIES_H
29 #define MOO_OM_STRATEGIES_H
30
31 #include "simulation/simulation_runtime.h"
32
33 #include <nlp/instances/gdop/gdop.h>
34
35 #include "info.h"
36
37 namespace OpenModelica {
38
39 struct AuxiliaryTrajectory {
40 Trajectory& trajectory;
41 InfoGDOP& info;
42 SOLVER_INFO* solver_info;
43 };
44
45 ✗ struct AuxiliaryControls {
46 const ControlTrajectory& controls;
47 InfoGDOP& info;
48 FixedVector<f64> u_interpolation;
49 };
50
51 void initialize_model(InfoGDOP& info);
52
53 ✗ class ConstantInitialization : public GDOP::Initialization {
54 public:
55 InfoGDOP& info;
56 ConstantInitialization(InfoGDOP& info);
57
58 std::unique_ptr<PrimalDualTrajectory> operator()(const GDOP::GDOP& gdop) override;
59 };
60
61 class Simulation : public GDOP::Simulation {
62 public:
63 InfoGDOP& info;
64 SOLVER_METHOD solver;
65
66 Simulation(InfoGDOP& info, SOLVER_METHOD solver);
67
68 std::unique_ptr<Trajectory> operator()(const ControlTrajectory& controls, const FixedVector<f64>& parameters,
69 int num_steps, f64 start_time, f64 stop_time, f64* x_start_values) override;
70 };
71
72 // TODO: OpenModelica::SimulationStep should not hold a simulation, but rather allocate all the structures in activate
73 // and deallocate them in reset, so we have minimal overhead (like solver_main())
74 class SimulationStep : public GDOP::SimulationStep {
75 public:
76 std::shared_ptr<Simulation> simulation;
77
78 SimulationStep(std::shared_ptr<Simulation> simulation);
79
80 void activate(const ControlTrajectory& controls_, const FixedVector<f64>& parameters_) override;
81 void reset() override;
82
83 std::unique_ptr<Trajectory> operator()(f64* x_start_values, f64 start_time, f64 stop_time) override;
84
85 private:
86 const ControlTrajectory* controls;
87 const FixedVector<f64>* parameters;
88 };
89
90 ✗ class MatEmitter : public GDOP::Emitter {
91 public:
92 InfoGDOP& info;
93
94 MatEmitter(InfoGDOP& info);
95
96 int operator()(const PrimalDualTrajectory& trajectory) override;
97 };
98
99 class NominalScalingFactory : public GDOP::ScalingFactory {
100 public:
101 InfoGDOP& info;
102
103 ✗ NominalScalingFactory(InfoGDOP& info) : info{info} {}
104
105 std::shared_ptr<NLP::Scaling> operator()(const GDOP::GDOP& gdop) override;
106 };
107
108 GDOP::Strategies default_strategies(InfoGDOP& info, GDOP::Problem& problem, bool use_moo_simulation);
109
110 } // namespace OpenModelica
111
112 #endif // MOO_OM_STRATEGIES_H
113