Skip to content

Commit

Permalink
Merge branch 'release-9.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
DanySK committed Sep 25, 2019
2 parents 1fbe8df + 374e405 commit 3fea543
Showing 139 changed files with 1,910 additions and 902 deletions.
21 changes: 13 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
reference_jdk: &reference_jdk
'JDK="[email protected]"'
'JDK="[email protected].0"'
reference_os: &reference_os
'linux'
official_repo: &official_repo
@@ -37,9 +37,10 @@ env:
- NO_WIN_DEFENDER=$(curl "${GRAVIS}.disable-windows-defender.sh" --output .no-defender.sh && source .no-defender.sh)
matrix:
- *reference_jdk
- JDK="[email protected]"
- JDK="[email protected]"
- JDK="[email protected]"
- JDK="[email protected]"
- JDK="[email protected]"
- JDK="[email protected]"
# - JDK="[email protected]"
matrix:
exclude:
- os: *reference_os
@@ -57,19 +58,26 @@ jobs:
workspaces:
create:
name: linux-reference-build
paths:
- "${TRAVIS_BUILD_DIR}/alchemist/build"
- stage: deploy
name: "Reports and deployment"
if: repo = env(OFFICIAL_REPO_SLUG) AND type != pull_request
os: *reference_os
env:
- PUBLISH="true"
- *reference_jdk
workspaces:
use:
- linux-reference-build
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 orchidDeploy -x test --scan --parallel > >(egrep -v '(null:-1:-1)|(t find node by signature)')
- ./gradlew dokka > >(egrep -v '(null:-1:-1)|(t find node by signature)') --scan
- ./gradlew fatJar projectReport orchidDeploy -x test --scan --parallel
- ./gradlew buildDashboard -x test
- mkdir -p report
- cp --parent */build/reports build/reports report -R
after_success:
@@ -83,9 +91,6 @@ script:
before_cache:
- curl "${GRAVIS}.clean_gradle_cache.sh" --output .clean_gradle_cache.sh
- bash .clean_gradle_cache.sh
workspaces:
use:
- linux-reference-build
cache:
directories:
- $HOME/.gradle/caches/
2 changes: 1 addition & 1 deletion alchemist/.idea/copyright/Alchemist.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions alchemist/.idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions alchemist/.idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
package it.unibo.alchemist.model.cognitiveagents.characteristics.cognitive

import com.google.common.primitives.Doubles
import com.uchuhimo.konf.Config
import it.unibo.alchemist.model.cognitiveagents.characteristics.PARAMETERS_FILE

/**
* The generic implementation of a cognitive characteristic.
*/
abstract class AbstractCognitiveCharacteristic : CognitiveCharacteristic {

/**
* The current level of this characteristic.
*/
protected var currentLevel: Double = 0.0
set(value) {
field = Doubles.constrainToRange(value, 0.0, 1.0)
}

override fun level() = currentLevel

/**
* Algorithm which decides how the parameters involved
* in the evolution of this characteristic must be combined together.
* It can be either a max, min, summation or any other type of function.
*/
abstract fun combinationFunction(): Double

companion object {
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
package it.unibo.alchemist.model.cognitiveagents.characteristics.cognitive

import it.unibo.alchemist.model.interfaces.CognitivePedestrian

/**
* The perception of the situation dangerousness.
* The name belief derives from the [IMPACT model](https://doi.org/10.1007/978-3-319-70647-4_11).
*
* @param zoneDangerousness
* the influence of the position of the agent owning this
* compared to the real position of the source of danger.
* @param fear
* the level of fear of the agent owning this.
* @param influencialPeople
* the list of cognitive agents with an influence on the agent owning this.
*/
class BeliefDanger(
private val zoneDangerousness: () -> Double,
private val fear: () -> Double,
private val influencialPeople: () -> List<CognitivePedestrian<*>>
private val influencialPeople: () -> List<CognitiveAgent>
) : MentalCognitiveCharacteristic() {

override fun combinationFunction(): Double = maxOf(
@@ -14,7 +24,7 @@ class BeliefDanger(
(affectiveBiasingOmega * fear() + influencialPeople().aggregateDangerBeliefs()) / (affectiveBiasingOmega + 1)
)

private fun List<CognitivePedestrian<*>>.aggregateDangerBeliefs() =
private fun List<CognitiveAgent>.aggregateDangerBeliefs() =
if (size > 0) {
this.sumByDouble { it.dangerBelief() } / size
} else 0.0
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package it.unibo.alchemist.model.cognitiveagents.characteristics.cognitive

/**
* A cognitive characteristic which has a body response.
*/
abstract class BodyCognitiveCharacteristic : AbstractCognitiveCharacteristic() {

override fun update(deltaT: Double) {
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package it.unibo.alchemist.model.cognitiveagents.characteristics.cognitive

/**
* An entity capable of having emotions and relations.
*/
interface CognitiveAgent {

/**
* Value representing the current belief of the situation dangerousness for this pedestrian.
*/
fun dangerBelief(): Double

/**
* Value representing the level of fear of this pedestrian.
*/
fun fear(): Double

/**
* Whether or not this pedestrian intends to evacuate.
*/
fun wantsToEvacuate(): Boolean

/**
* The list of all the cognitive characteristics of this pedestrian.
*/
fun cognitiveCharacteristics(): List<CognitiveCharacteristic>

/**
* A list of all the pedestrians inside at least one of the sensory spheres of this pedestrian.
*/
fun influencialPeople(): List<CognitiveAgent>
}
Original file line number Diff line number Diff line change
@@ -3,12 +3,12 @@ package it.unibo.alchemist.model.cognitiveagents.characteristics.cognitive
import it.unibo.alchemist.model.cognitiveagents.characteristics.Characteristic

/**
* A characteristic which depends also on the other pedestrians in the environment.
* A characteristic which depends on the other agents in the environment.
*/
interface CognitiveCharacteristic : Characteristic {

/**
* A number between 0 and 1 describing the current intensity of this characteristic.
* The current intensity of this characteristic.
*/
fun level(): Double

Original file line number Diff line number Diff line change
@@ -2,6 +2,9 @@ package it.unibo.alchemist.model.cognitiveagents.characteristics.cognitive

import com.uchuhimo.konf.ConfigSpec

/**
* A specification of the parameters regarding cognitive characteristics to load from a config file.
*/
object CognitiveSpec : ConfigSpec() {
val sensingOmega by required<Double>()
val affectiveBiasingOmega by required<Double>()
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package it.unibo.alchemist.model.cognitiveagents.characteristics.cognitive

/**
* The desire to evacuate.
*
* @param compliance
* the current level of compliance of the agent owning this.
* @param dangerBelief
* the current level of danger belief of the agent owning this.
* @param fear
* the current level of fear of the agent owning this.
*/
class DesireEvacuate(
private val compliance: Double,
private val dangerBelief: () -> Double,
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package it.unibo.alchemist.model.cognitiveagents.characteristics.cognitive

/**
* The desire not to evacuate.
*
* @param compliance
* the current level of compliance of the agent owning this.
* @param dangerBelief
* the current level of danger belief of the agent owning this.
* @param fear
* the current level of fear of the agent owning this.
*/
class DesireWalkRandomly(
private val compliance: Double,
private val dangerBelief: () -> Double,
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
package it.unibo.alchemist.model.cognitiveagents.characteristics.cognitive

import it.unibo.alchemist.model.interfaces.CognitivePedestrian
import it.unibo.alchemist.model.cognitiveagents.characteristics.utils.advancedLogistic

/**
* The fear emotion.
*
* @param desireWalkRandomly
* the current desire of not evacuating of the agent owning this.
* @param desireEvacuate
* the current desire of evacuating of the agent owning this.
* @param influencialPeople
* the list of cognitive agents with an influence on the agent owning this.
*/
class Fear(
private val desireWalkRandomly: () -> Double,
private val desireEvacuate: () -> Double,
private val influencialPeople: () -> List<CognitivePedestrian<*>>
private val influencialPeople: () -> List<CognitiveAgent>
) : MentalCognitiveCharacteristic() {

override fun combinationFunction() = maxOf(
@@ -19,7 +28,7 @@ class Fear(
)
)

private fun List<CognitivePedestrian<*>>.aggregateFears() =
private fun List<CognitiveAgent>.aggregateFears() =
if (size > 0) {
this.sumByDouble { it.fear() } / this.size
} else 0.0
Original file line number Diff line number Diff line change
@@ -2,6 +2,14 @@ package it.unibo.alchemist.model.cognitiveagents.characteristics.cognitive

import it.unibo.alchemist.model.cognitiveagents.characteristics.utils.logistic

/**
* The intention to evacuate of .
*
* @param desireWalkRandomly
* the desire not to evacuate of the agent owning this characteristic.
* @param desireEvacuate
* the desire to evacuate of the agent owning this characteristic.
*/
class IntentionEvacuate(
private val desireWalkRandomly: () -> Double,
private val desireEvacuate: () -> Double
Original file line number Diff line number Diff line change
@@ -2,6 +2,14 @@ package it.unibo.alchemist.model.cognitiveagents.characteristics.cognitive

import it.unibo.alchemist.model.cognitiveagents.characteristics.utils.logistic

/**
* The intention not to evacuate.
*
* @param desireWalkRandomly
* the desire not to evacuate of the agent owning this characteristic.
* @param desireEvacuate
* the desire to evacuate of the agent owning this characteristic.
*/
class IntentionWalkRandomly(
private val desireWalkRandomly: () -> Double,
private val desireEvacuate: () -> Double
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package it.unibo.alchemist.model.cognitiveagents.characteristics.cognitive

/**
* A cognitive characteristic which has a mental response.
*/
abstract class MentalCognitiveCharacteristic : AbstractCognitiveCharacteristic() {

override fun update(deltaT: Double) {
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package it.unibo.alchemist.model.cognitiveagents.characteristics.individual

enum class Age : IndividualCharacteristic {
import it.unibo.alchemist.model.cognitiveagents.characteristics.Characteristic

/**
* An enum representing the different periods of life.
*/
enum class Age : Characteristic {

CHILD,
ADULT,
@@ -14,12 +19,24 @@ enum class Age : IndividualCharacteristic {
private const val ADULT_KEYWORD = "adult"
private const val ELDERLY_KEYWORD = "elderly"

/**
* Returns the corresponding age in this enum given the age in years.
*
* @param age
* the age in years.
*/
fun fromYears(age: Int): Age = when {
age < CHILD_THRESHOLD -> CHILD
age < ADULT_THRESHOLD -> ADULT
else -> ELDERLY
}

/**
* Returns the corresponding age in this enum given a string resembling it.
*
* @param age
* the age as a string.
*/
fun fromString(age: String): Age = when {
age.equals(CHILD_KEYWORD, ignoreCase = true) -> CHILD
age.equals(ADULT_KEYWORD, ignoreCase = true) -> ADULT
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
package it.unibo.alchemist.model.cognitiveagents.characteristics.individual

import com.uchuhimo.konf.Config
import it.unibo.alchemist.model.cognitiveagents.characteristics.Characteristic
import it.unibo.alchemist.model.cognitiveagents.characteristics.PARAMETERS_FILE

class Compliance(age: Age, gender: Gender) : IndividualCharacteristic {
/**
* The level of compliance of an agent considering its gender and its age.
*
* @param age
* the age of the agent.
* @param gender
* the gender of the agent.
*/
class Compliance(age: Age, gender: Gender) : Characteristic {

/**
* The calculated level of compliance.
*/
val level = when {
age == Age.CHILD && gender == Gender.MALE -> childMale
age == Age.ADULT && gender == Gender.MALE -> adultMale
Original file line number Diff line number Diff line change
@@ -2,6 +2,9 @@ package it.unibo.alchemist.model.cognitiveagents.characteristics.individual

import com.uchuhimo.konf.ConfigSpec

/**
* A specification of the parameters regarding compliance to load from a config file.
*/
object ComplianceSpec : ConfigSpec() {
val childMale by required<Double>()
val adultMale by required<Double>()
Loading

0 comments on commit 3fea543

Please sign in to comment.