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 / 19
Functions: 0.0% 0 / 0 / 1
Branches: 0.0% 0 / 0 / 30

OMCompiler/SimulationRuntime/c/moo/main_opt.cpp
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 #include <base/fLGR.h>
29 #include <base/log.h>
30 #include <base/timing.h>
31 #include <base/mesh.h>
32
33 #include <nlp/solvers/ipopt/solver.h>
34 #include <nlp/instances/gdop/orchestrator.h>
35
36 #include "../simulation/options.h"
37 #include "problem.h"
38 #include "strategies.h"
39 #include "streamlog.h"
40
41 #ifndef NO_INTERACTIVE_DEPENDENCY
42 #include "simulation/socket.h"
43 extern Socket sim_communication_port;
44 #endif
45
46 using namespace OpenModelica;
47
48 /* entry point to the optimization runtime from OpenModelica generated code
49 * this contains the glue code between MOO and the simulation runtime */
50 extern "C"
51 ✗ int _main_OptimizationRuntime(int argc, char** argv, DATA* data, threadData_t* threadData) {
52 {
53 ✗ ScopedTimer timer("Optimization Runtime");
54 ✗ create_set_logger();
55 ✗ auto info = InfoGDOP(data, threadData, argc, argv);
56 ✗ auto nlp_solver_settings = NLP::NLPSolverSettings(argc, argv);
57 ✗ info.set_omc_flags(nlp_solver_settings);
58 ✗ nlp_solver_settings.print();
59
60 ✗ auto mesh = Mesh::create_equidistant_fixed_stages(info.t0, info.tf, info.intervals, info.stages, MeshType::Physical);
61 ✗ auto problem = create_gdop(info, *mesh);
62 ✗ auto strategies = std::make_unique<GDOP::Strategies>(default_strategies(info, problem, false));
63 ✗ auto gdop = GDOP::GDOP(problem);
64
65 ✗ IpoptSolver::IpoptSolver ipopt_solver(gdop, nlp_solver_settings);
66
67 ✗ auto orchestrator = GDOP::MeshRefinementOrchestrator(gdop, std::move(strategies), ipopt_solver);
68
69 ✗ orchestrator.optimize();
70
71 ✗ communicateStatus("Finished", 1, info.tf, 0.0);
72 ✗ }
73 // TODO: if MOO VERBOSE
74 // TimingTree::instance().print_tree_table();
75
76 #ifndef NO_INTERACTIVE_DEPENDENCY
77 ✗ if(omc_flag[FLAG_PORT] /* should be the same as static sim_communication_port_open */)
78 {
79 ✗ sim_communication_port.close();
80 }
81 #endif
82
83 ✗ return 0;
84 }
85