-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
78 changed files
with
1,868 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
reference_jdk: &reference_jdk | ||
'JDK="[email protected]"' | ||
reference_os: &reference_os | ||
'linux' | ||
official_repo: &official_repo | ||
'AlchemistSimulator/Alchemist' | ||
language: bash | ||
git: | ||
depth: false | ||
os: | ||
- osx | ||
- windows | ||
- linux | ||
- *reference_os | ||
dist: xenial | ||
addons: | ||
apt: | ||
|
@@ -27,73 +33,58 @@ env: | |
- TERM=dumb | ||
- GRAVIS="https://raw.githubusercontent.com/DanySK/Gravis-CI/master/" | ||
- PUBLISH="false" | ||
- OFFICIAL_REPO_SLUG="AlchemistSimulator/Alchemist" | ||
matrix: | ||
- JDK="[email protected]" | ||
- *reference_jdk | ||
- JDK="[email protected]" | ||
- JDK="[email protected]" | ||
- JDK="1.12.0-1" | ||
- JDK="adopt-openj9@1.12.33-0" | ||
matrix: | ||
exclude: | ||
- os: linux | ||
env: JDK="[email protected]" | ||
- os: *reference_os | ||
env: *reference_jdk | ||
jobs: | ||
include: | ||
- stage: check | ||
name: "Compile, check, test on Linux and OpenJDK11" | ||
os: linux | ||
name: "Deep check on reference OS and JDK" | ||
os: *reference_os | ||
env: | ||
- JDK="[email protected]" | ||
script: |- | ||
cd "$TRAVIS_BUILD_DIR"/alchemist | ||
./gradlew clean check --scan | ||
- *reference_jdk | ||
script: | ||
- cd "$TRAVIS_BUILD_DIR"/alchemist | ||
- ./gradlew clean check fatJar --scan --parallel | ||
- stage: deploy | ||
name: "Preparation of reports and deployment" | ||
os: linux | ||
name: "Reports and deployment" | ||
if: repo = env(OFFICIAL_REPO_SLUG) AND type != pull_request | ||
os: *reference_os | ||
env: | ||
- PUBLISH="true" | ||
- JDK="[email protected]" | ||
script: |- | ||
cd "$TRAVIS_BUILD_DIR"/alchemist | ||
./gradlew clean fatJar dokka buildDashboard projectReport -x test --scan > >(egrep -v '(null:-1:-1)|(t find node by signature)') | ||
- *reference_jdk | ||
install: | ||
- openssl aes-256-cbc -K $encrypted_9993846e3f84_key -iv $encrypted_9993846e3f84_iv -in prepare_environment.sh.enc -out prepare_environment.sh -d | ||
- bash prepare_environment.sh | ||
script: | ||
- cd "$TRAVIS_BUILD_DIR"/alchemist | ||
- ./gradlew fatJar dokka buildDashboard projectReport -x test --scan --parallel > >(egrep -v '(null:-1:-1)|(t find node by signature)') | ||
- mkdir -p report | ||
- cp --parent */build/reports build/reports report -R | ||
after_success: | ||
- ./gradlew orchidDeploy publish --scan --parallel --stacktrace | ||
before_install: | ||
- curl "${GRAVIS}.disable-windows-defender.sh" --output .disable-windows-defender.sh | ||
- source .disable-windows-defender.sh | ||
- curl "${GRAVIS}.install-jdk-travis.sh" --output .install-jdk-travis.sh | ||
- source .install-jdk-travis.sh | ||
- |- | ||
export SHOULD_CONFIGURE="$( | ||
if [ $TRAVIS_OS_NAME = 'linux' ] && \ | ||
[ $TRAVIS_PULL_REQUEST = "false" ] && \ | ||
[ $TRAVIS_REPO_SLUG = 'AlchemistSimulator/Alchemist' ] | ||
then | ||
echo 'true' | ||
else | ||
echo 'false' | ||
fi | ||
)" | ||
- echo should configure? $SHOULD_CONFIGURE | ||
install: >- | ||
if $SHOULD_CONFIGURE; then | ||
openssl aes-256-cbc -K $encrypted_9993846e3f84_key -iv $encrypted_9993846e3f84_iv -in prepare_environment.sh.enc -out prepare_environment.sh -d | ||
bash prepare_environment.sh | ||
fi | ||
script: |- | ||
cd "$TRAVIS_BUILD_DIR"/alchemist | ||
./gradlew clean test --scan | ||
script: | ||
- cd "$TRAVIS_BUILD_DIR"/alchemist | ||
- ./gradlew clean test --scan --parallel | ||
before_cache: | ||
- curl "${GRAVIS}.clean_gradle_cache.sh" --output .clean_gradle_cache.sh | ||
- bash .clean_gradle_cache.sh | ||
cache: | ||
directories: | ||
- $HOME/.gradle/caches/ | ||
- $HOME/.gradle/wrapper/ | ||
after_success: |- | ||
cd "$TRAVIS_BUILD_DIR"/alchemist | ||
if $SHOULD_CONFIGURE && $PUBLISH; then | ||
./gradlew orchidDeploy publish --scan --stacktrace | ||
mkdir -p report | ||
cp --parent */build/reports build/reports report -R | ||
fi | ||
deploy: | ||
- provider: releases | ||
skip_cleanup: true | ||
|
@@ -102,38 +93,43 @@ deploy: | |
file_glob: true | ||
file: "${HOME}/build/${TRAVIS_REPO_SLUG}/alchemist/build/libs/alchemist-redist*.jar" | ||
on: | ||
repo: AlchemistSimulator/Alchemist | ||
os: *reference_os | ||
repo: *official_repo | ||
tags: true | ||
condition: $PUBLISH = true | ||
condition: $PUBLISH = "true" | ||
- provider: surge | ||
skip_cleanup: true | ||
project: "./alchemist/build/docs/javadoc/" | ||
domain: alchemist-unstable-doc.surge.sh | ||
on: | ||
repo: AlchemistSimulator/Alchemist | ||
os: *reference_os | ||
repo: *official_repo | ||
branch: develop | ||
condition: $PUBLISH = true | ||
condition: $PUBLISH = "true" | ||
- provider: surge | ||
skip_cleanup: true | ||
project: "./alchemist/report" | ||
domain: alchemist-unstable-reports.surge.sh | ||
on: | ||
repo: AlchemistSimulator/Alchemist | ||
os: *reference_os | ||
repo: *official_repo | ||
branch: develop | ||
condition: $PUBLISH = true | ||
condition: $PUBLISH = "true" | ||
- provider: surge | ||
skip_cleanup: true | ||
project: "./alchemist/build/docs/javadoc/" | ||
domain: alchemist-doc.surge.sh | ||
on: | ||
repo: AlchemistSimulator/Alchemist | ||
os: *reference_os | ||
repo: *official_repo | ||
tags: true | ||
condition: $PUBLISH = true | ||
condition: $PUBLISH = "true" | ||
- provider: surge | ||
skip_cleanup: true | ||
project: "./alchemist/report" | ||
domain: alchemist-reports.surge.sh | ||
on: | ||
repo: AlchemistSimulator/Alchemist | ||
os: *reference_os | ||
repo: *official_repo | ||
tags: true | ||
condition: $PUBLISH = true | ||
condition: $PUBLISH = "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...gnitive-agents/src/main/kotlin/it/unibo/alchemist/model/implementations/actions/Arrive.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package it.unibo.alchemist.model.implementations.actions | ||
|
||
import it.unibo.alchemist.model.implementations.actions.utils.makePosition | ||
import it.unibo.alchemist.model.interfaces.Environment | ||
import it.unibo.alchemist.model.interfaces.Pedestrian | ||
import it.unibo.alchemist.model.interfaces.Position | ||
import it.unibo.alchemist.model.interfaces.movestrategies.SpeedSelectionStrategy | ||
import it.unibo.alchemist.model.interfaces.movestrategies.TargetSelectionStrategy | ||
|
||
/** | ||
* Move the agent towards a target position. | ||
* It is similar to Seek but it attempts to arrive at the target position with a zero velocity. | ||
* | ||
* @param env | ||
* the environment inside which the pedestrian moves. | ||
* @param pedestrian | ||
* the owner of this action. | ||
* @param decelerationRadius | ||
* the distance from which the pedestrian starts to decelerate. | ||
* @param arrivalTolerance | ||
* the distance at which the pedestrian is considered arrived to the target. | ||
* @param coords | ||
* the coordinates of the position the pedestrian moves towards. | ||
*/ | ||
open class Arrive<T, P : Position<P>>( | ||
env: Environment<T, P>, | ||
pedestrian: Pedestrian<T>, | ||
decelerationRadius: Double, | ||
arrivalTolerance: Double, | ||
vararg coords: Double | ||
) : SteeringActionImpl<T, P>( | ||
env, | ||
pedestrian, | ||
TargetSelectionStrategy { env.makePosition(coords.toTypedArray()) }, | ||
SpeedSelectionStrategy { | ||
target -> with(env.getPosition(pedestrian).getDistanceTo(target)) { | ||
when { | ||
this < arrivalTolerance -> 0.0 | ||
this < decelerationRadius -> pedestrian.walkingSpeed * this / decelerationRadius | ||
else -> pedestrian.walkingSpeed | ||
} | ||
} | ||
} | ||
) |
39 changes: 39 additions & 0 deletions
39
...-agents/src/main/kotlin/it/unibo/alchemist/model/implementations/actions/AvoidGradient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package it.unibo.alchemist.model.implementations.actions | ||
|
||
import it.unibo.alchemist.model.interfaces.Pedestrian | ||
import it.unibo.alchemist.model.interfaces.Environment | ||
import it.unibo.alchemist.model.interfaces.Molecule | ||
import it.unibo.alchemist.model.interfaces.Position2D | ||
import org.apache.commons.math3.random.RandomGenerator | ||
|
||
/** | ||
* Move the pedestrian towards positions of the environment with a low concentration of the target molecule. | ||
* | ||
* @param env | ||
* the environment inside which the pedestrian moves. | ||
* @param pedestrian | ||
* the owner of this action. | ||
* @param targetMolecule | ||
* the {@link Molecule} you want to know the concentration in the different positions of the environment. | ||
* @param rg | ||
* the simulation {@link RandomGenerator}. | ||
* @param radius | ||
* the distance all the positions where the molecule concentration is checked | ||
* must have from the current pedestrian position. | ||
*/ | ||
open class AvoidGradient<T, P : Position2D<P>>( | ||
env: Environment<T, P>, | ||
pedestrian: Pedestrian<T>, | ||
targetMolecule: Molecule, | ||
rg: RandomGenerator, | ||
radius: Double | ||
) : GradientSteeringAction<T, P>( | ||
env, | ||
pedestrian, | ||
targetMolecule, | ||
rg, | ||
radius, | ||
{ molecule -> with(env.getLayer(molecule).get()) { | ||
map { it to getValue(it) as Double }.minBy { it.second }?.first | ||
} } | ||
) |
44 changes: 44 additions & 0 deletions
44
...nitive-agents/src/main/kotlin/it/unibo/alchemist/model/implementations/actions/Blended.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package it.unibo.alchemist.model.implementations.actions | ||
|
||
import it.unibo.alchemist.model.implementations.actions.utils.makePosition | ||
import it.unibo.alchemist.model.implementations.actions.utils.times | ||
import it.unibo.alchemist.model.interfaces.Environment | ||
import it.unibo.alchemist.model.interfaces.Pedestrian | ||
import it.unibo.alchemist.model.interfaces.Position | ||
import it.unibo.alchemist.model.interfaces.SteeringAction | ||
import it.unibo.alchemist.model.interfaces.movestrategies.SpeedSelectionStrategy | ||
import it.unibo.alchemist.model.interfaces.movestrategies.TargetSelectionStrategy | ||
|
||
/** | ||
* Combination of multiple steering actions. | ||
* | ||
* @param env | ||
* the environment inside which the pedestrian moves. | ||
* @param pedestrian | ||
* the owner of this action. | ||
* @param actions | ||
* the list of actions to combine to determine the pedestrian movement. | ||
* @param formula | ||
* the logic according to the actions inside the list are combined. | ||
*/ | ||
open class Blended<T, P : Position<P>> @JvmOverloads constructor( | ||
env: Environment<T, P>, | ||
pedestrian: Pedestrian<T>, | ||
actions: List<SteeringAction<T, P>>, | ||
formula: List<SteeringAction<T, P>>.() -> P = { | ||
val currentPosition = env.getPosition(pedestrian) | ||
if (size > 1) { | ||
with(map { it.nextPosition() to it.target().getDistanceTo(currentPosition) }) { | ||
val totalDistance = map { it.second }.sum() | ||
filter { totalDistance > 0 }.map { | ||
env.makePosition(it.first * (1 - (it.second / totalDistance))) | ||
}.fold(currentPosition) { accumulator, position -> accumulator + position } | ||
} | ||
} else firstOrNull()?.let { currentPosition + it.nextPosition() } ?: currentPosition | ||
} | ||
) : SteeringActionImpl<T, P>( | ||
env, | ||
pedestrian, | ||
TargetSelectionStrategy { actions.formula() }, | ||
SpeedSelectionStrategy { pedestrian.walkingSpeed } | ||
) |
24 changes: 24 additions & 0 deletions
24
...cognitive-agents/src/main/kotlin/it/unibo/alchemist/model/implementations/actions/Flee.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package it.unibo.alchemist.model.implementations.actions | ||
|
||
import it.unibo.alchemist.model.interfaces.Environment | ||
import it.unibo.alchemist.model.interfaces.Pedestrian | ||
import it.unibo.alchemist.model.interfaces.Position | ||
|
||
/** | ||
* Move the agent away from a target position. It's the opposite of Seek. | ||
* | ||
* @param env | ||
* the environment inside which the pedestrian moves. | ||
* @param pedestrian | ||
* the owner of this action. | ||
* @param coords | ||
* the coordinates of the position the pedestrian moves away. | ||
*/ | ||
open class Flee<T, P : Position<P>>( | ||
env: Environment<T, P>, | ||
pedestrian: Pedestrian<T>, | ||
vararg coords: Double | ||
) : Seek<T, P>(env, pedestrian, *coords) { | ||
|
||
override fun getDestination(current: P, target: P, maxWalk: Double): P = super.getDestination(target, current, maxWalk) | ||
} |
Oops, something went wrong.