All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.unibo.alchemist.model.cognitive.impact.individual.Compliance.kt Maven / Gradle / Ivy

There is a newer version: 35.0.0
Show newest version
package it.unibo.alchemist.model.cognitive.impact.individual

import com.uchuhimo.konf.Config
import com.uchuhimo.konf.source.toml
import it.unibo.alchemist.model.cognitive.impact.PARAMETERS_FILE

/**
 * 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
        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 {
        private val config = Config { addSpec(ComplianceSpec) }
            .from.toml.resource(PARAMETERS_FILE)

        private val childMale = config[ComplianceSpec.childMale]
        private val adultMale = config[ComplianceSpec.adultMale]
        private val elderlyMale = config[ComplianceSpec.elderlyMale]
        private val childFemale = config[ComplianceSpec.childFemale]
        private val adultFemale = config[ComplianceSpec.adultFemale]
        private val elderlyFemale = config[ComplianceSpec.elderlyFemale]
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy