Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api)!: add capabilities to nodes #1073

Merged
Merged
Show file tree
Hide file tree
Changes from 171 commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
b7932c1
docs: add clone and import howto on website
kelvin-olaiya Feb 2, 2022
be49a83
docs: move clone and import howto under development chapter
kelvin-olaiya Feb 2, 2022
535b8cb
docs: add gradle and maven import instructions
kelvin-olaiya Feb 2, 2022
ad3d32c
docs: add status page
kelvin-olaiya Feb 2, 2022
2b6ea7d
docs(website): fix typo
kelvin-olaiya Feb 3, 2022
669573a
docs(website): rephrase
kelvin-olaiya Feb 3, 2022
de23098
docs(website): rename
kelvin-olaiya Feb 3, 2022
2c9acf5
docs(website): sort development doc pages
kelvin-olaiya Feb 4, 2022
17c7507
docs(website): reorder development content pages
kelvin-olaiya Feb 4, 2022
33f0d41
docs: add contributions rules
kelvin-olaiya Feb 2, 2022
2bea336
docs(website): sort development doc pages
kelvin-olaiya Feb 4, 2022
572fe76
docs(website): improve the build instructions page
DanySK Feb 4, 2022
1e56a58
docs(website): improve the contributions page
DanySK Feb 4, 2022
b938855
docs(website): reorder development content pages
kelvin-olaiya Feb 4, 2022
df2ebe2
docs(website): allow click-ability of the explanatory link to the hug…
DanySK Feb 5, 2022
ad96d60
refactor(gradle): move plugin block on top
kelvin-olaiya Feb 8, 2022
3de320c
refactor(gradle): move extension method for gettin plugin id in Util …
kelvin-olaiya Feb 8, 2022
a2de979
refactor: add capabilities to nodes
kelvin-olaiya Feb 8, 2022
1b2dedc
refactor: follow QA guidelines
kelvin-olaiya Feb 8, 2022
f76d947
refactor: return the exact requested capability type
kelvin-olaiya Feb 8, 2022
c173f8a
refactor: improve capability retrieving, add method to check if node …
kelvin-olaiya Feb 9, 2022
ffa35f8
refactor: make node override equals
kelvin-olaiya Feb 9, 2022
0a5f6f2
refactor: change method name
kelvin-olaiya Feb 9, 2022
7ebcb56
refactor: change method name
kelvin-olaiya Feb 9, 2022
a61e2ff
refactor: add cast safety check
kelvin-olaiya Feb 9, 2022
89ebcc5
feat: add capabilities to AbstractHomogeneousPedestrian
kelvin-olaiya Feb 9, 2022
cae3be1
docs: add documentations to Capabilities
kelvin-olaiya Feb 10, 2022
7a41a4b
refactor: add constructor properties with defaults
kelvin-olaiya Feb 10, 2022
58dd83f
refactor: add capabilities to AbstractHeterogeneousPedestrian
kelvin-olaiya Feb 10, 2022
7556bde
refactor: rename interface
kelvin-olaiya Feb 10, 2022
033cc35
refactor: rename interface/class name
kelvin-olaiya Feb 10, 2022
2d5d96c
refactor: re-write function in kotlin style
kelvin-olaiya Feb 10, 2022
437ab6a
refactor: substitute exception with TODO
kelvin-olaiya Feb 10, 2022
be00ec2
docs: correct documentation grammar
kelvin-olaiya Feb 10, 2022
d734dc2
refactor: rename capabilities
kelvin-olaiya Feb 10, 2022
9e426c3
refactor: rename capabilities
kelvin-olaiya Feb 10, 2022
aa39409
refactor: add delegation
kelvin-olaiya Feb 10, 2022
76367a8
refactor: add constructor overloads
kelvin-olaiya Feb 10, 2022
00fec6e
refactor: change property name
kelvin-olaiya Feb 10, 2022
39cfb52
refactor: change property name
kelvin-olaiya Feb 10, 2022
2c44b3f
refactor: re-write in kotlin style
kelvin-olaiya Feb 10, 2022
bc5f54b
refactor: add capabilities files
kelvin-olaiya Feb 10, 2022
c02a875
build: add dependency to euclidean-geometry
kelvin-olaiya Feb 10, 2022
c57c562
feat: add capabilities interfaces
kelvin-olaiya Feb 10, 2022
27340ce
feat: create a spacial capability
kelvin-olaiya Feb 10, 2022
5e86e9a
refactor: fix typo
kelvin-olaiya Feb 10, 2022
207c6b8
feat: create a IndividualCapability
kelvin-olaiya Feb 10, 2022
5d2c761
refactor: remove circular dependency
kelvin-olaiya Feb 10, 2022
1a57f98
fix: make test pass again
kelvin-olaiya Feb 11, 2022
846cd71
chore: pull from master
kelvin-olaiya Feb 14, 2022
e86aadb
refactor: pass constructor parameters to delegated objects
kelvin-olaiya Feb 14, 2022
c7cf4fd
feat: create pedestrian physical capability
kelvin-olaiya Feb 14, 2022
9b81d84
feat: add pedestrian physical capability interface
kelvin-olaiya Feb 14, 2022
ca80c34
fix: a node shall contain only 1 instance of a type of capability
kelvin-olaiya Feb 14, 2022
6ce56fb
refactor: make homogeneous and heterogenous abstract class use capabi…
kelvin-olaiya Feb 14, 2022
6dce395
feat: implement PedestrainIndividualityCapability
kelvin-olaiya Feb 14, 2022
fff6a7b
refactor: map pedestrianModel to a capability
kelvin-olaiya Feb 14, 2022
ade5810
feat: implement PedestrianCognitiveCapability
kelvin-olaiya Feb 14, 2022
ea5337a
refactor: make use of cognitive capability
kelvin-olaiya Feb 15, 2022
35e589e
refactor: make capabilities know to the node they're attatched to
kelvin-olaiya Feb 15, 2022
c905627
feat: implement PedestrianPhysicalCapability
kelvin-olaiya Feb 15, 2022
0c641fe
refactor: implement Use spatial and physical capabilities
kelvin-olaiya Feb 15, 2022
35abce9
feat: implement Orienting capability
kelvin-olaiya Feb 15, 2022
ffade4a
docs: add documentation comments
kelvin-olaiya Feb 15, 2022
c298fc3
refactor: add delegate orienting feature to capability
kelvin-olaiya Feb 16, 2022
b304e40
refactor: remove unused import
kelvin-olaiya Feb 16, 2022
c75b617
refactor: resolve todo
kelvin-olaiya Feb 16, 2022
c8bd406
feat: implement and use InfluenceCapability
kelvin-olaiya Feb 16, 2022
991669f
feat: implement and use social capability
kelvin-olaiya Feb 16, 2022
59d2a95
fix: resolve TODO
kelvin-olaiya Feb 16, 2022
d30293a
refactor: use data class when possible
kelvin-olaiya Feb 16, 2022
58c194e
refactor: resolve detekt warnings
kelvin-olaiya Feb 16, 2022
f534776
refactor: change name of capabilities
kelvin-olaiya Feb 16, 2022
e7ae8f6
refactor: resolve detekt warnings
kelvin-olaiya Feb 16, 2022
3a34e34
refactor: rethrow instead of stacktrace printing
kelvin-olaiya Feb 16, 2022
7ab554a
refactor: split 2D version of orienting capability in its own file
kelvin-olaiya Feb 16, 2022
944ccee
docs: remove unsupported inheritDoc
kelvin-olaiya Feb 16, 2022
c3d6a4b
docs: resolve detekt warnings
kelvin-olaiya Feb 16, 2022
ee53be2
refactor: remove unused imports
kelvin-olaiya Feb 16, 2022
51ab5ba
refactor: default model in congnitive capability, refactor group
kelvin-olaiya Feb 18, 2022
5f149be
feat: allow adding capabilities to nodes
kelvin-olaiya Feb 18, 2022
fc61a9d
refactor: remove PedestrianGroup interface
kelvin-olaiya Feb 18, 2022
b9f94ed
refactor: avoid passing cognitive model in costructor
kelvin-olaiya Feb 21, 2022
a6ca29c
fix: correct the overriding of cognitiveModel, test are now passing
kelvin-olaiya Feb 21, 2022
32ddb30
fix: Replace missing PedestrianGroup2D
kelvin-olaiya Feb 22, 2022
40d87d2
feat: add loading support for capabilities whit shape filtering, also…
kelvin-olaiya Feb 22, 2022
d7ad801
refactor(api): Add CellularBehaviour capability
kelvin-olaiya Feb 22, 2022
8ab20e3
refactor(api): add Base implementation of various cellular behaviour
kelvin-olaiya Feb 22, 2022
b308a2c
refactor: createMolecule is not a capability
kelvin-olaiya Feb 23, 2022
0eb84e3
refactor(api): create protelis capability
kelvin-olaiya Feb 23, 2022
fc2c5ed
feat(api): create LSACapability
kelvin-olaiya Feb 23, 2022
b41f4f6
refactor: remove unused variable
kelvin-olaiya Feb 23, 2022
6417c47
refactor: rename Shape to ShapeFilter
kelvin-olaiya Feb 23, 2022
a1ee4f8
refactor: add Compound filters interfaces
kelvin-olaiya Feb 23, 2022
b30d674
refactor: remove unused property
kelvin-olaiya Feb 23, 2022
b8644e0
fix: RectangleFilter in yaml
kelvin-olaiya Feb 23, 2022
cfd2d80
refactor(incarnation-protelis): simplify the capability structure
DanySK Feb 23, 2022
2150d95
docs(alchemist-loading): add documentation
kelvin-olaiya Feb 23, 2022
11515bf
docs(incarnation-protelis): add documentation
kelvin-olaiya Feb 23, 2022
d338fe6
refactor: make capability serializable
kelvin-olaiya Feb 23, 2022
7a4f548
refactor(incarnation-protelis): delegate to capabily
kelvin-olaiya Feb 23, 2022
b6125f1
refactor(incarnation-protelis): use protelis capability
kelvin-olaiya Feb 28, 2022
71eacdb
refactor(incarnation-biochemistry): substitute nodes with capabilities
kelvin-olaiya Feb 28, 2022
5323c8d
refactor(api): add GenericNode implementation
kelvin-olaiya Feb 28, 2022
4da36a1
fix(incarnation-biochemistry): fix wrong capability retrieval
kelvin-olaiya Feb 28, 2022
c627eab
fix(incarnation-biochemistry): correctly update junction count
kelvin-olaiya Feb 28, 2022
847d086
fix(incarnation-biochemistry): fix addPolarizationVersor method
kelvin-olaiya Feb 28, 2022
a6ddc9f
refactor(api): manage generic variance
kelvin-olaiya Feb 28, 2022
88d6d1b
refactor(euclidean-goemetry): move capability to euclidean-geometry
kelvin-olaiya Feb 28, 2022
2ad3a3b
refactor(euclidean-goemetry): use spatial capability
kelvin-olaiya Feb 28, 2022
a9ad353
refactor(cognitive-agents): drop nodes and use capabilities
kelvin-olaiya Mar 1, 2022
b32da79
refactor(cognitive-agents): style refactor
kelvin-olaiya Mar 1, 2022
aed84d8
refactor(cognitive-agents): use capabilities in tests
kelvin-olaiya Mar 1, 2022
84bee41
refactor: use capabilities
kelvin-olaiya Mar 1, 2022
10dfbef
refactor: use default properties in capabilities
kelvin-olaiya Mar 1, 2022
6068a82
refactor: add a movement capability for heterogeneous pedestrians
kelvin-olaiya Mar 1, 2022
c80230e
refactor: use default confortArea
kelvin-olaiya Mar 1, 2022
0187a37
refactor: separate capabilities in different files
kelvin-olaiya Mar 1, 2022
67703a3
refactor: use default Speed
kelvin-olaiya Mar 1, 2022
217e8d0
refactor: add documentation
kelvin-olaiya Mar 1, 2022
bfdf0c3
refactor: add cognitive movement capabilty
kelvin-olaiya Mar 1, 2022
7a52267
fix: fix for non cognitive nodes
kelvin-olaiya Mar 2, 2022
00216eb
refactor(api): rename Capability to NodeProperty
kelvin-olaiya Mar 2, 2022
e938426
refactor(api): rename Capability to NodeProperty
kelvin-olaiya Mar 2, 2022
6552787
refactor(api): rename capabilities
kelvin-olaiya Mar 2, 2022
34ab593
refactor(api): rename properties
kelvin-olaiya Mar 2, 2022
e51d731
refactor(api): rename spatial capability
kelvin-olaiya Mar 2, 2022
4bbe355
refactor(api): rename properties
kelvin-olaiya Mar 2, 2022
f07be66
refactor(loading): capabilities are now called properties
kelvin-olaiya Mar 2, 2022
17b5a98
refactor(loading): capabilities are now called properties
kelvin-olaiya Mar 2, 2022
0bfe23c
refactor(loading): rename property
kelvin-olaiya Mar 2, 2022
a0fb541
refactor(loading): start rewriting yaml configuration
kelvin-olaiya Mar 2, 2022
3d87594
fix(test): rewrite yml configurations
kelvin-olaiya Mar 2, 2022
292ee57
fix(test): rewrite yaml for TestPedestrianLoading
kelvin-olaiya Mar 2, 2022
ffc68e0
fix(test): rewriting yaml configuration for TestOrientingBehavior
kelvin-olaiya Mar 3, 2022
0fa4485
fix(test): rewriting yaml configuration for TestFeelsTransmission
kelvin-olaiya Mar 3, 2022
1b3d3b9
fix(test): rewriting yaml configuration for WebSnippets
kelvin-olaiya Mar 3, 2022
87ced23
fix(test): rewrite yaml files
kelvin-olaiya Mar 3, 2022
0090fd3
refactor(test): remove reduntant boolean
kelvin-olaiya Mar 3, 2022
5701c35
refactor(incarnation-biochemistry): remove TODO
kelvin-olaiya Mar 3, 2022
cf27df5
refactor(incarnation-biochemistry): remove TODOs
kelvin-olaiya Mar 3, 2022
8c5f209
refactor: exception messages
kelvin-olaiya Mar 3, 2022
99afb2c
refactor(website): explain capabilities in cognitive simulation
kelvin-olaiya Mar 4, 2022
39ba4df
refactor(website): loading system
kelvin-olaiya Mar 4, 2022
e551a05
fix: conflicts
kelvin-olaiya Mar 4, 2022
9cc638e
fix: check errors
kelvin-olaiya Mar 4, 2022
cebbb64
fix: check task errors
kelvin-olaiya Mar 5, 2022
c10ae41
docs(website): fix classes references
kelvin-olaiya Mar 5, 2022
d4363cc
fix: yml filter specification
kelvin-olaiya Mar 5, 2022
1dd9584
fix: yml filter specification
kelvin-olaiya Mar 5, 2022
89c0843
docs(website): fix classes references
kelvin-olaiya Mar 5, 2022
70d5078
Merge branch 'master' into feature-addCapabilitiesToNodes
kelvin-olaiya Mar 5, 2022
5188eb3
refactor: better namings
kelvin-olaiya Mar 5, 2022
2b03b7e
refactor: better naming
kelvin-olaiya Mar 5, 2022
f98288a
refactor: docs
kelvin-olaiya Mar 5, 2022
c98d4a5
refactor: docs
kelvin-olaiya Mar 5, 2022
e43e6a6
refactor(docs): comments
kelvin-olaiya Mar 5, 2022
5f8485d
fix: detekt issues
kelvin-olaiya Mar 5, 2022
625f37c
fix: javadoc
kelvin-olaiya Mar 5, 2022
b0258b9
fix: javadoc
kelvin-olaiya Mar 5, 2022
5d7704d
Merge branch 'master' into feature-addCapabilitiesToNodes
kelvin-olaiya Mar 6, 2022
23edbd2
refactor: replace pedestrian occurences with node
kelvin-olaiya Mar 7, 2022
661bd27
Merge branch 'master' into feature-addCapabilitiesToNodes
kelvin-olaiya Mar 7, 2022
ef0b028
refactor: trailing commas
kelvin-olaiya Mar 7, 2022
84bbd8f
Update AbstractGroupSteeringAction.kt
kelvin-olaiya Mar 7, 2022
80149b2
Update AbstractGroupSteeringAction.kt
kelvin-olaiya Mar 7, 2022
5863c88
Update AbstractLayerAction.kt
kelvin-olaiya Mar 7, 2022
8b2dedd
refactor: style
kelvin-olaiya Mar 7, 2022
98d9b07
refactor: fix style issues
kelvin-olaiya Mar 7, 2022
2ec43e6
refactor: add another construct for compatibility with previuos imple…
kelvin-olaiya Mar 8, 2022
fdd452a
refactor: rewrite method in a idiomati way
kelvin-olaiya Mar 8, 2022
502ac80
refactor: fix style issues
kelvin-olaiya Mar 8, 2022
39224b0
refactor: add trailing comma
kelvin-olaiya Mar 8, 2022
f6d119d
refactor: add trailing comma
kelvin-olaiya Mar 8, 2022
74c85a4
refactor: fix check issues
kelvin-olaiya Mar 8, 2022
74b0b58
refactor: use typealias instead of class
kelvin-olaiya Mar 8, 2022
d466cf6
Merge branch 'master' into feature-addCapabilitiesToNodes
kelvin-olaiya Mar 8, 2022
0bfb2df
refactor: fix style and namings, clone properties on nodeCloning
kelvin-olaiya Mar 8, 2022
4217c40
docs(website): refactor
kelvin-olaiya Mar 8, 2022
61d8e6a
docs(website): refactor
kelvin-olaiya Mar 8, 2022
a2cec67
docs(website): refactor
kelvin-olaiya Mar 8, 2022
bc73218
docs(website): fix documentation
kelvin-olaiya Mar 8, 2022
aed4c6f
docs(website): fix documentation
kelvin-olaiya Mar 8, 2022
100de15
docs(website): fix documentation
kelvin-olaiya Mar 8, 2022
e75db99
docs(website): fix documentation
kelvin-olaiya Mar 8, 2022
1220ce5
docs(website): fix documentation
kelvin-olaiya Mar 8, 2022
e502ae6
docs(website): fix documentation
kelvin-olaiya Mar 8, 2022
0134de2
docs(website): fix documentation
kelvin-olaiya Mar 8, 2022
4e5c430
Merge branch 'master' into feature-addCapabilitiesToNodes
kelvin-olaiya Mar 8, 2022
bd5ea12
chore: merge truth branch
kelvin-olaiya Mar 8, 2022
7e4440c
refactor: rename loader.shapes to loader.filters
kelvin-olaiya Mar 9, 2022
d0fa007
refactor: remove unused imports
kelvin-olaiya Mar 9, 2022
a0448c4
refactor: namings
kelvin-olaiya Mar 9, 2022
8414e07
refactor: styling, namings and docs
kelvin-olaiya Mar 9, 2022
8db4e5c
refactor: fix complex method, rewrite yml
kelvin-olaiya Mar 9, 2022
4c9e991
Merge branch 'master' into feature-addCapabilitiesToNodes
kelvin-olaiya Mar 9, 2022
ceb74a6
refactor: remove double brace initialization
kelvin-olaiya Mar 9, 2022
9f3a14b
fix(website): correct shortcode
kelvin-olaiya Mar 9, 2022
02c1ce8
refactor: rename property
kelvin-olaiya Mar 9, 2022
8679907
refactor: trailing comma, style
kelvin-olaiya Mar 9, 2022
ef37cd4
refactor(biochemistry-incarnation): remove unnecessary parentheses
kelvin-olaiya Mar 9, 2022
77b91fa
fix: avoid NullPointerException
kelvin-olaiya Mar 9, 2022
9034a3f
Update alchemist-incarnation-biochemistry/src/test/java/it/unibo/alch…
DanySK Mar 10, 2022
3f9929a
refactor(loading-filters): remove useless parentheses
kelvin-olaiya Mar 10, 2022
d2480d0
chore: merge remote branch
kelvin-olaiya Mar 10, 2022
4f7553a
Merge branch 'master' into feature-addCapabilitiesToNodes
kelvin-olaiya Mar 10, 2022
6f999e7
Update src/main/hugo/content/howtos/simulation/cognitive/_index.md
DanySK Mar 10, 2022
4a82f05
Update src/main/hugo/content/howtos/simulation/cognitive/_index.md
DanySK Mar 10, 2022
600791b
refactor(loading-filters): make invoke an operator
kelvin-olaiya Mar 10, 2022
35ec8c6
Update src/main/hugo/content/howtos/simulation/cognitive/_index.md
DanySK Mar 10, 2022
1d3614f
Update src/main/hugo/content/howtos/simulation/cognitive/_index.md
DanySK Mar 10, 2022
04a733e
chore: merge origin branch
kelvin-olaiya Mar 10, 2022
1dc2b0f
Update src/main/hugo/content/howtos/simulation/cognitive/_index.md
DanySK Mar 10, 2022
e2dde49
Update src/main/hugo/content/howtos/simulation/cognitive/_index.md
DanySK Mar 10, 2022
ef52f6e
Update src/main/hugo/content/howtos/simulation/program/content/_index.md
DanySK Mar 10, 2022
f86b1e8
Update src/main/hugo/content/reference/biochemistry/_index.md
DanySK Mar 10, 2022
c6ff278
Update src/main/hugo/content/reference/biochemistry/_index.md
DanySK Mar 10, 2022
56242ef
Update src/main/hugo/content/howtos/simulation/program/content/_index.md
DanySK Mar 10, 2022
e242b05
Update src/main/hugo/content/howtos/simulation/program/content/_index.md
DanySK Mar 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface CognitiveModel {
fun update(frequency: Double)

/**
* Whether or not this pedestrian intends to escape.
* Whether or not this node intends to escape.
*/
fun wantsToEscape(): Boolean = escapeIntention() > remainIntention()
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package it.unibo.alchemist.model.implementations.actions

import it.unibo.alchemist.model.interfaces.Environment
import it.unibo.alchemist.model.interfaces.GroupSteeringAction
import it.unibo.alchemist.model.interfaces.Pedestrian
import it.unibo.alchemist.model.interfaces.Node
import it.unibo.alchemist.model.interfaces.Position
import it.unibo.alchemist.model.interfaces.Reaction
import it.unibo.alchemist.model.interfaces.geometry.GeometricTransformation
Expand All @@ -21,21 +21,19 @@ import it.unibo.alchemist.model.interfaces.geometry.Vector
* An abstract [GroupSteeringAction].
*/
abstract class AbstractGroupSteeringAction<T, P, A>(
/**
* The environment in which this action executes.
*/
protected open val env: Environment<T, P>,
environment: Environment<T, P>,
reaction: Reaction<T>,
pedestrian: Pedestrian<T, P, A>
) : AbstractSteeringAction<T, P, A>(env, reaction, pedestrian),
node: Node<T>,
) : AbstractSteeringAction<T, P, A>(environment, reaction, node),
GroupSteeringAction<T, P>
where P : Position<P>, P : Vector<P>,
where P : Position<P>,
P : Vector<P>,
A : GeometricTransformation<P> {

/**
* Computes the centroid of the [group] in absolute coordinates.
*/
protected fun centroid(): P = with(group()) {
map { env.getPosition(it) }.reduce { acc, pos -> acc + pos } / size.toDouble()
map { environment.getPosition(it) }.reduce { acc, pos -> acc + pos } / size.toDouble()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import it.unibo.alchemist.model.implementations.layers.BidimensionalGaussianLaye
import it.unibo.alchemist.model.implementations.positions.Euclidean2DPosition
import it.unibo.alchemist.model.interfaces.Layer
import it.unibo.alchemist.model.interfaces.Molecule
import it.unibo.alchemist.model.interfaces.Pedestrian
import it.unibo.alchemist.model.interfaces.Pedestrian2D
import it.unibo.alchemist.model.interfaces.Node
import it.unibo.alchemist.model.interfaces.Position
import it.unibo.alchemist.model.interfaces.Reaction
import it.unibo.alchemist.model.interfaces.environments.Euclidean2DEnvironment
Expand All @@ -15,27 +14,22 @@ import it.unibo.alchemist.model.interfaces.geometry.euclidean2d.Euclidean2DTrans
* Abstract implementation of an action influenced by the concentration of a given molecule in the environment.
*
* @param environment
* the environment inside which the pedestrian moves.
* the environment inside which the node moves.
* @param reaction
* the reaction which executes this action.
* @param pedestrian
* @param node
* the owner of this action.
* @param targetMolecule
* the {@link Molecule} you want to know the concentration in the different positions of the environment.
*/
abstract class AbstractLayerAction(
protected val environment: Euclidean2DEnvironment<Number>,
reaction: Reaction<Number>,
override val pedestrian: Pedestrian2D<Number>,
protected val targetMolecule: Molecule
) : AbstractSteeringAction<Number, Euclidean2DPosition, Euclidean2DTransformation>(environment, reaction, pedestrian) {
node: Node<Number>,
protected val targetMolecule: Molecule,
) : AbstractSteeringAction<Number, Euclidean2DPosition, Euclidean2DTransformation>(environment, reaction, node) {

override fun cloneAction(
n: Pedestrian<Number, Euclidean2DPosition, Euclidean2DTransformation>,
r: Reaction<Number>
) = requireNodeTypeAndProduce<Pedestrian2D<Number>, AbstractLayerAction>(n) { cloneAction(it, r) }

protected abstract fun cloneAction(n: Pedestrian2D<Number>, r: Reaction<Number>): AbstractLayerAction
abstract override fun cloneAction(node: Node<Number>, reaction: Reaction<Number>): AbstractLayerAction

/**
* @returns the layer containing [targetMolecule] or fails.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package it.unibo.alchemist.model.implementations.actions

import it.unibo.alchemist.model.interfaces.NavigationAction
import it.unibo.alchemist.model.interfaces.NavigationStrategy
import it.unibo.alchemist.model.interfaces.OrientingPedestrian
import it.unibo.alchemist.model.interfaces.Position
import it.unibo.alchemist.model.interfaces.Reaction
import it.unibo.alchemist.model.interfaces.environments.EnvironmentWithGraph
Expand All @@ -26,75 +25,88 @@ import it.unibo.alchemist.model.implementations.actions.AbstractNavigationAction
import it.unibo.alchemist.model.implementations.actions.AbstractNavigationAction.NavigationState.CROSSING_DOOR
import it.unibo.alchemist.model.implementations.actions.AbstractNavigationAction.NavigationState.MOVING_TO_FINAL
import it.unibo.alchemist.model.implementations.actions.AbstractNavigationAction.NavigationState.ARRIVED
import it.unibo.alchemist.model.interfaces.Node
import it.unibo.alchemist.model.interfaces.properties.OccupiesSpaceProperty
import it.unibo.alchemist.model.interfaces.Node.Companion.asProperty
import it.unibo.alchemist.model.interfaces.properties.OrientingProperty

/**
* An abstract [NavigationAction], taking care of properly moving the pedestrian in the
* An abstract [NavigationAction], taking care of properly moving the node in the
* environment while delegating the decision on where to move it to a [NavigationStrategy].
*
* @param T the concentration type.
* @param P the [Position] type and [Vector] type for the space the pedestrian is into.
* @param P the [Position] type and [Vector] type for the space the node is into.
* @param A the transformations supported by the shapes in this space.
* @param L the type of landmarks of the pedestrian's cognitive map.
* @param R the type of edges of the pedestrian's cognitive map, representing the [R]elations between landmarks.
* @param L the type of landmarks of the node's cognitive map.
* @param R the type of edges of the node's cognitive map, representing the [R]elations between landmarks.
* @param N the type of nodes of the navigation graph provided by the [environment].
* @param E the type of edges of the navigation graph provided by the [environment].
*/
abstract class AbstractNavigationAction<T, P, A, L, R, N, E>(
override val environment: EnvironmentWithGraph<*, T, P, A, N, E>,
override val reaction: Reaction<T>,
final override val pedestrian: OrientingPedestrian<T, P, A, L, R>
) : AbstractSteeringAction<T, P, A>(environment, reaction, pedestrian),
node: Node<T>,
) : AbstractSteeringAction<T, P, A>(environment, reaction, node),
NavigationAction<T, P, A, L, R, N, E>
where P : Position<P>, P : Vector<P>,
A : GeometricTransformation<P>,
L : ConvexGeometricShape<P, A>,
N : ConvexGeometricShape<P, A> {

override val navigatingNode = node

/**
* The strategy used to navigate the environment.
*/
protected open lateinit var strategy: NavigationStrategy<T, P, A, L, R, N, E>

/**
* The position of the [pedestrian] in the [environment], this is cached and updated
* The position of the [navigatingNode] in the [environment], this is cached and updated
* every time [update] is called so as to avoid potentially costly re-computations.
*/
override lateinit var pedestrianPosition: P

/**
* The room (= environment's area) the [pedestrian] is into, this is cached and updated
* The room (= environment's area) the [navigatingNode] is into, this is cached and updated
* every time [update] is called so as to avoid potentially costly re-computations.
*/
override var currentRoom: N? = null

/**
* Minimum distance to consider a target reached. Using zero (even with fuzzy equals) may lead to some
* boundary cases in which the pedestrian remains blocked due to how the environment manage collisions
* at present. This workaround allows to specify a minimum distance which is dependent on the pedestrian
* boundary cases in which the node remains blocked due to how the environment manage collisions
* at present. This workaround allows to specify a minimum distance which is dependent on the node
* shape. In the future, something better could be done.
*/
protected val minDistance: Double = pedestrian.shape.diameter
protected val minDistance: Double = node.asProperty<T, OccupiesSpaceProperty<T, P, A>>().shape.diameter

/**
* @returns true if the distance to [pedestrianPosition] is smaller than or equal to [minDistance].
*/
protected open fun P.isReached(): Boolean = distanceTo(pedestrianPosition) <= minDistance

/**
* The navigation state.
*/
protected var state: NavigationState = START

/**
* Caches the room the pedestrian is into when he/she starts moving. When the pedestrian is crossing a door, it
* contains the room being left. When in [NavigationState.MOVING_TO_FINAL], it contains the room the pedestrian
* was (and should be) into. It's used to detect if the pedestrian ended up in an unexpected room while moving.
* Caches the room the node is into when he/she starts moving. When the node is crossing a door, it
* contains the room being left. When in [NavigationState.MOVING_TO_FINAL], it contains the room the node
* was (and should be) into. It's used to detect if the node ended up in an unexpected room while moving.
*/
protected var previousRoom: N? = null

/**
* Defined when crossing a door. See [crossDoor].
*/
protected var crossingPoints: Pair<P, P>? = null

/**
* Defined when crossing a door.
*/
protected var expectedNewRoom: N? = null

/**
* Defined in [NavigationState.MOVING_TO_FINAL].
*/
Expand All @@ -109,16 +121,16 @@ abstract class AbstractNavigationAction<T, P, A, L, R, N, E>(

/**
* Updates [pedestrianPosition] and [currentRoom], this can be costly.
* Depending on how [ConvexGeometricShape.contains] manage points on the boundary, the pedestrian could
* Depending on how [ConvexGeometricShape.contains] manage points on the boundary, the node could
* be inside two (adjacent) rooms at once. This can happen in two cases:
* - when in [NavigationState.MOVING_TO_CROSSING_POINT_1] or [NavigationState.MOVING_TO_FINAL] and the pedestrian
* - when in [NavigationState.MOVING_TO_CROSSING_POINT_1] or [NavigationState.MOVING_TO_FINAL] and the node
* is moving on [previousRoom]'s boundary. In such case [previousRoom] is used.
* - when crossing a door or in [NavigationState.NEW_ROOM] and [expectedNewRoom] is adjacent to [previousRoom].
* In such case [expectedNewRoom] is used.
* Otherwise the first room containing [pedestrianPosition] is used.
*/
protected open fun updateCachedVariables() {
pedestrianPosition = environment.getPosition(pedestrian)
pedestrianPosition = environment.getPosition(navigatingNode)
currentRoom = when {
(state == MOVING_TO_CROSSING_POINT_1 || state == MOVING_TO_FINAL) &&
previousRoom.orFail().contains(pedestrianPosition) ->
Expand All @@ -131,11 +143,14 @@ abstract class AbstractNavigationAction<T, P, A, L, R, N, E>(
}
}

/**
* Execute on navigation start.
*/
protected open fun onStart() {
state = when {
currentRoom != null -> NEW_ROOM
/*
* If the pedestrian cannot locate itself inside any room on start, it simply won't move.
* If the node cannot locate itself inside any room on start, it simply won't move.
*/
else -> ARRIVED
}
Expand All @@ -153,7 +168,7 @@ abstract class AbstractNavigationAction<T, P, A, L, R, N, E>(
protected open val E.target: N get() = environment.graph.getEdgeTarget(this)

/**
* Moves the pedestrian across the provided [door], which must be among [doorsInSight].
* Moves the node across the provided [door], which must be among [doorsInSight].
* Since connected rooms may be non-adjacent, a pair of [crossingPoints] has to be provided:
* - the first point must belong to the current room's boundary and will be reached first,
* - the second point must belong to the next room's boundary and will be pursued after
Expand Down Expand Up @@ -198,7 +213,7 @@ abstract class AbstractNavigationAction<T, P, A, L, R, N, E>(
}

/**
* The position the pedestrian wants to reach.
* The position the node wants to reach.
*/
val desiredPosition: P get() = when (state) {
MOVING_TO_CROSSING_POINT_1 -> crossingPoints.orFail().first
Expand All @@ -208,18 +223,19 @@ abstract class AbstractNavigationAction<T, P, A, L, R, N, E>(
/*
* Always up to date current position.
*/
else -> environment.getPosition(pedestrian)
else -> environment.getPosition(navigatingNode)
}

/**
* Updates the internal state but does not move the pedestrian.
* Updates the internal state but does not move the node.
*/
open fun update() {
updateCachedVariables()
when (state) {
START -> onStart()
NEW_ROOM -> currentRoom.orFail().let {
pedestrian.registerVisit(it)
navigatingNode.asProperty<T, OrientingProperty<T, P, A, L, N, E>>()
.registerVisit(it)
strategy.inNewRoom(it)
}
in MOVING_TO_CROSSING_POINT_1..MOVING_TO_FINAL -> moving()
Expand All @@ -242,7 +258,7 @@ abstract class AbstractNavigationAction<T, P, A, L, R, N, E>(
*/
MOVING_TO_CROSSING_POINT_2,
/**
* When the second crossing point [isReached] (see [crossDoor]), the pedestrian may still be outside
* When the second crossing point [isReached] (see [crossDoor]), the node may still be outside
* any room. In such case it moves towards [expectedNewRoom] centroid until he/she enters a room.
*/
CROSSING_DOOR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,60 @@ package it.unibo.alchemist.model.implementations.actions
import it.unibo.alchemist.model.interfaces.Action
import it.unibo.alchemist.model.interfaces.Environment
import it.unibo.alchemist.model.interfaces.Node
import it.unibo.alchemist.model.interfaces.Pedestrian
import it.unibo.alchemist.model.interfaces.Position
import it.unibo.alchemist.model.interfaces.Reaction
import it.unibo.alchemist.model.interfaces.SteeringAction
import it.unibo.alchemist.model.interfaces.properties.PedestrianProperty
import it.unibo.alchemist.model.interfaces.geometry.GeometricTransformation
import it.unibo.alchemist.model.interfaces.geometry.Vector
import it.unibo.alchemist.model.interfaces.Node.Companion.asProperty

/**
* A [SteeringAction] in a vector space. The implementation of [nextPosition] is left to subclasses.
*/
abstract class AbstractSteeringAction<T, P, A>(
env: Environment<T, P>,
environment: Environment<T, P>,
/**
* The reaction in which this action is executed.
*/
protected open val reaction: Reaction<T>,
/**
* The owner of this action.
*/
protected open val pedestrian: Pedestrian<T, P, A>
) : AbstractMoveNode<T, P>(env, pedestrian),
node: Node<T>,
) : AbstractMoveNode<T, P>(environment, node),
SteeringAction<T, P>
where P : Position<P>, P : Vector<P>,
where P : Position<P>,
P : Vector<P>,
A : GeometricTransformation<P> {

/**
* The maximum distance the pedestrian can walk, this is a length.
* The maximum distance the node can walk, this is a length.
*/
open val maxWalk: Double get() = pedestrian.speed() / reaction.rate
open val maxWalk: Double get() = node.asProperty<T, PedestrianProperty<T>>().speed() / reaction.rate

/**
* @return The next position where to move, in absolute or relative coordinates depending on the
* value of isAbsolute.
*/
override fun getNextPosition(): P = nextPosition()

override fun getNode(): Pedestrian<T, P, A> = pedestrian

override fun cloneAction(node: Node<T>, reaction: Reaction<T>): Action<T> =
requireNodeTypeAndProduce<Pedestrian<T, P, A>, AbstractSteeringAction<T, P, A>>(node) {
cloneAction(it, reaction)
}

protected abstract fun cloneAction(n: Pedestrian<T, P, A>, r: Reaction<T>): AbstractSteeringAction<T, P, A>
/**
* This method allows to clone this action on a new node. It may result
* useful to support runtime creation of nodes with the same reaction
* programming, e.g. for morphogenesis.
*
* @param [node]
* The node where to clone this {@link Action}
* @param [reaction]
* The reaction to which the CURRENT action is assigned
* @return the cloned action
*/
abstract override fun cloneAction(node: Node<T>, reaction: Reaction<T>): AbstractSteeringAction<T, P, A>

/**
* Ensures that the passed [node] has type [N].
*/
protected inline fun <reified N : Node<*>, S : Action<*>> requireNodeTypeAndProduce(
node: Node<*>,
builder: (N) -> S
Expand Down
Loading