[Home]History of Simonton/RoboleagueScripting

Robo Home | Changes | Preferences | AllPages


Revision 3 . . September 30, 2006 4:10 EST by Simonton [Improved]
Revision 2 . . (edit) September 28, 2006 1:17 EST by Simonton
  

Difference (from prior major revision) (no other diffs)

Removed: 6d5


Changed: 38c37
i = makePropertyList?(args, vars, i);
i = makeVariableList?(args, vars, i);

Changed: 40,42c39,62
String fileBase = file.substring(0, file.length() - 4);
for (int season = 1; season > 0 && season <= numSeasons; ++season) {
season = run(vars, 0, fileBase, file, season);
System.out.println("RUNNING SINGLE VARIABLES");
for (int season = 1; season <= numSeasons; ++season) {
int minRun = Integer.MAX_VALUE;
for (i = 0; i < vars.size(); ++i) {
int finished = runSingle(vars, i, file, season);
vars.get(i).initialize();
if (finished == -1) {
System.out.println("INTURRUPTED!");
return;
}
if (finished < minRun) {
minRun = finished;
}
}
season = minRun;
System.out.println("FINISHED SEASON " + season);
}
System.out.println("RUNNING COMBINED VARIABLES");
for (int season = 1; season <= numSeasons; ++season) {
season = runCombined(vars, 0, file, season);
if (season == -1) {
System.out.println("INTURRUPTED!");
return;
}

Added: 45a66
gracefullExit();

Changed: 48,53c69,81
private boolean load(File file) {
CompetitionDataModel? before = loadedDataModel?;
bg_openDataModel?(file);
if (loadedDataModel? == null || loadedDataModel? == before) {
System.out.println("Load failed");
return false;
private int runSingle(List<Variable> vars, int i, String originalFile,
int season) {
Variable var = vars.get(i);
int minCount = Integer.MAX_VALUE;
for (String val : var.values) {
System.setProperty(var.name, val);
int count = run(vars, originalFile, season);
if (count == -1) {
return -1;
}
if (count < minCount) {
minCount = count;
}

Changed: 55c83
return true;
return minCount;

Changed: 59,60c87,88
private int run(List<Variable> vars, int i, String baseFilename,
String originalFile, int curSeason) {
private int runCombined(List<Variable> vars, int i, String originalFile,
int curSeason) {

Changed: 62,89c90
File file = new File(baseFilename + ".xml");
if (exists(file, originalFile) && load(file)) {
int seasonCount = getCompletedSeasonCount?();
if (seasonCount < curSeason) {
runSeasons(1);
try {
runSeasonJob?.join();
} catch (InterruptedException? e) {
// no prob, we'll abort when inturrupted
// possible race condition if inturrupted right away,
// but the job is still running, we get the old season
// count, then the new non-terminated state (it depends
// on the order in which the state & season count are
// updated)
}
int newSeasonCount? = getCompletedSeasonCount?();
if (newSeasonCount? == seasonCount) {
return -1;
}
assert newSeasonCount? == seasonCount + 1;
return newSeasonCount?;
}
System.out.println(baseFilename + " already ran season "
+ curSeason);
return seasonCount;
}
System.out.println("Couldn't find, create, or run " + file);
return Integer.MAX_VALUE;
return run(vars, originalFile, curSeason);

Removed: 92d92
baseFilename += "_" + var.name + "-";

Changed: 96,98c96
System.out.println(System.getProperty("patternDepth"));
int count = run(vars, i + 1, baseFilename + val, originalFile,
curSeason);
int count = runCombined(vars, i + 1, originalFile, curSeason);

Added: 108a107,154
private int run(List<Variable> vars, String originalFile, int curSeason) {
File file = new File(getFilename(vars, originalFile));
if (exists(file, originalFile) && load(file)) {
int seasonCount = getCompletedSeasonCount?();
if (seasonCount < curSeason) {
runSeasons(1);
try {
runSeasonJob?.join();
} catch (InterruptedException? e) {
// no prob, we'll abort when inturrupted
// possible race condition if inturrupted right away,
// but the job is still running, we get the old season
// count, then the new non-terminated state (it depends
// on the order in which the state & season count are
// updated)
}
int newSeasonCount? = getCompletedSeasonCount?();
if (newSeasonCount? == seasonCount) {
return -1;
}
return newSeasonCount?;
}
System.out.println(file + " already ran season " + curSeason);
return seasonCount;
}
System.out.println("Couldn't find, create, or run " + file);
return Integer.MAX_VALUE;
}

private String getFilename(List<Variable> vars, String originalFile) {
String filename = originalFile.substring(0, originalFile.length() - 4);
Set<Variable> varSet = new TreeSet?<Variable>(vars);
for (Variable var : varSet) {
filename += "-" + var;
}
return filename + ".xml";
}

private boolean load(File file) {
CompetitionDataModel? before = loadedDataModel?;
bg_openDataModel?(file);
if (loadedDataModel? == null || loadedDataModel? == before) {
System.out.println("Load failed");
return false;
}
return true;
}


Changed: 153c199
private int makePropertyList?(String[] args, List<Variable> vars, int i) {
private int makeVariableList?(String[] args, List<Variable> vars, int i) {

Changed: 173c219
class Variable {
class Variable implements Comparable<Variable> {

Added: 178a225,234
initialize();
}
public void initialize() {
System.setProperty(name, values.get(0));
}
public String toString() {
return name + "=" + System.getProperty(name);
}
public int compareTo(Variable o) {
return name.compareTo(o.name);

Added: 210a267,269



Now in version 1.1! It has been updated to vary all variables while keeping the others fixed at their first values, THEN start in on all the rest of the combinations. It also now sorts the variable names when naming files, so that you can change the order of them at will without losing saved data (changing the order lets you dictate which variables are varied first). I think it should also allow you to define a variable twice (e.g. wallMargin number 110 120 2 wallMargin number 130 200 10), but I did not test that. I think there's a bug in the order in which it does "first vary each variable while keeping the others fixed", but I'm not sure.

Robo Home | Changes | Preferences | AllPages
Search: