-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsynapse.rs
More file actions
50 lines (45 loc) · 1.29 KB
/
synapse.rs
File metadata and controls
50 lines (45 loc) · 1.29 KB
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
//! Synapse connecting two neurons.
//!
//! A synapse carries the value from a source neuron to a target neuron,
//! multiplying it by a weight.
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Synapse {
/// Globally unique identifier of the synapse.
pub id: Uuid,
/// Identifier of the source neuron.
pub from: Uuid,
/// Identifier of the target neuron.
pub to: Uuid,
/// Weight applied during propagation.
pub weight: f64,
/// Curiosity score evaluating exploratory potential.
pub curiosity_score: f64,
}
impl Synapse {
/// Creates a new directed synapse with a random [`Uuid`].
pub fn new(from: Uuid, to: Uuid, weight: f64) -> Self {
Self {
id: Uuid::new_v4(),
from,
to,
weight,
curiosity_score: 0.0,
}
}
/// Creates a synapse using the supplied [`Uuid`].
pub fn with_id(id: Uuid, from: Uuid, to: Uuid, weight: f64) -> Self {
Self {
id,
from,
to,
weight,
curiosity_score: 0.0,
}
}
/// Updates the curiosity score of the synapse.
pub fn update_curiosity_score(&mut self, score: f64) {
self.curiosity_score = score;
}
}