Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
batmen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sepia-pub
mael
batmen
Commits
3d42df63
Commit
3d42df63
authored
2 years ago
by
jgatt
Browse files
Options
Downloads
Patches
Plain Diff
change init_prob fun. Now all unset probability are set to 0
parent
776f1cd9
No related branches found
No related tags found
1 merge request
!12
Merge Request multibehavior
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/users/user_windows.cpp
+8
-44
8 additions, 44 deletions
src/users/user_windows.cpp
with
8 additions
and
44 deletions
src/users/user_windows.cpp
+
8
−
44
View file @
3d42df63
...
...
@@ -30,38 +30,20 @@ void DMUserMultiBehavior::init_prob(const rapidjson::Value ¶m,uint_fast32_t
//Red window probability initialization
std
::
vector
<
double
>
red_prob
(
5
,
-
1.0
);
std
::
vector
<
bool
>
red_set_prob
(
5
,
false
);
std
::
vector
<
double
>
red_prob
(
5
,
0.0
);
std
::
string
red_config
[]
=
{
"red_prob_degrad"
,
"red_prob_see_you_later"
,
"red_prob_reconfig"
,
"red_prob_renonce"
,
"red_prob_rigid"
};
double
total_unset_probability
=
1.0
;
double
total_random_set_prob
=
0.0
;
red_prob_total
=
0.0
;
//We set the probability either by reading json data or by drawing it randomly
for
(
std
::
vector
<
double
>::
size_type
i
=
0
;
i
<
red_prob
.
size
();
i
++
){
std
::
string
current_prob
=
red_config
[
i
];
if
(
param
.
HasMember
(
current_prob
.
c_str
())){
/*
PPK_ASSERT(param[current_prob.c_str()].IsDouble()
PPK_ASSERT
(
param
[
current_prob
.
c_str
()].
IsDouble
()
&&
param
[
current_prob
.
c_str
()].
GetDouble
()
>=
0.0
,
"Error every specified red probability should be a non-negative Double");*/
red_set_prob
[
i
]
=
true
;
"Error every specified red probability should be a non-negative Double"
);
red_prob
[
i
]
=
param
[
current_prob
.
c_str
()].
GetDouble
();
total_unset_probability
-
=
red_prob
[
i
];
red_prob_total
+
=
red_prob
[
i
];
}
else
{
red_prob
[
i
]
=
distribution
(
random_gen
);
total_random_set_prob
+=
red_prob
[
i
];
}
}
// We normalize the probability that wasn't set by user such that the total
// probability is 1.0
double
random_set_coeff
=
total_unset_probability
/
total_random_set_prob
;
for
(
std
::
vector
<
double
>::
size_type
i
=
0
;
i
<
red_prob
.
size
();
i
++
){
if
(
not
red_set_prob
[
i
]){
red_prob
[
i
]
=
red_prob
[
i
]
*
random_set_coeff
;
}
red_prob_total
+=
red_prob
[
i
];
}
//we save the result in the used probability variable
red_prob_degrad
=
red_prob
[
0
];
...
...
@@ -71,38 +53,20 @@ void DMUserMultiBehavior::init_prob(const rapidjson::Value ¶m,uint_fast32_t
// Yellow probability Initialization
std
::
vector
<
double
>
yellow_prob
(
3
,
-
1.0
);
std
::
vector
<
bool
>
yellow_set_prob
(
3
,
false
);
std
::
vector
<
double
>
yellow_prob
(
3
,
0.0
);
std
::
string
yellow_config
[]
=
{
"yellow_prob_degrad"
,
"yellow_prob_reconfig"
,
"yellow_prob_rigid"
};
total_unset_probability
=
1.0
;
total_random_set_prob
=
0.0
;
yellow_prob_total
=
0.0
;
//We set the probability either by reading json data or by drawing it randomly
for
(
std
::
vector
<
double
>::
size_type
i
=
0
;
i
<
yellow_prob
.
size
();
i
++
){
std
::
string
current_prob
=
yellow_config
[
i
];
if
(
param
.
HasMember
(
current_prob
.
c_str
())){
/*
PPK_ASSERT(param[current_prob.c_str()].IsDouble()
PPK_ASSERT
(
param
[
current_prob
.
c_str
()].
IsDouble
()
&&
param
[
current_prob
.
c_str
()].
GetDouble
()
>=
0.0
,
"Error every specified yellow probability should be a non-negative Double");*/
yellow_set_prob
[
i
]
=
true
;
"Error every specified yellow probability should be a non-negative Double"
);
yellow_prob
[
i
]
=
param
[
current_prob
.
c_str
()].
GetDouble
();
total_unset_probability
-=
yellow_prob
[
i
];
}
else
{
yellow_prob
[
i
]
=
distribution
(
random_gen
);
total_random_set_prob
+=
yellow_prob
[
i
];
}
}
// We normalize the probability that wasn't set by user such that the total
// probability is 1.0
random_set_coeff
=
total_unset_probability
/
total_random_set_prob
;
for
(
std
::
vector
<
double
>::
size_type
i
=
0
;
i
<
yellow_prob
.
size
();
i
++
){
if
(
not
yellow_set_prob
[
i
]){
yellow_prob
[
i
]
=
yellow_prob
[
i
]
*
random_set_coeff
;
yellow_prob_total
+=
yellow_prob
[
i
];
}
yellow_prob_total
+=
yellow_prob
[
i
];
}
yellow_prob_degrad
=
yellow_prob
[
0
];
yellow_prob_reconfig
=
yellow_prob
[
1
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment