From 2492b5f012b045917e7261bd5c78b432ec4d3dc6 Mon Sep 17 00:00:00 2001 From: Aren Babikian Date: Fri, 15 Jan 2021 04:40:17 -0500 Subject: Begin vql implementation + fix enums bug --- Domains/crossingScenario/.classpath | 1 + Domains/crossingScenario/META-INF/MANIFEST.MF | 6 +- .../ecore-gen/crossingScenario/Distance.java | 58 +- .../ecore-gen/crossingScenario/Size.java | 58 +- .../impl/CrossingScenarioPackageImpl.java | 12 +- .../ecore-gen/crossingScenario/impl/LaneImpl.java | 2 +- .../impl/SeparationDistanceImpl.java | 2 +- .../inputs/Debug/state000000019.xmi | 1353 ++++++++++++++++++++ .../inputs/crossingScenarioGen.vsconfig | 13 +- .../crossingScenario/model/crossingScenario.aird | 128 +- .../crossingScenario/model/crossingScenario.ecore | 12 +- .../model/crossingScenario.genmodel | 12 +- .../queries/crossingScenarioQueries.vql | 83 +- Domains/crossingScenario/queries/logProb2._vql | 55 + .../crossingScenario/run/CrossingScenarioMain.java | 28 +- .../src/crossingScenario/run/QueryDebug.java | 210 +-- .../patterns/PConstraintTransformer.xtend | 2 +- 17 files changed, 1735 insertions(+), 300 deletions(-) create mode 100644 Domains/crossingScenario/inputs/Debug/state000000019.xmi create mode 100644 Domains/crossingScenario/queries/logProb2._vql diff --git a/Domains/crossingScenario/.classpath b/Domains/crossingScenario/.classpath index 1643899c..0712d3e2 100644 --- a/Domains/crossingScenario/.classpath +++ b/Domains/crossingScenario/.classpath @@ -4,5 +4,6 @@ + diff --git a/Domains/crossingScenario/META-INF/MANIFEST.MF b/Domains/crossingScenario/META-INF/MANIFEST.MF index b2b98c75..62cd6eef 100644 --- a/Domains/crossingScenario/META-INF/MANIFEST.MF +++ b/Domains/crossingScenario/META-INF/MANIFEST.MF @@ -6,10 +6,10 @@ Bundle-Version: 1.0.0.qualifier Bundle-ClassPath: . Bundle-Vendor: %providerName Bundle-Localization: plugin -Export-Package: queries, - crossingScenario, +Export-Package: crossingScenario, crossingScenario.impl, - crossingScenario.util + crossingScenario.util, + queries Require-Bundle: org.eclipse.viatra.query.runtime, org.eclipse.viatra.query.runtime.rete, org.eclipse.viatra.query.runtime.localsearch, diff --git a/Domains/crossingScenario/ecore-gen/crossingScenario/Distance.java b/Domains/crossingScenario/ecore-gen/crossingScenario/Distance.java index 68a0deb6..80731e1f 100644 --- a/Domains/crossingScenario/ecore-gen/crossingScenario/Distance.java +++ b/Domains/crossingScenario/ecore-gen/crossingScenario/Distance.java @@ -19,67 +19,63 @@ import org.eclipse.emf.common.util.Enumerator; */ public enum Distance implements Enumerator { /** - * The 'Near' literal object. + * The 'DNear' literal object. * * - * @see #NEAR_VALUE + * @see #DNEAR_VALUE * @generated * @ordered */ - NEAR(0, "Near", "Near"), - - /** - * The 'Medium' literal object. + DNEAR(0, "D_Near", "D_Near"), /** + * The 'DMed' literal object. * * - * @see #MEDIUM_VALUE + * @see #DMED_VALUE * @generated * @ordered */ - MEDIUM(1, "Medium", "Medium"), - - /** - * The 'Far' literal object. + DMED(1, "D_Med", "D_Med"), /** + * The 'DFar' literal object. * * - * @see #FAR_VALUE + * @see #DFAR_VALUE * @generated * @ordered */ - FAR(2, "Far", "Far"); + DFAR(2, "D_Far", "D_Far"); /** - * The 'Near' literal value. + * The 'DNear' literal value. * * - * @see #NEAR - * @model name="Near" + * @see #DNEAR + * @model name="D_Near" * @generated * @ordered */ - public static final int NEAR_VALUE = 0; + public static final int DNEAR_VALUE = 0; /** - * The 'Medium' literal value. + * The 'DMed' literal value. * * - * @see #MEDIUM - * @model name="Medium" + * @see #DMED + * @model name="D_Med" * @generated * @ordered */ - public static final int MEDIUM_VALUE = 1; + public static final int DMED_VALUE = 1; /** - * The 'Far' literal value. + * The 'DFar' literal value. * * - * @see #FAR - * @model name="Far" + * @see #DFAR + * @model name="D_Far" * @generated * @ordered */ - public static final int FAR_VALUE = 2; + public static final int DFAR_VALUE = 2; /** * An array of all the 'Distance' enumerators. @@ -89,9 +85,9 @@ public enum Distance implements Enumerator { */ private static final Distance[] VALUES_ARRAY = new Distance[] { - NEAR, - MEDIUM, - FAR, + DNEAR, + DMED, + DFAR, }; /** @@ -148,9 +144,9 @@ public enum Distance implements Enumerator { */ public static Distance get(int value) { switch (value) { - case NEAR_VALUE: return NEAR; - case MEDIUM_VALUE: return MEDIUM; - case FAR_VALUE: return FAR; + case DNEAR_VALUE: return DNEAR; + case DMED_VALUE: return DMED; + case DFAR_VALUE: return DFAR; } return null; } diff --git a/Domains/crossingScenario/ecore-gen/crossingScenario/Size.java b/Domains/crossingScenario/ecore-gen/crossingScenario/Size.java index f4915b2e..1465201c 100644 --- a/Domains/crossingScenario/ecore-gen/crossingScenario/Size.java +++ b/Domains/crossingScenario/ecore-gen/crossingScenario/Size.java @@ -19,67 +19,63 @@ import org.eclipse.emf.common.util.Enumerator; */ public enum Size implements Enumerator { /** - * The 'Small' literal object. + * The 'SSmall' literal object. * * - * @see #SMALL_VALUE + * @see #SSMALL_VALUE * @generated * @ordered */ - SMALL(0, "Small", "Small"), - - /** - * The 'Medium' literal object. + SSMALL(0, "S_Small", "S_Small"), /** + * The 'SMed' literal object. * * - * @see #MEDIUM_VALUE + * @see #SMED_VALUE * @generated * @ordered */ - MEDIUM(1, "Medium", "Medium"), - - /** - * The 'Large' literal object. + SMED(1, "S_Med", "S_Med"), /** + * The 'SLarge' literal object. * * - * @see #LARGE_VALUE + * @see #SLARGE_VALUE * @generated * @ordered */ - LARGE(2, "Large", "Large"); + SLARGE(2, "S_Large", "S_Large"); /** - * The 'Small' literal value. + * The 'SSmall' literal value. * * - * @see #SMALL - * @model name="Small" + * @see #SSMALL + * @model name="S_Small" * @generated * @ordered */ - public static final int SMALL_VALUE = 0; + public static final int SSMALL_VALUE = 0; /** - * The 'Medium' literal value. + * The 'SMed' literal value. * * - * @see #MEDIUM - * @model name="Medium" + * @see #SMED + * @model name="S_Med" * @generated * @ordered */ - public static final int MEDIUM_VALUE = 1; + public static final int SMED_VALUE = 1; /** - * The 'Large' literal value. + * The 'SLarge' literal value. * * - * @see #LARGE - * @model name="Large" + * @see #SLARGE + * @model name="S_Large" * @generated * @ordered */ - public static final int LARGE_VALUE = 2; + public static final int SLARGE_VALUE = 2; /** * An array of all the 'Size' enumerators. @@ -89,9 +85,9 @@ public enum Size implements Enumerator { */ private static final Size[] VALUES_ARRAY = new Size[] { - SMALL, - MEDIUM, - LARGE, + SSMALL, + SMED, + SLARGE, }; /** @@ -148,9 +144,9 @@ public enum Size implements Enumerator { */ public static Size get(int value) { switch (value) { - case SMALL_VALUE: return SMALL; - case MEDIUM_VALUE: return MEDIUM; - case LARGE_VALUE: return LARGE; + case SSMALL_VALUE: return SSMALL; + case SMED_VALUE: return SMED; + case SLARGE_VALUE: return SLARGE; } return null; } diff --git a/Domains/crossingScenario/ecore-gen/crossingScenario/impl/CrossingScenarioPackageImpl.java b/Domains/crossingScenario/ecore-gen/crossingScenario/impl/CrossingScenarioPackageImpl.java index 6819135b..3d2ccc0d 100644 --- a/Domains/crossingScenario/ecore-gen/crossingScenario/impl/CrossingScenarioPackageImpl.java +++ b/Domains/crossingScenario/ecore-gen/crossingScenario/impl/CrossingScenarioPackageImpl.java @@ -754,14 +754,14 @@ public class CrossingScenarioPackageImpl extends EPackageImpl implements Crossin addEEnumLiteral(orientationEEnum, Orientation.HORIZONTAL); initEEnum(sizeEEnum, Size.class, "Size"); - addEEnumLiteral(sizeEEnum, Size.SMALL); - addEEnumLiteral(sizeEEnum, Size.MEDIUM); - addEEnumLiteral(sizeEEnum, Size.LARGE); + addEEnumLiteral(sizeEEnum, Size.SSMALL); + addEEnumLiteral(sizeEEnum, Size.SMED); + addEEnumLiteral(sizeEEnum, Size.SLARGE); initEEnum(distanceEEnum, Distance.class, "Distance"); - addEEnumLiteral(distanceEEnum, Distance.NEAR); - addEEnumLiteral(distanceEEnum, Distance.MEDIUM); - addEEnumLiteral(distanceEEnum, Distance.FAR); + addEEnumLiteral(distanceEEnum, Distance.DNEAR); + addEEnumLiteral(distanceEEnum, Distance.DMED); + addEEnumLiteral(distanceEEnum, Distance.DFAR); // Create resource createResource(eNS_URI); diff --git a/Domains/crossingScenario/ecore-gen/crossingScenario/impl/LaneImpl.java b/Domains/crossingScenario/ecore-gen/crossingScenario/impl/LaneImpl.java index a97c02fc..110f26c8 100644 --- a/Domains/crossingScenario/ecore-gen/crossingScenario/impl/LaneImpl.java +++ b/Domains/crossingScenario/ecore-gen/crossingScenario/impl/LaneImpl.java @@ -71,7 +71,7 @@ public class LaneImpl extends MinimalEObjectImpl.Container implements Lane { * @generated * @ordered */ - protected static final Size WIDTH_EDEFAULT = Size.SMALL; + protected static final Size WIDTH_EDEFAULT = Size.SSMALL; /** * The cached value of the '{@link #getWidth() Width}' attribute. diff --git a/Domains/crossingScenario/ecore-gen/crossingScenario/impl/SeparationDistanceImpl.java b/Domains/crossingScenario/ecore-gen/crossingScenario/impl/SeparationDistanceImpl.java index bad91f1c..298a2121 100644 --- a/Domains/crossingScenario/ecore-gen/crossingScenario/impl/SeparationDistanceImpl.java +++ b/Domains/crossingScenario/ecore-gen/crossingScenario/impl/SeparationDistanceImpl.java @@ -34,7 +34,7 @@ public class SeparationDistanceImpl extends SpatialRelationImpl implements Separ * @generated * @ordered */ - protected static final Distance DISTANCE_EDEFAULT = Distance.NEAR; + protected static final Distance DISTANCE_EDEFAULT = Distance.DNEAR; /** * The cached value of the '{@link #getDistance() Distance}' attribute. diff --git a/Domains/crossingScenario/inputs/Debug/state000000019.xmi b/Domains/crossingScenario/inputs/Debug/state000000019.xmi new file mode 100644 index 00000000..e94d2b0d --- /dev/null +++ b/Domains/crossingScenario/inputs/Debug/state000000019.xmi @@ -0,0 +1,1353 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Domains/crossingScenario/inputs/crossingScenarioGen.vsconfig b/Domains/crossingScenario/inputs/crossingScenarioGen.vsconfig index 8ac31bb2..4f8267b7 100644 --- a/Domains/crossingScenario/inputs/crossingScenarioGen.vsconfig +++ b/Domains/crossingScenario/inputs/crossingScenarioGen.vsconfig @@ -7,20 +7,19 @@ generate { partial-model = { "inputs/CrossingScenarioInit.xmi"} solver = ViatraSolver scope = { - #node = 10..30, + #node = 20..30, #int = {}, - # = 1 - } + # = 1..10, + # = 1..10, + # = 1..10} config = { runtime = 10000, log-level = normal, "numeric-solver" = "dreal", - "scopePropagator" = "typeHierarchy" - } - - runs = 1 + "scopePropagator" = "typeHierarchy"} + runs = 1 debug = "outputs/debug" log = "outputs/debug/log.txt" output = "outputs/models" diff --git a/Domains/crossingScenario/model/crossingScenario.aird b/Domains/crossingScenario/model/crossingScenario.aird index d23d4277..53943eaa 100644 --- a/Domains/crossingScenario/model/crossingScenario.aird +++ b/Domains/crossingScenario/model/crossingScenario.aird @@ -5,7 +5,7 @@ crossingScenario.genmodel - + @@ -140,7 +140,7 @@ - + @@ -173,7 +173,7 @@ - + @@ -182,7 +182,7 @@ - + @@ -191,7 +191,7 @@ - + @@ -200,7 +200,7 @@ - + @@ -209,7 +209,7 @@ - + @@ -222,7 +222,7 @@ - + @@ -235,7 +235,7 @@ - + @@ -244,7 +244,7 @@ - + @@ -265,7 +265,7 @@ - + @@ -274,7 +274,7 @@ - + @@ -283,7 +283,7 @@ - + @@ -298,7 +298,7 @@ - + @@ -328,7 +328,7 @@ - + @@ -358,7 +358,7 @@ - + @@ -373,7 +373,7 @@ - + @@ -388,22 +388,22 @@ - + - + - + - + - + @@ -441,33 +441,33 @@ - + - + - + - + - + - + - + - + @@ -548,7 +548,7 @@ - + @@ -563,8 +563,8 @@ - - + + @@ -617,17 +617,17 @@ - + - + - + - + @@ -651,7 +651,7 @@ - + @@ -659,7 +659,7 @@ - + @@ -675,7 +675,7 @@ - + @@ -683,9 +683,9 @@ - - - + + + @@ -742,7 +742,7 @@ - + @@ -804,25 +804,25 @@ - - - + + + - - - + + + - - - + + + @@ -946,7 +946,7 @@ - + @@ -995,25 +995,25 @@ - - - + + + - - - + + + - - - + + + @@ -1101,6 +1101,7 @@ labelSize + bold labelSize @@ -1114,6 +1115,7 @@ labelSize + bold labelSize diff --git a/Domains/crossingScenario/model/crossingScenario.ecore b/Domains/crossingScenario/model/crossingScenario.ecore index a0797672..d9d97470 100644 --- a/Domains/crossingScenario/model/crossingScenario.ecore +++ b/Domains/crossingScenario/model/crossingScenario.ecore @@ -28,9 +28,9 @@ - - - + + + @@ -69,9 +69,9 @@ - - - + + + diff --git a/Domains/crossingScenario/model/crossingScenario.genmodel b/Domains/crossingScenario/model/crossingScenario.genmodel index 53117561..b788485b 100644 --- a/Domains/crossingScenario/model/crossingScenario.genmodel +++ b/Domains/crossingScenario/model/crossingScenario.genmodel @@ -11,14 +11,14 @@ - - - + + + - - - + + + diff --git a/Domains/crossingScenario/queries/crossingScenarioQueries.vql b/Domains/crossingScenario/queries/crossingScenarioQueries.vql index fbd68472..7089d0da 100644 --- a/Domains/crossingScenario/queries/crossingScenarioQueries.vql +++ b/Domains/crossingScenario/queries/crossingScenarioQueries.vql @@ -3,51 +3,60 @@ package queries import "http://www.example.com/crossingScenario" import "http://www.eclipse.org/emf/2002/Ecore" -//Minimal Failing Example +////Minimal Failing Example @Constraint(severity = "error", key = {l}, message = "this defines the placedOn relation") pattern patterThatOnlyWorksWithInt(l : Lane) { Lane.referenceCoord(l, w); - check(w <= 2.0); + check(w <= 0-10.0); } -//////////////// -////Lane -//////////////// -// -///////////width, numWidth -//@Constraint(severity="error", key={l}, message="x") -//pattern define_numWidth_small(l : Lane) { -// Lane.width(l, Size::Small); -// Lane.numWidth(l, nw); -// check(nw <= 5); -//} or { -// Lane.width(l, Size::Small); -// Lane.numWidth(l, nw); -// check(nw >= 10); -//} -// -//@Constraint(severity="error", key={l}, message="x") -//pattern define_numWidth_medium(l : Lane) { -// Lane.width(l, Size::Medium); -// Lane.numWidth(l, nw); -// check(nw <= 10); -//} or { -// Lane.width(l, Size::Medium); -// Lane.numWidth(l, nw); -// check(nw >= 15); -//} -// +////////////// +//Lane +////////////// + +/////////width, numWidth //@Constraint(severity="error", key={l}, message="x") -//pattern define_numWidth_large(l : Lane) { -// Lane.width(l, Size::Large); -// Lane.numWidth(l, nw); -// check(nw <= 15); -//} or { -// Lane.width(l, Size::Large); +//pattern define_numWidth_small1(l : Lane) { +// Lane.width(l, Size::S_Small); // Lane.numWidth(l, nw); -// check(nw >= 20); +// check(nw >= 5.0); //} -// + +@Constraint(severity="error", key={l}, message="x") +pattern define_numWidth_small(l : Lane) { + Lane.width(l, Size::S_Small); + Lane.numWidth(l, nw); + check(nw <= 5.0); +} or { + Lane.width(l, Size::S_Small); + Lane.numWidth(l, nw); + check(nw >= 10.0); +} + +@Constraint(severity="error", key={l}, message="x") +pattern define_numWidth_medium(l : Lane) { + Lane.width(l, ::S_Med); + Lane.numWidth(l, nw); + check(nw <= 10.0); +} +or { + Lane.width(l, Size::S_Med); + Lane.numWidth(l, nw); + check(nw >= 15.0); +} + +@Constraint(severity="error", key={l}, message="x") +pattern define_numWidth_large(l : Lane) { + Lane.width(l, Size::S_Large); + Lane.numWidth(l, nw); + check(nw <= 15.0); +} +or { + Lane.width(l, Size::S_Large); + Lane.numWidth(l, nw); + check(nw >= 20.0); +} + ///////////referenceCoord //@Constraint(severity="error", key={l}, message="x") //pattern define_referenceCoord_horizontalAtOrigin(l:Lane) { diff --git a/Domains/crossingScenario/queries/logProb2._vql b/Domains/crossingScenario/queries/logProb2._vql new file mode 100644 index 00000000..284af8cb --- /dev/null +++ b/Domains/crossingScenario/queries/logProb2._vql @@ -0,0 +1,55 @@ +package queries + +import epackage "http://www.bme.hu/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage" +import epackage "http://www.bme.hu/mit/inf/dslreasoner/logic/model/problem" +import epackage "http://www.bme.hu/mit/inf/dslreasoner/logic/model/language" + +pattern UPMUSTPropagateConstraint1_pattern_queries_define_numWidth_small1( + problem:LogicProblem, interpretation:PartialInterpretation, + var_l, + up_1) +{ +// Original Constraints +// var_l exported +find mustInRelationnumWidth_attribute_Lane(problem,interpretation,var_l,var_nw); +var_virtual1 == const_S_Small_Size; +DefinedElement.name(const_S_Small_Size,"S_Small literal Size"); //LogicProblem.elements(problem,const_S_Small_Size); +find mustInRelationwidth_attribute_Lane(problem,interpretation,var_l,var_virtual1); +// Propagation for constraint +PrimitiveElement.valueSet(var_nw,setted_var_nw); RealElement.value(var_nw,value_var_nw); +// Matching variables +var_nw==up_1; +} + +/** + * Matcher for detecting tuples t where []referenceCoord attribute Lane(source,target) + */pattern mustInRelationwidth_attribute_Lane( + problem:LogicProblem, interpretation:PartialInterpretation, + source: DefinedElement, target:DefinedElement) +{ + find interpretation(problem,interpretation); + PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation); + PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"width attribute Lane"); + PartialRelationInterpretation.relationlinks(relationIterpretation,link); + BinaryElementRelationLink.param1(link,source); + BinaryElementRelationLink.param2(link,target); +} +pattern mustInRelationnumWidth_attribute_Lane( + problem:LogicProblem, interpretation:PartialInterpretation, + source: DefinedElement, target:DefinedElement) +{ + find interpretation(problem,interpretation); + PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation); + PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"numWidth attribute Lane"); + PartialRelationInterpretation.relationlinks(relationIterpretation,link); + BinaryElementRelationLink.param1(link,source); + BinaryElementRelationLink.param2(link,target); +} + +////////// +// 0. Util +////////// +pattern interpretation(problem:LogicProblem, interpretation:PartialInterpretation) { + PartialInterpretation.problem(interpretation,problem); +} + diff --git a/Domains/crossingScenario/src/crossingScenario/run/CrossingScenarioMain.java b/Domains/crossingScenario/src/crossingScenario/run/CrossingScenarioMain.java index bbef5665..4442fc7d 100644 --- a/Domains/crossingScenario/src/crossingScenario/run/CrossingScenarioMain.java +++ b/Domains/crossingScenario/src/crossingScenario/run/CrossingScenarioMain.java @@ -1,16 +1,38 @@ package crossingScenario.run; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor; public class CrossingScenarioMain { private CrossingScenarioMain() { throw new IllegalStateException("This is a static utility class and should not be instantiated directly."); } - - public static void main(String[] args) { + + public static void main(String[] args) throws IOException { String errorMessages = StandaloneScriptExecutor.executeScript("inputs/crossingScenarioGen.vsconfig"); - if(errorMessages!=null) { + if (errorMessages != null) { System.out.println(errorMessages); } + Path path = Paths.get("outputs/statistics.csv"); + List content = Files.readAllLines(path); + String[] times = content.get(1).split(","); + System.out.println("STATISTICS"); + int t1 = Integer.parseInt(times[3]); + int t2 = Integer.parseInt(times[4]); + int t3 = Integer.parseInt(times[5]); + int t4 = Integer.parseInt(times[6]); + int tot = t1+t2+t3+t4; + System.out.println("domain2logic -> " + t1); + System.out.println("logic2solver -> " + t2); + System.out.println("solver -> " + t3); + System.out.println("postprocessing -> " + t4); + + System.out.println("TOTAL -> " + tot); + } } diff --git a/Domains/crossingScenario/src/crossingScenario/run/QueryDebug.java b/Domains/crossingScenario/src/crossingScenario/run/QueryDebug.java index 7f19d2a8..2d866e85 100644 --- a/Domains/crossingScenario/src/crossingScenario/run/QueryDebug.java +++ b/Domains/crossingScenario/src/crossingScenario/run/QueryDebug.java @@ -1,111 +1,113 @@ package crossingScenario.run; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class QueryDebug { - /* - public static void main(String[] args) { - Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put("*", new XMIResourceFactoryImpl()); - EPackage.Registry.INSTANCE.put(SimpleScenarioPackage.eNS_URI, SimpleScenarioPackage.eINSTANCE); - ResourceSet rs = new ResourceSetImpl(); - rs.getResource(URI.createFileURI("inputs/sample.xmi"), true); - - ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(rs)); - // Access pattern matcher - - - - SimpleScenarioQueries.instance().prepare(engine); - RefSpec.Matcher matcher = RefSpec.Matcher.on(engine); - // Get and iterate over all matches - for (RefSpec.Match match : matcher.getAllMatches()) { - // Print all the matches to the standard output - System.out.println(match.getL()); - } - } - */ + +// public static void main(String[] args) { +// Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put("*", new XMIResourceFactoryImpl()); +// EPackage.Registry.INSTANCE.put(CrossingScenarioPackage.eNS_URI, CrossingScenarioPackage.eINSTANCE); +// ResourceSet rs = new ResourceSetImpl(); +// rs.getResource(URI.createFileURI("outputs/models/1.xmi"), true); +// +// ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(rs)); +// // Access pattern matcher +// +// +// +// CrossingScenarioQueries.instance().prepare(engine); +// Define_numWidth_medium.Matcher matcher = Define_numWidth_medium.Matcher.on(engine); +// // Get and iterate over all matches +// System.out.println("MATCHES:"); +// for (Define_numWidth_medium.Match match : matcher.getAllMatches()) { +// // Print all the matches to the standard output +// System.out.println(match.getL()); +// } +// } + - /* - public static void main(String[] args) { - //Add xmi resource - Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put("*", new XMIResourceFactoryImpl()); - //Add required EPackages -// EPackage.Registry.INSTANCE.put(SimpleScenarioPackage.eNS_URI, SimpleScenarioPackage.eINSTANCE); - EPackage.Registry.INSTANCE.put(LogiclanguagePackage.eNS_URI, LogiclanguagePackage.eINSTANCE); - EPackage.Registry.INSTANCE.put(LogicproblemPackage.eNS_URI, LogicproblemPackage.eINSTANCE); - EPackage.Registry.INSTANCE.put(PartialinterpretationPackage.eNS_URI, PartialinterpretationPackage.eINSTANCE); - EPackage.Registry.INSTANCE.put(Ecore2logicannotationsPackage.eNS_URI, Ecore2logicannotationsPackage.eINSTANCE); - EPackage.Registry.INSTANCE.put(Partial2logicannotationsPackage.eNS_URI, Partial2logicannotationsPackage.eINSTANCE); - EPackage.Registry.INSTANCE.put(Viatra2LogicAnnotationsPackage.eNS_URI, Viatra2LogicAnnotationsPackage.eINSTANCE); - EPackage.Registry.INSTANCE.put(LogicresultPackage.eNS_URI, LogicresultPackage.eINSTANCE); - - //Get res - ResourceSet rs = new ResourceSetImpl(); - rs.getResource(URI.createFileURI("inputs/partial-int.xmi"), true); - - ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(rs)); - // Access pattern matcher - - - - LogProb.instance().prepare(engine); - // Get and iterate over all matches - System.out.println("UPMUST:"); - for (UPMUSTPropagateConstraint0_pattern_queries_refSpec.Match match : - UPMUSTPropagateConstraint0_pattern_queries_refSpec.Matcher.on(engine).getAllMatches()) { - // Print all the matches to the standard output - System.out.println(match.getVar_l()); - } - - System.out.println("mustIn:"); - for (MustInRelationreferenceCoord_attribute_Lane.Match match : - MustInRelationreferenceCoord_attribute_Lane.Matcher.on(engine).getAllMatches()) { - // Print all the matches to the standard output - DefinedElement de = match.getTarget(); - System.out.println(de); - System.out.println("--set?: " + ((PrimitiveElement) de).isValueSet()); - System.out.println("--val?: " + ((IntegerElement) de).getValue()); - - } - - System.out.println("interp:"); - for (Interpretation.Match match : - Interpretation.Matcher.on(engine).getAllMatches()) { - // Print all the matches to the standard output - System.out.println(match.getProblem()); - } - } - */ +// public static void main(String[] args) { +// //Add xmi resource +// Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put("*", new XMIResourceFactoryImpl()); +// //Add required EPackages +//// EPackage.Registry.INSTANCE.put(SimpleScenarioPackage.eNS_URI, SimpleScenarioPackage.eINSTANCE); +// EPackage.Registry.INSTANCE.put(LogiclanguagePackage.eNS_URI, LogiclanguagePackage.eINSTANCE); +// EPackage.Registry.INSTANCE.put(LogicproblemPackage.eNS_URI, LogicproblemPackage.eINSTANCE); +// EPackage.Registry.INSTANCE.put(PartialinterpretationPackage.eNS_URI, PartialinterpretationPackage.eINSTANCE); +// EPackage.Registry.INSTANCE.put(Ecore2logicannotationsPackage.eNS_URI, Ecore2logicannotationsPackage.eINSTANCE); +// EPackage.Registry.INSTANCE.put(Partial2logicannotationsPackage.eNS_URI, Partial2logicannotationsPackage.eINSTANCE); +// EPackage.Registry.INSTANCE.put(Viatra2LogicAnnotationsPackage.eNS_URI, Viatra2LogicAnnotationsPackage.eINSTANCE); +// EPackage.Registry.INSTANCE.put(LogicresultPackage.eNS_URI, LogicresultPackage.eINSTANCE); +// +// //Get res +// ResourceSet rs = new ResourceSetImpl(); +// rs.getResource(URI.createFileURI("inputs/Debug/state000000019.xmi"), true); +// +// ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(rs)); +// // Access pattern matcher +// +// +// +// LogProb.instance().prepare(engine); +// // Get and iterate over all matches +// System.out.println("UPMUST:"); +// for (UPMUSTPropagateConstraint1_pattern_queries_define_numWidth_small1.Match match : +// UPMUSTPropagateConstraint1_pattern_queries_define_numWidth_small1.Matcher.on(engine).getAllMatches()) { +// // Print all the matches to the standard output +// System.out.println(match.getVar_l()); +// } +// +// System.out.println("mustIn1:"); +// for (MustInRelationwidth_attribute_Lane.Match match : +// MustInRelationwidth_attribute_Lane.Matcher.on(engine).getAllMatches()) { +// // Print all the matches to the standard output +// DefinedElement de = match.getTarget(); +// System.out.println(de); +// System.out.println("--name?: " + de.getName()); +//// System.out.println("--val?: " + de.getName()); +// } +// +// System.out.println("mustIn2:"); +// for (MustInRelationnumWidth_attribute_Lane.Match match : +// MustInRelationnumWidth_attribute_Lane.Matcher.on(engine).getAllMatches()) { +// // Print all the matches to the standard output +// DefinedElement de = match.getTarget(); +// System.out.println(de); +// System.out.println("--set?: " + ((PrimitiveElement) de).isValueSet()); +// System.out.println("--val?: " + ((RealElement) de).getValue()); +// } +// +// System.out.println("interp:"); +// for (Interpretation.Match match : +// Interpretation.Matcher.on(engine).getAllMatches()) { +// // Print all the matches to the standard output +// System.out.println(match.getProblem()); +// } +// } - public static void main(String[] args) { - ArrayList out = new ArrayList(); - out.add("delta-sat with delta = 0.001"); - out.add("w1602659765 : [1.797693134862315708e+308, 1.797693134862315708e+308]"); - String s = "1.797693134862315708e+308"; - - System.out.println(parseDrealOutput(out)); - - } - private static Map parseDrealOutput(List output) { - Map res = new HashMap(); - String re = "(\\w+) : \\[([0-9\\+-.e]+), ([0-9\\+-.e]+)\\]"; -// String re = "(\\w+) : \\[(.*), (.*)\\]"; - Pattern p = Pattern.compile(re); - for (String varVal : output) { - Matcher m = p.matcher(varVal); - if (m.matches()) { - String name = m.group(1); - String lowerB = m.group(2); - String upperB = m.group(2); - res.put(name, lowerB); - } - } - return res; - } +// public static void main(String[] args) { +// ArrayList out = new ArrayList(); +// out.add("delta-sat with delta = 0.001"); +// out.add("w1602659765 : [1.797693134862315708e+308, 1.797693134862315708e+308]"); +// String s = "1.797693134862315708e+308"; +// +// System.out.println(parseDrealOutput(out)); +// +// } +// +// private static Map parseDrealOutput(List output) { +// Map res = new HashMap(); +// String re = "(\\w+) : \\[([0-9\\+-.e]+), ([0-9\\+-.e]+)\\]"; +//// String re = "(\\w+) : \\[(.*), (.*)\\]"; +// Pattern p = Pattern.compile(re); +// for (String varVal : output) { +// Matcher m = p.matcher(varVal); +// if (m.matches()) { +// String name = m.group(1); +// String lowerB = m.group(2); +// String upperB = m.group(2); +// res.put(name, lowerB); +// } +// } +// return res; +// } } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PConstraintTransformer.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PConstraintTransformer.xtend index dd5cade1..2b616e32 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PConstraintTransformer.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PConstraintTransformer.xtend @@ -159,7 +159,7 @@ class PConstraintTransformer { var String additionalDefinition; if(target instanceof EEnumLiteral) { targetString = '''const_«target.name»_«target.EEnum.name»''' - additionalDefinition = '''DefinedElement.name(«targetString»,"«target.name» «target.EEnum.name»"); //LogicProblem.elements(problem,«targetString»);''' + additionalDefinition = '''DefinedElement.name(«targetString»,"«target.name» literal «target.EEnum.name»"); //LogicProblem.elements(problem,«targetString»);''' } else if(target instanceof Integer) { targetString = '''const_«target»_Integer''' additionalDefinition = '''PrimitiveElement.valueSet(«targetString»,true); IntegerElement.value(«targetString»,«target»);''' -- cgit v1.2.3-54-g00ecf