FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
seldon/src/models/ActivityDrivenModel.cpp at develop · seldon-code/seldon · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
seldon-code
/
seldon
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
7
Code
Issues
4
Pull requests
2
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
seldon
/
src
/
models
/
ActivityDrivenModel.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
51 lines (44 loc) · 1.62 KB
Breadcrumbs
seldon
/
src
/
models
/
ActivityDrivenModel.cpp
Copy path
File metadata and controls
51 lines (44 loc) · 1.62 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#
include
"
models/ActivityDrivenModel.hpp
"
#
include
"
network.hpp
"
#
include
"
util/math.hpp
"
#
include
<
cstddef
>
#
include
<
random
>
#
include
<
vector
>
namespace
Seldon
{
template
<>
void
ActivityDrivenModelAbstract<ActivityAgent>::iteration()
{
Model<AgentT>::
iteration
();
update_network
();
//
Integrate the ODE using 4th order Runge-Kutta
//
k_1 = hf(x_n,y_n)
get_euler_slopes
( k1_buffer, [
this
](
size_t
i ) {
return
network.
agents
[i].
data
.
opinion
; } );
//
k_2 = hf(x_n+1/2h,y_n+1/2k_1)
get_euler_slopes
(
k2_buffer, [
this
](
size_t
i ) {
return
network.
agents
[i].
data
.
opinion
+
0.5
* dt *
this
->
k1_buffer
[i]; } );
//
k_3 = hf(x_n+1/2h,y_n+1/2k_2)
get_euler_slopes
(
k3_buffer, [
this
](
size_t
i ) {
return
network.
agents
[i].
data
.
opinion
+
0.5
* dt *
this
->
k2_buffer
[i]; } );
//
k_4 = hf(x_n+h,y_n+k_3)
get_euler_slopes
(
k4_buffer, [
this
](
size_t
i ) {
return
network.
agents
[i].
data
.
opinion
+ dt *
this
->
k3_buffer
[i]; } );
//
Update the agent opinions
for
(
size_t
idx_agent =
0
; idx_agent < network.
n_agents
(); ++idx_agent )
{
//
y_(n+1) = y_n+1/6k_1+1/3k_2+1/3k_3+1/6k_4+O(h^5)
network.
agents
[idx_agent].
data
.
opinion
+= dt
* ( k1_buffer[idx_agent] +
2
* k2_buffer[idx_agent] +
2
* k3_buffer[idx_agent] + k4_buffer[idx_agent] )
/
6.0
;
}
if
(
bot_present
() )
{
for
(
size_t
bot_idx =
0
; bot_idx < n_bots; bot_idx++ )
{
network.
agents
[bot_idx].
data
.
opinion
= bot_opinion[bot_idx];
}
}
}
template
class
ActivityDrivenModelAbstract
<ActivityAgent>;
}
//
namespace Seldon
Back
|
FazBrowse Home
|
New Git URL