From f06427cd7375551582461f91b3458339a8227f9b Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Mon, 2 Nov 2020 02:02:40 +0100 Subject: Optimizing generator with linear objective functions --- .../modes3/run/.CloseTrainsObjectiveHint.xtendbin | Bin 0 -> 8218 bytes .../modes3/run/.EndOfSidingObjectiveHint.xtendbin | Bin 0 -> 7190 bytes .../run/.MisalignedTurnoutObjectiveHint.xtendbin | Bin 0 -> 7395 bytes .../modes3/run/.Modes3ModelGenerator.xtendbin | Bin 15038 -> 18637 bytes .../modes3/run/.Modes3TypeScopeHint.xtendbin | Bin 7179 -> 6927 bytes .../run/.Modes3UnitPropagationGenerator.xtendbin | Bin 11735 -> 11284 bytes .../run/.TrainLocationsObjectiveHint.xtendbin | Bin 0 -> 6269 bytes .../xtend-gen/modes3/run/.gitignore | 10 + .../modes3/run/CloseTrainsObjectiveHint.java | 279 +++++++++++++++++++ .../modes3/run/EndOfSidingObjectiveHint.java | 193 +++++++++++++ .../modes3/run/MisalignedTurnoutObjectiveHint.java | 195 +++++++++++++ .../xtend-gen/modes3/run/Modes3ModelGenerator.java | 305 +++++++++++++++++---- .../modes3/run/TrainLocationsObjectiveHint.java | 117 ++++++++ 13 files changed, 1049 insertions(+), 50 deletions(-) create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.CloseTrainsObjectiveHint.xtendbin create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.EndOfSidingObjectiveHint.xtendbin create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.MisalignedTurnoutObjectiveHint.xtendbin create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.TrainLocationsObjectiveHint.xtendbin create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/CloseTrainsObjectiveHint.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/EndOfSidingObjectiveHint.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/MisalignedTurnoutObjectiveHint.java create mode 100644 Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/TrainLocationsObjectiveHint.java (limited to 'Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3') diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.CloseTrainsObjectiveHint.xtendbin b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.CloseTrainsObjectiveHint.xtendbin new file mode 100644 index 00000000..87975792 Binary files /dev/null and b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.CloseTrainsObjectiveHint.xtendbin differ diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.EndOfSidingObjectiveHint.xtendbin b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.EndOfSidingObjectiveHint.xtendbin new file mode 100644 index 00000000..f243e180 Binary files /dev/null and b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.EndOfSidingObjectiveHint.xtendbin differ diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.MisalignedTurnoutObjectiveHint.xtendbin b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.MisalignedTurnoutObjectiveHint.xtendbin new file mode 100644 index 00000000..cdef4dc7 Binary files /dev/null and b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.MisalignedTurnoutObjectiveHint.xtendbin differ diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3ModelGenerator.xtendbin b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3ModelGenerator.xtendbin index 77f1ea6e..759ac9e4 100644 Binary files a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3ModelGenerator.xtendbin and b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3ModelGenerator.xtendbin differ diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3TypeScopeHint.xtendbin b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3TypeScopeHint.xtendbin index 4fdbb71b..386baeda 100644 Binary files a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3TypeScopeHint.xtendbin and b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3TypeScopeHint.xtendbin differ diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3UnitPropagationGenerator.xtendbin b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3UnitPropagationGenerator.xtendbin index e5e1b63e..79059b7f 100644 Binary files a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3UnitPropagationGenerator.xtendbin and b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3UnitPropagationGenerator.xtendbin differ diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.TrainLocationsObjectiveHint.xtendbin b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.TrainLocationsObjectiveHint.xtendbin new file mode 100644 index 00000000..3c3a380e Binary files /dev/null and b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.TrainLocationsObjectiveHint.xtendbin differ diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.gitignore b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.gitignore index fb94df96..1a7df1d9 100644 --- a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.gitignore +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.gitignore @@ -1,3 +1,13 @@ /.Modes3ModelGenerator.java._trace /.Modes3UnitPropagationGenerator.java._trace /.Modes3TypeScopeHint.java._trace +/.Modes3TypeScopeHint.xtendbin +/.Modes3UnitPropagationGenerator.xtendbin +/Modes3TypeScopeHint.java +/.Modes3ModelGenerator.xtendbin +/Modes3ModelGenerator.java +/Modes3UnitPropagationGenerator.java +/.CloseTrainsObjectiveHint.java._trace +/.TrainLocationsObjectiveHint.java._trace +/.MisalignedTurnoutObjectiveHint.java._trace +/.EndOfSidingObjectiveHint.java._trace diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/CloseTrainsObjectiveHint.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/CloseTrainsObjectiveHint.java new file mode 100644 index 00000000..babfa7e1 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/CloseTrainsObjectiveHint.java @@ -0,0 +1,279 @@ +package modes3.run; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableList; +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Dimension; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilder; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import modes3.Modes3Package; +import modes3.queries.CloseTrains_step_2; +import modes3.queries.CloseTrains_step_3; +import modes3.queries.CloseTrains_step_4; +import modes3.queries.CloseTrains_step_5; +import modes3.queries.CloseTrains_step_6; +import modes3.queries.CloseTrains_step_7; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.xtext.xbase.lib.Extension; +import org.eclipse.xtext.xbase.lib.Functions.Function1; +import org.eclipse.xtext.xbase.lib.IterableExtensions; + +@SuppressWarnings("all") +public class CloseTrainsObjectiveHint extends CostObjectiveHint { + private final Type segmentType; + + private final Type trainType; + + public CloseTrainsObjectiveHint(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { + @Extension + final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; + this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); + this.trainType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTrain()); + } + + @Override + public boolean isExact() { + return true; + } + + @Override + public PolyhedronExtensionOperator createPolyhedronExtensionOperator(final Map costElementMatchers) { + PolyhedronExtensionOperator _xblockexpression = null; + { + final CostElementMatchers step2 = costElementMatchers.get(CloseTrains_step_2.instance().getFullyQualifiedName()); + final CostElementMatchers step3 = costElementMatchers.get(CloseTrains_step_3.instance().getFullyQualifiedName()); + final CostElementMatchers step4 = costElementMatchers.get(CloseTrains_step_4.instance().getFullyQualifiedName()); + final CostElementMatchers step5 = costElementMatchers.get(CloseTrains_step_5.instance().getFullyQualifiedName()); + final CostElementMatchers step6 = costElementMatchers.get(CloseTrains_step_6.instance().getFullyQualifiedName()); + final CostElementMatchers step7 = costElementMatchers.get(CloseTrains_step_7.instance().getFullyQualifiedName()); + final PolyhedronExtensionOperator _function = (ExtendedLinearExpressionBuilderFactory it) -> { + final ExtendedLinearExpressionBuilder objectiveBuilder = it.createBuilder(); + ImmutableList _matches = step2.getMatches(); + for (final CostElementMatch m : _matches) { + { + final Dimension dimension = it.getDimension(m.getMatch()); + objectiveBuilder.add(step2.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m.isMulti(); + if (_isMulti) { + it.createBuilder().add(1, dimension).add((-1), this.trainType).build().assertEqualsTo(0); + } else { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + } + } + final ImmutableList step3Matches = step3.getMatches(); + for (final CostElementMatch m_1 : step3Matches) { + { + final Dimension dimension = it.getDimension(m_1.getMatch()); + objectiveBuilder.add(step3.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m_1.isMulti(); + boolean _not = (!_isMulti); + if (_not) { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m_1.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + } + } + final Function1 _function_1 = (CostElementMatch it_1) -> { + return step2.projectMayMatch(it_1.getMatch(), 2); + }; + Set>> _entrySet = IterableExtensions.groupBy(step3Matches, _function_1).entrySet(); + for (final Map.Entry> pair : _entrySet) { + { + final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); + List _value = pair.getValue(); + for (final CostElementMatch m_2 : _value) { + multiplicityBuilder.add(1, m_2.getMatch()); + } + multiplicityBuilder.add((-1), pair.getKey()); + multiplicityBuilder.build().assertEqualsTo(0); + } + } + CloseTrainsObjectiveHint.boundLimit(it, step3Matches, 2, this.trainType, 1); + CloseTrainsObjectiveHint.boundLimit(it, step3Matches, 3, this.segmentType, 1); + final ImmutableList step4Matches = step4.getMatches(); + for (final CostElementMatch m_2 : step4Matches) { + { + final Dimension dimension = it.getDimension(m_2.getMatch()); + objectiveBuilder.add(step4.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m_2.isMulti(); + boolean _not = (!_isMulti); + if (_not) { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m_2.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + } + } + final Function1 _function_2 = (CostElementMatch it_1) -> { + return step3.projectMayMatch(it_1.getMatch(), 2, 3); + }; + Set>> _entrySet_1 = IterableExtensions.groupBy(step4Matches, _function_2).entrySet(); + for (final Map.Entry> pair_1 : _entrySet_1) { + { + final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); + List _value = pair_1.getValue(); + for (final CostElementMatch m_3 : _value) { + multiplicityBuilder.add(1, m_3.getMatch()); + } + multiplicityBuilder.add((-2), pair_1.getKey()); + multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); + } + } + CloseTrainsObjectiveHint.boundLimit(it, step4Matches, 2, this.trainType, 2); + CloseTrainsObjectiveHint.boundLimit(it, step4Matches, 3, this.segmentType, 2); + CloseTrainsObjectiveHint.boundLimit(it, step4Matches, 4, this.segmentType, 2); + final ImmutableList step5Matches = step5.getMatches(); + for (final CostElementMatch m_3 : step5Matches) { + { + final Dimension dimension = it.getDimension(m_3.getMatch()); + objectiveBuilder.add(step5.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m_3.isMulti(); + boolean _not = (!_isMulti); + if (_not) { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m_3.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + } + } + final Function1 _function_3 = (CostElementMatch it_1) -> { + return step4.projectMayMatch(it_1.getMatch(), 2, 3, 4); + }; + Set>> _entrySet_2 = IterableExtensions.groupBy(step5Matches, _function_3).entrySet(); + for (final Map.Entry> pair_2 : _entrySet_2) { + { + final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); + List _value = pair_2.getValue(); + for (final CostElementMatch m_4 : _value) { + multiplicityBuilder.add(1, m_4.getMatch()); + } + multiplicityBuilder.add((-2), pair_2.getKey()); + multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); + } + } + CloseTrainsObjectiveHint.boundLimit(it, step5Matches, 2, this.trainType, 4); + CloseTrainsObjectiveHint.boundLimit(it, step5Matches, 3, this.segmentType, 4); + CloseTrainsObjectiveHint.boundLimit(it, step5Matches, 4, this.segmentType, 4); + CloseTrainsObjectiveHint.boundLimit(it, step5Matches, 5, this.segmentType, 4); + final ImmutableList step6Matches = step6.getMatches(); + for (final CostElementMatch m_4 : step6Matches) { + { + final Dimension dimension = it.getDimension(m_4.getMatch()); + objectiveBuilder.add(step6.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m_4.isMulti(); + if (_isMulti) { + Object _get = m_4.getMatch().get(3); + Object _get_1 = m_4.getMatch().get(5); + boolean _equals = Objects.equal(_get, _get_1); + if (_equals) { + it.createBuilder().add(2, m_4.getMatch()).add((-1), step5.projectMayMatch(m_4.getMatch(), 2, 3, 4, 5)).build().assertEqualsTo(0); + } else { + it.createBuilder().add(1, m_4.getMatch()).add((-1), step5.projectMayMatch(m_4.getMatch(), 2, 3, 4, 5)).build().assertEqualsTo(0); + } + } else { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m_4.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + } + } + CloseTrainsObjectiveHint.boundLimit(it, step6Matches, 2, this.trainType, 2); + CloseTrainsObjectiveHint.boundLimit(it, step6Matches, 3, this.segmentType, 2); + CloseTrainsObjectiveHint.boundLimit(it, step6Matches, 4, this.segmentType, 2); + CloseTrainsObjectiveHint.boundLimit(it, step6Matches, 5, this.segmentType, 2); + final ImmutableList step7Matches = step7.getMatches(); + for (final CostElementMatch m_5 : step7Matches) { + { + final Dimension dimension = it.getDimension(m_5.getMatch()); + objectiveBuilder.add(step7.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m_5.isMulti(); + boolean _not = (!_isMulti); + if (_not) { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m_5.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + } + } + final Function1 _function_4 = (CostElementMatch it_1) -> { + return step6.projectMayMatch(it_1.getMatch(), 2, 3, 4, 5); + }; + Set>> _entrySet_3 = IterableExtensions.groupBy(step7Matches, _function_4).entrySet(); + for (final Map.Entry> pair_3 : _entrySet_3) { + { + final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); + List _value = pair_3.getValue(); + for (final CostElementMatch m_6 : _value) { + multiplicityBuilder.add(1, m_6.getMatch()); + } + multiplicityBuilder.add((-1), pair_3.getKey()); + multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); + } + } + CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 2, this.trainType, 2); + CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 3, this.segmentType, 2); + CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 4, this.segmentType, 2); + CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 5, this.segmentType, 2); + CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 6, this.trainType, 2); + this.buildWithBounds(objectiveBuilder); + }; + _xblockexpression = _function; + } + return _xblockexpression; + } + + private static void boundLimit(@Extension final ExtendedLinearExpressionBuilderFactory factory, final Collection matches, final int index, final Type type, final int count) { + final Function1 _function = (CostElementMatch it) -> { + return it.getMatch().get(index); + }; + Set>> _entrySet = IterableExtensions.groupBy(matches, _function).entrySet(); + for (final Map.Entry> pair : _entrySet) { + { + final ExtendedLinearExpressionBuilder multiplicityBuilder = factory.createBuilder(); + List _value = pair.getValue(); + for (final CostElementMatch m : _value) { + multiplicityBuilder.add(1, m.getMatch()); + } + boolean _isMulti = CostElementMatchers.isMulti(pair.getKey()); + if (_isMulti) { + multiplicityBuilder.add((-count), type); + multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); + } else { + multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(count)); + } + } + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/EndOfSidingObjectiveHint.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/EndOfSidingObjectiveHint.java new file mode 100644 index 00000000..77c513e1 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/EndOfSidingObjectiveHint.java @@ -0,0 +1,193 @@ +package modes3.run; + +import com.google.common.collect.ImmutableList; +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Dimension; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilder; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import modes3.Modes3Package; +import modes3.queries.EndOfSiding_step_2; +import modes3.queries.EndOfSiding_step_3; +import modes3.queries.EndOfSiding_step_4; +import modes3.queries.EndOfSiding_step_5; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.xtext.xbase.lib.Extension; +import org.eclipse.xtext.xbase.lib.Functions.Function1; +import org.eclipse.xtext.xbase.lib.IterableExtensions; + +@SuppressWarnings("all") +public class EndOfSidingObjectiveHint extends CostObjectiveHint { + private final Type segmentType; + + private final Type trainType; + + public EndOfSidingObjectiveHint(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { + @Extension + final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; + this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); + this.trainType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTrain()); + } + + @Override + public boolean isExact() { + return true; + } + + @Override + public PolyhedronExtensionOperator createPolyhedronExtensionOperator(final Map costElementMatchers) { + PolyhedronExtensionOperator _xblockexpression = null; + { + final CostElementMatchers step2 = costElementMatchers.get(EndOfSiding_step_2.instance().getFullyQualifiedName()); + final CostElementMatchers step3 = costElementMatchers.get(EndOfSiding_step_3.instance().getFullyQualifiedName()); + final CostElementMatchers step4 = costElementMatchers.get(EndOfSiding_step_4.instance().getFullyQualifiedName()); + final CostElementMatchers step5 = costElementMatchers.get(EndOfSiding_step_5.instance().getFullyQualifiedName()); + final PolyhedronExtensionOperator _function = (ExtendedLinearExpressionBuilderFactory it) -> { + final ExtendedLinearExpressionBuilder objectiveBuilder = it.createBuilder(); + ImmutableList _matches = step2.getMatches(); + for (final CostElementMatch m : _matches) { + { + final Dimension dimension = it.getDimension(m.getMatch()); + objectiveBuilder.add(step2.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m.isMulti(); + if (_isMulti) { + it.createBuilder().add(1, dimension).add((-1), this.trainType).build().assertEqualsTo(0); + } else { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + } + } + final ImmutableList step3Matches = step3.getMatches(); + for (final CostElementMatch m_1 : step3Matches) { + { + final Dimension dimension = it.getDimension(m_1.getMatch()); + objectiveBuilder.add(step3.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m_1.isMulti(); + boolean _not = (!_isMulti); + if (_not) { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m_1.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + } + } + final Function1 _function_1 = (CostElementMatch it_1) -> { + return step2.projectMayMatch(it_1.getMatch(), 2); + }; + Set>> _entrySet = IterableExtensions.groupBy(step3Matches, _function_1).entrySet(); + for (final Map.Entry> pair : _entrySet) { + { + final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); + List _value = pair.getValue(); + for (final CostElementMatch m_2 : _value) { + multiplicityBuilder.add(1, m_2.getMatch()); + } + multiplicityBuilder.add((-1), pair.getKey()); + multiplicityBuilder.build().assertEqualsTo(0); + } + } + EndOfSidingObjectiveHint.boundLimit(it, step3Matches, 2, this.trainType, 1); + EndOfSidingObjectiveHint.boundLimit(it, step3Matches, 3, this.segmentType, 1); + final ImmutableList step4Matches = step4.getMatches(); + for (final CostElementMatch m_2 : step4Matches) { + { + final Dimension dimension = it.getDimension(m_2.getMatch()); + objectiveBuilder.add(step4.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m_2.isMulti(); + boolean _not = (!_isMulti); + if (_not) { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m_2.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + } + } + final Function1 _function_2 = (CostElementMatch it_1) -> { + return step3.projectMayMatch(it_1.getMatch(), 2, 3); + }; + Set>> _entrySet_1 = IterableExtensions.groupBy(step4Matches, _function_2).entrySet(); + for (final Map.Entry> pair_1 : _entrySet_1) { + { + final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); + List _value = pair_1.getValue(); + for (final CostElementMatch m_3 : _value) { + multiplicityBuilder.add(1, m_3.getMatch()); + } + multiplicityBuilder.add((-2), pair_1.getKey()); + multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); + } + } + EndOfSidingObjectiveHint.boundLimit(it, step4Matches, 2, this.trainType, 2); + EndOfSidingObjectiveHint.boundLimit(it, step4Matches, 3, this.segmentType, 2); + EndOfSidingObjectiveHint.boundLimit(it, step4Matches, 4, this.segmentType, 2); + final ImmutableList step5Matches = step5.getMatches(); + for (final CostElementMatch m_3 : step5Matches) { + { + final Dimension dimension = it.getDimension(m_3.getMatch()); + objectiveBuilder.add(step5.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m_3.isMulti(); + boolean _not = (!_isMulti); + if (_not) { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m_3.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + it.createBuilder().add(1, m_3.getMatch()).add((-1), step4.projectMayMatch(m_3.getMatch(), 2, 3, 4)).build().tightenUpperBound(Integer.valueOf(0)); + } + } + EndOfSidingObjectiveHint.boundLimit(it, step5Matches, 2, this.trainType, 1); + EndOfSidingObjectiveHint.boundLimit(it, step5Matches, 3, this.segmentType, 2); + EndOfSidingObjectiveHint.boundLimit(it, step5Matches, 4, this.segmentType, 1); + this.buildWithBounds(objectiveBuilder); + }; + _xblockexpression = _function; + } + return _xblockexpression; + } + + private static void boundLimit(@Extension final ExtendedLinearExpressionBuilderFactory factory, final Collection matches, final int index, final Type type, final int count) { + final Function1 _function = (CostElementMatch it) -> { + return it.getMatch().get(index); + }; + Set>> _entrySet = IterableExtensions.groupBy(matches, _function).entrySet(); + for (final Map.Entry> pair : _entrySet) { + { + final ExtendedLinearExpressionBuilder multiplicityBuilder = factory.createBuilder(); + List _value = pair.getValue(); + for (final CostElementMatch m : _value) { + multiplicityBuilder.add(1, m.getMatch()); + } + boolean _isMulti = CostElementMatchers.isMulti(pair.getKey()); + if (_isMulti) { + multiplicityBuilder.add((-count), type); + multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); + } else { + multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(count)); + } + } + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/MisalignedTurnoutObjectiveHint.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/MisalignedTurnoutObjectiveHint.java new file mode 100644 index 00000000..835a6559 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/MisalignedTurnoutObjectiveHint.java @@ -0,0 +1,195 @@ +package modes3.run; + +import com.google.common.collect.ImmutableList; +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Dimension; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilder; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import modes3.Modes3Package; +import modes3.queries.MisalignedTurnout_step_2; +import modes3.queries.MisalignedTurnout_step_3; +import modes3.queries.MisalignedTurnout_step_4; +import modes3.queries.MisalignedTurnout_step_5; +import org.eclipse.viatra.query.runtime.api.IPatternMatch; +import org.eclipse.xtext.xbase.lib.Extension; +import org.eclipse.xtext.xbase.lib.Functions.Function1; +import org.eclipse.xtext.xbase.lib.IterableExtensions; + +@SuppressWarnings("all") +public class MisalignedTurnoutObjectiveHint extends CostObjectiveHint { + private final Type segmentType; + + private final Type turnoutType; + + private final Type trainType; + + public MisalignedTurnoutObjectiveHint(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { + @Extension + final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; + this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); + this.turnoutType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTurnout()); + this.trainType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTrain()); + } + + @Override + public boolean isExact() { + return true; + } + + @Override + public PolyhedronExtensionOperator createPolyhedronExtensionOperator(final Map costElementMatchers) { + PolyhedronExtensionOperator _xblockexpression = null; + { + final CostElementMatchers step2 = costElementMatchers.get(MisalignedTurnout_step_2.instance().getFullyQualifiedName()); + final CostElementMatchers step3 = costElementMatchers.get(MisalignedTurnout_step_3.instance().getFullyQualifiedName()); + final CostElementMatchers step4 = costElementMatchers.get(MisalignedTurnout_step_4.instance().getFullyQualifiedName()); + final CostElementMatchers step5 = costElementMatchers.get(MisalignedTurnout_step_5.instance().getFullyQualifiedName()); + final PolyhedronExtensionOperator _function = (ExtendedLinearExpressionBuilderFactory it) -> { + final ExtendedLinearExpressionBuilder objectiveBuilder = it.createBuilder(); + ImmutableList _matches = step2.getMatches(); + for (final CostElementMatch m : _matches) { + { + final Dimension dimension = it.getDimension(m.getMatch()); + objectiveBuilder.add(step2.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m.isMulti(); + if (_isMulti) { + it.createBuilder().add(1, dimension).add((-1), this.turnoutType).build().assertEqualsTo(0); + } else { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + } + } + final ImmutableList step3Matches = step3.getMatches(); + for (final CostElementMatch m_1 : step3Matches) { + { + final Dimension dimension = it.getDimension(m_1.getMatch()); + objectiveBuilder.add(step3.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m_1.isMulti(); + boolean _not = (!_isMulti); + if (_not) { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m_1.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + } + } + final Function1 _function_1 = (CostElementMatch it_1) -> { + return step2.projectMayMatch(it_1.getMatch(), 2); + }; + Set>> _entrySet = IterableExtensions.groupBy(step3Matches, _function_1).entrySet(); + for (final Map.Entry> pair : _entrySet) { + { + final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); + List _value = pair.getValue(); + for (final CostElementMatch m_2 : _value) { + multiplicityBuilder.add(1, m_2.getMatch()); + } + multiplicityBuilder.add((-1), pair.getKey()); + multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); + } + } + MisalignedTurnoutObjectiveHint.boundLimit(it, step3Matches, 2, this.turnoutType, 1); + MisalignedTurnoutObjectiveHint.boundLimit(it, step3Matches, 3, this.segmentType, 2); + final ImmutableList step4Matches = step4.getMatches(); + for (final CostElementMatch m_2 : step4Matches) { + { + final Dimension dimension = it.getDimension(m_2.getMatch()); + objectiveBuilder.add(step4.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m_2.isMulti(); + boolean _not = (!_isMulti); + if (_not) { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m_2.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + it.createBuilder().add(1, m_2.getMatch()).add((-1), step3.projectMayMatch(m_2.getMatch(), 2, 3)).build().tightenUpperBound(Integer.valueOf(0)); + } + } + MisalignedTurnoutObjectiveHint.boundLimit(it, step4Matches, 2, this.turnoutType, 1); + MisalignedTurnoutObjectiveHint.boundLimit(it, step4Matches, 3, this.segmentType, 2); + final ImmutableList step5Matches = step5.getMatches(); + for (final CostElementMatch m_3 : step5Matches) { + { + final Dimension dimension = it.getDimension(m_3.getMatch()); + objectiveBuilder.add(step5.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m_3.isMulti(); + boolean _not = (!_isMulti); + if (_not) { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m_3.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + } + } + final Function1 _function_2 = (CostElementMatch it_1) -> { + return step4.projectMayMatch(it_1.getMatch(), 2, 3); + }; + Set>> _entrySet_1 = IterableExtensions.groupBy(step5Matches, _function_2).entrySet(); + for (final Map.Entry> pair_1 : _entrySet_1) { + { + final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); + List _value = pair_1.getValue(); + for (final CostElementMatch m_4 : _value) { + multiplicityBuilder.add(1, m_4.getMatch()); + } + multiplicityBuilder.add((-1), pair_1.getKey()); + multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); + } + } + MisalignedTurnoutObjectiveHint.boundLimit(it, step5Matches, 2, this.turnoutType, 1); + MisalignedTurnoutObjectiveHint.boundLimit(it, step5Matches, 3, this.segmentType, 2); + MisalignedTurnoutObjectiveHint.boundLimit(it, step5Matches, 4, this.trainType, 2); + this.buildWithBounds(objectiveBuilder); + }; + _xblockexpression = _function; + } + return _xblockexpression; + } + + private static void boundLimit(@Extension final ExtendedLinearExpressionBuilderFactory factory, final Collection matches, final int index, final Type type, final int count) { + final Function1 _function = (CostElementMatch it) -> { + return it.getMatch().get(index); + }; + Set>> _entrySet = IterableExtensions.groupBy(matches, _function).entrySet(); + for (final Map.Entry> pair : _entrySet) { + { + final ExtendedLinearExpressionBuilder multiplicityBuilder = factory.createBuilder(); + List _value = pair.getValue(); + for (final CostElementMatch m : _value) { + multiplicityBuilder.add(1, m.getMatch()); + } + boolean _isMulti = CostElementMatchers.isMulti(pair.getKey()); + if (_isMulti) { + multiplicityBuilder.add((-count), type); + multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); + } else { + multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(count)); + } + } + } + } +} diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java index f32a7172..16db7053 100644 --- a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java @@ -13,6 +13,7 @@ import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logic import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsPackage; import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion; import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; +import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicModelInterpretation; import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder; import hu.bme.mit.inf.dslreasoner.logic.model.builder.SolutionScope; import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput; @@ -32,6 +33,7 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage; import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult; +import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore; import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic; import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration; import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicTrace; @@ -50,10 +52,15 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.par import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.RelationLink; import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.CostObjectiveConfiguration; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.CostObjectiveElementConfiguration; import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.DebugConfiguration; import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.StateCoderStrategy; import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.PartialModelAsLogicInterpretation; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold; import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser; import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; import java.util.Collections; @@ -64,10 +71,31 @@ import java.util.function.Predicate; import modes3.Modes3Factory; import modes3.Modes3ModelRoot; import modes3.Modes3Package; +import modes3.queries.CloseTrains_step_2; +import modes3.queries.CloseTrains_step_3; +import modes3.queries.CloseTrains_step_4; +import modes3.queries.CloseTrains_step_5; +import modes3.queries.CloseTrains_step_6; +import modes3.queries.CloseTrains_step_7; +import modes3.queries.EndOfSiding_step_2; +import modes3.queries.EndOfSiding_step_3; +import modes3.queries.EndOfSiding_step_4; +import modes3.queries.EndOfSiding_step_5; +import modes3.queries.MisalignedTurnout_step_2; +import modes3.queries.MisalignedTurnout_step_3; +import modes3.queries.MisalignedTurnout_step_4; +import modes3.queries.MisalignedTurnout_step_5; import modes3.queries.Modes3Queries; +import modes3.queries.TrainLocations_step_2; +import modes3.queries.TrainLocations_step_3; +import modes3.run.CloseTrainsObjectiveHint; +import modes3.run.EndOfSidingObjectiveHint; +import modes3.run.MisalignedTurnoutObjectiveHint; import modes3.run.Modes3TypeScopeHint; import modes3.run.Modes3UnitPropagationGenerator; +import modes3.run.TrainLocationsObjectiveHint; import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; @@ -102,6 +130,10 @@ public class Modes3ModelGenerator { private enum MonitoringQuery { closeTrains, + trainLocations, + + endOfSiding, + misalignedTurnout; } @@ -183,8 +215,9 @@ public class Modes3ModelGenerator { ObjectExtensions.>operator_doubleArrow( it_1.minNewElementsByType, _function_4); final Procedure1> _function_5 = (Map it_2) -> { - it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTrain()), Integer.valueOf(5)); - it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTurnout()), Integer.valueOf(5)); + it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTrain()), Integer.valueOf((this.modelSize / 5))); + it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTurnout()), Integer.valueOf((this.modelSize / 5))); + it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getSimpleSegment()), Integer.valueOf(((3 * this.modelSize) / 5))); }; ObjectExtensions.>operator_doubleArrow( it_1.maxNewElementsByType, _function_5); @@ -196,7 +229,9 @@ public class Modes3ModelGenerator { }; ObjectExtensions.operator_doubleArrow( it.solutionScope, _function_4); - it.scopeWeight = 5; + CostObjectiveConfiguration _objective = this.getObjective(this.ecore2Logic, metamodelLogic.getTrace()); + it.costObjectives.add(_objective); + it.scopeWeight = 6; it.nameNewElements = false; it.typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis; it.stateCoderStrategy = StateCoderStrategy.PairwiseNeighbourhood; @@ -224,80 +259,103 @@ public class Modes3ModelGenerator { URI _xifexpression = null; if ((solution instanceof ModelResult)) { InputOutput.println("Saving generated solutions"); - final EList representations = ((ModelResult)solution).getRepresentation(); - int _size = representations.size(); + final Logic2Ecore logic2Ecore = new Logic2Ecore(this.ecore2Logic); + final List interpretations = this.solver.getInterpretations(((ModelResult)solution)); + int _size = interpretations.size(); ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); for (final Integer representationIndex : _doubleDotLessThan) { { - final Object representation = representations.get((representationIndex).intValue()); + final LogicModelInterpretation interpretation = interpretations.get((representationIndex).intValue()); final int representationNumber = ((representationIndex).intValue() + 1); - if ((representation instanceof PartialInterpretation)) { + if ((interpretation instanceof PartialModelAsLogicInterpretation)) { + final PartialInterpretation representation = ((PartialModelAsLogicInterpretation)interpretation).getPartialInterpretation(); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("solution"); _builder_1.append(representationNumber); _builder_1.append(".partialinterpretation"); - workspace.writeModel(((EObject)representation), _builder_1.toString()); + workspace.writeModel(representation, _builder_1.toString()); final PartialInterpretation2Gml partialInterpretation2GML = new PartialInterpretation2Gml(); - final String gml = partialInterpretation2GML.transform(((PartialInterpretation)representation)); + final String gml = partialInterpretation2GML.transform(representation); StringConcatenation _builder_2 = new StringConcatenation(); _builder_2.append("solution"); _builder_2.append(representationNumber); _builder_2.append(".gml"); workspace.writeText(_builder_2.toString(), gml); - int _size_1 = ((PartialInterpretation)representation).getNewElements().size(); - boolean _lessThan = (_size_1 < 160); - if (_lessThan) { - if ((representation instanceof PartialInterpretation)) { - final Function1 _function_3 = (Type it) -> { + final EObject model = logic2Ecore.transformInterpretation(interpretation, metamodelLogic.getTrace()); + final TreeIterator iterator = model.eAllContents(); + int id = 0; + while (iterator.hasNext()) { + { + final EObject obj = iterator.next(); + final Function1 _function_3 = (EAttribute it) -> { String _name_2 = it.getName(); - return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class DefinedPart")); + return Boolean.valueOf(Objects.equal(_name_2, "id")); }; - Type _findFirst = IterableExtensions.findFirst(((PartialInterpretation)representation).getProblem().getTypes(), _function_3); - final TypeDefinition rootType = ((TypeDefinition) _findFirst); - final Function1 _function_4 = (PartialComplexTypeInterpretation it) -> { - String _name_2 = it.getInterpretationOf().getName(); - return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class")); - }; - final PartialComplexTypeInterpretation rootIntepretation = IterableExtensions.findFirst(Iterables.filter(((PartialInterpretation)representation).getPartialtypeinterpratation(), - PartialComplexTypeInterpretation.class), _function_4); - rootIntepretation.getElements().removeAll(rootType.getElements()); - ((PartialInterpretation)representation).getProblem().getElements().removeAll(rootType.getElements()); - EList _partialrelationinterpretation = ((PartialInterpretation)representation).getPartialrelationinterpretation(); - for (final PartialRelationInterpretation relationInterpretation : _partialrelationinterpretation) { - final Predicate _function_5 = (RelationLink link) -> { - boolean _xifexpression_1 = false; - if ((link instanceof BinaryElementRelationLink)) { - _xifexpression_1 = (rootType.getElements().contains(((BinaryElementRelationLink)link).getParam1()) || rootType.getElements().contains(((BinaryElementRelationLink)link).getParam2())); - } else { - _xifexpression_1 = false; - } - return _xifexpression_1; - }; - relationInterpretation.getRelationlinks().removeIf(_function_5); + final EAttribute idFeature = IterableExtensions.findFirst(obj.eClass().getEAllAttributes(), _function_3); + if ((idFeature != null)) { + obj.eSet(idFeature, Integer.valueOf(id)); + id++; } - rootType.getElements().clear(); } + } + StringConcatenation _builder_3 = new StringConcatenation(); + _builder_3.append("solution"); + _builder_3.append(representationNumber); + _builder_3.append(".modes3"); + workspace.writeModel(model, _builder_3.toString()); + int _size_1 = representation.getNewElements().size(); + boolean _lessThan = (_size_1 < 160); + if (_lessThan) { + final Function1 _function_3 = (Type it) -> { + String _name_2 = it.getName(); + return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class DefinedPart")); + }; + Type _findFirst = IterableExtensions.findFirst(representation.getProblem().getTypes(), _function_3); + final TypeDefinition rootType = ((TypeDefinition) _findFirst); + final Function1 _function_4 = (PartialComplexTypeInterpretation it) -> { + String _name_2 = it.getInterpretationOf().getName(); + return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class")); + }; + final PartialComplexTypeInterpretation rootIntepretation = IterableExtensions.findFirst(Iterables.filter(representation.getPartialtypeinterpratation(), + PartialComplexTypeInterpretation.class), _function_4); + rootIntepretation.getElements().removeAll(rootType.getElements()); + representation.getProblem().getElements().removeAll(rootType.getElements()); + EList _partialrelationinterpretation = representation.getPartialrelationinterpretation(); + for (final PartialRelationInterpretation relationInterpretation : _partialrelationinterpretation) { + final Predicate _function_5 = (RelationLink link) -> { + boolean _xifexpression_1 = false; + if ((link instanceof BinaryElementRelationLink)) { + _xifexpression_1 = (rootType.getElements().contains(((BinaryElementRelationLink)link).getParam1()) || + rootType.getElements().contains(((BinaryElementRelationLink)link).getParam2())); + } else { + _xifexpression_1 = false; + } + return _xifexpression_1; + }; + relationInterpretation.getRelationlinks().removeIf(_function_5); + } + rootType.getElements().clear(); final GraphvizVisualiser visualiser = new GraphvizVisualiser(); - final PartialInterpretationVisualisation visualisation = visualiser.visualiseConcretization(((PartialInterpretation)representation)); - StringConcatenation _builder_3 = new StringConcatenation(); - _builder_3.append("solution"); - _builder_3.append(representationNumber); - _builder_3.append(".png"); - visualisation.writeToFile(workspace, _builder_3.toString()); + final PartialInterpretationVisualisation visualisation = visualiser.visualiseConcretization(representation); + StringConcatenation _builder_4 = new StringConcatenation(); + _builder_4.append("solution"); + _builder_4.append(representationNumber); + _builder_4.append(".png"); + visualisation.writeToFile(workspace, _builder_4.toString()); } } else { - StringConcatenation _builder_4 = new StringConcatenation(); - _builder_4.append("solution"); - _builder_4.append(representationNumber); - _builder_4.append(".txt"); - workspace.writeText(_builder_4.toString(), representation.toString()); + StringConcatenation _builder_5 = new StringConcatenation(); + _builder_5.append("solution"); + _builder_5.append(representationNumber); + _builder_5.append(".txt"); + workspace.writeText(_builder_5.toString(), interpretation.toString()); } } } } else { URI _xblockexpression_1 = null; { - InputOutput.println("Failed to solver problem"); + InputOutput.println("Failed to solve problem"); final LogicProblem partial = logic.getOutput(); _xblockexpression_1 = workspace.writeModel(partial, "solution.partialinterpretation"); } @@ -354,6 +412,153 @@ public class Modes3ModelGenerator { return _xblockexpression; } + public CostObjectiveConfiguration getObjective(final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { + CostObjectiveConfiguration _costObjectiveConfiguration = new CostObjectiveConfiguration(); + final Procedure1 _function = (CostObjectiveConfiguration it) -> { + final Modes3ModelGenerator.MonitoringQuery monitoringQuery = this.monitoringQuery; + if (monitoringQuery != null) { + switch (monitoringQuery) { + case closeTrains: + CostObjectiveElementConfiguration _costObjectiveElementConfiguration = new CostObjectiveElementConfiguration(); + final Procedure1 _function_1 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = CloseTrains_step_2.instance().getFullyQualifiedName(); + it_1.weight = ((14 + 53) + 11); + }; + CostObjectiveElementConfiguration _doubleArrow = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration, _function_1); + it.elements.add(_doubleArrow); + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_1 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_2 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = CloseTrains_step_3.instance().getFullyQualifiedName(); + it_1.weight = (21 + 14); + }; + CostObjectiveElementConfiguration _doubleArrow_1 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_1, _function_2); + it.elements.add(_doubleArrow_1); + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_2 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_3 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = CloseTrains_step_4.instance().getFullyQualifiedName(); + it_1.weight = (((14 + 44) + 14) + 9); + }; + CostObjectiveElementConfiguration _doubleArrow_2 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_2, _function_3); + it.elements.add(_doubleArrow_2); + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_3 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_4 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = CloseTrains_step_5.instance().getFullyQualifiedName(); + it_1.weight = ((14 + 41) + 11); + }; + CostObjectiveElementConfiguration _doubleArrow_3 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_3, _function_4); + it.elements.add(_doubleArrow_3); + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_4 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_5 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = CloseTrains_step_6.instance().getFullyQualifiedName(); + it_1.weight = 27; + }; + CostObjectiveElementConfiguration _doubleArrow_4 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_4, _function_5); + it.elements.add(_doubleArrow_4); + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_5 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_6 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = CloseTrains_step_7.instance().getFullyQualifiedName(); + it_1.weight = 48; + }; + CostObjectiveElementConfiguration _doubleArrow_5 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_5, _function_6); + it.elements.add(_doubleArrow_5); + CloseTrainsObjectiveHint _closeTrainsObjectiveHint = new CloseTrainsObjectiveHint(ecore2Logic, ecore2LogicTrace); + it.hint = _closeTrainsObjectiveHint; + break; + case trainLocations: + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_6 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_7 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = TrainLocations_step_2.instance().getFullyQualifiedName(); + it_1.weight = ((14 + 53) + 11); + }; + CostObjectiveElementConfiguration _doubleArrow_6 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_6, _function_7); + it.elements.add(_doubleArrow_6); + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_7 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_8 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = TrainLocations_step_3.instance().getFullyQualifiedName(); + it_1.weight = 48; + }; + CostObjectiveElementConfiguration _doubleArrow_7 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_7, _function_8); + it.elements.add(_doubleArrow_7); + TrainLocationsObjectiveHint _trainLocationsObjectiveHint = new TrainLocationsObjectiveHint(ecore2Logic, ecore2LogicTrace); + it.hint = _trainLocationsObjectiveHint; + break; + case misalignedTurnout: + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_8 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_9 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = MisalignedTurnout_step_2.instance().getFullyQualifiedName(); + it_1.weight = ((14 + 53) + 11); + }; + CostObjectiveElementConfiguration _doubleArrow_8 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_8, _function_9); + it.elements.add(_doubleArrow_8); + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_9 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_10 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = MisalignedTurnout_step_3.instance().getFullyQualifiedName(); + it_1.weight = 108; + }; + CostObjectiveElementConfiguration _doubleArrow_9 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_9, _function_10); + it.elements.add(_doubleArrow_9); + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_10 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_11 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = MisalignedTurnout_step_4.instance().getFullyQualifiedName(); + it_1.weight = 27; + }; + CostObjectiveElementConfiguration _doubleArrow_10 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_10, _function_11); + it.elements.add(_doubleArrow_10); + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_11 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_12 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = MisalignedTurnout_step_5.instance().getFullyQualifiedName(); + it_1.weight = 48; + }; + CostObjectiveElementConfiguration _doubleArrow_11 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_11, _function_12); + it.elements.add(_doubleArrow_11); + MisalignedTurnoutObjectiveHint _misalignedTurnoutObjectiveHint = new MisalignedTurnoutObjectiveHint(ecore2Logic, ecore2LogicTrace); + it.hint = _misalignedTurnoutObjectiveHint; + break; + case endOfSiding: + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_12 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_13 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = EndOfSiding_step_2.instance().getFullyQualifiedName(); + it_1.weight = ((14 + 53) + 11); + }; + CostObjectiveElementConfiguration _doubleArrow_12 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_12, _function_13); + it.elements.add(_doubleArrow_12); + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_13 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_14 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = EndOfSiding_step_3.instance().getFullyQualifiedName(); + it_1.weight = (21 + 14); + }; + CostObjectiveElementConfiguration _doubleArrow_13 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_13, _function_14); + it.elements.add(_doubleArrow_13); + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_14 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_15 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = EndOfSiding_step_4.instance().getFullyQualifiedName(); + it_1.weight = (((((((14 + 35) + 21) + 15) + 14) + 21) + 15) + 11); + }; + CostObjectiveElementConfiguration _doubleArrow_14 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_14, _function_15); + it.elements.add(_doubleArrow_14); + CostObjectiveElementConfiguration _costObjectiveElementConfiguration_15 = new CostObjectiveElementConfiguration(); + final Procedure1 _function_16 = (CostObjectiveElementConfiguration it_1) -> { + it_1.patternQualifiedName = EndOfSiding_step_5.instance().getFullyQualifiedName(); + it_1.weight = 48; + }; + CostObjectiveElementConfiguration _doubleArrow_15 = ObjectExtensions.operator_doubleArrow(_costObjectiveElementConfiguration_15, _function_16); + it.elements.add(_doubleArrow_15); + EndOfSidingObjectiveHint _endOfSidingObjectiveHint = new EndOfSidingObjectiveHint(ecore2Logic, ecore2LogicTrace); + it.hint = _endOfSidingObjectiveHint; + break; + default: + throw new IllegalArgumentException(("Unknown monitoring query: " + this.monitoringQuery)); + } + } else { + throw new IllegalArgumentException(("Unknown monitoring query: " + this.monitoringQuery)); + } + it.kind = ObjectiveKind.HIGHER_IS_BETTER; + it.threshold = ObjectiveThreshold.NO_THRESHOLD; + it.findExtremum = true; + }; + return ObjectExtensions.operator_doubleArrow(_costObjectiveConfiguration, _function); + } + public static Object init() { Object _xblockexpression = null; { diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/TrainLocationsObjectiveHint.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/TrainLocationsObjectiveHint.java new file mode 100644 index 00000000..570f9deb --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/TrainLocationsObjectiveHint.java @@ -0,0 +1,117 @@ +package modes3.run; + +import com.google.common.collect.ImmutableList; +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; +import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; +import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Dimension; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilder; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory; +import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers; +import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import modes3.Modes3Package; +import modes3.queries.TrainLocations_step_2; +import modes3.queries.TrainLocations_step_3; +import org.eclipse.xtext.xbase.lib.Extension; +import org.eclipse.xtext.xbase.lib.Functions.Function1; +import org.eclipse.xtext.xbase.lib.IterableExtensions; + +@SuppressWarnings("all") +public class TrainLocationsObjectiveHint extends CostObjectiveHint { + private final Type segmentType; + + private final Type trainType; + + public TrainLocationsObjectiveHint(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { + @Extension + final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; + this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); + this.trainType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTrain()); + } + + @Override + public boolean isExact() { + return true; + } + + @Override + public PolyhedronExtensionOperator createPolyhedronExtensionOperator(final Map costElementMatchers) { + PolyhedronExtensionOperator _xblockexpression = null; + { + final CostElementMatchers step2 = costElementMatchers.get(TrainLocations_step_2.instance().getFullyQualifiedName()); + final CostElementMatchers step3 = costElementMatchers.get(TrainLocations_step_3.instance().getFullyQualifiedName()); + final PolyhedronExtensionOperator _function = (ExtendedLinearExpressionBuilderFactory it) -> { + final ExtendedLinearExpressionBuilder objectiveBuilder = it.createBuilder(); + ImmutableList _matches = step2.getMatches(); + for (final CostElementMatch m : _matches) { + { + final Dimension dimension = it.getDimension(m.getMatch()); + objectiveBuilder.add(step2.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m.isMulti(); + if (_isMulti) { + it.createBuilder().add(1, dimension).add((-1), this.trainType).build().assertEqualsTo(0); + } else { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + } + } + final ImmutableList step3Matches = step3.getMatches(); + for (final CostElementMatch m_1 : step3Matches) { + { + final Dimension dimension = it.getDimension(m_1.getMatch()); + objectiveBuilder.add(step3.getWeight(), dimension); + dimension.tightenLowerBound(Integer.valueOf(0)); + boolean _isMulti = m_1.isMulti(); + boolean _not = (!_isMulti); + if (_not) { + dimension.tightenUpperBound(Integer.valueOf(1)); + boolean _isMust = m_1.isMust(); + if (_isMust) { + dimension.tightenLowerBound(Integer.valueOf(1)); + } + } + } + } + TrainLocationsObjectiveHint.boundLimit(it, step3Matches, 2, this.trainType, 1); + TrainLocationsObjectiveHint.boundLimit(it, step3Matches, 3, this.segmentType, 1); + this.buildWithBounds(objectiveBuilder); + }; + _xblockexpression = _function; + } + return _xblockexpression; + } + + private static void boundLimit(@Extension final ExtendedLinearExpressionBuilderFactory factory, final Collection matches, final int index, final Type type, final int count) { + final Function1 _function = (CostElementMatch it) -> { + return it.getMatch().get(index); + }; + Set>> _entrySet = IterableExtensions.groupBy(matches, _function).entrySet(); + for (final Map.Entry> pair : _entrySet) { + { + final ExtendedLinearExpressionBuilder multiplicityBuilder = factory.createBuilder(); + List _value = pair.getValue(); + for (final CostElementMatch m : _value) { + multiplicityBuilder.add(1, m.getMatch()); + } + boolean _isMulti = CostElementMatchers.isMulti(pair.getKey()); + if (_isMulti) { + multiplicityBuilder.add((-count), type); + multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); + } else { + multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(count)); + } + } + } + } +} -- cgit v1.2.3-70-g09d2