mirror of
https://github.com/Echtzeitsysteme/gips-examples.git
synced 2024-06-03 02:31:53 +00:00
Adds example instance + runner class
This commit is contained in:
parent
ad5919c630
commit
f1e7d41dea
|
@ -2,7 +2,7 @@ package "org.emoflon.gips.gipsl.examples.headlessrunner"
|
|||
import "platform:/resource/org.emoflon.gips.gipsl.examples.headlessrunnermodel/model/Headlessrunnermodel.ecore"
|
||||
|
||||
config {
|
||||
solver := GLPK [home:="fu", license:="bar"];
|
||||
solver := GUROBI [home:="fu", license:="bar"];
|
||||
timeLimit := true [value := 10.0];
|
||||
randomSeed := true [value := 0];
|
||||
presolve := true;
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package org.emoflon.gips.gipsl.examples.headlessrunner.runner;
|
||||
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.emoflon.gips.core.ilp.ILPSolverOutput;
|
||||
import org.emoflon.gips.gipsl.examples.headlessrunner.api.gips.HeadlessrunnerGipsAPI;
|
||||
|
||||
public class HeadlessRunner {
|
||||
|
||||
/**
|
||||
* Runs the headless example. First argument must be the file path for the input model to load.
|
||||
*
|
||||
* @param args Array of arguments.
|
||||
*/
|
||||
public static void main(final String[] args) {
|
||||
if (args == null || args.length == 0) {
|
||||
throw new IllegalArgumentException("Arguments were null or empty.");
|
||||
}
|
||||
|
||||
final String arg = args[0];
|
||||
if (arg == null || arg.isBlank()) {
|
||||
throw new IllegalArgumentException("First argument was null or empty.");
|
||||
}
|
||||
|
||||
final HeadlessrunnerGipsAPI api = new HeadlessrunnerGipsAPI();
|
||||
api.init(URI.createFileURI(arg));
|
||||
|
||||
api.buildILPProblem(true);
|
||||
final ILPSolverOutput output = api.solveILPProblem();
|
||||
System.out.println("Solver status: " + output.status());
|
||||
System.out.println("Objective value: " + output.objectiveValue());
|
||||
|
||||
api.getZeroNode().applyNonZeroMappings();
|
||||
|
||||
System.out.println("GIPSL run finished.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<org.emoflon.gips.gipsl.examples.headlessrunnermodel:Root
|
||||
xmi:version="2.0"
|
||||
xmlns:xmi="http://www.omg.org/XMI"
|
||||
xmlns:org.emoflon.gips.gipsl.examples.headlessrunnermodel="platform:/resource/org.emoflon.gips.gipsl.examples.headlessrunnermodel/model/Headlessrunnermodel.ecore">
|
||||
<nodes name="a"
|
||||
cost="10"/>
|
||||
</org.emoflon.gips.gipsl.examples.headlessrunnermodel:Root>
|
|
@ -7,7 +7,7 @@
|
|||
</eAnnotations>
|
||||
<eClassifiers xsi:type="ecore:EClass" name="Root">
|
||||
<eStructuralFeatures xsi:type="ecore:EReference" name="nodes" upperBound="-1"
|
||||
eType="#//Node"/>
|
||||
eType="#//Node" containment="true"/>
|
||||
</eClassifiers>
|
||||
<eClassifiers xsi:type="ecore:EClass" name="Node">
|
||||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
|
||||
|
|
Loading…
Reference in a new issue