aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
factorySimulator.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 by *
5
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
6
* - Christophe GONZALES(_at_AMU) *
7
* *
8
* The aGrUM/pyAgrum library is free software; you can redistribute it *
9
* and/or modify it under the terms of either : *
10
* *
11
* - the GNU Lesser General Public License as published by *
12
* the Free Software Foundation, either version 3 of the License, *
13
* or (at your option) any later version, *
14
* - the MIT license (MIT), *
15
* - or both in dual license, as here. *
16
* *
17
* (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18
* *
19
* This aGrUM/pyAgrum library is distributed in the hope that it will be *
20
* useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26
* OTHER DEALINGS IN THE SOFTWARE. *
27
* *
28
* See LICENCES for more details. *
29
* *
30
* SPDX-FileCopyrightText: Copyright 2005-2026 *
31
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
32
* - Christophe GONZALES(_at_AMU) *
33
* SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34
* *
35
* Contact : info_at_agrum_dot_org *
36
* homepage : http://agrum.gitlab.io *
37
* gitlab : https://gitlab.com/agrumery/agrum *
38
* *
39
****************************************************************************/
40
41
49
#ifndef GUM_FACTORY_SIMULATOR_H
50
#define GUM_FACTORY_SIMULATOR_H
51
//======================================================================
52
//======================================================================
53
//======================================================================
54
#include <
agrum/FMDP/simulation/abstractSimulator.h
>
55
56
//======================================================================
57
//======================================================================
58
59
namespace
gum
{
60
61
62
enum
FactorySimulationLandmark
:
Idx
{
HOME
= 0,
WORK
= 1,
THEATER
= 2,
CLUB
= 3,
Factory
= 4 };
63
64
enum
FactorySimulationLandmarkX
:
Idx
{
65
HOMEX
= 0,
66
WORKX
= 0,
67
THEATERX
= 3,
68
CLUBX
= 4,
69
STATIONX
= 2
70
};
71
72
enum
FactorySimulationLandmarkY
:
Idx
{
73
HOMEY
= 0,
74
WORKY
= 4,
75
THEATERY
= 0,
76
CLUBY
= 4,
77
STATIONY
= 1
78
};
79
80
enum
FactorySimulationAction
:
Idx
{
81
GoNorth
= 0,
82
GoEast
= 1,
83
GoSouth
= 2,
84
GoWest
= 3,
85
PickUp
= 4,
86
PutDown
= 5,
87
FillUp
= 6
88
};
89
90
// clang-format off
97
// clang-format on
98
99
class
FactorySimulator
:
public
AbstractSimulator
{
100
public
:
101
// ===========================================================================
103
// ===========================================================================
105
109
FactorySimulator
();
110
114
~FactorySimulator
();
115
117
118
// ===========================================================================
120
// ===========================================================================
122
123
protected
:
125
Instantiation
randomState_
();
126
127
public
:
128
bool
hasReachEnd
();
130
double
reward
();
131
void
perform
(
Idx
);
132
134
135
// ===========================================================================
137
// ===========================================================================
139
140
const
DiscreteVariable
*
primeVar
(
const
DiscreteVariable
* mainVar);
141
143
SequenceIteratorSafe< const DiscreteVariable* >
beginVariables
();
144
145
SequenceIteratorSafe< const DiscreteVariable* >
endVariables
();
146
148
149
// ===========================================================================
151
// ===========================================================================
153
154
const
std::string&
actionName
(
Idx
actionId);
155
157
SequenceIteratorSafe< Idx >
beginActions
();
158
159
SequenceIteratorSafe< Idx >
endActions
();
160
162
163
164
private
:
165
void
_goNorth_
();
166
void
_goEast_
();
167
void
_goSouth_
();
168
void
_goWest_
();
169
void
_pickUp_
();
170
void
_putDown_
();
171
void
_fillUp_
();
172
174
Sequence< const DiscreteVariable* >
_FactoryVars_
;
175
Bijection< const DiscreteVariable*, const DiscreteVariable* >
_primeMap_
;
176
DiscreteVariable
*
_xPos_
;
177
DiscreteVariable
*
_yPos_
;
178
DiscreteVariable
*
_passengerPos_
;
179
DiscreteVariable
*
_passengerDest_
;
180
DiscreteVariable
*
_fuelLevel_
;
181
183
Sequence< Idx >
_FactoryActions_
;
184
HashTable< Idx, std::string* >
_actionMap_
;
// __actionMap.insert ( actionId,
185
// new std::string ( action ) );
186
FactorySimulationAction
_lastAction_
;
187
};
188
189
}
/* namespace gum */
190
191
#ifndef GUM_NO_INLINE
192
# include <
agrum/FMDP/simulation/factorySimulator_inl.h
>
193
#endif
// GUM_NO_INLINE
194
#endif
// GUM_FACTORY_SIMULATOR_H
abstractSimulator.h
Class for simulating a discrete time stochastic process.
gum::AbstractSimulator::AbstractSimulator
AbstractSimulator()
Default constructor.
Definition
abstractSimulator.cpp:69
gum::Bijection
Set of pairs of elements with fast search for both elements.
Definition
bijection.h:1640
gum::DiscreteVariable
Base class for discrete random variable.
Definition
discreteVariable.h:80
gum::FactorySimulator::_fillUp_
void _fillUp_()
gum::FactorySimulator::_passengerDest_
DiscreteVariable * _passengerDest_
Definition
factorySimulator.h:179
gum::FactorySimulator::actionName
const std::string & actionName(Idx actionId)
Iteration over the variables of the simulated probleme.
Definition
factorySimulator_inl.h:60
gum::FactorySimulator::randomState_
Instantiation randomState_()
Choses a random state as the first test for a run.
gum::FactorySimulator::_goEast_
void _goEast_()
gum::FactorySimulator::_lastAction_
FactorySimulationAction _lastAction_
Definition
factorySimulator.h:186
gum::FactorySimulator::beginActions
SequenceIteratorSafe< Idx > beginActions()
Iteration over the variables of the simulated probleme.
Definition
factorySimulator_inl.h:64
gum::FactorySimulator::beginVariables
SequenceIteratorSafe< const DiscreteVariable * > beginVariables()
Iteration over the variables of the simulated probleme.
Definition
factorySimulator_inl.h:52
gum::FactorySimulator::_pickUp_
void _pickUp_()
gum::FactorySimulator::_passengerPos_
DiscreteVariable * _passengerPos_
Definition
factorySimulator.h:178
gum::FactorySimulator::FactorySimulator
FactorySimulator()
Default constructor.
gum::FactorySimulator::hasReachEnd
bool hasReachEnd()
Choses a random state as the first test for a run.
gum::FactorySimulator::_putDown_
void _putDown_()
gum::FactorySimulator::_FactoryVars_
Sequence< const DiscreteVariable * > _FactoryVars_
Variables data structures.
Definition
factorySimulator.h:174
gum::FactorySimulator::_goWest_
void _goWest_()
gum::FactorySimulator::_goNorth_
void _goNorth_()
gum::FactorySimulator::_actionMap_
HashTable< Idx, std::string * > _actionMap_
Definition
factorySimulator.h:184
gum::FactorySimulator::perform
void perform(Idx)
Choses a random state as the first test for a run.
gum::FactorySimulator::primeVar
const DiscreteVariable * primeVar(const DiscreteVariable *mainVar)
Iteration over the variables of the simulated probleme.
Definition
factorySimulator_inl.h:48
gum::FactorySimulator::_goSouth_
void _goSouth_()
gum::FactorySimulator::_xPos_
DiscreteVariable * _xPos_
Definition
factorySimulator.h:176
gum::FactorySimulator::_fuelLevel_
DiscreteVariable * _fuelLevel_
Definition
factorySimulator.h:180
gum::FactorySimulator::reward
double reward()
Choses a random state as the first test for a run.
gum::FactorySimulator::endVariables
SequenceIteratorSafe< const DiscreteVariable * > endVariables()
Iteration over the variables of the simulated probleme.
Definition
factorySimulator_inl.h:56
gum::FactorySimulator::_primeMap_
Bijection< const DiscreteVariable *, const DiscreteVariable * > _primeMap_
Definition
factorySimulator.h:175
gum::FactorySimulator::endActions
SequenceIteratorSafe< Idx > endActions()
Iteration over the variables of the simulated probleme.
Definition
factorySimulator_inl.h:68
gum::FactorySimulator::~FactorySimulator
~FactorySimulator()
Default destructor.
gum::FactorySimulator::_yPos_
DiscreteVariable * _yPos_
Definition
factorySimulator.h:177
gum::FactorySimulator::_FactoryActions_
Sequence< Idx > _FactoryActions_
Actions.
Definition
factorySimulator.h:183
gum::HashTable
The class for generic Hash Tables.
Definition
hashTable.h:640
gum::Instantiation
Class for assigning/browsing values to tuples of discrete variables.
Definition
instantiation.h:102
gum::SequenceIteratorSafe
Safe iterators for Sequence.
Definition
sequence.h:1148
gum::Sequence
The generic class for storing (ordered) sequences of objects.
Definition
sequence.h:994
factorySimulator_inl.h
gum::Idx
Size Idx
Type for indexes.
Definition
types.h:79
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
gum::WORKX
@ WORKX
Definition
factorySimulator.h:66
gum::STATIONX
@ STATIONX
Definition
factorySimulator.h:69
gum::CLUBX
@ CLUBX
Definition
factorySimulator.h:68
gum::HOMEX
@ HOMEX
Definition
factorySimulator.h:65
gum::THEATERX
@ THEATERX
Definition
factorySimulator.h:67
gum::FactorySimulationLandmark
FactorySimulationLandmark
Definition
factorySimulator.h:62
gum::Factory
@ Factory
Definition
factorySimulator.h:62
gum::HOME
@ HOME
Definition
factorySimulator.h:62
gum::THEATER
@ THEATER
Definition
factorySimulator.h:62
gum::WORK
@ WORK
Definition
factorySimulator.h:62
gum::CLUB
@ CLUB
Definition
factorySimulator.h:62
gum::FactorySimulationAction
FactorySimulationAction
Definition
factorySimulator.h:80
gum::STATIONY
@ STATIONY
Definition
factorySimulator.h:77
gum::THEATERY
@ THEATERY
Definition
factorySimulator.h:75
gum::WORKY
@ WORKY
Definition
factorySimulator.h:74
gum::HOMEY
@ HOMEY
Definition
factorySimulator.h:73
gum::CLUBY
@ CLUBY
Definition
factorySimulator.h:76
gum::FactorySimulationLandmarkY
FactorySimulationLandmarkY
Definition
factorySimulator.h:72
gum::FactorySimulationLandmarkX
FactorySimulationLandmarkX
Definition
factorySimulator.h:64
gum::PickUp
@ PickUp
Definition
factorySimulator.h:85
gum::GoSouth
@ GoSouth
Definition
factorySimulator.h:83
gum::GoWest
@ GoWest
Definition
factorySimulator.h:84
gum::GoEast
@ GoEast
Definition
factorySimulator.h:82
gum::PutDown
@ PutDown
Definition
factorySimulator.h:86
gum::GoNorth
@ GoNorth
Definition
factorySimulator.h:81
gum::FillUp
@ FillUp
Definition
factorySimulator.h:87
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0