Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F25856753
Reliability-functionality.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Size
3 KB
Referenced Files
None
Subscribers
None
Reliability-functionality.cpp
View Options
//===- examples/agent-functionalities/Reliability-functionality.cpp *C++-*-===//
//
// The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file examples/agent-functionalities/Reliability-functionality.cpp
///
/// \author Daniel Schnoell (daniel.schnoell@tuwien.ac.at )
///
/// \date 2019
///
/// \brief A simple example on defining \c rosa::Agent instances using
/// Relianility Functionalities.
///
//===----------------------------------------------------------------------===//
#include
"rosa/config/version.h"
#include
"rosa/core/Agent.hpp"
#include
"rosa/core/MessagingSystem.hpp"
#include
"rosa/support/log.h"
#include
"rosa/support/terminal_colors.h"
#include
"rosa/agent/Reliability.h"
#include
"rosa/agent/RangeConfidence.hpp"
#include
<vector>
#include
<map>
using
namespace
rosa
::
agent
;
int
main
(
void
)
{
typedef
double
SensorValueType
;
typedef
long
StateType
;
typedef
double
ReliabilityType
;
// defining Range confidence
auto
Confidence
=
new
RangeConfidence
<
ReliabilityType
,
StateType
,
SensorValueType
>
({
{
0
,
PartialFunction
<
double
,
double
>
({
{{
0
,
3
},
std
::
make_shared
<
LinearFunction
<
double
,
double
>>
(
0
,
1.0
/
3
)},
{{
3
,
6
},
std
::
make_shared
<
LinearFunction
<
double
,
double
>>
(
1
,
0
)},
{{
6
,
9
},
std
::
make_shared
<
LinearFunction
<
double
,
double
>>
(
3.0
,
-1.0
/
3
)},
},
0
)},
{
1
,
PartialFunction
<
double
,
double
>
({
{{
6
,
9
},
std
::
make_shared
<
LinearFunction
<
double
,
double
>>
(
-2
,
1.0
/
3
)},
{{
9
,
12
},
std
::
make_shared
<
LinearFunction
<
double
,
double
>>
(
1
,
0
)},
{{
12
,
15
},
std
::
make_shared
<
LinearFunction
<
double
,
double
>>
(
5
,
-1.0
/
3
)},
},
0
)},
{
2
,
PartialFunction
<
double
,
double
>
({
{{
12
,
15
},
std
::
make_shared
<
LinearFunction
<
double
,
double
>>
(
-4
,
1.0
/
3
)},
{{
15
,
18
},
std
::
make_shared
<
LinearFunction
<
double
,
double
>>
(
1
,
0
)},
{{
18
,
21
},
std
::
make_shared
<
LinearFunction
<
double
,
double
>>
(
7
,
-1.0
/
3
)},
},
0
)}
});
Abstraction
<
SensorValueType
,
ReliabilityType
>*
Reliability
=
new
LinearFunction
<
SensorValueType
,
ReliabilityType
>
(
1
,
-1.0
/
9
);
auto
ReliabilitySlope
=
new
LinearFunction
<
SensorValueType
,
ReliabilityType
>
(
1
,
-1.0
/
9
);
auto
TimeConfidence
=
new
LinearFunction
<
std
::
size_t
,
ReliabilityType
>
(
1
,
-1.0
/
9
);
auto
lowlevel
=
new
LowLevel
<
SensorValueType
,
StateType
,
ReliabilityType
>
();
std
::
vector
<
long
>
states
;
states
.
push_back
(
0
);
states
.
push_back
(
1
);
states
.
push_back
(
2
);
lowlevel
->
setConfidenceFunction
(
Confidence
);
lowlevel
->
setReliabilityFunction
(
Reliability
);
lowlevel
->
setReliabilitySlopeFunction
(
ReliabilitySlope
);
lowlevel
->
setTimeConfidenceFunction
(
TimeConfidence
);
lowlevel
->
setStates
(
states
);
lowlevel
->
setHistoryLength
(
1
);
/* ----------------------------- Do Something ---------------------------------------------------------------- */
for
(
int
a
=
0
;
a
<
10
;
a
++
)
std
::
cout
<<
"a: "
<<
a
<<
"
\n
"
<<
(
lowlevel
->
feedback
({{
0
,
0
},{
1
,
0.3
},{
2
,
0.5
}}),
lowlevel
->
operator
()(
a
))
<<
"
\n
"
;
/* ----------------------------- Cleanup --------------------------------------------------------------------- */
delete
lowlevel
;
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sat, Aug 29, 2:33 PM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
377408
Default Alt Text
Reliability-functionality.cpp (3 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline
Log In to Comment