Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
<classpathentry kind="lib" path="/home/forrest/.ivy2/cache/org.ow2.asm/asm-all/jars/asm-all-5.0.4.jar"/>
<classpathentry kind="lib" path="/home/forrest/.ivy2/cache/com.novocode/junit-interface/jars/junit-interface-0.11.jar"/>
<classpathentry kind="lib" path="/home/forrest/.ivy2/cache/org.scala-lang.modules/scala-parser-combinators_2.12/bundles/scala-parser-combinators_2.12-1.0.4.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/MOEAFramework"/>
<classpathentry kind="lib" path="/home/forrest/.ivy2/cache/com.google.code.gson/gson/jars/gson-1.7.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
*tmp.nlogo

/bin/
target/
/test/tmp
/test/tmptmp
2 changes: 1 addition & 1 deletion CREDITS.TXT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2013 Forrest Stonedahl & Uri Wilensky
Copyright 2013-2017 Forrest Stonedahl & Uri Wilensky

The BehaviorSearch software was initially developed as part of Forrest Stonedahl's doctoral thesis research, with adviser Uri Wilensky at the Center for Connected Learning and Computer-Based Modeling at Northwestern University.
It is an open source project, and new contributors/developers are welcome (contact feedback@behaviorsearch.org if interested).
Expand Down
6 changes: 5 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4",
"org.ow2.asm" % "asm-all" % "5.0.4",
"org.parboiled" %% "parboiled" % "2.1.3",
"com.novocode" % "junit-interface" % "0.11" % "test"
"com.novocode" % "junit-interface" % "0.11" % "test",
"com.google.code.gson" % "gson" % "1.7.1"
// libraryDependencies += "org.moeaframework" % "moeaframework" % "2.12"
// PROBLEM: MOEA 2.12 isn't good enough, since I need my custom contributions (already merged to master, but not released)

)

libraryDependencies ++= {
Expand Down
22 changes: 22 additions & 0 deletions documentation/tutorialFx.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@
<title>BehaviorSearch Documentation</title>
</head>


<!--MULTI-OBJ NOTES:
* Need to document:

measureIf can either be Netlogo reporter OR the special value "@DONE"


Raw (step-by-step) measures are collected throughout the simulation run
(although you can use the measureIf condition to only collect a subset, which may be faster and more memory-efficient)
all turtles are cleared (necessary for technical reasons), and single run condensers get evaluated
with the outputs from the raw measures (which are LISTS -- although note that they might contain 0 or 1 data elements).
The condensing is done in your model workspace, so you can use custom procedures that you wrote)...)
Combining across runs happens in one of the workspaces where your model has been loaded, but you should not assume
anything about the model state (e.g. that it is at the end of a run, etc)...

The condensed or combined results should ONLY consist of lists or primitive data (numbers, strings),
not agents or any of the more complex data types (arrays, tables, etc)

-->



<body>
<div id="container">
<div id="header">
Expand Down
43 changes: 43 additions & 0 deletions examples/Example_Fire_Burn_Variance.bsearch2
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"bsearchVersionNumber": 2.0,
"infoTab": "Write notes here...",
"modelDCInfo": {
"modelFileName": "../../models/Sample Models/Earth Science/Fire.nlogo",
"setupCommands": "setup",
"stepCommands": "go",
"stopCondition": "not any? turtles",
"measureIfReporter": "@DONE",
"maxModelSteps": 10000,
"rawMeasureReporters": {
"RAW1": "(burned-trees / initial-trees) * 100"
},
"singleRunCondenserReporters": {
"CONDENSED1": "last @{RAW1}"
},
"fitnessSamplingReplications": 5,
"bestCheckingNumReplications": 20
},
"paramSpecStrings": [
"[\"density\" [1 \"C\" 99]]"
],
"objectives": [
{
"name": "objective1",
"objectiveType": "MAXIMIZE",
"fitnessCombineReplications": "standard-deviation @{CONDENSED1}",
"fitnessDerivativeParameter": "",
"fitnessDerivativeDelta": 0.0,
"fitnessDerivativeUseAbs": false
}
],
"searchAlgorithmInfo": {
"searchMethodType": "MutationHillClimber",
"searchMethodParams": {
"mutation-rate": "1.0",
"restart-after-stall-count": "0"
},
"chromosomeType": "MixedTypeChromosome",
"caching": false,
"evaluationLimit": 500
}
}
43 changes: 43 additions & 0 deletions examples/Example_Fire_Derivative.bsearch2
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"bsearchVersionNumber": 2.0,
"infoTab": "Write notes here...",
"modelDCInfo": {
"modelFileName": "../../models/Sample Models/Earth Science/Fire.nlogo",
"setupCommands": "setup",
"stepCommands": "go",
"stopCondition": "not any? turtles",
"measureIfReporter": "@DONE",
"maxModelSteps": 10000,
"rawMeasureReporters": {
"RAW1": "(burned-trees / initial-trees) * 100"
},
"singleRunCondenserReporters": {
"CONDENSED1": "last @{RAW1}"
},
"fitnessSamplingReplications": 2,
"bestCheckingNumReplications": 4
},
"paramSpecStrings": [
"[\"density\" [2 \"C\" 99]]"
],
"objectives": [
{
"name": "objective1",
"objectiveType": "MAXIMIZE",
"fitnessCombineReplications": "mean @{CONDENSED1}",
"fitnessDerivativeParameter": "density",
"fitnessDerivativeDelta": 1.0,
"fitnessDerivativeUseAbs": false
}
],
"searchAlgorithmInfo": {
"searchMethodType": "MutationHillClimber",
"searchMethodParams": {
"mutation-rate": "1.0",
"restart-after-stall-count": "0"
},
"chromosomeType": "MixedTypeChromosome",
"caching": false,
"evaluationLimit": 600
}
}
51 changes: 51 additions & 0 deletions examples/Example_Flocking_Convergence.bsearch2
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"bsearchVersionNumber": 2.0,
"infoTab": "Write notes here...",
"modelDCInfo": {
"modelFileName": "../../models/Sample Models/Biology/Flocking.nlogo",
"setupCommands": "setup",
"stepCommands": "go",
"stopCondition": "",
"measureIfReporter": "ticks >= 75",
"maxModelSteps": 100,
"rawMeasureReporters": {
"RAW1": "standard-deviation [dx] of turtles + standard-deviation [dy] of turtles"
},
"singleRunCondenserReporters": {
"CONDENSED1": "mean @{RAW1}"
},
"fitnessSamplingReplications": 5,
"bestCheckingNumReplications": 10
},
"paramSpecStrings": [
"[\"population\" 50]",
"[\"vision\" [0 0.25 10]]",
"[\"minimum-separation\" [0 0.25 5]]",
"[\"max-align-turn\" [0 0.25 20]]",
"[\"max-separate-turn\" [0 0.25 20]]",
"[\"max-cohere-turn\" [0 0.25 20]]"
],
"objectives": [
{
"name": "objective1",
"objectiveType": "MINIMIZE",
"fitnessCombineReplications": "mean @{CONDENSED1}",
"fitnessDerivativeParameter": "",
"fitnessDerivativeDelta": 0.0,
"fitnessDerivativeUseAbs": false
}
],
"searchAlgorithmInfo": {
"searchMethodType": "StandardGA",
"searchMethodParams": {
"mutation-rate": "0.05",
"population-size": "30",
"crossover-rate": "0.7",
"population-model": "generational",
"tournament-size": "3"
},
"chromosomeType": "GrayBinaryChromosome",
"caching": true,
"evaluationLimit": 12000
}
}
Empty file removed mySearchOutput.bestHistory.csv
Empty file.
Empty file removed mySearchOutput.finalBests.csv
Empty file.
Empty file removed mySearchOutput.modelRunHistory.csv
Empty file.
Empty file.
36 changes: 0 additions & 36 deletions mySearchOutput.searchConfig.xml

This file was deleted.

12 changes: 12 additions & 0 deletions resources/SearchMethodList.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
-- Legacy single-objective --
RandomSearch
SimulatedAnnealing
MutationHillClimber
StandardGA

-- Single objective from MOEA --
Random
GA

-- Multi-objective from MOEA --
DBEA
SPEA2
NSGA-II
NSGA-III
e-NSGA-II
eMOEA
70 changes: 70 additions & 0 deletions src/bsearch/MOEAlink/BSProblem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package bsearch.MOEAlink;

import java.util.List;

import org.moeaframework.core.Solution;
import org.moeaframework.core.Variable;
import org.moeaframework.problem.AbstractProblem;
import org.moeaframework.util.distributed.FutureSolution;
import org.nlogo.api.MersenneTwisterFast;

import bsearch.app.BehaviorSearchException;
import bsearch.datamodel.SearchProtocolInfo;
import bsearch.evaluation.SearchManager;
import bsearch.space.SearchSpace;

public class BSProblem extends AbstractProblem {
private SearchProtocolInfo protocol;
private SearchSpace space;
private SearchManager searchManager;
private long evaluationRequestCounter = 0;
private int uncorrelatedSearchSeed;

public BSProblem(SearchProtocolInfo protocol, SearchManager searchManager, int searchSeed) {
super(protocol.paramSpecStrings.size(), protocol.objectives.size());
this.protocol = protocol;
this.searchManager = searchManager;
this.space = new SearchSpace(protocol.paramSpecStrings);
// we choose a seed that is deterministically derived from the search seed,
// but is not correlated with it, so that we don't get the same NetLogo model
// runs for searches numbered N and N+1.
this.uncorrelatedSearchSeed = new MersenneTwisterFast(searchSeed).nextInt();
}

@Override
public void evaluate(Solution solution) {

MOEASolutionWrapper solWrapper = new MOEASolutionWrapper(solution, space, protocol.objectives);
// int rand;
// synchronized (otherRng) {
// rand = otherRng.nextInt();
// GeneralUtils.debug(rand + solWrapper.getParameterSettings().toString());
// }
long evaluationCount;
if (solution instanceof FutureSolution) {
evaluationCount = ((FutureSolution) solution).getDistributedEvaluationID();
} else {
// we must be running single threaded, so no need to synchronize to avoid race condition
evaluationCount = evaluationRequestCounter++;
}
// GeneralUtils.debug(evaluationCount + ": " + solWrapper.getParameterSettings().toString().hashCode());

MersenneTwisterFast rng = new MersenneTwisterFast(uncorrelatedSearchSeed + evaluationCount);
try {
//TODO: Pass evaluationCount into computeFitnessSingle, so we can use that for getting perfectly replicable output?
searchManager.computeFitnessSingle(solWrapper, protocol.modelDCInfo.fitnessSamplingReplications, rng);
} catch (BehaviorSearchException e) {
e.printStackTrace();
}
}

@Override
public Solution newSolution() {
List<Variable> vars = space.getMOEAVariables();
Solution solution = new Solution(this.numberOfVariables, this.numberOfObjectives);
for (int i = 0; i < vars.size(); i++) {
solution.setVariable(i, vars.get(i));
}
return solution;
}
}
Loading