Skip to content

Commit 5096e0b

Browse files
committed
Merge branch 'main' of git.ics.ele.tue.nl:computational-modeling/maxpluslib
2 parents 002dc75 + 659d841 commit 5096e0b

File tree

15 files changed

+137
-141
lines changed

15 files changed

+137
-141
lines changed

include/maxplus/base/analysis/mcm/mcmgraph.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#include "maxplus/base/basic_types.h"
4646
#include <memory>
4747

48-
4948
namespace MaxPlus::Graphs {
5049
class MCMnode;
5150

include/maxplus/base/fsm/fsm.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ class DetectCycle : public DepthFirstSearch {
471471
void onSimpleCycle(DfsStack &stack) override {
472472
if (!this->hasCycle) {
473473
if (this->cycle != nullptr) {
474-
for (const auto& si : stack) {
474+
for (const auto &si : stack) {
475475
this->cycle->push_back(si.getState());
476476
}
477477
}
@@ -771,7 +771,7 @@ class FiniteStateMachine : public Abstract::FiniteStateMachine {
771771

772772
Abstract::SetOfStateRefs getStateRefs() {
773773
Abstract::SetOfStateRefs result;
774-
for (const auto& i : this->states) {
774+
for (const auto &i : this->states) {
775775
result.insert(&(*(i.second)));
776776
}
777777
return result;
@@ -801,8 +801,8 @@ class FiniteStateMachine : public Abstract::FiniteStateMachine {
801801
};
802802

803803
void setEdgeLabel(const EdgeRef<StateLabelType, EdgeLabelType> &e, const EdgeLabelType &l) {
804-
const auto& p = (*this->edges.find(e->getId())).second;
805-
auto ee = dynamic_cast<Edge<StateLabelType, EdgeLabelType>*>(p.get());
804+
const auto &p = (*this->edges.find(e->getId())).second;
805+
auto ee = dynamic_cast<Edge<StateLabelType, EdgeLabelType> *>(p.get());
806806
ee->setLabel(l);
807807
}
808808

@@ -829,7 +829,7 @@ class FiniteStateMachine : public Abstract::FiniteStateMachine {
829829
// get all labels
830830
const SetOfStates<StateLabelType, EdgeLabelType> &allStates = this->getStates();
831831

832-
for (const auto& iter : allStates) {
832+
for (const auto &iter : allStates) {
833833
auto s = dynamic_cast<State<StateLabelType, EdgeLabelType> &>(*(iter.second));
834834
if (s.stateLabel == src) {
835835
const StateRef<StateLabelType, EdgeLabelType> srcState = this->getStateLabeled(src);
@@ -856,7 +856,8 @@ class FiniteStateMachine : public Abstract::FiniteStateMachine {
856856
std::unique_ptr<FiniteStateMachine<StateLabelType, EdgeLabelType>> determinizeEdgeLabels() {
857857
std::unique_ptr<FiniteStateMachine<StateLabelType, EdgeLabelType>> result =
858858
std::unique_ptr<FiniteStateMachine<StateLabelType, EdgeLabelType>>(
859-
dynamic_cast<FiniteStateMachine<StateLabelType, EdgeLabelType> *>(this->newInstance().release()));
859+
dynamic_cast<FiniteStateMachine<StateLabelType, EdgeLabelType> *>(
860+
this->newInstance().release()));
860861

861862
// maintain map of sets of states to the corresponding new states.
862863
std::map<const Abstract::SetOfStateRefs, const State<StateLabelType, EdgeLabelType> *>
@@ -1058,8 +1059,8 @@ class FiniteStateMachine : public Abstract::FiniteStateMachine {
10581059
eqClasses = std::move(newEqClasses);
10591060
} while (changed);
10601061

1061-
auto x = this->newInstance().release();
1062-
auto y = static_cast<FiniteStateMachine<StateLabelType, EdgeLabelType>*>(x);
1062+
auto x = this->newInstance().release();
1063+
auto y = static_cast<FiniteStateMachine<StateLabelType, EdgeLabelType> *>(x);
10631064
std::unique_ptr<FiniteStateMachine<StateLabelType, EdgeLabelType>> result =
10641065
std::unique_ptr<FiniteStateMachine<StateLabelType, EdgeLabelType>>(y);
10651066

@@ -1227,8 +1228,8 @@ class FiniteStateMachine : public Abstract::FiniteStateMachine {
12271228
const Abstract::Edge &e2) const = 0;
12281229

12291230
private:
1230-
const Abstract::FiniteStateMachine* fsm_a;
1231-
const Abstract::FiniteStateMachine* fsm_b;
1231+
const Abstract::FiniteStateMachine *fsm_a;
1232+
const Abstract::FiniteStateMachine *fsm_b;
12321233
};
12331234

12341235
} // namespace Product

include/maxplus/game/policyiteration.h

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ template <typename SL, typename EL> class PolicyIteration {
7878
PolicyIteration(PolicyIteration &&) = delete;
7979
PolicyIteration &operator=(PolicyIteration &&) = delete;
8080

81-
8281
struct PolicyIterationResult {
8382
std::map<const State<SL, EL> *, CDouble> values;
8483
StrategyVector<SL, EL> strategy;
@@ -325,7 +324,7 @@ template <typename SL, typename EL> class PolicyIteration {
325324
* @return the new distance and ratio vectors
326325
*/
327326
StrategyEvaluation evaluateStrategy(RatioGame<SL, EL> &game,
328-
StrategyVector<SL, EL>& currentStrategy,
327+
StrategyVector<SL, EL> &currentStrategy,
329328
std::map<const State<SL, EL> *, CDouble> &distanceVector,
330329
std::map<const State<SL, EL> *, CDouble> &ratioVector,
331330
std::map<const State<SL, EL> *, CDouble> &dw2,
@@ -391,7 +390,7 @@ template <typename SL, typename EL> class PolicyIteration {
391390
if (visited[v] == BOTTOM_VERTEX) {
392391
const State<SL, EL> *u = v;
393392
while (visited[u] == BOTTOM_VERTEX) { // NOLINT(*pointer-arithmetic)
394-
visited[u] = v; // NOLINT(*pointer-arithmetic)
393+
visited[u] = v; // NOLINT(*pointer-arithmetic)
395394
u = currentStrategy.getSuccessor(u);
396395
}
397396
if (visited[u] == v) { // NOLINT(*pointer-arithmetic)
@@ -452,15 +451,14 @@ template <typename SL, typename EL> class PolicyIteration {
452451
* @param epsilon epsilon value for equality on real numbers
453452
* @return
454453
*/
455-
DistanceResult
456-
computeDistances(RatioGame<SL, EL> &game,
457-
StrategyVector<SL, EL> &currentStrategy,
458-
FSM::Abstract::SetOfStateRefs &selectedStates,
459-
std::map<const State<SL, EL> *, CDouble> &r_i_t,
460-
std::map<const State<SL, EL> *, CDouble> &d_prev,
461-
std::map<const State<SL, EL> *, CDouble> &r_prev,
462-
std::map<const State<SL, EL> *, CDouble> &dw2_prev,
463-
CDouble epsilon) {
454+
DistanceResult computeDistances(RatioGame<SL, EL> &game,
455+
StrategyVector<SL, EL> &currentStrategy,
456+
FSM::Abstract::SetOfStateRefs &selectedStates,
457+
std::map<const State<SL, EL> *, CDouble> &r_i_t,
458+
std::map<const State<SL, EL> *, CDouble> &d_prev,
459+
std::map<const State<SL, EL> *, CDouble> &r_prev,
460+
std::map<const State<SL, EL> *, CDouble> &dw2_prev,
461+
CDouble epsilon) {
464462
const SetOfStates<SL, EL> &states = game.getStates();
465463

466464
std::stack<const State<SL, EL> *> stack;
@@ -489,7 +487,7 @@ template <typename SL, typename EL> class PolicyIteration {
489487
auto state = dynamic_cast<const State<SL, EL> *>(&(si));
490488
if (!visited[state]) {
491489
const State<SL, EL> *u = state;
492-
while (!visited[u]) { // NOLINT(*pointer-arithmetic)
490+
while (!visited[u]) { // NOLINT(*pointer-arithmetic)
493491
visited[u] = true; // NOLINT(*pointer-arithmetic)
494492
stack.push(u);
495493
u = currentStrategy.getSuccessor(u);
@@ -509,7 +507,7 @@ template <typename SL, typename EL> class PolicyIteration {
509507
r_i_t[x] = cycleRatio; // NOLINT(*pointer-arithmetic)
510508
// Update distance to cycle.
511509
d_i_t[x] = d_i_t[u] + re_weighted; // NOLINT(*pointer-arithmetic)
512-
dw2[x] = dw2[u] + w2; // NOLINT(*pointer-arithmetic)
510+
dw2[x] = dw2[u] + w2; // NOLINT(*pointer-arithmetic)
513511
u = x;
514512
}
515513
}

include/maxplus/graph/mpautomaton.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ class MaxPlusAutomaton
169169
MaxPlusAutomaton &operator=(const MaxPlusAutomaton &) = delete;
170170
MaxPlusAutomaton(MaxPlusAutomaton &&) = delete;
171171
MaxPlusAutomaton &operator=(MaxPlusAutomaton &&) = delete;
172-
173172
};
174173

175174
/**
@@ -232,7 +231,6 @@ using MPARSetOfStates = ::MaxPlus::FSM::Labeled::SetOfStates<MPAStateLabel, MPAR
232231
using MPARSetOfEdges = ::MaxPlus::FSM::Abstract::SetOfEdges;
233232
using MPARCycle = std::list<const ::MaxPlus::FSM::Abstract::Edge *>;
234233

235-
236234
/**
237235
* A max-plus automaton with rewards. In addition to the usual max-plus automaton,
238236
* its edges are labeled with rewards; a quantified amount of 'progress'.
@@ -247,13 +245,12 @@ class MaxPlusAutomatonWithRewards
247245
return std::make_unique<MaxPlusAutomatonWithRewards>();
248246
}
249247

250-
// Delete copy/move constructors and assignment operators
248+
// Delete copy/move constructors and assignment operators
251249
MaxPlusAutomatonWithRewards(const MaxPlusAutomatonWithRewards &) = delete;
252250
MaxPlusAutomatonWithRewards &operator=(const MaxPlusAutomatonWithRewards &) = delete;
253251
MaxPlusAutomatonWithRewards(MaxPlusAutomatonWithRewards &&) = delete;
254252
MaxPlusAutomatonWithRewards &operator=(MaxPlusAutomatonWithRewards &&) = delete;
255253

256-
257254
// compute the maximum cycle ratio of delay over progress
258255
CDouble calculateMCR();
259256
// compute the maximum cycle ratio of delay over progress and also return a critical cycle

include/maxplus/graph/smpls.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ class SMPLS {
7575
// the mode automaton
7676
EdgeLabeledModeFSM elsFSM;
7777

78-
7978
[[nodiscard]] std::unique_ptr<MaxPlusAutomaton> convertToMaxPlusAutomaton() const;
8079

8180
// transposes all matrices of the SMPLS
@@ -89,18 +88,18 @@ class SMPLS {
8988
private:
9089
// the mode matrices
9190
ModeMatrices mm;
92-
9391
};
9492

9593
using ListOfMatrices = std::list<std::unique_ptr<Matrix>>;
9694

9795
class DissectedModeMatrix {
9896
public:
9997
DissectedModeMatrix() = default;
100-
ModeMatrices& getCore() { return core; }
101-
[[nodiscard]] const ModeMatrices& getCore() const { return core; }
102-
ListOfMatrices& getEventRows() { return eventRows; }
103-
[[nodiscard]] const ListOfMatrices& getEventRows() const { return eventRows; }
98+
ModeMatrices &getCore() { return core; }
99+
[[nodiscard]] const ModeMatrices &getCore() const { return core; }
100+
ListOfMatrices &getEventRows() { return eventRows; }
101+
[[nodiscard]] const ListOfMatrices &getEventRows() const { return eventRows; }
102+
104103
private:
105104
ModeMatrices core;
106105
ListOfMatrices eventRows;
@@ -167,7 +166,7 @@ class SMPLSwithEvents : public SMPLS {
167166
std::multiset<Event> &eventList,
168167
IOASetOfEdgeRefs &visitedEdges);
169168

170-
DissectedModeMatrix* findDissectedModeMatrix(const MPString &sName);
169+
DissectedModeMatrix *findDissectedModeMatrix(const MPString &sName);
171170

172171
/**
173172
* recursive part of isConsistent

src/algebra/mpmatrix.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ Matrix::mp_generalized_eigenvectors() const { // NOLINT(*cognitive-complexity)
11681168
uint k = 0;
11691169
// for each SCC
11701170
for (auto scc_i = scc_s.begin(); scc_i != scc_s.end(); scc_i++, k++) {
1171-
MCMgraph& scc = *(*scc_i);
1171+
MCMgraph &scc = *(*scc_i);
11721172
sccMapInv[k] = &scc;
11731173

11741174
// MCM calculation requires node relabelling

src/base/analysis/mcm/mcmgraph.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ void splitMCMedgeToSequence(MCMgraph &g, MCMedge &e) { // NOLINT(*no-recursion)
150150
* algorithm.
151151
* Note: algorithm assumes that edge weights are integer values !
152152
*/
153-
void addLongestDelayEdgeForNode(MCMgraph &g, MCMnode &n, MCMedge &e) { // NOLINT(*cognitive-complexity)
153+
void addLongestDelayEdgeForNode(MCMgraph &g, // NOLINT(*cognitive-complexity)
154+
MCMnode &n,
155+
MCMedge &e) {
154156
std::vector<int> d(g.getNodes().size());
155157
std::vector<const MCMnode *> pi(g.getNodes().size());
156158
MCMnodeRefs S;
@@ -464,7 +466,10 @@ void addNodeToComponent(const MCMnode &n, MCMgraph &comp) {
464466
* The function visits all children of the actor 'u'. The parent-child
465467
* relation is given via the vector 'pi'.
466468
*/
467-
bool treeVisitChildren(MCMgraph &g, std::vector<const MCMnode *> &pi, MCMnode *u, MCMgraph &comp) { // NOLINT(*no-recursion)
469+
bool treeVisitChildren(MCMgraph &g, // NOLINT(*no-recursion)
470+
std::vector<const MCMnode *> &pi,
471+
MCMnode *u,
472+
MCMgraph &comp) {
468473
bool children = false;
469474

470475
for (uint i = 0; i < g.getNodes().size(); i++) {

src/base/analysis/mcm/mcmhoward.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
* SOFTWARE.
5050
*/
5151

52-
#include "base/analysis/mcm/mcmgraph.h"
5352
#include "base/analysis/mcm/mcmhoward.h"
53+
#include "base/analysis/mcm/mcmgraph.h"
5454
#include "base/exception/exception.h"
5555

5656
#include <algorithm>
@@ -456,8 +456,6 @@ class AlgHoward {
456456
* policy which is returned.
457457
*/
458458

459-
460-
461459
void Howard(const std::vector<int> &ij,
462460
const std::vector<CDouble> &A,
463461
int nr_nodes,
@@ -577,7 +575,7 @@ CDouble maximumCycleMeanHowardGeneral(MCMgraph &g, MCMnode **criticalNode) {
577575
std::map<CId, CId> nodeMap;
578576
scc->relabelNodeIds(&nodeMap);
579577
MCMnode *sccCriticalNode = nullptr;
580-
578+
581579
CDouble c_mcm = maximumCycleMeanHoward(*scc, &sccCriticalNode);
582580
if (c_mcm > mcm) {
583581
mcm = c_mcm;

src/base/analysis/mcm/mcmkarp.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
* SOFTWARE.
4040
*/
4141

42-
#include "base/analysis/mcm/mcmgraph.h"
4342
#include "base/analysis/mcm/mcmkarp.h"
43+
#include "base/analysis/mcm/mcmgraph.h"
4444
#include "base/math/cmath.h"
4545
#include <algorithm>
4646
#include <climits>

0 commit comments

Comments
 (0)