Commit a2ca6428 authored by Johannes Mey's avatar Johannes Mey
Browse files

add simple main file for genetic solver

parent 3ac3a7e8
apply plugin: 'java'
apply plugin: 'application'
sourceCompatibility = 1.8
......@@ -7,6 +8,16 @@ repositories {
mavenCentral()
}
jar {
manifest {
attributes "Main-Class": 'de.tudresden.inf.st.mquat.solving.genetic.GeneticMain'
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.10.0'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.10.0'
......
package de.tudresden.inf.st.mquat.solving.genetic;
import de.tudresden.inf.st.mquat.generator.ScenarioDescription;
import de.tudresden.inf.st.mquat.generator.ScenarioGenerator;
import de.tudresden.inf.st.mquat.jastadd.model.Root;
import de.tudresden.inf.st.mquat.jastadd.model.Solution;
import de.tudresden.inf.st.mquat.solving.BenchmarkableSolver;
import de.tudresden.inf.st.mquat.solving.SolvingException;
import java.util.concurrent.TimeUnit;
public class GeneticMain {
public static void main(String[] args) {
ScenarioGenerator generator = new ScenarioGenerator(new ScenarioDescription(1,1, 0,1,0,2, 10, 10, 1, 1, 0));
Root model = generator.generate();
System.out.println("Problem has an initial solution with objective " + generator.getInitialSolution().computeObjective());
BenchmarkableSolver solver = new GeneticSolver(GeneticSolver.SelectorType.NSGA2, 100,100);
solver.setTimeout(30, TimeUnit.SECONDS);
try {
Solution solution = solver.solve(model);
System.out.println("Solution is valid: " + solution.isValid());
System.out.println("Found solution with objective " + solution.computeObjective());
} catch (SolvingException e) {
e.printStackTrace();
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment