Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Adds tests for boolean exprs. like [a] == [b] #21

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions gipsl.all.build.boolexpr/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="output" path="bin"/>
</classpath>
25 changes: 25 additions & 0 deletions gipsl.all.build.boolexpr/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>gipsl.all.build.boolexpr</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.emoflon.gips.gipsl.ui.gipsNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
10 changes: 10 additions & 0 deletions gipsl.all.build.boolexpr/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17
17 changes: 17 additions & 0 deletions gipsl.all.build.boolexpr/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Manifest-Version: 1.0
Automatic-Module-Name: gipsl.all.build.boolexpr
Bundle-ManifestVersion: 2
Bundle-Name: gipsl.all.build.boolexpr
Bundle-Vendor: My Company
Bundle-Version: 1.0.0.qualifier
Export-Package: gipsl.all.build.boolexpr.connector
Import-Package: test.suite.gips.utils
Require-Bundle: gipsl.all.build.model;bundle-version="0.0.1",
org.emoflon.ibex.common,
org.emoflon.ibex.gt,
org.emoflon.gips.core,
org.emoflon.ibex.gt.democles,
org.emoflon.ibex.gt.hipe
Bundle-SymbolicName: gipsl.all.build.boolexpr; singleton:=true
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-16
5 changes: 5 additions & 0 deletions gipsl.all.build.boolexpr/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source.. = src/,\
src-gen/
bin.includes = META-INF/,\
.,\
plugin.xml
35 changes: 35 additions & 0 deletions gipsl.all.build.boolexpr/src/gipsl/all/build/boolexpr/Model.gipsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package "gipsl.all.build.boolexpr"
import "platform:/resource/gipsl.all.build.model/model/Model.ecore"

config {
solver := GLPK [home:="fu", license:="bar"];
launchConfig := true [main := "TODO"];
timeLimit := true [value := 10.0];
randomSeed := true [value := 0];
presolve := true;
debugOutput := true;
}

pattern snode {
snode: SubstrateResourceNode
}

//
// GIPSL starts here!
//

mapping sn with snode;

constraint -> class::SubstrateResourceNode {
[self.resourceAmountAvailable == 1]
==
[mappings.sn->filter(m | m.nodes().snode == self)->count() >= 1]
}

objective o -> mapping::sn {
1
}

global objective : max {
o
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package gipsl.all.build.boolexpr.connector;

import org.emoflon.gips.core.ilp.ILPSolverOutput;

import gipsl.all.build.boolexpr.api.gips.BoolexprGipsAPI;
import test.suite.gips.utils.AConnector;
import test.suite.gips.utils.GipsTestUtils;

public class BoolExprConnector extends AConnector {

public BoolExprConnector(final String modelPath) {
api = new BoolexprGipsAPI();
api.init(GipsTestUtils.pathToAbsUri(modelPath));
}

@Override
public ILPSolverOutput run(final String outputPath) {
final ILPSolverOutput output = solve();
return output;
}

}
1 change: 1 addition & 0 deletions test.suite.gips/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Import-Package: gips.ilp.lpoutput.connector,
gips.sort.patternreg.connector,
gipsl.all.build.and.connector,
gipsl.all.build.booleanbrackets.connector,
gipsl.all.build.boolexpr.connector,
gipsl.all.build.count.connector,
gipsl.all.build.filter.connector,
gipsl.all.build.implication.connector,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package test.suite.gipsl.all.build;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.emoflon.gips.core.ilp.ILPSolverOutput;
import org.emoflon.gips.core.ilp.ILPSolverStatus;
import org.junit.jupiter.api.Test;

import gipsl.all.build.booleanbrackets.connector.BooleanBracketsConnector;

public class GipslAllBuildBoolExprTest extends AGipslAllBuildTest {

// Setup method

public void callableSetUp() {
gen.persistModel(MODEL_PATH);
con = new BooleanBracketsConnector(MODEL_PATH);
}

// Actual tests

@Test
public void testStaticVal1() {
// Static value 1 -> Mapping must be chosen
gen.genSubstrateNode("s1", 1);
callableSetUp();

final ILPSolverOutput ret = con.run(OUTPUT_PATH);
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(1, Math.abs(ret.solutionCount()));
}

@Test
public void testStaticVal0() {
// Static value = 0 -> Mapping must not be chosen
gen.genSubstrateNode("s1", 0);
callableSetUp();

final ILPSolverOutput ret = con.run(OUTPUT_PATH);
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(0, Math.abs(ret.solutionCount()));
}

@Test
public void testStaticNoNode() {
// No SubstrateResourceNode -> No constraint generated
callableSetUp();

final ILPSolverOutput ret = con.run(OUTPUT_PATH);
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
assertEquals(1, Math.abs(ret.solutionCount()));
}

}