mirror of
https://github.com/Echtzeitsysteme/gips-tests.git
synced 2024-06-02 18:31:59 +00:00
Adds a test to check correct behavior of the pattern mapping bug (fixed)
This commit is contained in:
parent
7401f33b3b
commit
658336fba6
|
@ -4,6 +4,8 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: gipsl.sortpatternmappingbug
|
||||
Bundle-Vendor: My Company
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Import-Package: test.suite.gips.utils
|
||||
Export-Package: gipsl.sortpatternmappingbug.connector
|
||||
Bundle-SymbolicName: gipsl.sortpatternmappingbug; singleton:=true
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-16
|
||||
|
|
|
@ -16,10 +16,12 @@ config {
|
|||
|
||||
rule ra {
|
||||
root: Root {
|
||||
-- -entries -> val
|
||||
-entries -> val
|
||||
}
|
||||
|
||||
val: Entry
|
||||
val: Entry {
|
||||
++ -next -> val
|
||||
}
|
||||
}
|
||||
|
||||
rule rb {
|
||||
|
@ -40,5 +42,17 @@ mapping ma with ra;
|
|||
mapping mb with rb;
|
||||
|
||||
constraint -> class::Entry {
|
||||
patterns.p->filter(m | m.nodes().val == self)->count() + mappings.ma->filter(m | m.nodes().val == self)->count() + mappings.mb->filter(m | m.nodes().val == self)->count() == 1
|
||||
patterns.p->filter(m | m.nodes().val == self)->count() + mappings.ma->filter(m | m.nodes().val == self)->count() + mappings.mb->filter(m | m.nodes().val == self)->count() == 3
|
||||
}
|
||||
|
||||
objective maObj -> mapping::ma {
|
||||
1
|
||||
}
|
||||
|
||||
objective mbObj -> mapping::mb {
|
||||
1
|
||||
}
|
||||
|
||||
global objective : min {
|
||||
maObj + mbObj
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package gipsl.sortpatternmappingbug.connector;
|
||||
|
||||
import org.emoflon.gips.core.ilp.ILPSolverOutput;
|
||||
|
||||
import gipsl.sortpatternmappingbug.api.gips.SortpatternmappingbugGipsAPI;
|
||||
import test.suite.gips.utils.AConnector;
|
||||
import test.suite.gips.utils.GipsTestUtils;
|
||||
import test.suite.gips.utils.GlobalTestConfig;
|
||||
|
||||
public class SortPatternMappingBugConnector extends AConnector {
|
||||
|
||||
public SortPatternMappingBugConnector(final String modelPath) {
|
||||
api = new SortpatternmappingbugGipsAPI();
|
||||
api.init(GipsTestUtils.pathToAbsUri(modelPath));
|
||||
GlobalTestConfig.overrideSolver(api);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILPSolverOutput run(final String outputPath) {
|
||||
final ILPSolverOutput output = solve();
|
||||
((SortpatternmappingbugGipsAPI) api).getMa().applyNonZeroMappings();
|
||||
((SortpatternmappingbugGipsAPI) api).getMb().applyNonZeroMappings();
|
||||
save(outputPath);
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
|
@ -56,6 +56,7 @@ Import-Package: gips.ilp.lpoutput.connector,
|
|||
gipsl.all.build.varssum.connector,
|
||||
gipsl.all.build.xor.connector,
|
||||
gipsl.imports.sub.connector,
|
||||
gipsl.sortpatternmappingbug.connector,
|
||||
org.junit.jupiter.api,
|
||||
test.suite.gips.utils
|
||||
Export-Package: test.suite.gips,
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package test.suite.gips.sort;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.emoflon.gips.core.ilp.ILPSolverOutput;
|
||||
import org.emoflon.gips.core.ilp.ILPSolverStatus;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import gips.sort.connector.SortConnector;
|
||||
import gipsl.sortpatternmappingbug.connector.SortPatternMappingBugConnector;
|
||||
import listmodel.Entry;
|
||||
import test.suite.gips.sort.utils.SortModelGenerator;
|
||||
|
||||
public class GipsSortPatternMappingBugTest extends AGipsSortTest {
|
||||
|
||||
@BeforeEach
|
||||
public void resetModel() {
|
||||
SortModelGenerator.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callableSetUp() {
|
||||
SortModelGenerator.persistModel(MODEL_PATH);
|
||||
con = new SortPatternMappingBugConnector(MODEL_PATH);
|
||||
}
|
||||
|
||||
// Actual tests
|
||||
|
||||
@Test
|
||||
public void test1Entry() {
|
||||
SortModelGenerator.genNEntries(1);
|
||||
callableSetUp();
|
||||
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
|
||||
SortModelGenerator.loadModel(OUTPUT_PATH);
|
||||
|
||||
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
|
||||
assertEquals(2 * 1, ret.objectiveValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2Entries() {
|
||||
SortModelGenerator.genNEntries(2);
|
||||
callableSetUp();
|
||||
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
|
||||
SortModelGenerator.loadModel(OUTPUT_PATH);
|
||||
|
||||
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
|
||||
assertEquals(2 * 2, ret.objectiveValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test10Entries() {
|
||||
SortModelGenerator.genNEntries(10);
|
||||
callableSetUp();
|
||||
final ILPSolverOutput ret = con.run(OUTPUT_PATH);
|
||||
SortModelGenerator.loadModel(OUTPUT_PATH);
|
||||
|
||||
assertEquals(ILPSolverStatus.OPTIMAL, ret.status());
|
||||
assertEquals(2 * 10, ret.objectiveValue());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue