From 44cb21ea1e9f7e6ede7d36e062990e4456265252 Mon Sep 17 00:00:00 2001 From: Luis Gustavo Nardin Date: Sun, 9 Sep 2018 08:57:44 +0200 Subject: [PATCH] Add investigation output; Maven plugin update --- .classpath | 21 +- .gitignore | 9 +- .project | 7 - .settings/org.eclipse.jdt.core.prefs | 2 + CHANGES.LOG | 4 + pom.xml | 19 +- script/runBatch.sh | 2 +- script/runRandomBatch.sh | 4 +- script/runSim.sh | 4 +- src/main/java/gloderss/Constants.java | 398 ++++----- .../entrepreneur/EntrepreneurAgent.java | 10 +- .../intermediaryOrg/IntermediaryOrg.java | 2 +- .../java/gloderss/agents/state/IStateOrg.java | 54 +- .../agents/state/PoliceOfficerAgent.java | 284 ++++--- .../java/gloderss/agents/state/StateOrg.java | 790 ++++++++++-------- .../CommunicationController.java | 4 +- src/main/java/gloderss/conf/FilenameConf.java | 13 + src/main/java/gloderss/conf/StateConf.java | 13 + .../java/gloderss/main/RunSimulation.java | 150 ++-- .../java/gloderss/output/AbstractEntity.java | 1 + .../output/InvestigationOutputEntity.java | 107 +++ .../gloderss/output/OutputController.java | 5 +- src/main/resources/conf/{ => batch}/batch.xml | 4 +- src/main/resources/conf/batch/general.txt | 1 + .../resources/conf/batch/state-no-noNorm.txt | 1 + .../resources/conf/batch/state-no-norm.txt | 1 + .../conf/batch/state-strong-noNorm.txt | 1 + .../conf/batch/state-strong-norm.txt | 1 + .../conf/batch/state-weak-noNorm.txt | 1 + .../resources/conf/batch/state-weak-norm.txt | 1 + src/main/resources/conf/scenario-B.xml | 314 +++++++ src/main/resources/conf/scenario-CA.xml | 378 +++++++++ src/main/resources/conf/scenario-LA.xml | 379 +++++++++ src/main/resources/conf/scenario-SA.xml | 324 +++++++ src/main/resources/conf/scenario.xml | 2 + src/main/resources/conf/scenario.xsd | 2 + .../conf/sensitivity-analysis/consumer.xml | 12 + .../conf/sensitivity-analysis/emilia.xsd | 17 + .../sensitivity-analysis/entrepreneur.xml | 12 + .../randomBatch.xml | 14 +- .../conf/sensitivity-analysis/randomBatch.xsd | 31 + .../scenario.xml} | 277 ++---- .../conf/sensitivity-analysis/scenario.xsd | 662 +++++++++++++++ src/test/java/gloderss/conf/ScenarioTest.java | 27 +- 44 files changed, 3294 insertions(+), 1071 deletions(-) mode change 100755 => 100644 .classpath mode change 100755 => 100644 .project create mode 100644 src/main/java/gloderss/output/InvestigationOutputEntity.java rename src/main/resources/conf/{ => batch}/batch.xml (94%) create mode 100755 src/main/resources/conf/scenario-B.xml create mode 100644 src/main/resources/conf/scenario-CA.xml create mode 100644 src/main/resources/conf/scenario-LA.xml create mode 100644 src/main/resources/conf/scenario-SA.xml create mode 100755 src/main/resources/conf/sensitivity-analysis/consumer.xml create mode 100755 src/main/resources/conf/sensitivity-analysis/emilia.xsd create mode 100755 src/main/resources/conf/sensitivity-analysis/entrepreneur.xml rename src/main/resources/conf/{ => sensitivity-analysis}/randomBatch.xml (91%) create mode 100644 src/main/resources/conf/sensitivity-analysis/randomBatch.xsd rename src/main/resources/conf/{scenario.xml.old => sensitivity-analysis/scenario.xml} (52%) mode change 100755 => 100644 create mode 100755 src/main/resources/conf/sensitivity-analysis/scenario.xsd diff --git a/.classpath b/.classpath old mode 100755 new mode 100644 index ace8266..0ca1374 --- a/.classpath +++ b/.classpath @@ -15,9 +15,16 @@ + + + + + + + @@ -27,9 +34,21 @@ - + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore index ca97329..6b7ce95 100755 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ -*.class +.settings +.project +.classpath -# Mobile Tools for Java (J2ME) -.mtj.tmp/ +*.class # Package Files # *.jar @@ -15,4 +16,4 @@ hs_err_pid* /output /log *.csv -*.log +*.log \ No newline at end of file diff --git a/.project b/.project old mode 100755 new mode 100644 index 412a914..5249f33 --- a/.project +++ b/.project @@ -10,11 +10,6 @@ - - de.walware.statet.r.builders.RSupport - - - org.eclipse.m2e.core.maven2Builder @@ -24,7 +19,5 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature - de.walware.statet.base.StatetNature - de.walware.statet.r.RNature diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 714351a..5592a0a 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -2,4 +2,6 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.processAnnotations=disabled +org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.8 diff --git a/CHANGES.LOG b/CHANGES.LOG index df4fbff..34ece0c 100755 --- a/CHANGES.LOG +++ b/CHANGES.LOG @@ -1,6 +1,10 @@ Changes ======= +09/07/2018 +---------- +1. (New Feature) Log the number of General and Specific Investigations conducted and requested + 08/05/2017 ---------- 1. (New Feature) Created the GLODERSRandomBatch that allows the execution of a set of diff --git a/pom.xml b/pom.xml index 0951196..a370a08 100755 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,5 @@ - + 4.0.0 gloderss @@ -9,14 +9,14 @@ UTF-8 - 3.2 - 1.3.2 - 2.6 + 3.8.0 + 3.1.0 + 1.6.0 1.8 0.1 - 4.11 - 1.7.7 - 1.1.2 + 4.12 + 1.7.25 + 1.2.3 1.2.0 0.9.4 3.12.1.GA @@ -130,7 +130,8 @@ java - -Xmx1024m -javaagent:target/${project.artifactId}-${project.version}.jar -classpath %classpath gloderss.GLODERSSimulator ${exec.args} + + -Xmx1024m -classpath %classpath gloderss.GLODERSSimulator ${exec.args} diff --git a/script/runBatch.sh b/script/runBatch.sh index 4744a77..c258b9d 100755 --- a/script/runBatch.sh +++ b/script/runBatch.sh @@ -1,6 +1,6 @@ #!/bin/bash -XMLpath=src/main/resources/conf/sampleBatch.xml +XMLpath=src/main/resources/conf/batch/batch.xml XSDpath=src/main/resources/conf/batch.xsd if [ $# -gt 0 ] diff --git a/script/runRandomBatch.sh b/script/runRandomBatch.sh index 8375589..c6ab952 100755 --- a/script/runRandomBatch.sh +++ b/script/runRandomBatch.sh @@ -1,6 +1,6 @@ #!/bin/bash -XMLpath=src/main/resources/conf/randomBatch.xml +XMLpath=src/main/resources/conf/sensitivity-analysis/randomBatch.xml XSDpath=src/main/resources/conf/randomBatch.xsd if [ $# -gt 0 ] @@ -9,7 +9,7 @@ then then XMLpath=$1 else - echo "./runBatch.sh [Batch XML path]" + echo "./runRandomBatch.sh [Batch XML path]" exit 1 fi fi diff --git a/script/runSim.sh b/script/runSim.sh index 3627ed0..10c6bd8 100755 --- a/script/runSim.sh +++ b/script/runSim.sh @@ -1,6 +1,6 @@ #!/bin/bash -XMLpath=src/test/resources/conf/sampleScenario.xml +XMLpath=src/test/resources/conf/scenario.xml XSDpath=src/main/resources/conf/scenario.xsd if [ $# -gt 0 ] @@ -15,4 +15,4 @@ then fi cd .. -/usr/bin/mvn exec:exec -Pexec -Dexec.args="$XMLpath $XSDpath" \ No newline at end of file +/usr/bin/mvn exec:exec -Pexec -Dexec.args="$XMLpath $XSDpath" diff --git a/src/main/java/gloderss/Constants.java b/src/main/java/gloderss/Constants.java index b7f0f90..08958d7 100755 --- a/src/main/java/gloderss/Constants.java +++ b/src/main/java/gloderss/Constants.java @@ -1,377 +1,381 @@ package gloderss; public final class Constants { - + /** * General */ - + public static final String ENCONDING = "UTF-8"; - + /** * Parameters */ public static final String PARAM_XML_FILENAME = "xmlFilename"; - + public static final String PARAM_XSD_FILENAME = "xsdFilename"; - + /** * Simulation tags */ public static final String TAG_NAMESPACE = "palermo.conf"; - + public static final String TAG_SCENARIO = "scenario"; - + /** * General tags */ public static final String TAG_GENERAL = "general"; - + public static final String TAG_NUMBER_REPLICATIONS = "numberReplications"; - + public static final String TAG_NUMBER_CYCLES = "numberCycles"; - + public static final String TAG_NETWORK_TOPOLOGY = "networkTopology"; - + public static final String TAG_CITIZENS_DISTRIBUTION = "citizensDistribution"; - + /** * Seed tags */ public static final String TAG_SEEDS = "seeds"; - + public static final String TAG_SEED = "seed"; - + /** * Output tags */ public static final String TAG_OUTPUT = "output"; - + public static final String TAG_OUTPUT_DIRECTORY = "directory"; - + public static final String TAG_OUTPUT_APPEND = "append"; - + public static final String TAG_OUTPUT_SEPARATOR = "separator"; - + public static final String TAG_OUTPUT_TIME_TO_WRITE = "timeToWrite"; - + /** * Filename tags */ public static final String TAG_FILENAME = "filename"; - + public static final String TAG_FILENAME_EXTORTION = "extortion"; - + public static final String TAG_FILENAME_COMPENSATION = "compensation"; - + public static final String TAG_FILENAME_PURCHASE = "purchase"; - + public static final String TAG_FILENAME_NORMATIVE = "normative"; - + public static final String TAG_FILENAME_ENTREPRENEUR = "entrepreneur"; - + public static final String TAG_FILENAME_CONSUMER = "consumer"; - + public static final String TAG_FILENAME_MAFIA = "mafia"; - + public static final String TAG_FILENAME_MAFIOSI = "mafiosi"; - + public static final String TAG_FILENAME_STATE = "state"; - + + public static final String TAG_FILENAME_INVESTIGATION = "investigation"; + public static final String TAG_FILENAME_INTERMEDIARY_ORGANIZATION = "intermediaryOrganization"; - + /** * Visibility tags */ public static final String TAG_COMMUNICATION = "communication"; - + public static final String TAG_COMMUNICATION_TYPES = "types"; - + public static final String TAG_COMMUNICATION_TYPE = "type"; - + public static final String TAG_COMMUNICATION_TYPE_NAME = "name"; - + public static final String TAG_COMMUNICATION_ACTIONS = "actions"; - + public static final String TAG_COMMUNICATION_ACTION = "action"; - + public static final String TAG_COMMUNICATION_ACTION_NAME = "name"; - + /** * Consumers tags */ public static final String TAG_CONSUMERS = "consumers"; - + public static final String TAG_CONSUMER = "consumer"; - + public static final String TAG_CONSUMER_NUMBER_CONSUMERS = "numberConsumers"; - + public static final String TAG_CONSUMER_LOGGING_TIME_UNIT = "loggingTimeUnit"; - + public static final String TAG_CONSUMER_CLUSTERED = "clustered"; - + public static final String TAG_CONSUMER_BUY_PDF = "buyPDF"; - + public static final String TAG_CONSUMER_NUMBER_ENTREPRENEURS_SEARCH = "numberEntrepreneursSearch"; - + public static final String TAG_CONSUMER_REPUTATION = "reputation"; - + public static final String TAG_CONSUMER_REPUTATION_ENTREPRENEUR = "entrepreneur"; - + public static final String TAG_CONSUMER_REPUTATION_ENTREPRENEUR_THRESHOLD = "entrepreneurThreshold"; - + public static final String TAG_CONSUMER_SANCTION = "sanction"; - + public static final String TAG_CONSUMER_SANCTION_THRESHOLD = "threshold"; - + public static final String TAG_CONSUMER_SANCTION_DISCERNABILITY = "discernability"; - + /** * Entrepreneurs tags */ public static final String TAG_ENTREPRENEURS = "entrepreneurs"; - + public static final String TAG_ENTREPRENEUR = "entrepreneur"; - + public static final String TAG_ENTREPRENEUR_NUMBER_ENTREPRENEURS = "numberEntrepreneurs"; - + public static final String TAG_ENTREPRENEUR_LOGGING_TIME_UNIT = "loggingTimeUnit"; - + public static final String TAG_ENTREPRENEUR_CLUSTERED = "clustered"; - + public static final String TAG_ENTREPRENEUR_WEALTH = "wealth"; - + public static final String TAG_ENTREPRENEUR_PERIODICITY_WAGE_PDF = "periodicityWagePDF"; - + public static final String TAG_ENTREPRENEUR_MINIMUM_WAGE = "minimumWage"; - + public static final String TAG_ENTREPRENEUR_MAXIMUM_WAGE = "maximumWage"; - + public static final String TAG_ENTREPRENEUR_VARIATION_WAGE = "variationWage"; - + public static final String TAG_ENTREPRENEUR_MINIMUM_PRICE = "minimumPrice"; - + public static final String TAG_ENTREPRENEUR_MAXIMUM_PRICE = "maximumPrice"; - + public static final String TAG_ENTREPRENEUR_VARIATION_PRICE = "variationPrice"; - + public static final String TAG_ENTREPRENEUR_DENOUNCE_ALPHA = "denounceAlpha"; - + public static final String TAG_ENTREPRENEUR_COLLABORATION_PROBABILITY = "collaborationProbability"; - + public static final String TAG_ENTREPRENEUR_AFFILIATE_THRESHOLD = "affiliateThreshold"; - + public static final String TAG_ENTREPRENEUR_AFFILIATED = "affiliated"; - + public static final String TAG_ENTREPRENEUR_REPUTATION = "reputation"; - + public static final String TAG_ENTREPRENEUR_REPUTATION_STATE_PROTECTOR = "stateProtector"; - + public static final String TAG_ENTREPRENEUR_REPUTATION_STATE_PUNISHER = "statePunisher"; - + public static final String TAG_ENTREPRENEUR_REPUTATION_MAFIA_PUNISHER = "mafiaPunisher"; - + /** * Normative tags */ public static final String TAG_NORMATIVE_XML = "normativeXML"; - + public static final String TAG_NORMATIVE_XSD = "normativeXSD"; - + public static final String TAG_NORMATIVE_INDIVIDUAL_WEIGHT = "individualWeight"; - + public static final String TAG_NORMATIVE_NORMATIVE_WEIGHT = "normativeWeight"; - + public static final String TAG_NORMATIVE_NORMS_SALIENCE = "normsSalience"; - + public static final String TAG_NORMATIVE_NORM_SALIENCE = "normSalience"; - + public static final String TAG_NORMATIVE_NORM_ID = "id"; - + public static final String TAG_NORMATIVE_NORM_ACTIVE = "active"; - + public static final String TAG_NORMATIVE_NORM_INITIAL_COMPLIANCE = "compliance"; - + public static final String TAG_NORMATIVE_NORM_INITIAL_VIOLATION = "violation"; - + public static final String TAG_NORMATIVE_NORM_INITIAL_OBS_COMPLIANCE = "obsCompliance"; - + public static final String TAG_NORMATIVE_NORM_INITIAL_OBS_VIOLATION = "obsViolation"; - + public static final String TAG_NORMATIVE_NORM_INITIAL_PUNISHMENT = "punishment"; - + public static final String TAG_NORMATIVE_NORM_INITIAL_SANCTION = "sanction"; - + public static final String TAG_NORMATIVE_NORM_INITIAL_INVOCATION_COMPLIANCE = "invocationCompliance"; - + public static final String TAG_NORMATIVE_NORM_INITIAL_INVOCATION_VIOLATION = "invocationViolation"; - + /** * State tags */ public static final String TAG_STATE = "state"; - + public static final String TAG_STATE_NUMBER_POLICE_OFFICERS = "numberPoliceOfficers"; - + + public static final String TAG_STATE_LOGGING_TIME_UNIT = "loggingTimeUnit"; + public static final String TAG_STATE_GENERAL_INVESTIGATION_DURATION_PDF = "generalInvestigationDurationPDF"; - + public static final String TAG_STATE_BUREAUCRATIC_ACTIVITY_DURATION_PDF = "bureaucraticActivityDurationPDF"; - + public static final String TAG_STATE_SPECIFIC_INVESTIGATION_DURATION_PDF = "specificInvestigationDurationPDF"; - + public static final String TAG_STATE_SPECIFIC_INVESTIGATION_PROBABILITY = "specificInvestigationProbability"; - + public static final String TAG_STATE_CAPTURE_PROBABILITY = "captureProbability"; - + public static final String TAG_STATE_EVIDENCE_PROBABILITY = "evidenceProbability"; - + public static final String TAG_STATE_CUSTODY_DURATION_PDF = "custodyDurationPDF"; - + public static final String TAG_STATE_CONVICTION_PROBABILITY = "convictionProbability"; - + public static final String TAG_STATE_COLLABORATION_CONVICTION_FUNCTION = "collaborationConvictionFunction"; - + public static final String TAG_STATE_IMPRISONMENT_DURATION_PDF = "imprisonmentDurationPDF"; - + public static final String TAG_STATE_TIME_TO_COMPENSATION_PDF = "timeToCompensationPDF"; - + public static final String TAG_STATE_NO_COLLABORATION_PUNISHMENT_PROBABILITY = "noCollaborationPunishmentProbability"; - + public static final String TAG_STATE_NO_COLLABORATION_PUNISHMENT = "noCollaborationPunishment"; - + public static final String TAG_STATE_RESOURCE_FONDO = "resourceFondo"; - + public static final String TAG_STATE_PERIODICITY_FONDO_PDF = "periodicityFondoPDF"; - + public static final String TAG_STATE_PROPORTION_TRANSFER_FONDO = "proportionTransferFondo"; - + public static final String TAG_STATE_SPREAD_INFO_FUNCTION = "spreadInfoFunction"; - + public static final String TAG_STATE_PROPORTION_CONSUMERS = "proportionConsumers"; - + public static final String TAG_STATE_PROPORTION_ENTREPRENEURS = "proportionEntrepreneurs"; - + /** * Mafia tags */ public static final String TAG_MAFIA = "mafia"; - + public static final String TAG_MAFIA_NUMBER_MAFIOSI = "numberMafiosi"; - + public static final String TAG_MAFIA_LOGGING_TIME_UNIT = "loggingTimeUnit"; - + public static final String TAG_MAFIA_WEALTH = "wealth"; - + public static final String TAG_MAFIA_DEMAND_PDF = "demandPDF"; - + public static final String TAG_MAFIA_DEMAND_AFFILIATED_PROBABILITY = "demandAffiliatedProbability"; - + public static final String TAG_MAFIA_EXTORTION_LEVEL = "extortionLevel"; - + public static final String TAG_MAFIA_PUNISHMENT_SEVERITY = "punishmentSeverity"; - + public static final String TAG_MAFIA_COLLECTION_PDF = "collectionPDF"; - + public static final String TAG_MAFIA_PUNISHMENT_PROBABILITY = "punishmentProbability"; - + public static final String TAG_MAFIA_MINIMUM_BENEFIT = "minimumBenefit"; - + public static final String TAG_MAFIA_MAXIMUM_BENEFIT = "maximumBenefit"; - + public static final String TAG_MAFIA_PENTITI_PROBABILITY = "pentitiProbability"; - + public static final String TAG_MAFIA_RECRUITING_THRESHOLD = "recruitingThreshold"; - + public static final String TAG_MAFIA_RECRUITING_PROBABILITY = "recruitingProbability"; - + /** * Intermediary organization tags */ public static final String TAG_INTERMEDIARY_ORG = "intermediaryOrg"; - + public static final String TAG_INTERMEDIARY_ORG_TIME_TO_AFFILIATE_PDF = "timeToAffiliatePDF"; - + public static final String TAG_INTERMEDIARY_ORG_SPREAD_INFO_FUNCTION = "spreadInfoFunction"; - + public static final String TAG_INTERMEDIARY_ORG_PROPORTION_CONSUMERS = "proportionConsumers"; - + public static final String TAG_INTERMEDIARY_ORG_PROPORTION_ENTREPRENEURS = "proportionEntrepreneurs"; - + /** * Change tags */ public static final String TAG_CHANGES = "changes"; - + public static final String TAG_CHANGE = "change"; - + public static final String TAG_CHANGE_TIME = "time"; - + public static final String TAG_CHANGE_PARAMETER = "parameter"; - + public static final String TAG_CHANGE_VALUE = "value"; - + /** * Batch tags */ public static final String TAG_BATCH = "batch"; - + public static final String TAG_BATCH_BASE = "base"; - + public static final String TAG_BATCH_OUTPUT = "output"; - + public static final String TAG_BATCH_REPLICA = "replica"; - + public static final String TAG_BATCH_XML_SCENARIO = "xmlScenario"; - + public static final String TAG_BATCH_XSD_SCENARIO = "xsdScenario"; - + public static final String TAG_BATCH_HEADER = "header"; - + public static final String TAG_BATCH_GENERAL = "general"; - + public static final String TAG_BATCH_COMMUNICATION = "communication"; - + public static final String TAG_BATCH_CITIZENS = "citizens"; - + public static final String TAG_BATCH_STATES = "states"; - + public static final String TAG_BATCH_MAFIAS = "mafias"; - + public static final String TAG_BATCH_IOS = "ios"; - + public static final String TAG_BATCH_TAIL = "tail"; - + public static final String TAG_BATCH_CODE = "code"; - + public static final String TAG_BATCH_CONTENT = "content"; - + /** * Batch tags */ public static final String TAG_RANDOM_BATCH = "randomBatch"; - + public static final String TAG_RANDOM_BATCH_OUTPUT_DIR = "outputDir"; - + public static final String TAG_RANDOM_BATCH_OUTPUT_FILE = "outputFile"; - + public static final String TAG_RANDOM_BATCH_REPLICA = "replica"; - + public static final String TAG_RANDOM_BATCH_XML_SCENARIO = "xmlScenario"; - + public static final String TAG_RANDOM_BATCH_XSD_SCENARIO = "xsdScenario"; - + public static final String TAG_RANDOM_BATCH_CHANGES = "changes"; - + public static final String TAG_RANDOM_BATCH_CHANGE = "change"; - + public static final String TAG_RANDOM_BATCH_NAME = "name"; - + public static final String TAG_RANDOM_BATCH_PARAMETER = "parameter"; - + public static final String TAG_RANDOM_BATCH_TYPE = "type"; - + public static final String TAG_RANDOM_BATCH_VALUE = "value"; - + /** * Actions */ @@ -413,7 +417,7 @@ public static enum Actions { REPUTATION_INFO, CRITICAL_CONSUMER_INFO; } - + /** * Norms */ @@ -425,7 +429,7 @@ public static enum Norms { BUY_FROM_NOT_PAYING_ENTREPRENEURS, BUY_FROM_PAYING_ENTREPRENEURS; } - + /** * Sanctions */ @@ -433,7 +437,7 @@ public static enum Sanctions { REPUTATION_ENTREPRENEUR, NORM_SANCTION; } - + /** * Citizens distribution */ @@ -441,7 +445,7 @@ public static enum CitizensDistribution { CLUSTERED, RANDOM; } - + /** * Network topology */ @@ -449,75 +453,77 @@ public static enum NetworkTopolgy { MESH, SCALEFREE; } - + /** * Information request */ public static final String REQUEST_AFFILIATION = "affiliated"; - + public static final String REQUEST_COLLECT_PAYERS = "requestCollectPayers"; - + public static final String REQUEST_CRITICAL_CONSUMERS = "criticalConsumers"; - + public static final String REQUEST_ID = "id"; - + public static final String REQUEST_DEFAULT_WAGE = "defaultWage"; - + public static final String REQUEST_DURATION = "duration"; - + public static final String REQUEST_ENTREPRENEUR_ID = "entrepreneurId"; - + public static final String REQUEST_PRODUCT_PRICE = "productPrice"; - + public static final String REQUEST_TARGET_ID = "targetId"; - + public static final String REQUEST_WEALTH = "wealth"; - + /** * Information set */ public static final String PARAMETER_STATE_ID = "stateId"; - + public static final String PARAMETER_STATE_PUNISHMENT = "statePunishment"; - + public static final String PARAMETER_ADD_MAFIOSO = "addMafioso"; - + public static final String PARAMETER_REMOVE_MAFIOSO = "removeMafioso"; - + public static final String PARAMETER_WEALTH = "wealth"; - + /** * Events */ public static final String EVENT_AFFILIATE_PROCESSING = "eventAffiliateProcessing"; - + public static final String EVENT_ASSIST_ENTREPRENEUR = "eventAssistEntrepreneur"; - + public static final String EVENT_BUROCRATIC_ACTIVITY = "eventBurocraticActivity"; - + public static final String EVENT_BUY_PRODUCT = "eventBuyProduct"; - + public static final String EVENT_COLLECT_EXTORTION = "eventCollectExtortion"; - + public static final String EVENT_DEMAND_EXTORTION = "eventDemandExtortion"; - + public static final String EVENT_GENERAL_INVESTIGATION = "eventGeneralInvestigation"; - + public static final String EVENT_LOGGING_CONSUMERS = "eventLoggingConsumers"; - + public static final String EVENT_LOGGING_ENTREPRENEURS = "eventLoggingEntrepreneurs"; - + public static final String EVENT_LOGGING_MAFIOSI = "eventLoggingMafiosi"; - + + public static final String EVENT_LOGGING_INVESTIGATION = "eventLoggingInvestigations"; + public static final String EVENT_RECEIVE_WAGE = "eventReceiveWage"; - + public static final String EVENT_RELEASE_PRISON = "eventReleasePrison"; - + public static final String EVENT_RELEASE_CUSTODY = "eventReleaseCustody"; - + public static final String EVENT_RESOURCE_FONDO = "eventResourceFondo"; - + public static final String EVENT_SPREAD_INFORMATION = "eventSpreadInformation"; - + public static final String EVENT_WRITE_DATA = "eventWriteData"; } \ No newline at end of file diff --git a/src/main/java/gloderss/agents/entrepreneur/EntrepreneurAgent.java b/src/main/java/gloderss/agents/entrepreneur/EntrepreneurAgent.java index 5221138..f1f3bff 100755 --- a/src/main/java/gloderss/agents/entrepreneur/EntrepreneurAgent.java +++ b/src/main/java/gloderss/agents/entrepreneur/EntrepreneurAgent.java @@ -1363,6 +1363,8 @@ public synchronized void handleMessage( Message msg ) { // Normative process this.normative.input( msg ); + this.normative.update(); + // Reputation this.mafiaPunisherRep .updateReputation( (MafiaPunishmentAction) content ); @@ -1470,9 +1472,7 @@ public synchronized void handleMessage( Message msg ) { msg.getReceiver(), pay ); this.normative.input( newMsg ); } - } - } } } @@ -1502,20 +1502,20 @@ public Object handleInfo( InfoAbstract info ) { return infoRequested; } else if ( info.getType().equals( InfoAbstract.Type.SET ) ) { - Object infoResult = new Boolean( false ); + Object infoResult = Boolean.FALSE; InfoSet set = (InfoSet) info; switch ( set.getParameter() ) { case Constants.PARAMETER_STATE_ID: if ( set.getValue() instanceof Integer ) { this.stateId = (Integer) set.getValue(); - infoResult = new Boolean( true ); + infoResult = Boolean.TRUE; } break; case Constants.PARAMETER_STATE_PUNISHMENT: if ( set.getValue() instanceof Double ) { this.statePunishment = ((Double) set.getValue() * this.defaultWage); - infoResult = new Boolean( true ); + infoResult = Boolean.TRUE; } break; } diff --git a/src/main/java/gloderss/agents/intermediaryOrg/IntermediaryOrg.java b/src/main/java/gloderss/agents/intermediaryOrg/IntermediaryOrg.java index 0c832e4..9be89e5 100755 --- a/src/main/java/gloderss/agents/intermediaryOrg/IntermediaryOrg.java +++ b/src/main/java/gloderss/agents/intermediaryOrg/IntermediaryOrg.java @@ -189,7 +189,7 @@ public void spreadNormativeInformation() { this.spreadInfoFunction.clearVariables(); this.spreadInfoFunction.putVariable( NUMBER_ACTIONS, - (new Integer( this.numActions )).toString() ); + Integer.valueOf( this.numActions ).toString() ); double probSpreadInfo = 0.0; try { diff --git a/src/main/java/gloderss/agents/state/IStateOrg.java b/src/main/java/gloderss/agents/state/IStateOrg.java index 4fe7b97..033af33 100755 --- a/src/main/java/gloderss/agents/state/IStateOrg.java +++ b/src/main/java/gloderss/agents/state/IStateOrg.java @@ -11,47 +11,47 @@ import gloderss.actions.ReleaseInvestigationAction; public interface IStateOrg { - + public void initializeSim(); - - + + public void decideInvestigateExtortion( DenounceExtortionAction action ); - - + + public void decideInvestigateExtortionAffiliated( DenounceExtortionAffiliatedAction action ); - - + + public void decideInvestigatePunishment( DenouncePunishmentAction action ); - - + + public void decideInvestigatePunishmentAffiliated( DenouncePunishmentAffiliatedAction action ); - - + + public void releaseInvestigation( ReleaseInvestigationAction action ); - - + + public void decideCustody( CaptureMafiosoAction action ); - - + + public void decideConviction( CaptureMafiosoAction action ); - - + + public void receivePentito( PentitoAction action ); - - + + public void receiveCollaboration( CollaborateAction action ); - - + + public void decideStatePunishment( NotCollaborateAction action ); - - + + public void decideStateCompensation(); - - + + public void spreadNormativeInformation(); - - + + public void finalizeSim(); } \ No newline at end of file diff --git a/src/main/java/gloderss/agents/state/PoliceOfficerAgent.java b/src/main/java/gloderss/agents/state/PoliceOfficerAgent.java index d6bf04e..ee44161 100755 --- a/src/main/java/gloderss/agents/state/PoliceOfficerAgent.java +++ b/src/main/java/gloderss/agents/state/PoliceOfficerAgent.java @@ -22,264 +22,282 @@ public class PoliceOfficerAgent extends AbstractAgent implements IPoliceOfficer { - + private int stateId; - + private String generalInvestigationDuration; - + private PDFAbstract generalInvestigationDurationPDF; - + private String bureaucraticActivityDuration; - + private PDFAbstract bureaucraticActivityDurationPDF; - + private String specificInvestigationDuration; - + private PDFAbstract specificInvestigationDurationPDF; - + private double captureProbability; - + private int observed; - + private List mafiosi; - + private Event event; - + private int extortionId; - + private boolean specificInvestigation; - - + + private int numGeneralInv; + + /** * Police constructor - * + * * @param id - * Police officer agent identification + * Police officer agent identification * @param simulator - * Event simulator + * Event simulator * @param conf - * Police officer configuration + * Police officer configuration * @return none */ public PoliceOfficerAgent( Integer id, EventSimulator simulator, StateConf conf, int stateId ) { super( id, simulator ); - + this.stateId = stateId; - + this.generalInvestigationDuration = conf .getGeneralInvestigationDurationPDF(); - + this.generalInvestigationDurationPDF = PDFAbstract .getInstance( this.generalInvestigationDuration ); - + this.bureaucraticActivityDuration = conf .getBureaucraticActivityDurationPDF(); - + this.bureaucraticActivityDurationPDF = PDFAbstract .getInstance( this.bureaucraticActivityDuration ); - + this.specificInvestigationDuration = conf .getSpecificInvestigationDurationPDF(); - + this.specificInvestigationDurationPDF = PDFAbstract .getInstance( this.specificInvestigationDuration ); - + this.captureProbability = conf.getCaptureProbability(); - + this.observed = -1; - + this.mafiosi = new ArrayList(); - + this.event = null; - + this.specificInvestigation = false; this.extortionId = -1; + + this.numGeneralInv = 0; } - - + + /******************************* - * + * * Getters and Setters - * + * *******************************/ - + public String getGeneralInvestigationDuration() { return this.generalInvestigationDuration; } - - + + public void setGeneralInvestigationDuration( String generalInvestigationDuration ) { this.generalInvestigationDuration = generalInvestigationDuration; - + this.generalInvestigationDurationPDF = PDFAbstract .getInstance( this.generalInvestigationDuration ); } - - + + public String getBureaucraticActivityDuration() { return this.bureaucraticActivityDuration; } - - + + public void setBureaucraticActivityDuration( String bureaucraticActivityDuration ) { this.bureaucraticActivityDuration = bureaucraticActivityDuration; - + this.bureaucraticActivityDurationPDF = PDFAbstract .getInstance( this.bureaucraticActivityDuration ); } - - + + public String getSpecificInvestigationDuration() { return this.specificInvestigationDuration; } - - + + public void setSpecificInvestigationDuration( String specificInvestigationDuration ) { this.specificInvestigationDuration = specificInvestigationDuration; - + this.specificInvestigationDurationPDF = PDFAbstract .getInstance( this.specificInvestigationDuration ); } - - + + public double getCaptureProbability() { return this.captureProbability; } - - + + public void setCaptureProbability( double captureProbability ) { this.captureProbability = captureProbability; } - - + + public int getObserved() { return this.observed; } - - + + public void setObserved( int observed ) { this.observed = observed; } - - + + public List getMafiosi() { return this.mafiosi; } - - + + public void setMafiosi( List mafiosi ) { this.mafiosi = mafiosi; } - - + + public void addMafioso( int mafioso ) { if ( !this.mafiosi.contains( mafioso ) ) { this.mafiosi.add( mafioso ); } } - - + + public void removeMafioso( int mafioso ) { if ( this.mafiosi.contains( mafioso ) ) { this.mafiosi.remove( mafioso ); } } - - + + + public int getNumGeneralInv() { + return this.numGeneralInv; + } + + + public void setNumGeneralInv( int numGeneralInv ) { + this.numGeneralInv = numGeneralInv; + } + + /******************************* - * + * * Decision Processes - * + * *******************************/ - + @Override public void initializeSim() { this.specificInvestigation = false; - + + this.numGeneralInv = 0; + this.event = new Event( this.simulator.now() + 1, this, Constants.EVENT_GENERAL_INVESTIGATION ); this.simulator.insert( this.event ); } - - + + @Override public void generalInvestigation() { - + // Release specific investigation if ( this.specificInvestigation ) { ReleaseInvestigationAction action = new ReleaseInvestigationAction( this.id, this.observed ); - + Message msg = new Message( this.simulator.now(), this.id, this.stateId, action ); this.sendMsg( msg ); - + this.specificInvestigation = false; this.extortionId = -1; } - + if ( (this.observed != -1) ) { this.removeObservation( this.id, this.observed ); this.observed = -1; } - + // Get one target with the Mafia Organization InfoRequest entrepreneurRequest = new InfoRequest( this.id, this.stateId, Constants.REQUEST_ENTREPRENEUR_ID ); this.observed = (int) this.sendInfo( entrepreneurRequest ); - + this.addObservation( this.id, this.observed ); - + + this.numGeneralInv += 1; + this.event = new Event( this.simulator.now() + this.bureaucraticActivityDurationPDF.nextValue(), this, Constants.EVENT_BUROCRATIC_ACTIVITY ); this.simulator.insert( this.event ); } - - + + @Override public void specificInvestigation( SpecificInvestigationAction action ) { - + if ( this.event != null ) { this.simulator.cancel( this.event ); } - + if ( (this.observed != -1) ) { this.removeObservation( this.id, this.observed ); } - + this.extortionId = (int) action .getParam( SpecificInvestigationAction.Param.EXTORTION_ID ); - + this.observed = (int) action .getParam( SpecificInvestigationAction.Param.ENTREPRENEUR_ID ); - + this.addObservation( this.id, this.observed ); - + this.event = new Event( this.simulator.now() + this.specificInvestigationDurationPDF.nextValue(), this, Constants.EVENT_GENERAL_INVESTIGATION ); this.simulator.insert( this.event ); - + this.specificInvestigation = true; } - - + + /** * Decides to capture observed Mafioso - * + * * @param mafiosoId - * Mafioso identification + * Mafioso identification * @return none */ private void captureMafioso( int mafiosoId ) { - + if ( RandomUtil.nextDouble() < this.captureProbability ) { - + CaptureMafiosoAction action; if ( this.specificInvestigation ) { action = new CaptureMafiosoAction( this.extortionId, this.id, mafiosoId, @@ -287,17 +305,17 @@ private void captureMafioso( int mafiosoId ) { } else { action = new CaptureMafiosoAction( -1, this.id, mafiosoId, false ); } - + Message msg = new Message( this.simulator.now(), this.id, this.stateId, action ); this.sendMsg( msg ); } } - - + + /** * Waits a period of time before initiating a new general investigation - * + * * @param none * @return none */ @@ -306,52 +324,52 @@ private void burocraticActivity() { this.simulator.now() + this.generalInvestigationDurationPDF.nextValue(), this, Constants.EVENT_GENERAL_INVESTIGATION ); this.simulator.insert( this.event ); - + } - - + + @Override public void finalizeSim() { } - - + + /******************************* - * + * * Handle communication requests - * + * *******************************/ - + @Override public synchronized void handleMessage( Message msg ) { - + Object content = msg.getContent(); - + if ( (msg.getSender() != this.id) && (msg.getReceiver().contains( this.id )) ) { - + if ( content instanceof SpecificInvestigationAction ) { this.specificInvestigation( (SpecificInvestigationAction) content ); - + } } } - - + + @Override public Object handleInfo( InfoAbstract info ) { Object infoRequested = null; - + if ( info.getType().equals( InfoAbstract.Type.REQUEST ) ) { - + InfoRequest request = (InfoRequest) info; switch ( request.getInfoRequest() ) { case Constants.REQUEST_ID: infoRequested = this.getId(); break; } - + } else if ( info.getType().equals( InfoAbstract.Type.SET ) ) { - + InfoSet set = (InfoSet) info; int mafioso; switch ( set.getParameter() ) { @@ -365,53 +383,53 @@ public Object handleInfo( InfoAbstract info ) { break; } } - + return infoRequested; } - - + + @Override public void handleObservation( Message msg ) { - + Object content = msg.getContent(); - + if ( (msg.getSender() != this.id) && (!msg.getReceiver().contains( this.id )) ) { - + // Collect if ( content instanceof CollectAction ) { CollectAction action = (CollectAction) content; int mafiosoId = (int) action.getParam( CollectAction.Param.MAFIOSO_ID ); this.captureMafioso( mafiosoId ); - - // Exortion + + // Extortion } else if ( content instanceof ExtortionAction ) { ExtortionAction action = (ExtortionAction) content; int mafiosoId = (int) action .getParam( ExtortionAction.Param.MAFIOSO_ID ); this.captureMafioso( mafiosoId ); - + // Mafia Punishment } else if ( content instanceof MafiaPunishmentAction ) { MafiaPunishmentAction action = (MafiaPunishmentAction) content; int mafiosoId = (int) action .getParam( MafiaPunishmentAction.Param.MAFIOSO_ID ); this.captureMafioso( mafiosoId ); - + } } } - - + + /******************************* - * + * * Handle simulation events - * + * *******************************/ - + @Override public void handleEvent( Event event ) { - + switch ( (String) event.getCommand() ) { case Constants.EVENT_GENERAL_INVESTIGATION: this.generalInvestigation(); diff --git a/src/main/java/gloderss/agents/state/StateOrg.java b/src/main/java/gloderss/agents/state/StateOrg.java index 0255390..da33be1 100755 --- a/src/main/java/gloderss/agents/state/StateOrg.java +++ b/src/main/java/gloderss/agents/state/StateOrg.java @@ -43,6 +43,7 @@ import gloderss.output.AbstractEntity.EntityType; import gloderss.output.CompensationOutputEntity; import gloderss.output.ExtortionOutputEntity; +import gloderss.output.InvestigationOutputEntity; import gloderss.output.NormativeOutputEntity; import gloderss.output.OutputController; import gloderss.output.StateOutputEntity; @@ -52,153 +53,161 @@ import net.sourceforge.jeval.Evaluator; public class StateOrg extends AbstractAgent implements IStateOrg { - + private final static Logger logger = LoggerFactory .getLogger( StateOrg.class ); - + private static final String COLLABORATION = "COLLABORATION"; - + + private int loggingTimeUnit; + private int ioId; - + private List changesConf; - + private double specificInvestigationProbability; - + private double evidenceProbability; - + private double convictionProbability; - + private double noCollaborationPunishmentProbability; - + private double noCollaborationPunishment; - + private double resourceFondo; - + private double proportionTransferFondo; - + private PDFAbstract custodyDurationPDF; - + private PDFAbstract imprisonmentDurationPDF; - + private PDFAbstract timeToCompensationPDF; - + private PDFAbstract periodicityFondoPDF; - + private String collaborationConvictionFunction; - + private String spreadInfoFunctionStr; - + private Evaluator spreadInfoFunction; - + private String proportionConsumersStr; - + private Evaluator proportionConsumers; - + private String proportionEntrepreneursStr; - + private Evaluator proportionEntrepreneurs; - + private double fondoSolidarieta; - + private Map policeOfficers; - + private Map consumers; - + private Map entrepreneurs; - + private List mafiosiBlackList; - + private List investigateEntrepreneurs; - + private List allocatedPoliceOfficers; - + private Queue custodyQueue; - + private Queue prisonQueue; - + private Queue assistQueue; - + private Map collaborations; - - + + private int numRequestedSpecInv; + + private int numConductedSpecInv; + + /** * State constructor - * + * * @param id - * State identification + * State identification * @param conf - * State configuration + * State configuration * @param consumers - * List of all consumers + * List of all consumers * @param entrepreneurs - * List of all entrepreneurs + * List of all entrepreneurs * @return none */ public StateOrg( Integer id, EventSimulator simulator, StateConf conf, Map consumers, Map entrepreneurs ) { super( id, simulator ); - + + this.loggingTimeUnit = conf.getLoggingTimeUnit(); + this.changesConf = conf.getChangesConf(); - + this.specificInvestigationProbability = conf .getSpecificInvestigationProbability(); - + this.evidenceProbability = conf.getEvidenceProbability(); - + this.convictionProbability = conf.getConvictionProbability(); - + this.noCollaborationPunishmentProbability = conf .getNoCollaborationPunishmentProbability(); - + this.noCollaborationPunishment = conf.getNoCollaborationPunishment(); - + this.resourceFondo = conf.getResourceFondo(); - + this.proportionTransferFondo = conf.getProportionTransferFondo(); - + this.custodyDurationPDF = PDFAbstract .getInstance( conf.getCustodyDurationPDF() ); - + this.imprisonmentDurationPDF = PDFAbstract .getInstance( conf.getImprisonmentDurationPDF() ); - + this.timeToCompensationPDF = PDFAbstract .getInstance( conf.getTimeToCompensationPDF() ); - + this.periodicityFondoPDF = PDFAbstract .getInstance( conf.getPeriodicityFondoPDF() ); - + this.collaborationConvictionFunction = conf .getCollaborationConvictionFunction(); - + this.spreadInfoFunctionStr = conf.getSpreadInfoFunction(); - + this.spreadInfoFunction = new Evaluator(); - + this.proportionConsumersStr = conf.getProportionConsumers(); - + this.proportionConsumers = new Evaluator(); - + this.proportionEntrepreneursStr = conf.getProportionEntrepreneurs(); - + this.proportionEntrepreneurs = new Evaluator(); - + this.fondoSolidarieta = 0.0; - + this.consumers = consumers; - + // Make Entrepreneur recognize the State identification this.entrepreneurs = entrepreneurs; for ( Integer entrepreneurId : this.entrepreneurs.keySet() ) { InfoSet infoSet = new InfoSet( id, entrepreneurId, Constants.PARAMETER_STATE_ID, id ); this.sendInfo( infoSet ); - + infoSet = new InfoSet( id, entrepreneurId, Constants.PARAMETER_STATE_PUNISHMENT, conf.getNoCollaborationPunishment() ); this.sendInfo( infoSet ); } - + PoliceOfficerAgent police; int policeId = id + 1; this.policeOfficers = new HashMap(); @@ -206,7 +215,7 @@ public StateOrg( Integer id, EventSimulator simulator, StateConf conf, Map(); this.investigateEntrepreneurs = new ArrayList(); this.allocatedPoliceOfficers = new ArrayList(); @@ -214,53 +223,53 @@ public StateOrg( Integer id, EventSimulator simulator, StateConf conf, Map(); this.assistQueue = new LinkedList(); this.collaborations = new HashMap(); + + this.numRequestedSpecInv = 0; + this.numConductedSpecInv = 0; } - - + + /******************************* - * + * * Getters and Setters - * + * *******************************/ - + public int getIOId() { return this.ioId; } - - + + public void setIOId( int ioId ) { this.ioId = ioId; } - - + + public Map getPoliceOfficers() { return this.policeOfficers; } - - + + /******************************* - * + * * Decision Processes - * + * *******************************/ - + @Override public void initializeSim() { for ( PoliceOfficerAgent police : this.policeOfficers.values() ) { police.initializeSim(); } - - AbstractEntity outputEntity = OutputController.getInstance() - .getEntity( AbstractEntity.EntityType.STATE ); - outputEntity.setValue( StateOutputEntity.Field.TIME.name(), - this.simulator.now() ); - outputEntity.setValue( StateOutputEntity.Field.FONDO.name(), 0.0 ); - outputEntity.setActive(); - + Event event = new Event( this.simulator.now(), this, Constants.EVENT_RESOURCE_FONDO ); this.simulator.insert( event ); - + + event = new Event( this.simulator.now(), this, + Constants.EVENT_LOGGING_INVESTIGATION ); + this.simulator.insert( event ); + this.spreadInfoFunction.clearVariables(); double nextSpreadInfo = 0.0; try { @@ -269,11 +278,11 @@ public void initializeSim() { } catch ( EvaluationException e ) { logger.debug( e.toString() ); } - + event = new Event( this.simulator.now() + nextSpreadInfo, this, Constants.EVENT_SPREAD_INFORMATION ); this.simulator.insert( event ); - + // Schedule changes for ( ChangeConf change : this.changesConf ) { event = new Event( change.getTime(), this, change.getParameter(), @@ -281,349 +290,372 @@ public void initializeSim() { this.simulator.insert( event ); } } - - + + @Override public void decideInvestigateExtortion( DenounceExtortionAction action ) { - + int extortionId = (int) action .getParam( DenounceExtortionAction.Param.EXTORTION_ID ); - + int entrepreneurId = (int) action .getParam( DenounceExtortionAction.Param.ENTREPRENEUR_ID ); - - AbstractEntity outputEntity = OutputController.getInstance() + + AbstractEntity extortionOutputEntity = OutputController.getInstance() .getEntity( EntityType.EXTORTION, extortionId ); - + + this.numRequestedSpecInv += 1; + if ( (!this.investigateEntrepreneurs.contains( entrepreneurId )) && (this.policeOfficers.size() > 0) && (RandomUtil.nextDouble() < this.specificInvestigationProbability) ) { - + int mafiosoId = (int) action .getParam( DenounceExtortionAction.Param.MAFIOSO_ID ); - + if ( !this.mafiosiBlackList.contains( mafiosoId ) ) { this.mafiosiBlackList.add( mafiosoId ); - + for ( PoliceOfficerAgent police : this.policeOfficers.values() ) { InfoSet set = new InfoSet( this.id, police.getId(), Constants.PARAMETER_ADD_MAFIOSO, mafiosoId ); this.sendInfo( set ); } } - + int policeOfficerId; do { - + policeOfficerId = (int) this.policeOfficers.keySet() .toArray()[RandomUtil.nextIntFromTo( 0, (this.policeOfficers.size() - 1) )]; - + } while ( this.allocatedPoliceOfficers.contains( policeOfficerId ) ); - + SpecificInvestigationAction investigation = new SpecificInvestigationAction( extortionId, policeOfficerId, entrepreneurId ); - + Message msg = new Message( this.simulator.now(), this.id, policeOfficerId, investigation ); this.sendMsg( msg ); - + + this.numConductedSpecInv += 1; + // Output - outputEntity.setValue( + extortionOutputEntity.setValue( ExtortionOutputEntity.Field.INVESTIGATED_EXTORTION.name(), true ); - + } else { - - outputEntity.setValue( + + // Output + extortionOutputEntity.setValue( ExtortionOutputEntity.Field.INVESTIGATED_EXTORTION.name(), false ); - outputEntity.setActive(); + extortionOutputEntity.setActive(); + } } - - + + @Override public void decideInvestigateExtortionAffiliated( DenounceExtortionAffiliatedAction action ) { - + int extortionId = (int) action .getParam( DenounceExtortionAffiliatedAction.Param.EXTORTION_ID ); - + int entrepreneurId = (int) action .getParam( DenounceExtortionAffiliatedAction.Param.ENTREPRENEUR_ID ); - - AbstractEntity outputEntity = OutputController.getInstance() + + AbstractEntity extortionOutputEntity = OutputController.getInstance() .getEntity( EntityType.EXTORTION, extortionId ); - + + this.numRequestedSpecInv += 1; + if ( (!this.investigateEntrepreneurs.contains( entrepreneurId )) && (this.policeOfficers.size() > 0) && (RandomUtil.nextDouble() < this.specificInvestigationProbability) ) { - + int mafiosoId = (int) action .getParam( DenounceExtortionAffiliatedAction.Param.MAFIOSO_ID ); - + if ( !this.mafiosiBlackList.contains( mafiosoId ) ) { this.mafiosiBlackList.add( mafiosoId ); - + for ( PoliceOfficerAgent police : this.policeOfficers.values() ) { InfoSet set = new InfoSet( this.id, police.getId(), Constants.PARAMETER_ADD_MAFIOSO, mafiosoId ); this.sendInfo( set ); } } - + int policeOfficerId; do { - + policeOfficerId = (int) this.policeOfficers.keySet() .toArray()[RandomUtil.nextIntFromTo( 0, (this.policeOfficers.size() - 1) )]; - + } while ( this.allocatedPoliceOfficers.contains( policeOfficerId ) ); - + SpecificInvestigationAction investigation = new SpecificInvestigationAction( extortionId, policeOfficerId, entrepreneurId ); - + Message msg = new Message( this.simulator.now(), this.id, policeOfficerId, investigation ); this.sendMsg( msg ); - + + this.numConductedSpecInv += 1; + // Output - outputEntity.setValue( + extortionOutputEntity.setValue( ExtortionOutputEntity.Field.INVESTIGATED_EXTORTION.name(), true ); - + } else { - - outputEntity.setValue( + + // Output + extortionOutputEntity.setValue( ExtortionOutputEntity.Field.INVESTIGATED_EXTORTION.name(), false ); - outputEntity.setActive(); + extortionOutputEntity.setActive(); } } - - + + @Override public void decideInvestigatePunishment( DenouncePunishmentAction action ) { - + int extortionId = (int) action .getParam( DenouncePunishmentAction.Param.EXTORTION_ID ); - + int entrepreneurId = (int) action .getParam( DenouncePunishmentAction.Param.ENTREPRENEUR_ID ); - + int mafiosoId = (int) action .getParam( DenouncePunishmentAction.Param.MAFIOSO_ID ); - + + AbstractEntity outputEntity = OutputController.getInstance() + .getEntity( EntityType.EXTORTION, extortionId ); + + this.numRequestedSpecInv += 1; + if ( (!this.investigateEntrepreneurs.contains( entrepreneurId )) && (this.policeOfficers.size() > 0) ) { - + if ( !this.mafiosiBlackList.contains( mafiosoId ) ) { this.mafiosiBlackList.add( mafiosoId ); - + for ( PoliceOfficerAgent police : this.policeOfficers.values() ) { InfoSet set = new InfoSet( this.id, police.getId(), Constants.PARAMETER_ADD_MAFIOSO, mafiosoId ); this.sendInfo( set ); } } - + int policeOfficerId; do { - + policeOfficerId = (int) this.policeOfficers.keySet() .toArray()[RandomUtil.nextIntFromTo( 0, (this.policeOfficers.size() - 1) )]; - + } while ( this.allocatedPoliceOfficers.contains( policeOfficerId ) ); - + SpecificInvestigationAction investigation = new SpecificInvestigationAction( extortionId, policeOfficerId, entrepreneurId ); - + Message msg = new Message( this.simulator.now(), this.id, policeOfficerId, investigation ); this.sendMsg( msg ); + + this.numConductedSpecInv += 1; } - - // Add Entrepreneur in a queue to receive compensation for the punishment + + // Add Entrepreneur in a queue to receive compensation for the + // punishment this.assistQueue.add( action ); - + // Spread action Denounce Punishment Message msg = new Message( this.simulator.now(), entrepreneurId, this.id, action ); this.spreadActionInformation( msg ); - + // Output - AbstractEntity outputEntity = OutputController.getInstance() - .getEntity( EntityType.EXTORTION, extortionId ); outputEntity.setValue( ExtortionOutputEntity.Field.INVESTIGATED_PUNISHMENT.name(), true ); - + Event event = new Event( this.simulator.now() + this.timeToCompensationPDF.nextValue(), this, Constants.EVENT_ASSIST_ENTREPRENEUR ); this.simulator.insert( event ); } - - + + @Override public void decideInvestigatePunishmentAffiliated( DenouncePunishmentAffiliatedAction action ) { - + int extortionId = (int) action .getParam( DenouncePunishmentAffiliatedAction.Param.EXTORTION_ID ); - + int entrepreneurId = (int) action .getParam( DenouncePunishmentAffiliatedAction.Param.ENTREPRENEUR_ID ); - + int mafiosoId = (int) action .getParam( DenouncePunishmentAffiliatedAction.Param.MAFIOSO_ID ); - + + AbstractEntity outputEntity = OutputController.getInstance() + .getEntity( EntityType.EXTORTION, extortionId ); + + this.numRequestedSpecInv += 1; + if ( (!this.investigateEntrepreneurs.contains( entrepreneurId )) && (this.policeOfficers.size() > 0) ) { - + if ( !this.mafiosiBlackList.contains( mafiosoId ) ) { this.mafiosiBlackList.add( mafiosoId ); - + for ( PoliceOfficerAgent police : this.policeOfficers.values() ) { InfoSet set = new InfoSet( this.id, police.getId(), Constants.PARAMETER_ADD_MAFIOSO, mafiosoId ); this.sendInfo( set ); } } - + int policeOfficerId; do { - + policeOfficerId = (int) this.policeOfficers.keySet() .toArray()[RandomUtil.nextIntFromTo( 0, (this.policeOfficers.size() - 1) )]; - + } while ( this.allocatedPoliceOfficers.contains( policeOfficerId ) ); - + SpecificInvestigationAction investigation = new SpecificInvestigationAction( extortionId, policeOfficerId, entrepreneurId ); - + Message msg = new Message( this.simulator.now(), this.id, policeOfficerId, investigation ); this.sendMsg( msg ); + + this.numConductedSpecInv += 1; } - - // Add Entrepreneur in a queue to receive compensation for the punishment + + // Add Entrepreneur in a queue to receive compensation for the + // punishment this.assistQueue.add( action ); - + // Spread action Denounce Punishment Message msg = new Message( this.simulator.now(), entrepreneurId, this.id, action ); this.spreadActionInformation( msg ); - + // Output - AbstractEntity outputEntity = OutputController.getInstance() - .getEntity( EntityType.EXTORTION, extortionId ); outputEntity.setValue( ExtortionOutputEntity.Field.INVESTIGATED_PUNISHMENT.name(), true ); - + Event event = new Event( this.simulator.now() + this.timeToCompensationPDF.nextValue(), this, Constants.EVENT_ASSIST_ENTREPRENEUR ); this.simulator.insert( event ); } - - + + @Override public void releaseInvestigation( ReleaseInvestigationAction action ) { - + int policeOfficerId = (int) action .getParam( ReleaseInvestigationAction.Param.POLICE_OFFICER_ID ); - + if ( this.allocatedPoliceOfficers.contains( policeOfficerId ) ) { this.allocatedPoliceOfficers.remove( policeOfficerId ); } } - - + + @Override public void decideCustody( CaptureMafiosoAction action ) { - + int extortionId = (int) action .getParam( CaptureMafiosoAction.Param.EXTORTION_ID ); - + int mafiosoId = (int) action .getParam( CaptureMafiosoAction.Param.MAFIOSO_ID ); - + + AbstractEntity outputEntity = OutputController.getInstance() + .getEntity( EntityType.EXTORTION, extortionId ); + CustodyAction custody = new CustodyAction( extortionId, this.id, mafiosoId, this.custodyDurationPDF.nextValue() ); - + Message msg = new Message( this.simulator.now(), this.id, mafiosoId, custody ); this.sendMsg( msg ); - + // Spread action this.spreadActionInformation( msg ); - - AbstractEntity outputEntity = OutputController.getInstance() - .getEntity( EntityType.EXTORTION, extortionId ); - + // Collaboration evidence collection if ( RandomUtil.nextDouble() < this.evidenceProbability ) { - + InfoRequest info = new InfoRequest( this.id, mafiosoId, Constants.REQUEST_COLLECT_PAYERS ); - + @SuppressWarnings ( "unchecked" ) List evidences = (List) this.sendInfo( info ); if ( !evidences.isEmpty() ) { for ( Integer entrepreneurId : evidences ) { CollaborationRequestAction collaboration = new CollaborationRequestAction( mafiosoId, entrepreneurId ); - + msg = new Message( this.simulator.now(), this.id, entrepreneurId, collaboration ); this.sendMsg( msg ); } } - + outputEntity.setValue( ExtortionOutputEntity.Field.EVIDENCE_COLLECTED.name(), evidences.size() ); } - + // Output if ( extortionId >= 0 ) { outputEntity.setValue( ExtortionOutputEntity.Field.MAFIOSO_CUSTODY.name(), true ); } - + Event event = new Event( this.simulator.now() + this.custodyDurationPDF.nextValue(), this, Constants.EVENT_RELEASE_CUSTODY ); this.simulator.insert( event ); - + this.custodyQueue.offer( action ); } - - + + @Override public void decideConviction( CaptureMafiosoAction action ) { - + int mafiosoId = (int) action .getParam( CaptureMafiosoAction.Param.MAFIOSO_ID ); - + int extortionId = (int) action .getParam( CaptureMafiosoAction.Param.EXTORTION_ID ); - + AbstractEntity outputEntity = null; if ( extortionId >= 0 ) { outputEntity = OutputController.getInstance() .getEntity( EntityType.EXTORTION, extortionId ); } - + // Calculate conviction probability double convictionProb = this.convictionProbability; if ( this.collaborations.containsKey( mafiosoId ) ) { int numCollaborations = this.collaborations.get( mafiosoId ); - + Evaluator eval = new Evaluator(); eval.putVariable( COLLABORATION, - (new Integer( numCollaborations )).toString() ); - + Integer.valueOf( numCollaborations ).toString() ); + try { convictionProb += eval .getNumberResult( this.collaborationConvictionFunction ); @@ -631,59 +663,59 @@ public void decideConviction( CaptureMafiosoAction action ) { logger.debug( e.toString() ); } } - + // Decide whether the Mafioso is going to be imprisoned if ( RandomUtil.nextDouble() < Math.max( 0, Math.min( 1, convictionProb ) ) ) { - + InfoRequest wealthRequest = new InfoRequest( this.id, mafiosoId, Constants.REQUEST_WEALTH ); double wealth = (double) this.sendInfo( wealthRequest ); - + this.fondoSolidarieta += wealth * this.proportionTransferFondo; - + InfoSet wealthSet = new InfoSet( this.id, mafiosoId, Constants.PARAMETER_WEALTH, 0.0 ); this.sendInfo( wealthSet ); - + double duration = this.imprisonmentDurationPDF.nextValue(); - + ImprisonmentAction imprisonment = new ImprisonmentAction( mafiosoId, duration ); - + Message msg = new Message( this.simulator.now(), this.id, mafiosoId, imprisonment ); this.sendMsg( msg ); - + this.prisonQueue.add( imprisonment ); - + Event releasePrison = new Event( this.simulator.now() + duration, this, Constants.EVENT_RELEASE_PRISON ); this.simulator.insert( releasePrison ); - + // Spread action this.spreadActionInformation( msg ); - + // Output if ( extortionId >= 0 ) { outputEntity.setValue( ExtortionOutputEntity.Field.MAFIOSO_CONVICTED.name(), true ); outputEntity.setActive(); } - + // Release the Mafioso of custody } else { - + ReleaseCustodyAction releaseCustody = new ReleaseCustodyAction( mafiosoId ); - + Message msg = new Message( this.simulator.now(), this.id, mafiosoId, releaseCustody ); this.sendMsg( msg ); - + // Spread action this.spreadActionInformation( msg ); - + // Output if ( extortionId >= 0 ) { outputEntity.setValue( @@ -692,15 +724,15 @@ public void decideConviction( CaptureMafiosoAction action ) { } } } - - + + @Override public void receivePentito( PentitoAction action ) { - + @SuppressWarnings ( "unchecked" ) List mafiosoList = (List) action .getParam( PentitoAction.Param.MAFIOSI_LIST ); - + if ( mafiosoList != null ) { for ( Integer mafiosoId : mafiosoList ) { if ( !this.mafiosiBlackList.contains( mafiosoId ) ) { @@ -708,35 +740,35 @@ public void receivePentito( PentitoAction action ) { } } } - + int mafiosoId = (int) action.getParam( PentitoAction.Param.MAFIOSO_ID ); - + @SuppressWarnings ( "unchecked" ) List entrepreneurList = (List) action .getParam( PentitoAction.Param.ENTREPRENEUR_LIST ); - + if ( entrepreneurList != null ) { for ( Integer entrepreneurId : entrepreneurList ) { CollaborationRequestAction collaboration = new CollaborationRequestAction( mafiosoId, entrepreneurId ); - + Message msg = new Message( this.simulator.now(), this.id, entrepreneurId, collaboration ); this.sendMsg( msg ); } } - + // Spread action Message msg = new Message( this.simulator.now(), mafiosoId, this.id, action ); this.spreadActionInformation( msg ); } - - + + @Override public void receiveCollaboration( CollaborateAction action ) { int mafiosoId = (int) action.getParam( CollaborateAction.Param.MAFIOSO_ID ); - + int numCollaborations = 0; if ( this.collaborations.containsKey( mafiosoId ) ) { numCollaborations = this.collaborations.get( mafiosoId ); @@ -744,81 +776,81 @@ public void receiveCollaboration( CollaborateAction action ) { numCollaborations++; this.collaborations.put( mafiosoId, numCollaborations ); } - - + + @Override public void decideStatePunishment( NotCollaborateAction action ) { - + if ( RandomUtil.nextDouble() < this.noCollaborationPunishmentProbability ) { int entrepreneurId = (int) action .getParam( NotCollaborateAction.Param.ENTREPRENEUR_ID ); - + if ( this.assistQueue.contains( entrepreneurId ) ) { this.assistQueue.remove( entrepreneurId ); } - + StatePunishmentAction punishment = new StatePunishmentAction( this.id, entrepreneurId, this.noCollaborationPunishment ); - + Message msg = new Message( this.simulator.now(), this.id, entrepreneurId, punishment ); this.sendMsg( msg ); - + // Spread action this.spreadActionInformation( msg ); } } - - + + @Override public void decideStateCompensation() { - + if ( !this.assistQueue.isEmpty() ) { Object obj = this.assistQueue.poll(); - + int extortionId = -1; int entrepreneurId = -1; double punishment = -1; if ( obj instanceof DenouncePunishmentAction ) { DenouncePunishmentAction action = (DenouncePunishmentAction) obj; - + extortionId = (int) action .getParam( DenouncePunishmentAction.Param.EXTORTION_ID ); - + entrepreneurId = (int) action .getParam( DenouncePunishmentAction.Param.ENTREPRENEUR_ID ); - + punishment = (double) action .getParam( DenouncePunishmentAction.Param.PUNISHMENT ); - + } else if ( obj instanceof DenouncePunishmentAffiliatedAction ) { DenouncePunishmentAffiliatedAction action = (DenouncePunishmentAffiliatedAction) obj; - + extortionId = (int) action .getParam( DenouncePunishmentAffiliatedAction.Param.EXTORTION_ID ); - + entrepreneurId = (int) action.getParam( DenouncePunishmentAffiliatedAction.Param.ENTREPRENEUR_ID ); - + punishment = (double) action .getParam( DenouncePunishmentAffiliatedAction.Param.PUNISHMENT ); } - + // State has enough money to compensate the Entrepreneur if ( this.fondoSolidarieta >= punishment ) { - + this.fondoSolidarieta -= punishment; - + StateCompensationAction compensation = new StateCompensationAction( extortionId, this.id, entrepreneurId, punishment ); - + Message msg = new Message( this.simulator.now(), this.id, entrepreneurId, compensation ); this.sendMsg( msg ); - + // Spread action this.spreadActionInformation( msg ); - + // Output AbstractEntity outputEntity = OutputController.getInstance() .getEntity( EntityType.COMPENSATION, extortionId ); @@ -830,31 +862,31 @@ public void decideStateCompensation() { outputEntity.setValue( CompensationOutputEntity.Field.STATE_COMPENSATION.name(), punishment ); - + // Entrepreneur goes back to the queue } else { - + this.assistQueue.add( obj ); - + Event event = new Event( this.simulator.now() + this.timeToCompensationPDF.nextValue(), this, Constants.EVENT_ASSIST_ENTREPRENEUR ); this.simulator.insert( event ); - + } } } - - + + @Override public void spreadNormativeInformation() { - + // Spread information to Consumers NormInvocationAction notBuyPayExtortion = new NormInvocationAction( this.id, Norms.BUY_FROM_NOT_PAYING_ENTREPRENEURS.name() ); - + this.proportionConsumers.clearVariables(); - + double propConsumers = 0.0; try { propConsumers = this.proportionConsumers @@ -862,33 +894,33 @@ public void spreadNormativeInformation() { } catch ( EvaluationException e ) { logger.debug( e.toString() ); } - + propConsumers = Math.max( 0, Math.min( 1.0, propConsumers ) ); - + int numConsumers = (int) (this.consumers.size() * propConsumers); List consumerIds = new ArrayList(); while ( consumerIds.size() < numConsumers ) { - + int consumerId = (int) this.consumers.keySet().toArray()[RandomUtil .nextIntFromTo( 0, (this.consumers.size() - 1) )]; - + if ( !consumerIds.contains( consumerId ) ) { consumerIds.add( consumerId ); - + Message msg = new Message( this.simulator.now(), this.id, consumerId, notBuyPayExtortion ); this.sendMsg( msg ); } } - + NormInvocationAction notPayExtortion = new NormInvocationAction( this.id, Norms.NOT_PAY_EXTORTION.name() ); - + NormInvocationAction denounceExtortion = new NormInvocationAction( this.id, Norms.DENOUNCE.name() ); - + this.proportionEntrepreneurs.clearVariables(); - + double propEntrepreneurs = 0.0; try { propEntrepreneurs = this.proportionEntrepreneurs @@ -896,31 +928,31 @@ public void spreadNormativeInformation() { } catch ( EvaluationException e ) { logger.debug( e.toString() ); } - + propEntrepreneurs = Math.max( 0, Math.min( 1.0, propEntrepreneurs ) ); - + int numEntrepreneurs = (int) (this.entrepreneurs.size() * propEntrepreneurs); List entrepreneurIds = new ArrayList(); int qtyEntrepreneurs = this.entrepreneurs.size(); while ( entrepreneurIds.size() < numEntrepreneurs ) { - + int entrepreneurId = (int) this.entrepreneurs.keySet() .toArray()[RandomUtil.nextIntFromTo( 0, (qtyEntrepreneurs - 1) )]; - + if ( !entrepreneurIds.contains( entrepreneurId ) ) { entrepreneurIds.add( entrepreneurId ); - + Message msgNP = new Message( this.simulator.now(), this.id, entrepreneurId, notPayExtortion ); this.sendMsg( msgNP ); - + Message msgD = new Message( this.simulator.now(), this.id, entrepreneurId, denounceExtortion ); this.sendMsg( msgD ); } } - + // Output AbstractEntity outputEntity = OutputController.getInstance() .getEntity( EntityType.NORMATIVE ); @@ -934,7 +966,7 @@ public void spreadNormativeInformation() { NormativeOutputEntity.Field.NUMBER_ENTREPRENEURS.name(), numEntrepreneurs ); outputEntity.setActive(); - + this.spreadInfoFunction.clearVariables(); double nextSpreadInfo = 0.0; try { @@ -943,43 +975,43 @@ public void spreadNormativeInformation() { } catch ( EvaluationException e ) { logger.debug( e.toString() ); } - + Event event = new Event( this.simulator.now() + nextSpreadInfo, this, Constants.EVENT_SPREAD_INFORMATION ); this.simulator.insert( event ); } - - + + /** * Selects an Entrepreneur for investigation - * + * * @param none * @return Entrepreneur for investigation */ private int decideEntrepreneur() { - + int entrepreneurId; do { - + entrepreneurId = (int) this.entrepreneurs.keySet().toArray()[RandomUtil .nextIntFromTo( 0, (this.entrepreneurs.size() - 1) )]; - + } while ( this.investigateEntrepreneurs.contains( entrepreneurId ) ); - + return entrepreneurId; } - - + + /** * Increase the Fondo di Solidarieta by a constant amount - * + * * @param none * @return none */ private void increaseFondo() { - + this.fondoSolidarieta += this.resourceFondo; - + AbstractEntity outputEntity = OutputController.getInstance() .getEntity( AbstractEntity.EntityType.STATE ); outputEntity.setValue( StateOutputEntity.Field.TIME.name(), @@ -987,68 +1019,68 @@ private void increaseFondo() { outputEntity.setValue( StateOutputEntity.Field.FONDO.name(), this.fondoSolidarieta ); outputEntity.setActive(); - + Event event = new Event( this.simulator.now() + this.periodicityFondoPDF.nextValue(), this, Constants.EVENT_RESOURCE_FONDO ); this.simulator.insert( event ); } - - + + /** * Judge whether a captured Mafioso should be imprisoned - * + * * @param none * @return none */ private void judgeMafioso() { - + if ( !this.custodyQueue.isEmpty() ) { CaptureMafiosoAction action = this.custodyQueue.poll(); this.decideConviction( action ); } } - - + + /** * Release a imprisoned Mafioso - * + * * @param none * @return none */ private void releaseMafioso() { - + if ( !this.prisonQueue.isEmpty() ) { ImprisonmentAction prison = this.prisonQueue.poll(); - + int mafiosoId = (int) prison .getParam( ImprisonmentAction.Param.MAFIOSO_ID ); - + ReleaseImprisonmentAction action = new ReleaseImprisonmentAction( mafiosoId ); - + Message msg = new Message( this.simulator.now(), this.id, mafiosoId, action ); this.sendMsg( msg ); - + // Spread action this.spreadActionInformation( msg ); } } - - + + /** * Spread action information - * + * * @param msg - * Spread action message to a proportion of consumers and - * entrepreneurs, and also to the Intermediary Organization + * Spread action message to a proportion of consumers and + * entrepreneurs, and also to the Intermediary Organization * @return none */ private void spreadActionInformation( Message msg ) { - + this.proportionConsumers.clearVariables(); - + double propConsumers = 0.0; try { propConsumers = this.proportionConsumers @@ -1056,28 +1088,28 @@ private void spreadActionInformation( Message msg ) { } catch ( EvaluationException e ) { logger.debug( e.toString() ); } - + propConsumers = Math.max( 0, Math.min( 1.0, propConsumers ) ); - + // Spread to a proportion of Consumers int numConsumers = (int) (this.consumers.size() * propConsumers); List consumerIds = new ArrayList(); while ( consumerIds.size() < numConsumers ) { - + int consumerId = (int) this.consumers.keySet().toArray()[RandomUtil .nextIntFromTo( 0, (this.consumers.size() - 1) )]; - + if ( !consumerIds.contains( consumerId ) ) { consumerIds.add( consumerId ); - + Message newMsg = new Message( this.simulator.now(), this.id, consumerId, msg ); this.sendMsg( newMsg ); } } - + this.proportionEntrepreneurs.clearVariables(); - + double propEntrepreneurs = 0.0; try { propEntrepreneurs = this.proportionEntrepreneurs @@ -1085,99 +1117,132 @@ private void spreadActionInformation( Message msg ) { } catch ( EvaluationException e ) { logger.debug( e.toString() ); } - + propEntrepreneurs = Math.max( 0, Math.min( 1.0, propEntrepreneurs ) ); - + // Spread to a proportion of Entrepreneurs int numEntrepreneurs = (int) (this.entrepreneurs.size() * propEntrepreneurs); List entrepreneurIds = new ArrayList(); int qtyEntrepreneurs = this.entrepreneurs.size(); while ( entrepreneurIds.size() < numEntrepreneurs ) { - + int entrepreneurId = (int) this.entrepreneurs.keySet() .toArray()[RandomUtil.nextIntFromTo( 0, (qtyEntrepreneurs - 1) )]; - + if ( !entrepreneurIds.contains( entrepreneurId ) ) { entrepreneurIds.add( entrepreneurId ); - + Message newMsg = new Message( this.simulator.now(), this.id, entrepreneurId, msg ); this.sendMsg( newMsg ); } } - + // Send to the Intermediary Organization Message newMsg = new Message( this.simulator.now(), this.id, this.ioId, msg ); this.sendMsg( newMsg ); } - - + + + public void loggingInvestigations() { + int numConductedGenInv = 0; + for ( PoliceOfficerAgent policeOfficer : policeOfficers.values() ) { + numConductedGenInv += policeOfficer.getNumGeneralInv(); + policeOfficer.setNumGeneralInv( 0 ); + } + + AbstractEntity outputEntity = OutputController.getInstance() + .getEntity( EntityType.INVESTIGATION ); + + outputEntity.setValue( InvestigationOutputEntity.Field.TIME.name(), + (int) this.simulator.now() ); + outputEntity.setValue( + InvestigationOutputEntity.Field.CONDUCTED_GENERAL_INVESTIGATION.name(), + numConductedGenInv ); + outputEntity.setValue( + InvestigationOutputEntity.Field.REQUESTED_SPECIFIC_INVESTIGATION.name(), + this.numRequestedSpecInv ); + outputEntity.setValue( + InvestigationOutputEntity.Field.CONDUCTED_SPECIFIC_INVESTIGATION.name(), + this.numConductedSpecInv ); + outputEntity.setActive(); + + this.numRequestedSpecInv = 0; + this.numConductedSpecInv = 0; + + Event event = new Event( this.simulator.now() + this.loggingTimeUnit, this, + Constants.EVENT_LOGGING_INVESTIGATION ); + this.simulator.insert( event ); + } + + @Override public void finalizeSim() { + this.loggingInvestigations(); } - - + + /******************************* - * + * * Handle communication requests - * + * *******************************/ - + @Override public synchronized void handleMessage( Message msg ) { - + Object content = msg.getContent(); - + if ( (msg.getSender() != this.id) && (msg.getReceiver().contains( this.id )) ) { - + // Denounce extortion if ( content instanceof DenounceExtortionAction ) { this.decideInvestigateExtortion( (DenounceExtortionAction) content ); - + // Denounce extortion Affiliated } else if ( content instanceof DenounceExtortionAffiliatedAction ) { this.decideInvestigateExtortionAffiliated( (DenounceExtortionAffiliatedAction) content ); - + // Denounce punishment } else if ( content instanceof DenouncePunishmentAction ) { this.decideInvestigatePunishment( (DenouncePunishmentAction) content ); - + // Denounce punishment Affiliated } else if ( content instanceof DenouncePunishmentAffiliatedAction ) { this.decideInvestigatePunishmentAffiliated( (DenouncePunishmentAffiliatedAction) content ); - + // Pentito } else if ( content instanceof PentitoAction ) { this.receivePentito( (PentitoAction) content ); - + // Release investigation } else if ( content instanceof ReleaseInvestigationAction ) { this.releaseInvestigation( (ReleaseInvestigationAction) content ); - + // Capture Mafioso } else if ( content instanceof CaptureMafiosoAction ) { this.decideCustody( (CaptureMafiosoAction) content ); - + // Collaboration } else if ( content instanceof CollaborateAction ) { this.receiveCollaboration( (CollaborateAction) content ); - + } } } - - + + @Override public Object handleInfo( InfoAbstract info ) { Object infoRequested = null; - + if ( info.getType().equals( InfoAbstract.Type.REQUEST ) ) { - + InfoRequest request = (InfoRequest) info; switch ( request.getInfoRequest() ) { case Constants.REQUEST_ID: @@ -1187,36 +1252,36 @@ public Object handleInfo( InfoAbstract info ) { infoRequested = this.decideEntrepreneur(); break; } - + } else if ( info.getType().equals( InfoAbstract.Type.SET ) ) { - + } - + return infoRequested; } - - + + @Override public void handleObservation( Message msg ) { // NOTHING } - - + + /******************************* - * + * * Handle simulation events - * + * *******************************/ - + @Override public void handleEvent( Event event ) { - + ChangeConf change = null; if ( (event.getParameter() != null) && (event.getParameter() instanceof ChangeConf) ) { change = (ChangeConf) event.getParameter(); } - + switch ( (String) event.getCommand() ) { case Constants.EVENT_RESOURCE_FONDO: this.increaseFondo(); @@ -1233,6 +1298,9 @@ public void handleEvent( Event event ) { case Constants.EVENT_SPREAD_INFORMATION: this.spreadNormativeInformation(); break; + case Constants.EVENT_LOGGING_INVESTIGATION: + this.loggingInvestigations(); + break; case Constants.TAG_STATE_GENERAL_INVESTIGATION_DURATION_PDF: if ( change != null ) { for ( PoliceOfficerAgent police : this.policeOfficers.values() ) { diff --git a/src/main/java/gloderss/communication/CommunicationController.java b/src/main/java/gloderss/communication/CommunicationController.java index 627c5b3..962f352 100755 --- a/src/main/java/gloderss/communication/CommunicationController.java +++ b/src/main/java/gloderss/communication/CommunicationController.java @@ -348,7 +348,7 @@ public void removeObservation( int observer, List observedList ) { if ( this.observe.containsKey( observed ) ) { List aux = this.observe.get( observed ); if ( aux.contains( observer ) ) { - aux.remove( new Integer( observer ) ); + aux.remove( Integer.valueOf( observer ) ); this.observe.put( observed, aux ); } } @@ -369,7 +369,7 @@ public void removeObservation( int observer, int observed ) { if ( this.observe.containsKey( observed ) ) { List aux = this.observe.get( observed ); if ( aux.contains( observer ) ) { - aux.remove( new Integer( observer ) ); + aux.remove( Integer.valueOf( observer ) ); this.observe.put( observed, aux ); } } diff --git a/src/main/java/gloderss/conf/FilenameConf.java b/src/main/java/gloderss/conf/FilenameConf.java index 471f857..cffb760 100755 --- a/src/main/java/gloderss/conf/FilenameConf.java +++ b/src/main/java/gloderss/conf/FilenameConf.java @@ -23,6 +23,8 @@ public class FilenameConf { private String state; + private String investigation; + private String intermediaryOrganization; @@ -125,6 +127,17 @@ public void setState( String state ) { } + public String getInvestigation() { + return this.investigation; + } + + + @XmlElement ( name = Constants.TAG_FILENAME_INVESTIGATION ) + public void setInvestigation( String investigation ) { + this.investigation = investigation; + } + + public String getIntermediaryOrganization() { return this.intermediaryOrganization; } diff --git a/src/main/java/gloderss/conf/StateConf.java b/src/main/java/gloderss/conf/StateConf.java index a13cf87..b6d98a3 100755 --- a/src/main/java/gloderss/conf/StateConf.java +++ b/src/main/java/gloderss/conf/StateConf.java @@ -14,6 +14,8 @@ public class StateConf { private int numberPoliceOfficers; + private int loggingTimeUnit; + private String generalInvestigationDurationPDF; private String bureaucraticActivityDurationPDF; @@ -67,6 +69,17 @@ public void setNumberPoliceOfficers( int numberPoliceOfficers ) { } + public int getLoggingTimeUnit() { + return this.loggingTimeUnit; + } + + + @XmlElement ( name = Constants.TAG_STATE_LOGGING_TIME_UNIT ) + public void setLoggingTimeUnit( int loggingTimeUnit ) { + this.loggingTimeUnit = loggingTimeUnit; + } + + public String getGeneralInvestigationDurationPDF() { return this.generalInvestigationDurationPDF; } diff --git a/src/main/java/gloderss/main/RunSimulation.java b/src/main/java/gloderss/main/RunSimulation.java index 6edfa7e..e74dff0 100755 --- a/src/main/java/gloderss/main/RunSimulation.java +++ b/src/main/java/gloderss/main/RunSimulation.java @@ -27,59 +27,59 @@ import gloderss.util.random.RandomUtil; public class RunSimulation extends EventSimulator { - + private final static Logger logger = LoggerFactory .getLogger( RunSimulation.class ); - + private ScenarioConf scenarioConf; - + private Map consumers; - + private Map entrepreneurs; - + private StateOrg state; - + private MafiaOrg mafia; - + private IntermediaryOrg intermediaryOrg; - - + + /** * Run a single instance of the simulation - * + * * @param xmlFilename - * Configuration file + * Configuration file * @param xsdFilename - * Schema of the configuration file + * Schema of the configuration file */ public RunSimulation( String xmlFilename, String xsdFilename ) { this.scenarioConf = ScenarioConf.getScenarioConf( xmlFilename, xsdFilename ); - + boolean valid = ScenarioConf.isValid( xmlFilename, xsdFilename ); logger.debug( "[XML VALID] " + valid ); - + if ( !valid ) { System.out.println( "INVALID XML FILE" ); System.exit( 1 ); } } - - + + /** * Create the citizens distributed in a way they will be randomly distributed * in the network - * + * * @param id - * Initial agents identification + * Initial agents identification * @param citizens - * Random citizens + * Random citizens * @return Next available agent identification */ private int randomDistribution( int id, List citizens ) { int citizenId = id; int index; - + logger.debug( "CREATE CONSUMERS" ); int totalConsumers = 0; List consumersConf = new Vector(); @@ -90,7 +90,7 @@ private int randomDistribution( int id, List citizens ) { nConsumers[index++] = consumerConf.getNumberConsumers(); totalConsumers += consumerConf.getNumberConsumers(); } - + int totalEntrepreneurs = 0; List entrepreneursConf = new Vector(); entrepreneursConf.addAll( this.scenarioConf.getEntrepreneursConf() ); @@ -100,14 +100,14 @@ private int randomDistribution( int id, List citizens ) { nEntrepreneurs[index++] = entrepreneurConf.getNumberEntrepreneurs(); totalEntrepreneurs += entrepreneurConf.getNumberEntrepreneurs(); } - + EntrepreneurAgent entrepreneur; ConsumerAgent consumer; for ( int i = 0; i < (totalConsumers + totalEntrepreneurs); ) { - + index = RandomUtil.nextIntFromTo( 0, (nConsumers.length + nEntrepreneurs.length) - 1 ); - + if ( index <= (nConsumers.length - 1) ) { if ( nConsumers[index] > 0 ) { consumer = new ConsumerAgent( citizenId, this, @@ -131,32 +131,32 @@ private int randomDistribution( int id, List citizens ) { } } } - + return citizenId; } - - + + /** * Create the citizens clustered in the network - * + * * @param id - * Initial agents identification + * Initial agents identification * @param citizens - * Clustered citizens + * Clustered citizens * @return Next available agent identification */ private int clusteredDistribution( int id, List citizens ) { int citizenId = id; int index; - + List consumersConf = new Vector(); consumersConf.addAll( this.scenarioConf.getConsumersConf() ); int nConsumers[] = new int[consumersConf.size()]; - + List entrepreneursConf = new Vector(); entrepreneursConf.addAll( this.scenarioConf.getEntrepreneursConf() ); int nEntrepreneurs[] = new int[entrepreneursConf.size()]; - + logger.debug( "CREATE CONSUMERS CLUSTERED" ); index = 0; int totalConsumers = 0; @@ -168,7 +168,7 @@ private int clusteredDistribution( int id, List citizens ) { nConsumers[index++] = 0; } } - + logger.debug( "CREATE ENTREPRENEURS CLUSTERED" ); index = 0; int totalEntrepreneurs = 0; @@ -180,14 +180,14 @@ private int clusteredDistribution( int id, List citizens ) { nEntrepreneurs[index++] = 0; } } - + EntrepreneurAgent entrepreneur; ConsumerAgent consumer; for ( int i = 0; i < (totalConsumers + totalEntrepreneurs); ) { - + index = RandomUtil.nextIntFromTo( 0, (nConsumers.length + nEntrepreneurs.length) - 1 ); - + if ( index <= (nConsumers.length - 1) ) { if ( nConsumers[index] > 0 ) { consumer = new ConsumerAgent( citizenId, this, @@ -211,7 +211,7 @@ private int clusteredDistribution( int id, List citizens ) { } } } - + logger.debug( "CREATE CONSUMERS" ); index = 0; totalConsumers = 0; @@ -223,7 +223,7 @@ private int clusteredDistribution( int id, List citizens ) { nConsumers[index++] = 0; } } - + logger.debug( "CREATE ENTREPRENEURS" ); index = 0; totalEntrepreneurs = 0; @@ -235,12 +235,12 @@ private int clusteredDistribution( int id, List citizens ) { nEntrepreneurs[index++] = 0; } } - + for ( int i = 0; i < (totalConsumers + totalEntrepreneurs); ) { - + index = RandomUtil.nextIntFromTo( 0, (nConsumers.length + nEntrepreneurs.length) - 1 ); - + if ( index <= (nConsumers.length - 1) ) { if ( nConsumers[index] > 0 ) { consumer = new ConsumerAgent( citizenId, this, @@ -264,41 +264,41 @@ private int clusteredDistribution( int id, List citizens ) { } } } - + return citizenId; } - - + + /** * Run the simulation for a period of time - * + * * @param none * @return none */ public void run() { - + int numReplications = this.scenarioConf.getGeneralConf() .getNumberReplications(); - + double numCycles = this.scenarioConf.getGeneralConf().getNumberCycles(); - + Vector seeds = new Vector(); seeds.addAll( this.scenarioConf.getGeneralConf().getSeedsConf() ); - + CommunicationController .getInstance( this.scenarioConf.getCommunicationConf() ); - + OutputController outputController = new OutputController( this, this.scenarioConf.getGeneralConf().getOutputConf() ); - + int nextSeed = 0; for ( int replica = 0; replica < numReplications; replica++ ) { this.init(); this.events = new ListQueue(); - + CommunicationController.getInstance() .reset( this.scenarioConf.getCommunicationConf() ); - + /** * Output controller */ @@ -321,10 +321,12 @@ public void run() { this.scenarioConf.getGeneralConf().getFilenameConf().getMafiosi() ); outputController.init( EntityType.STATE, this.scenarioConf.getGeneralConf().getFilenameConf().getState() ); + outputController.init( EntityType.INVESTIGATION, this.scenarioConf + .getGeneralConf().getFilenameConf().getInvestigation() ); outputController.init( EntityType.INTERMEDIARY_ORGANIZATION, this.scenarioConf.getGeneralConf().getFilenameConf() .getIntermediaryOrganization() ); - + /** * Set random seed */ @@ -334,16 +336,16 @@ public void run() { } else { nextSeed = 0; } - + /** * Create agents */ int id = 0; - + // Create Citizens this.consumers = new HashMap(); this.entrepreneurs = new HashMap(); - + List citizens = new ArrayList(); switch ( Constants.CitizensDistribution.valueOf( this.scenarioConf.getGeneralConf().getCitizensDistribution() ) ) { @@ -357,43 +359,43 @@ public void run() { id = this.randomDistribution( id, citizens ); break; } - + ConsumerAgent consumer; // Provide the set of Entrepreneurs to the Consumers for ( Integer consumerId : this.consumers.keySet() ) { consumer = this.consumers.get( consumerId ); consumer.setEntrepreneurs( this.entrepreneurs ); } - + // Create the State agent logger.debug( "[CREATE STATE]" ); this.state = new StateOrg( id, this, this.scenarioConf.getStateConf(), this.consumers, this.entrepreneurs ); id += this.scenarioConf.getStateConf().getNumberPoliceOfficers() + 1; - + // Create the Mafia agent logger.debug( "[CREATE MAFIA]" ); this.mafia = new MafiaOrg( id, this, this.scenarioConf.getMafiaConf(), this.state.getId(), this.entrepreneurs ); id += this.scenarioConf.getMafiaConf().getNumberMafiosi() + 1; - + // Create the Intermediary Organization agent logger.debug( "[CREATE INTERMEDIARY ORGANIZATION]" ); this.intermediaryOrg = new IntermediaryOrg( id++, this, this.scenarioConf.getIntermediaryOrgConf(), this.consumers, this.entrepreneurs ); - + this.state.setIOId( this.intermediaryOrg.getId() ); for ( EntrepreneurAgent e : this.entrepreneurs.values() ) { e.setIOId( this.intermediaryOrg.getId() ); } - + /** * Networks */ logger.debug( "[CREATE NETWORK OF ENTREPRENEURS AND CONSUMERS]" ); Network socialNetwork = new Network(); - + // Customers and Entrepreneurs network switch ( Constants.NetworkTopolgy.valueOf( this.scenarioConf.getGeneralConf().getNetworkTopology() ) ) { @@ -407,14 +409,14 @@ public void run() { socialNetwork.generateBarabasiAlbertScaleFreeNetwork( citizens ); break; } - + for ( EntrepreneurAgent e : this.entrepreneurs.values() ) { e.setNeighbors( socialNetwork.getNeighbors( e.getId() ) ); } for ( ConsumerAgent c : this.consumers.values() ) { c.setNeighbors( socialNetwork.getNeighbors( c.getId() ) ); } - + // Mafia network Network mafiaNetwork = new Network(); mafiaNetwork.generateBarabasiAlbertScaleFreeNetwork( @@ -422,33 +424,33 @@ public void run() { for ( MafiosoAgent m : this.mafia.getMafiosi().values() ) { m.setNeighbors( mafiaNetwork.getNeighbors( m.getId() ) ); } - + for ( ConsumerAgent c : this.consumers.values() ) { c.initializeSim(); } - + for ( EntrepreneurAgent e : this.entrepreneurs.values() ) { e.initializeSim(); } - + this.state.initializeSim(); this.mafia.initializeSim(); this.intermediaryOrg.initializeSim(); outputController.initializeSim(); - + this.doAllEvents( numCycles ); - + this.state.finalizeSim(); this.mafia.finalizeSim(); this.intermediaryOrg.finalizeSim(); for ( ConsumerAgent c : this.consumers.values() ) { c.finalizeSim(); } - + for ( EntrepreneurAgent e : this.entrepreneurs.values() ) { e.finalizeSim(); } - + try { outputController.write( true ); } catch ( IOException e ) { diff --git a/src/main/java/gloderss/output/AbstractEntity.java b/src/main/java/gloderss/output/AbstractEntity.java index e08f2a3..740fb8a 100755 --- a/src/main/java/gloderss/output/AbstractEntity.java +++ b/src/main/java/gloderss/output/AbstractEntity.java @@ -12,6 +12,7 @@ public enum EntityType { MAFIA, MAFIOSI, STATE, + INVESTIGATION, INTERMEDIARY_ORGANIZATION; } diff --git a/src/main/java/gloderss/output/InvestigationOutputEntity.java b/src/main/java/gloderss/output/InvestigationOutputEntity.java new file mode 100644 index 0000000..954b301 --- /dev/null +++ b/src/main/java/gloderss/output/InvestigationOutputEntity.java @@ -0,0 +1,107 @@ +package gloderss.output; + +public class InvestigationOutputEntity extends AbstractEntity { + + public enum Field { + TIME("time", DataType.INTEGER), + CONDUCTED_GENERAL_INVESTIGATION("conductedGeneralInv", DataType.INTEGER), + REQUESTED_SPECIFIC_INVESTIGATION("requestedSpecificInv", DataType.INTEGER), + CONDUCTED_SPECIFIC_INVESTIGATION("conductedSpecificInv", DataType.INTEGER); + + private String name; + + private DataType type; + + + Field( String name, DataType type ) { + this.name = name; + this.type = type; + } + + + public String getName() { + return this.name; + } + + + public DataType getType() { + return this.type; + } + } + + private String separator; + + private Object[] entity; + + + public InvestigationOutputEntity( int id, String separator ) { + super( id ); + this.separator = separator; + this.entity = new Object[Field.values().length]; + + this.entity[Field.TIME.ordinal()] = 0.0; + this.entity[Field.CONDUCTED_GENERAL_INVESTIGATION.ordinal()] = 0; + this.entity[Field.REQUESTED_SPECIFIC_INVESTIGATION.ordinal()] = 0; + this.entity[Field.CONDUCTED_SPECIFIC_INVESTIGATION.ordinal()] = 0; + } + + + @Override + public void setValue( String fieldStr, Object value ) { + + Field field = Field.valueOf( fieldStr ); + + if ( field.getType().equals( DataType.BOOLEAN ) ) { + this.entity[field.ordinal()] = (Boolean) value; + + } else if ( field.getType().equals( DataType.DOUBLE ) ) { + this.entity[field.ordinal()] = (Double) value; + + } else if ( field.getType().equals( DataType.INTEGER ) ) { + this.entity[field.ordinal()] = (Integer) value; + + } else if ( field.getType().equals( DataType.STRING ) ) { + this.entity[field.ordinal()] = (String) value; + + } + } + + + @Override + public Object getValue( String fieldStr ) { + return this.entity[Field.valueOf( fieldStr ).ordinal()]; + } + + + @Override + public String getLine() { + String line = new String(); + + Object value; + for ( Field field : Field.values() ) { + value = this.entity[field.ordinal()]; + if ( value == null ) { + value = (String) ""; + } else if ( field.getType().equals( DataType.DOUBLE ) ) { + value = String.format( "%.2f", value ); + } + line += value + this.separator; + } + line = line.substring( 0, line.length() - 1 ); + + return line; + } + + + @Override + public String getHeader() { + String header = new String(); + + for ( Field field : Field.values() ) { + header += field.getName() + this.separator; + } + header = header.substring( 0, header.length() - 1 ); + + return header; + } +} \ No newline at end of file diff --git a/src/main/java/gloderss/output/OutputController.java b/src/main/java/gloderss/output/OutputController.java index 741ac8a..1f077b1 100755 --- a/src/main/java/gloderss/output/OutputController.java +++ b/src/main/java/gloderss/output/OutputController.java @@ -200,7 +200,7 @@ public synchronized AbstractEntity getEntity( EntityType type ) { entity = this.getEntity( type, id ); if ( entity != null ) { - this.entityId.put( type, id + 1 ); + this.entityId.put( type, id + 1); } } @@ -256,6 +256,9 @@ public synchronized AbstractEntity getEntity( EntityType type, int id ) { case STATE: entity = new StateOutputEntity( id, this.separator ); break; + case INVESTIGATION: + entity = new InvestigationOutputEntity( id, this.separator ); + break; case INTERMEDIARY_ORGANIZATION: entity = new IntermediaryOrganizationOutputEntity( id, this.separator ); diff --git a/src/main/resources/conf/batch.xml b/src/main/resources/conf/batch/batch.xml similarity index 94% rename from src/main/resources/conf/batch.xml rename to src/main/resources/conf/batch/batch.xml index 5769b30..8110298 100755 --- a/src/main/resources/conf/batch.xml +++ b/src/main/resources/conf/batch/batch.xml @@ -1,8 +1,8 @@ + xsi:noNamespaceSchemaLocation="../batch.xsd"> - ./src/main/resources/conf + ./src/main/resources/conf/batch ./output 10 diff --git a/src/main/resources/conf/batch/general.txt b/src/main/resources/conf/batch/general.txt index ce0ff4b..9a65ec8 100755 --- a/src/main/resources/conf/batch/general.txt +++ b/src/main/resources/conf/batch/general.txt @@ -62,6 +62,7 @@ mafia.csv mafiosi.csv state.csv + investigation.csv intermediaryOrganization.csv \ No newline at end of file diff --git a/src/main/resources/conf/batch/state-no-noNorm.txt b/src/main/resources/conf/batch/state-no-noNorm.txt index 57cad67..7eccd5f 100755 --- a/src/main/resources/conf/batch/state-no-noNorm.txt +++ b/src/main/resources/conf/batch/state-no-noNorm.txt @@ -2,6 +2,7 @@ 0 + 100 NORMAL(10,5) NORMAL(100,5) NORMAL(10,5) diff --git a/src/main/resources/conf/batch/state-no-norm.txt b/src/main/resources/conf/batch/state-no-norm.txt index f9a5421..99a3924 100755 --- a/src/main/resources/conf/batch/state-no-norm.txt +++ b/src/main/resources/conf/batch/state-no-norm.txt @@ -2,6 +2,7 @@ 0 + 100 NORMAL(100,10) NORMAL(50,10) NORMAL(300,10) diff --git a/src/main/resources/conf/batch/state-strong-noNorm.txt b/src/main/resources/conf/batch/state-strong-noNorm.txt index df58d92..515162e 100755 --- a/src/main/resources/conf/batch/state-strong-noNorm.txt +++ b/src/main/resources/conf/batch/state-strong-noNorm.txt @@ -2,6 +2,7 @@ 20 + 100 NORMAL(100,10) NORMAL(50,10) NORMAL(300,10) diff --git a/src/main/resources/conf/batch/state-strong-norm.txt b/src/main/resources/conf/batch/state-strong-norm.txt index 4a3efd1..de51c0b 100755 --- a/src/main/resources/conf/batch/state-strong-norm.txt +++ b/src/main/resources/conf/batch/state-strong-norm.txt @@ -2,6 +2,7 @@ 20 + 100 NORMAL(100,10) NORMAL(50,10) NORMAL(300,10) diff --git a/src/main/resources/conf/batch/state-weak-noNorm.txt b/src/main/resources/conf/batch/state-weak-noNorm.txt index be77658..59c692b 100755 --- a/src/main/resources/conf/batch/state-weak-noNorm.txt +++ b/src/main/resources/conf/batch/state-weak-noNorm.txt @@ -2,6 +2,7 @@ 5 + 100 NORMAL(10,5) NORMAL(100,5) NORMAL(10,5) diff --git a/src/main/resources/conf/batch/state-weak-norm.txt b/src/main/resources/conf/batch/state-weak-norm.txt index 067d2b9..1c3daa9 100755 --- a/src/main/resources/conf/batch/state-weak-norm.txt +++ b/src/main/resources/conf/batch/state-weak-norm.txt @@ -2,6 +2,7 @@ 5 + 100 NORMAL(10,5) NORMAL(100,5) NORMAL(10,5) diff --git a/src/main/resources/conf/scenario-B.xml b/src/main/resources/conf/scenario-B.xml new file mode 100755 index 0000000..ae13606 --- /dev/null +++ b/src/main/resources/conf/scenario-B.xml @@ -0,0 +1,314 @@ + + + + + 30 + 20000 + SCALEFREE + CLUSTERED + + 557704 + 467948 + 57158 + 434653 + 959301 + 973854 + 479357 + 625849 + 355990 + 157039 + 668591 + 144910 + 616748 + 294850 + 831806 + 810898 + 618666 + 571834 + 277354 + 404974 + 963562 + 835197 + 259775 + 17595 + 881675 + 787343 + 281389 + 550226 + 953865 + 79584 + 585388 + 421814 + 637289 + 642546 + 856467 + 596590 + 616400 + 335825 + 222440 + 972391 + + + /data/downloads/garbage/SS17/0.49-0.51/New/B + false + ; + 20000 + + + extortion.csv + compensation.csv + purchase.csv + normative.csv + entrepreneur.csv + consumer.csv + mafia.csv + mafiosi.csv + state.csv + investigation.csv + intermediaryOrganization.csv + + + + + + 0.0 + 0.5 + 1.0 + + + COMPLETE + COMPLETE + COMPLETE + COMPLETE + COMPLETE + COMPLETE + COMPLETE + PARTIAL + PARTIAL + PARTIAL + NONE + COMPLETE + COMPLETE + PARTIAL + COMPLETE + PARTIAL + COMPLETE + PARTIAL + COMPLETE + PARTIAL + COMPLETE + NONE + NONE + PARTIAL + PARTIAL + COMPLETE + PARTIAL + COMPLETE + PARTIAL + PARTIAL + COMPLETE + COMPLETE + COMPLETE + NONE + NONE + NONE + COMPLETE + COMPLETE + + + + + + + 200 + 100 + false + + + NORMAL(30,10) + 5 + + + + 0.0 + 0.0 + + + + + 0.90 + 0.75 + + + + src/main/resources/conf/consumer.xml + src/main/resources/conf/emilia.xsd + 0.49 + 0.51 + + + + + + + + + + + + + + + + + + + + + + + + 100 + 100 + false + + + 0.00 + NORMAL(30,2) + 500.00 + 1000.00 + 0.5 + 50.00 + 100.00 + + + 0.5 + + + 0.9 + + + 1.0 + false + + + + 0.5 + 0.3 + 0.9 + + + + src/main/resources/conf/entrepreneur.xml + src/main/resources/conf/emilia.xsd + 0.49 + 0.51 + + + + + + + + + + + + + + + + + + + + 20 + 100 + NORMAL(10,5) + NORMAL(100,5) + NORMAL(10,5) + 0.2 + 0.2 + 0.01 + + + CONSTANT(10) + 0.1 + #{COLLABORATION} * 0.05 + NORMAL(100,5) + 0.1 + 0.1 + + + CONSTANT(50) + 0 + NORMAL(500,100) + 0.0 + + + 200 + 0.0 + 0.0 + + + + + + + + 20 + 100 + 0.00 + NORMAL(3,2) + 0.9 + 0.03 + 0.5 + CONSTANT(2) + 0.5 + 0.0 + 0.01 + 0.01 + + 0.5 + + 0.05 + + + + + + + + + NORMAL(200,5) + + + tanh(#{NUMBER_ACTIONS},0.1) + 0.0 + 0.0 + + + + + diff --git a/src/main/resources/conf/scenario-CA.xml b/src/main/resources/conf/scenario-CA.xml new file mode 100644 index 0000000..9d1d5b9 --- /dev/null +++ b/src/main/resources/conf/scenario-CA.xml @@ -0,0 +1,378 @@ + + + + + 30 + 20000 + SCALEFREE + CLUSTERED + + 557704 + 467948 + 57158 + 434653 + 959301 + 973854 + 479357 + 625849 + 355990 + 157039 + 668591 + 144910 + 616748 + 294850 + 831806 + 810898 + 618666 + 571834 + 277354 + 404974 + 963562 + 835197 + 259775 + 17595 + 881675 + 787343 + 281389 + 550226 + 953865 + 79584 + 585388 + 421814 + 637289 + 642546 + 856467 + 596590 + 616400 + 335825 + 222440 + 972391 + + + /data/downloads/garbage/SS17/0.49-0.51/New/CA + false + ; + 20000 + + + extortion.csv + compensation.csv + purchase.csv + normative.csv + entrepreneur.csv + consumer.csv + mafia.csv + mafiosi.csv + state.csv + investigation.csv + intermediaryOrganization.csv + + + + + + 0.0 + 0.5 + 1.0 + + + COMPLETE + COMPLETE + COMPLETE + COMPLETE + COMPLETE + COMPLETE + COMPLETE + PARTIAL + PARTIAL + PARTIAL + NONE + COMPLETE + COMPLETE + PARTIAL + COMPLETE + PARTIAL + COMPLETE + PARTIAL + COMPLETE + PARTIAL + COMPLETE + NONE + NONE + PARTIAL + PARTIAL + COMPLETE + PARTIAL + COMPLETE + PARTIAL + PARTIAL + COMPLETE + COMPLETE + COMPLETE + NONE + NONE + NONE + COMPLETE + COMPLETE + + + + + + + 200 + 100 + false + + + NORMAL(30,10) + 5 + + + + 0.0 + 0.0 + + + + + 0.90 + 0.75 + + + + src/main/resources/conf/consumer.xml + src/main/resources/conf/emilia.xsd + 0.49 + 0.51 + + + + + + + + + + + + + + + + + + + + + + + + 100 + 100 + false + + + 0.00 + NORMAL(30,2) + 500.00 + 1000.00 + 0.5 + 50.00 + 100.00 + + + 0.5 + + + 0.9 + + + 1.0 + false + + + + 0.5 + 0.3 + 0.9 + + + + src/main/resources/conf/entrepreneur.xml + src/main/resources/conf/emilia.xsd + 0.49 + 0.51 + + + + + + + + + + + + + + + + + + + + 20 + 100 + NORMAL(100,10) + NORMAL(50,10) + NORMAL(300,10) + 0.8 + 0.8 + 0.2 + + + CONSTANT(150) + 0.6 + #{COLLABORATION} * 0.05 + NORMAL(500,100) + 0.3 + 0.5 + + + CONSTANT(50) + 4000 + NORMAL(500,100) + 0.5 + + + 200 + 0.05 + 0.05 + + + + + generalInvestigationDurationPDF + NORMAL(10,5) + + + + bureaucraticActivityDurationPDF + NORMAL(100,5) + + + + specificInvestigationDurationPDF + NORMAL(10,5) + + + + specificInvestigationProbability + 0.2 + + + + captureProbability + 0.2 + + + + evidenceProbability + 0.01 + + + + custodyDurationPDF + CONSTANT(10) + + + + convictionProbability + 0.1 + + + + imprisonmentDurationPDF + NORMAL(100,5) + + + + noCollaborationPunishmentProbability + 0.1 + + + + noCollaborationPunishment + 0.1 + + + + resourceFondo + 0 + + + + proportionTransferFondo + 0.0 + + + + proportionConsumers + 0.0 + + + + proportionEntrepreneurs + 0.0 + + + + + + + 20 + 100 + 0.00 + NORMAL(3,2) + 0.5 + 0.03 + 0.5 + CONSTANT(2) + 0.5 + 0.0 + 0.01 + 0.01 + + 0.5 + + 0.05 + + + + + + + + + NORMAL(200,5) + + + tanh(#{NUMBER_ACTIONS},0.1) + 0.1 + 0.1 + + + + + proportionConsumers + 0.0 + + + + proportionEntrepreneurs + 0.0 + + + + diff --git a/src/main/resources/conf/scenario-LA.xml b/src/main/resources/conf/scenario-LA.xml new file mode 100644 index 0000000..221f3e2 --- /dev/null +++ b/src/main/resources/conf/scenario-LA.xml @@ -0,0 +1,379 @@ + + + + + 30 + 20000 + SCALEFREE + CLUSTERED + + 557704 + 467948 + 57158 + 434653 + 959301 + 973854 + 479357 + 625849 + 355990 + 157039 + 668591 + 144910 + 616748 + 294850 + 831806 + 810898 + 618666 + 571834 + 277354 + 404974 + 963562 + 835197 + 259775 + 17595 + 881675 + 787343 + 281389 + 550226 + 953865 + 79584 + 585388 + 421814 + 637289 + 642546 + 856467 + 596590 + 616400 + 335825 + 222440 + 972391 + + + /data/downloads/garbage/SS17/0.49-0.51/New/LA + false + ; + 20000 + + + extortion.csv + compensation.csv + purchase.csv + normative.csv + entrepreneur.csv + consumer.csv + mafia.csv + mafiosi.csv + state.csv + investigation.csv + intermediaryOrganization.csv + + + + + + 0.0 + 0.5 + 1.0 + + + COMPLETE + COMPLETE + COMPLETE + COMPLETE + COMPLETE + COMPLETE + COMPLETE + PARTIAL + PARTIAL + PARTIAL + NONE + COMPLETE + COMPLETE + PARTIAL + COMPLETE + PARTIAL + COMPLETE + PARTIAL + COMPLETE + PARTIAL + COMPLETE + NONE + NONE + PARTIAL + PARTIAL + COMPLETE + PARTIAL + COMPLETE + PARTIAL + PARTIAL + COMPLETE + COMPLETE + COMPLETE + NONE + NONE + NONE + COMPLETE + COMPLETE + + + + + + + 200 + 100 + false + + + NORMAL(30,10) + 5 + + + + 0.0 + 0.0 + + + + + 0.90 + 0.75 + + + + src/main/resources/conf/consumer.xml + src/main/resources/conf/emilia.xsd + 0.49 + 0.51 + + + + + + + + + + + + + + + + + + + + + + + + 100 + 100 + false + + + 0.00 + NORMAL(30,2) + 500.00 + 1000.00 + 0.5 + 50.00 + 100.00 + + + 0.5 + + + 0.9 + + + 1.0 + false + + + + 0.5 + 0.3 + 0.9 + + + + src/main/resources/conf/entrepreneur.xml + src/main/resources/conf/emilia.xsd + 0.49 + 0.51 + + + + + + + + + + + + + + + + + + + + 20 + 100 + NORMAL(100,10) + NORMAL(50,10) + NORMAL(300,10) + 0.8 + 0.8 + 0.2 + + + CONSTANT(150) + 0.6 + #{COLLABORATION} * 0.05 + NORMAL(500,100) + 0.3 + 0.5 + + + CONSTANT(50) + 4000 + NORMAL(500,100) + 0.5 + + + 200 + 0.0 + 0.0 + + + + + generalInvestigationDurationPDF + NORMAL(10,5) + + + + bureaucraticActivityDurationPDF + NORMAL(100,5) + + + + specificInvestigationDurationPDF + NORMAL(10,5) + + + + specificInvestigationProbability + 0.2 + + + + captureProbability + 0.2 + + + + evidenceProbability + 0.01 + + + + custodyDurationPDF + CONSTANT(10) + + + + convictionProbability + 0.1 + + + + imprisonmentDurationPDF + NORMAL(100,5) + + + + noCollaborationPunishmentProbability + 0.1 + + + + noCollaborationPunishment + 0.1 + + + + resourceFondo + 0 + + + + proportionTransferFondo + 0.0 + + + + + + + 20 + 100 + 0.00 + NORMAL(3,2) + 0.9 + 0.03 + 0.5 + CONSTANT(2) + 0.5 + 0.0 + 0.01 + 0.01 + + 0.5 + + 0.05 + + + + + + + + + NORMAL(200,5) + + + tanh(#{NUMBER_ACTIONS},0.1) + 0.0 + 0.0 + + + + + diff --git a/src/main/resources/conf/scenario-SA.xml b/src/main/resources/conf/scenario-SA.xml new file mode 100644 index 0000000..864ca52 --- /dev/null +++ b/src/main/resources/conf/scenario-SA.xml @@ -0,0 +1,324 @@ + + + + + 30 + 20000 + SCALEFREE + CLUSTERED + + 557704 + 467948 + 57158 + 434653 + 959301 + 973854 + 479357 + 625849 + 355990 + 157039 + 668591 + 144910 + 616748 + 294850 + 831806 + 810898 + 618666 + 571834 + 277354 + 404974 + 963562 + 835197 + 259775 + 17595 + 881675 + 787343 + 281389 + 550226 + 953865 + 79584 + 585388 + 421814 + 637289 + 642546 + 856467 + 596590 + 616400 + 335825 + 222440 + 972391 + + + /data/downloads/garbage/SS17/0.49-0.51/New/SA + false + ; + 20000 + + + extortion.csv + compensation.csv + purchase.csv + normative.csv + entrepreneur.csv + consumer.csv + mafia.csv + mafiosi.csv + state.csv + investigation.csv + intermediaryOrganization.csv + + + + + + 0.0 + 0.5 + 1.0 + + + COMPLETE + COMPLETE + COMPLETE + COMPLETE + COMPLETE + COMPLETE + COMPLETE + PARTIAL + PARTIAL + PARTIAL + NONE + COMPLETE + COMPLETE + PARTIAL + COMPLETE + PARTIAL + COMPLETE + PARTIAL + COMPLETE + PARTIAL + COMPLETE + NONE + NONE + PARTIAL + PARTIAL + COMPLETE + PARTIAL + COMPLETE + PARTIAL + PARTIAL + COMPLETE + COMPLETE + COMPLETE + NONE + NONE + NONE + COMPLETE + COMPLETE + + + + + + + 200 + 100 + false + + + NORMAL(30,10) + 5 + + + + 0.0 + 0.0 + + + + + 0.90 + 0.75 + + + + src/main/resources/conf/consumer.xml + src/main/resources/conf/emilia.xsd + 0.49 + 0.51 + + + + + + + + + + + + + + + + + + + + + + + + 100 + 100 + false + + + 0.00 + NORMAL(30,2) + 500.00 + 1000.00 + 0.5 + 50.00 + 100.00 + + + 0.5 + + + 0.9 + + + 1.0 + false + + + + 0.5 + 0.3 + 0.9 + + + + src/main/resources/conf/entrepreneur.xml + src/main/resources/conf/emilia.xsd + 0.49 + 0.51 + + + + + + + + + + + + + + + + + + + + 20 + 100 + NORMAL(10,5) + NORMAL(100,5) + NORMAL(10,5) + 0.2 + 0.2 + 0.01 + + + CONSTANT(10) + 0.1 + #{COLLABORATION} * 0.05 + NORMAL(100,5) + 0.1 + 0.1 + + + CONSTANT(50) + 0 + NORMAL(500,100) + 0.0 + + + 200 + 0.0 + 0.0 + + + + + + + + 20 + 100 + 0.00 + NORMAL(3,2) + 0.9 + 0.03 + 0.5 + CONSTANT(2) + 0.5 + 0.0 + 0.01 + 0.01 + + 0.5 + + 0.05 + + + + + + + + + NORMAL(200,5) + + + tanh(#{NUMBER_ACTIONS},0.1) + 0.1 + 0.1 + + + + + proportionConsumers + 0.0 + + + + proportionEntrepreneurs + 0.0 + + + + diff --git a/src/main/resources/conf/scenario.xml b/src/main/resources/conf/scenario.xml index b98e50c..92e178f 100644 --- a/src/main/resources/conf/scenario.xml +++ b/src/main/resources/conf/scenario.xml @@ -66,6 +66,7 @@ mafia.csv mafiosi.csv state.csv + investigation.csv intermediaryOrganization.csv @@ -242,6 +243,7 @@ 20 + 100 NORMAL(100,10) NORMAL(50,10) NORMAL(300,10) diff --git a/src/main/resources/conf/scenario.xsd b/src/main/resources/conf/scenario.xsd index 56e3120..1b55113 100755 --- a/src/main/resources/conf/scenario.xsd +++ b/src/main/resources/conf/scenario.xsd @@ -55,6 +55,7 @@ + @@ -416,6 +417,7 @@ + diff --git a/src/main/resources/conf/sensitivity-analysis/consumer.xml b/src/main/resources/conf/sensitivity-analysis/consumer.xml new file mode 100755 index 0000000..11fd0ac --- /dev/null +++ b/src/main/resources/conf/sensitivity-analysis/consumer.xml @@ -0,0 +1,12 @@ + + + + gloderss.agents.consumer.normative.modules.classifier.EventClassifier + gloderss.normative.modules.recognition.NormRecognitionController + gloderss.normative.modules.adoption.NormAdoptionController + gloderss.normative.modules.salience.NormSalienceController + gloderss.agents.consumer.normative.modules.enforcement.NormEnforcementController + gloderss.normative.modules.compliance.NormComplianceController + gloderss.normative.board.NormativeBoard + \ No newline at end of file diff --git a/src/main/resources/conf/sensitivity-analysis/emilia.xsd b/src/main/resources/conf/sensitivity-analysis/emilia.xsd new file mode 100755 index 0000000..459bdca --- /dev/null +++ b/src/main/resources/conf/sensitivity-analysis/emilia.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/conf/sensitivity-analysis/entrepreneur.xml b/src/main/resources/conf/sensitivity-analysis/entrepreneur.xml new file mode 100755 index 0000000..69d9bf0 --- /dev/null +++ b/src/main/resources/conf/sensitivity-analysis/entrepreneur.xml @@ -0,0 +1,12 @@ + + + + gloderss.agents.entrepreneur.normative.modules.classifier.EventClassifier + gloderss.normative.modules.recognition.NormRecognitionController + gloderss.normative.modules.adoption.NormAdoptionController + gloderss.normative.modules.salience.NormSalienceController + gloderss.agents.entrepreneur.normative.modules.enforcement.NormEnforcementController + gloderss.normative.modules.compliance.NormComplianceController + gloderss.normative.board.NormativeBoard + \ No newline at end of file diff --git a/src/main/resources/conf/randomBatch.xml b/src/main/resources/conf/sensitivity-analysis/randomBatch.xml similarity index 91% rename from src/main/resources/conf/randomBatch.xml rename to src/main/resources/conf/sensitivity-analysis/randomBatch.xml index fb03c62..44d3f20 100644 --- a/src/main/resources/conf/randomBatch.xml +++ b/src/main/resources/conf/sensitivity-analysis/randomBatch.xml @@ -1,14 +1,14 @@ - - ./output + + /data/downloads/garbage/SS17/0.49-0.51/data/sensitivity-analysis config.csv - 500 - - ./src/main/resources/conf/scenario.xml - ./src/main/resources/conf/scenario.xsd - + 400 + + src/main/resources/conf/sensitivity-analysis/scenario.xml + src/main/resources/conf/scenario.xsd + 1 10000 SCALEFREE - RANDOM + CLUSTERED + 355990 557704 467948 57158 @@ -16,7 +17,6 @@ 973854 479357 625849 - 355990 157039 668591 144910 @@ -50,7 +50,7 @@ 972391 - ./output + /data/downloads/garbage/SS17/0.49-0.51/data/sensitivity-analysis false ; 10000 @@ -65,9 +65,11 @@ mafia.csv mafiosi.csv state.csv + investigation.csv intermediaryOrganization.csv + @@ -116,6 +118,7 @@ COMPLETE + @@ -136,95 +139,38 @@ 0.90 - 0.1 - - - - src/main/resources/conf/consumer.xml - src/main/resources/conf/emilia.xsd - 0.5 - 0.5 - - - - - - - - - - - - - - - - - - - - - 0 - 100 - true - - - NORMAL(30,10) - 5 - - - - 0.5 - 0.5 - - - - - 0.75 0.75 src/main/resources/conf/consumer.xml src/main/resources/conf/emilia.xsd - 0.5 - 0.5 + 0.49 + 0.51 + violation="0" obsCompliance="1" obsViolation="1" punishment="1" + sanction="1" invocationCompliance="1" invocationViolation="0" /> - + - + + violation="0" obsCompliance="1" obsViolation="1" punishment="1" + sanction="1" invocationCompliance="1" invocationViolation="0" /> @@ -232,8 +178,8 @@ - - + + 100 @@ -252,180 +198,64 @@ 0.5 - - 0.1 - - - 1.0 - false - - - - 0.1 - 0.1 - 0.9 - - - - src/main/resources/conf/entrepreneur.xml - src/main/resources/conf/emilia.xsd - 0.5 - 0.5 - - - - - - - - - - - - - - - - - 0 - 100 - true - - - 0.00 - NORMAL(30,2) - 500.00 - 1000.00 - 0.5 - 50.00 - 100.00 - - - 0.5 - 0.9 - 0.95 + 1.0 false 0.5 0.3 - 0.7 - - - - src/main/resources/conf/entrepreneur.xml - src/main/resources/conf/emilia.xsd - 0.5 - 0.5 - - - - - - - - - - - - - - - - - 0 - 100 - true - - - 0.00 - NORMAL(30,2) - 500.00 - 1000.00 - 0.5 - 50.00 - 100.00 - - - 0.5 - - - 0.9 - - - 0.95 - true - - - - 0.5 - 0.3 - 0.7 + 0.9 src/main/resources/conf/entrepreneur.xml src/main/resources/conf/emilia.xsd - 0.5 - 0.5 + 0.49 + 0.51 + violation="0" obsCompliance="1" obsViolation="1" punishment="1" + sanction="1" invocationCompliance="1" invocationViolation="0" /> - + - + + violation="0" obsCompliance="1" obsViolation="1" punishment="1" + sanction="1" invocationCompliance="1" invocationViolation="0" /> + 20 + 100 NORMAL(100,10) NORMAL(50,10) - NORMAL(10,5) - 0.2 - 0.2 - 0.1 + NORMAL(300,10) + 0.8 + 0.8 + 0.2 - CONSTANT(100) - 0.1 + CONSTANT(150) + 0.6 #{COLLABORATION} * 0.05 NORMAL(500,100) 0.3 @@ -445,19 +275,20 @@ + 20 100 0.00 NORMAL(3,2) - 1.0 + 0.5 0.03 - 0.5 + 0.9 CONSTANT(2) - 0.5 + 0.7 0.0 - 0.01 + 0.1 0.01 0.5 @@ -467,6 +298,7 @@ + @@ -474,10 +306,11 @@ tanh(#{NUMBER_ACTIONS},0.1) - 0.05 - 0.05 + 0.1 + 0.1 - + + \ No newline at end of file diff --git a/src/main/resources/conf/sensitivity-analysis/scenario.xsd b/src/main/resources/conf/sensitivity-analysis/scenario.xsd new file mode 100755 index 0000000..1b55113 --- /dev/null +++ b/src/main/resources/conf/sensitivity-analysis/scenario.xsd @@ -0,0 +1,662 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/java/gloderss/conf/ScenarioTest.java b/src/test/java/gloderss/conf/ScenarioTest.java index df4047e..35411ef 100644 --- a/src/test/java/gloderss/conf/ScenarioTest.java +++ b/src/test/java/gloderss/conf/ScenarioTest.java @@ -11,39 +11,38 @@ import org.xml.sax.SAXException; public class ScenarioTest { - + @Test public void scenarioTest() { boolean valid = false; - + try { SchemaFactory factory = SchemaFactory .newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI ); - + File file = new File( "./src/main/resources/conf/scenario.xsd" ); System.out.println( file.exists() ); - - file = new File( - "/data/workspace/gloders/gloderss/output/85/scenario.xml" ); + + file = new File( "./src/main/resources/conf/scenario.xml" ); System.out.println( file.exists() ); - + Schema schema = factory.newSchema( new StreamSource( "./src/main/resources/conf/scenario.xsd" ) ); - + Validator validator = schema.newValidator(); - validator.validate( new StreamSource( - "/data/workspace/gloders/gloderss/output/85/scenario.xml" ) ); - + validator.validate( + new StreamSource( "./src/main/resources/conf/scenario.xml" ) ); + valid = true; - + } catch ( SAXException e ) { System.out.println( e.getMessage() ); } catch ( Exception e ) { System.out.println( e.getMessage() ); } - + System.out.println( valid ); assertTrue( valid ); } - + } \ No newline at end of file