Skip to content

Commit

Permalink
Merge branch 'release-8.2.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
DanySK committed Aug 1, 2019
2 parents d91b38c + db80a63 commit b813682
Show file tree
Hide file tree
Showing 78 changed files with 1,868 additions and 153 deletions.
104 changes: 50 additions & 54 deletions .travis.yml
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:
Expand All @@ -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
Expand All @@ -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"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Install the following plugins (use <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>A</kbd>

#### Importing the project

0. Windows user should perform an additional first step: before cloning the repository, make sure that the autocrlf feature of git is disabled, by issuing `git config --global core.autocrlf false`. If the step is not performed, git will automatically insert CRLF line endings, violating the project's Checkstyle rules (which are rather strict, and prevent the build from succeeding).
0. Clone this repository in a folder of your preference using `git clone` appropriately
0. Open IntellJ. If a project opens automatically, select "Close project". You should be on the welcome screen of IntelliJ idea, with an aspect similar to this image: ![IntelliJ Welcome Screen](https://www.jetbrains.com/help/img/idea/2018.2/ideaWelcomeScreen.png)
0. Select "Import Project"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import it.unibo.alchemist.model.interfaces.CognitivePedestrian
class BeliefDanger(
private val dangerousZone: () -> Double,
private val fear: () -> Double,
private val influencialPeople: () -> Collection<CognitivePedestrian<*>>
private val influencialPeople: () -> List<CognitivePedestrian<*>>
) : MentalCognitiveCharacteristic() {

override fun combinationFunction() = maxOf(
Expand All @@ -14,6 +14,6 @@ class BeliefDanger(
(affectiveBiasingOmega * fear() + influencialPeople().aggregateDangerBeliefs()) / (affectiveBiasingOmega + 1)
)

private fun Collection<CognitivePedestrian<*>>.aggregateDangerBeliefs() =
private fun List<CognitivePedestrian<*>>.aggregateDangerBeliefs() =
this.sumByDouble { it.dangerBelief() } / this.size
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import it.unibo.alchemist.model.cognitiveagents.characteristics.utils.advancedLo
class Fear(
private val desireWalkRandomly: () -> Double,
private val desireEvacuate: () -> Double,
private val influencialPeople: () -> Collection<CognitivePedestrian<*>>
private val influencialPeople: () -> List<CognitivePedestrian<*>>
) : MentalCognitiveCharacteristic() {

override fun combinationFunction() = maxOf(
Expand All @@ -19,6 +19,6 @@ class Fear(
)
)

private fun Collection<CognitivePedestrian<*>>.aggregateFears() =
private fun List<CognitivePedestrian<*>>.aggregateFears() =
this.sumByDouble { it.fear() } / this.size
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import it.unibo.alchemist.model.cognitiveagents.characteristics.PARAMETERS_FILE
class Compliance(age: Age, gender: Gender) : IndividualCharacteristic {

val level = when {
age == Age.ELDERLY && gender == Gender.MALE -> 0.92
age == Age.ELDERLY && gender == Gender.FEMALE -> 0.97
age == Age.ADULT && gender == Gender.MALE -> 0.89
age == Age.ADULT && gender == Gender.FEMALE -> 0.94
else -> 0.89 // Age.CHILD
age == Age.CHILD && gender == Gender.MALE -> childMale
age == Age.ADULT && gender == Gender.MALE -> adultMale
age == Age.ELDERLY && gender == Gender.MALE -> elderlyMale
age == Age.CHILD && gender == Gender.FEMALE -> childFemale
age == Age.ADULT && gender == Gender.FEMALE -> adultFemale
else -> elderlyFemale
}

companion object {
Expand Down
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
}
}
}
)
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
} }
)
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 }
)
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)
}
Loading

0 comments on commit b813682

Please sign in to comment.