deep_causality/alias/alias_base.rs
1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
4 */
5
6use crate::{
7 BaseSymbol, Causaloid, CausaloidGraph, Context, Contextoid, Data, EuclideanSpace,
8 EuclideanSpacetime, EuclideanTime, FloatType, Model, NumericalValue,
9};
10use std::collections::HashMap;
11use std::sync::{Arc, RwLock};
12
13/// A type alias for the default `Model` configuration.
14///
15/// This alias represents a `Model` that operates with a standard set of generic
16/// parameters, making it suitable for common causal modeling scenarios that
17/// operate within a Euclidean and numerical framework.
18///
19/// Specifically, `BaseModel` is a `Model` parameterized as follows:
20///
21/// - **`Data<NumericalValue>`**: Used for its data component. `NumberType` is a
22/// generic numeric type, typically an alias for a floating-point or integer,
23/// allowing for flexible data representation within the model.
24/// - **`EuclideanSpace`**: Defines the spatial context. This implies that
25/// spatial relationships within this model adhere to standard 3D Euclidean geometry.
26/// - **`EuclideanTime`**: Specifies the temporal context, utilizing a
27/// Euclidean representation of time. This typically refers to a continuous,
28/// linear progression of time.
29/// - **`EuclideanSpacetime`**: Combines the Euclidean spatial and temporal
30/// contexts into a unified spacetime representation, where both space and
31/// time are treated with Euclidean properties.
32/// - **`BaseSymbol`**: Provides a basic symbolic representation for elements
33/// within the model, useful for labeling, identification, or abstract reasoning.
34/// - **`FloatType` (x2)**: Two `FloatType` parameters, typically used for
35/// internal calculations, scalar values, metrics, or other generic numerical
36/// requirements within the `Model` structure, such as probabilities, weights,
37/// or magnitudes.
38///
39/// This `BaseModel` is intended for general-purpose use cases where a standard
40/// Euclidean and numerical context is sufficient, offering a consistent and
41/// easily recognizable model structure for common causal reasoning and
42/// simulation scenarios.
43pub type BaseModel = Model<bool, bool, BaseContext>;
44
45/// A type alias for a default, general-purpose `Causaloid` configuration.
46///
47/// This alias represents a `Causaloid`—a single, identity-bearing causal unit—
48/// configured with a standard set of generic parameters. It is designed for
49/// common causal modeling scenarios that operate within a Euclidean and numerical
50/// framework, providing a convenient and readable shorthand.
51///
52/// Each `BaseCausaloid` is parameterized with the following concrete types,
53/// defining its default context and data handling:
54///
55/// - **`Data<NumericalValue>`**: Represents the data component associated with the causaloid.
56/// `NumberType` is a generic numeric type, typically a floating-point or integer,
57/// allowing for flexible data representation.
58/// - **`EuclideanSpace`**: Defines the spatial context of the causaloid within a
59/// standard 3D Euclidean coordinate system. This implies that spatial relationships
60/// are governed by Euclidean geometry.
61/// - **`EuclideanTime`**: Specifies the temporal context, using a Euclidean
62/// representation of time. This typically refers to a continuous, linear progression
63/// of time.
64/// - **`EuclideanSpacetime`**: Combines the Euclidean spatial and temporal contexts
65/// into a unified spacetime representation, where both space and time are treated
66/// with Euclidean properties.
67/// - **`BaseSymbol`**: Provides a basic symbolic representation for the causaloid,
68/// useful for labeling, identification, or abstract reasoning.
69/// - **`FloatType` (x2)**: Two `FloatType` parameters, typically used for internal
70/// calculations, scalar values, or other generic numeric requirements within
71/// the `Causaloid` structure, such as probabilities, weights, or magnitudes.
72///
73/// This `BaseCausaloid` is the standard choice for creating individual causal nodes
74/// that are compatible with other "base" types like `BaseCausalGraph` and `BaseContext`,
75/// ensuring a consistent and easily understandable modeling environment.
76#[allow(type_alias_bounds)]
77pub type BaseCausaloid<I, O> = Causaloid<I, O, (), Arc<RwLock<BaseContext>>>;
78
79/// A type alias for a `Vec` (vector) containing `BaseCausaloid` instances.
80///
81/// This alias provides a convenient shorthand for a collection of causaloids,
82/// where each causaloid adheres to a standard "base" configuration. It's designed
83/// to represent an ordered list of `Causaloid` instances that share a common
84/// set of generic parameters, making it suitable for scenarios where multiple
85/// causaloids need to be grouped or processed together.
86///
87/// Each `Causaloid` within this vector is parameterized with the following
88/// concrete types, defining its default context and data handling:
89///
90/// - **`Data<NumericalValue>`**: Represents the data component associated with each causaloid.
91/// `NumberType` is a generic numeric type, typically a floating-point or integer,
92/// allowing for flexible data representation.
93/// - **`EuclideanSpace`**: Defines the spatial context of the causaloids within a
94/// standard 3D Euclidean coordinate system. This implies that spatial relationships
95/// are governed by Euclidean geometry.
96/// - **`EuclideanTime`**: Specifies the temporal context, using a Euclidean
97/// representation of time. This typically refers to a continuous, linear progression
98/// of time.
99/// - **`EuclideanSpacetime`**: Combines the Euclidean spatial and temporal contexts
100/// into a unified spacetime representation, where both space and time are treated
101/// with Euclidean properties.
102/// - **`BaseSymbol`**: Provides a basic symbolic representation for the causaloids,
103/// useful for labeling, identification, or abstract reasoning.
104/// - **`FloatType` (x2)**: Two `FloatType` parameters, typically used for internal
105/// calculations, scalar values, or other generic numeric requirements within
106/// the `Causaloid` structure, such as probabilities, weights, or magnitudes.
107///
108/// This `BaseCausaloidVec` is suitable for general-purpose use cases where a standard
109/// Euclidean and numerical context is sufficient for defining and managing ordered
110/// collections of causal entities. It offers a consistent and easily recognizable
111/// way to organize causaloids for common causal modeling scenarios, such as
112/// representing a sequence of events or a set of related causal agents.
113#[allow(type_alias_bounds)]
114pub type BaseCausaloidVec<I, O> = Vec<Causaloid<I, O, (), Arc<RwLock<BaseContext>>>>;
115
116/// A type alias for a `HashMap` that stores `BaseCausaloid` instances, typically indexed by their unique identifiers.
117///
118/// This alias provides a convenient shorthand for a collection of causaloids,
119/// where each causaloid adheres to a standard "base" configuration. It's designed
120/// to represent a mapping from an integer ID (e.g., a node index or a unique identifier)
121/// to a `Causaloid` instance.
122///
123/// The `BaseCausaloid` type, which forms the value of this map, is parameterized
124/// with the following concrete types:
125///
126/// - **`Data<NumericalValue>`**: Represents the data component associated with each causaloid.
127/// `NumberType` is a generic numeric type, typically a floating-point or integer.
128/// - **`EuclideanSpace`**: Defines the spatial context of the causaloids within a
129/// standard Euclidean coordinate system.
130/// - **`EuclideanTime`**: Specifies the temporal context, using a Euclidean
131/// representation of time.
132/// - **`EuclideanSpacetime`**: Combines the Euclidean spatial and temporal contexts
133/// into a unified spacetime representation.
134/// - **`BaseSymbol`**: Provides a basic symbolic representation for the causaloids.
135/// - **`FloatType` (x2)**: Two `FloatType` parameters, typically used for internal
136/// calculations, scalar values, or other generic numeric requirements within
137/// the `Causaloid` structure.
138///
139/// This `BaseCausalMap` is suitable for general-purpose use cases where a standard
140/// Euclidean and numerical context is sufficient for defining and managing causal
141/// entities within a map structure. It offers a consistent and easily recognizable
142/// way to organize causaloids for common causal modeling scenarios.
143pub type BaseCausalMap = HashMap<usize, Causaloid<bool, bool, (), Arc<RwLock<BaseContext>>>>;
144
145pub type BenchmarkCausalMap = HashMap<usize, BaseCausaloid<f64, bool>>;
146
147/// A type alias for a `CausaloidGraph` composed of `BaseCausaloid` instances.
148///
149/// This alias provides a convenient shorthand for defining a causal graph where
150/// each node (causaloid) adheres to a standard "base" configuration.
151///
152/// Specifically, `BaseCausalGraph` is a `CausaloidGraph` parameterized by a `Causaloid`
153/// that uses the following concrete types for its generic parameters:
154/// - **`Data<NumericalValue>`**: Represents the data associated with each causaloid,
155/// using a generic `NumberType` (typically a floating-point or integer type).
156/// - **`EuclideanSpace`**: Defines the spatial context of the causaloids within
157/// a standard Euclidean coordinate system.
158/// - **`EuclideanTime`**: Specifies the temporal context, using a Euclidean
159/// representation of time.
160/// - **`EuclideanSpacetime`**: Combines the Euclidean spatial and temporal
161/// contexts into a unified spacetime representation.
162/// - **`BaseSymbol`**: Provides a basic symbolic representation for the causaloids.
163/// - **`FloatType` (x2)**: Two `FloatType` parameters, typically used for internal
164/// calculations, scalar values, or other generic numeric requirements within
165/// the `Causaloid` structure.
166///
167/// This `BaseCausalGraph` is designed for general-purpose use cases where a
168/// standard Euclidean and numerical context is sufficient, offering a consistent
169/// and easily recognizable graph structure for common causal modeling scenarios.
170pub type BaseCausalGraph = CausaloidGraph<Causaloid<bool, bool, (), Arc<RwLock<BaseContext>>>>;
171
172/// A type alias for a default, general-purpose `Context` configuration.
173///
174/// This `BaseContext` alias represents a `Context` instance specifically configured
175/// with a standard set of generic parameters, making it suitable for common
176/// causal modeling scenarios that operate within a Euclidean and numerical framework.
177///
178/// It provides a convenient and readable shorthand for defining a `Context`
179/// that encapsulates:
180///
181/// - **`Data<NumericalValue>`**: For handling general numerical data. `NumberType`
182/// is typically an alias for a floating-point or integer type, allowing for
183/// flexible data representation within the context.
184/// - **`EuclideanSpace`**: Defines the spatial context using a standard
185/// Euclidean coordinate system. This implies that spatial relationships
186/// within this context adhere to Euclidean geometry.
187/// - **`EuclideanTime`**: Specifies the temporal context, utilizing a
188/// Euclidean representation of time. This typically refers to a continuous,
189/// linear progression of time.
190/// - **`EuclideanSpacetime`**: Combines the Euclidean spatial and temporal
191/// contexts into a unified spacetime representation, where both space and
192/// time are treated with Euclidean properties.
193/// - **`BaseSymbol`**: Provides a basic symbolic representation for elements
194/// within the context, useful for labeling, identification, or abstract
195/// reasoning.
196/// - **`FloatType` (x2)**: Two `FloatType` parameters, which are typically
197/// used for internal calculations, scalar values, metrics, or other generic
198/// numerical requirements within the `Context` structure, such as probabilities,
199/// weights, or magnitudes.
200///
201/// This `BaseContext` is designed to be a sensible default for many applications,
202/// offering a consistent and easily recognizable context structure for
203/// general-purpose causal reasoning and data representation.
204pub type BaseContext = Context<
205 Data<NumericalValue>,
206 EuclideanSpace,
207 EuclideanTime,
208 EuclideanSpacetime,
209 BaseSymbol,
210 FloatType,
211 FloatType,
212>;
213
214/// A type alias for a default, general-purpose `Contextoid` configuration.
215///
216/// This `BaseContextoid` alias represents a `Contextoid` instance—a single,
217/// identity-bearing unit of context—configured with a standard set of generic
218/// parameters. It is designed for common causal modeling scenarios that operate
219/// within a Euclidean and numerical framework.
220///
221/// It provides a convenient and readable shorthand for defining a `Contextoid`
222/// that encapsulates one of the following contextual roles:
223///
224/// - **`Data<NumericalValue>`**: For handling general numerical data (a `Datoid`). `NumberType`
225/// is typically an alias for a floating-point or integer type.
226/// - **`EuclideanSpace`**: Defines a spatial context using a standard
227/// Euclidean coordinate system (a `Spaceoid`).
228/// - **`EuclideanTime`**: Specifies a temporal context, utilizing a
229/// Euclidean representation of time (a `Tempoid`).
230/// - **`EuclideanSpacetime`**: Combines the Euclidean spatial and temporal
231/// contexts into a unified spacetime representation (a `SpaceTempoid`).
232/// - **`BaseSymbol`**: Provides a basic symbolic representation for elements
233/// within the context (a `Symboid`).
234///
235/// The two `FloatType` parameters correspond to the generic `VS` and `VT` types
236/// required by the underlying `Contextoid` structure, representing the value types
237/// for spatial and temporal coordinates, respectively.
238///
239/// This `BaseContextoid` is the standard choice for creating individual context nodes
240/// that are compatible with other "base" types like `BaseContext` and `BaseCausalGraph`,
241/// ensuring a consistent and easily understandable modeling environment.
242pub type BaseContextoid = Contextoid<
243 Data<NumericalValue>,
244 EuclideanSpace,
245 EuclideanTime,
246 EuclideanSpacetime,
247 BaseSymbol,
248 FloatType,
249 FloatType,
250>;