aboutsummaryrefslogtreecommitdiffstats
path: root/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java
blob: c7364257ba0021acab301b2b7db05976603d2eff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
package modes3.run;

import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import hu.bme.mit.inf.dslreasoner.ecore2logic.EReferenceMapper_RelationsOverTypes_Trace;
import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic;
import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration;
import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace;
import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor;
import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsFactory;
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.LogicProblemBuilder;
import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput;
import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes;
import hu.bme.mit.inf.dslreasoner.logic.model.builder.VariableContext;
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Assertion;
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Iff;
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage;
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration;
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.SymbolicValue;
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TermDescription;
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type;
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition;
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Variable;
import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.Annotation;
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.viatra2logic.Viatra2Logic;
import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration;
import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicTrace;
import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor;
import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.Viatra2LogicAnnotationsPackage;
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod;
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorConstraints;
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorSolver;
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy;
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic;
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink;
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation;
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation;
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation;
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage;
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.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.visualisation.pi2graphviz.GraphvizVisualiser;
import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Predicate;
import modes3.Modes3Factory;
import modes3.Modes3ModelRoot;
import modes3.Modes3Package;
import modes3.queries.Modes3Queries;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup;
import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions;
import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchEMFBackendFactory;
import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory;
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.ExclusiveRange;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.InputOutput;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@FinalFieldsConstructor
@SuppressWarnings("all")
public class Modes3ModelGenerator {
  private enum MonitoringQuery {
    closeTrains,
    
    misalignedTurnout;
  }
  
  private final Modes3ModelGenerator.MonitoringQuery monitoringQuery;
  
  private final int modelSize;
  
  private final Ecore2Logic ecore2Logic = new Ecore2Logic();
  
  private final InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic();
  
  private final Viatra2Logic viatra2Logic = new Viatra2Logic(this.ecore2Logic);
  
  private final ViatraReasoner solver = new ViatraReasoner();
  
  @Extension
  private final LogicProblemBuilder _logicProblemBuilder = new LogicProblemBuilder();
  
  public URI generate() {
    try {
      URI _xblockexpression = null;
      {
        final EcoreMetamodelDescriptor metamodel = Modes3ModelGenerator.createMetamodelDescriptor();
        Ecore2LogicConfiguration _ecore2LogicConfiguration = new Ecore2LogicConfiguration();
        final TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelLogic = this.ecore2Logic.transformMetamodel(metamodel, _ecore2LogicConfiguration);
        final Type segment = this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getSegment());
        final RelationDeclaration connectedTo = this.ecore2Logic.relationOfReference(metamodelLogic.getTrace(), 
          Modes3Package.eINSTANCE.getSegment_ConnectedTo());
        final RelationDeclaration connectedToIndicator = ((EReferenceMapper_RelationsOverTypes_Trace) metamodelLogic.getTrace().referenceMapperTrace).indicators.get(
          Modes3Package.eINSTANCE.getSegment_ConnectedTo());
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("oppositeReference ");
        String _name = connectedTo.getName();
        _builder.append(_name);
        _builder.append(" ");
        String _name_1 = connectedTo.getName();
        _builder.append(_name_1);
        final Function1<VariableContext, TermDescription> _function = (VariableContext it) -> {
          Iff _xblockexpression_1 = null;
          {
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("src");
            final Variable src = it.addVar(_builder_1, segment);
            StringConcatenation _builder_2 = new StringConcatenation();
            _builder_2.append("trg");
            final Variable trg = it.addVar(_builder_2, segment);
            SymbolicValue _call = this._logicProblemBuilder.call(connectedToIndicator, src, trg);
            SymbolicValue _call_1 = this._logicProblemBuilder.call(connectedToIndicator, trg, src);
            _xblockexpression_1 = this._logicProblemBuilder.operator_spaceship(_call, _call_1);
          }
          return _xblockexpression_1;
        };
        final Assertion inverseAssertion = this._logicProblemBuilder.Assertion(_builder, 
          this._logicProblemBuilder.Forall(_function));
        EList<Assertion> _assertions = metamodelLogic.getOutput().getAssertions();
        _assertions.add(inverseAssertion);
        InverseRelationAssertion _createInverseRelationAssertion = Ecore2logicannotationsFactory.eINSTANCE.createInverseRelationAssertion();
        final Procedure1<InverseRelationAssertion> _function_1 = (InverseRelationAssertion it) -> {
          it.setTarget(inverseAssertion);
          it.setInverseA(connectedTo);
          it.setInverseB(connectedTo);
        };
        final InverseRelationAssertion inverseAnnotation = ObjectExtensions.<InverseRelationAssertion>operator_doubleArrow(_createInverseRelationAssertion, _function_1);
        EList<Annotation> _annotations = metamodelLogic.getOutput().getAnnotations();
        _annotations.add(inverseAnnotation);
        final List<EObject> initialModel = Modes3ModelGenerator.loadInitialModel();
        final TracedOutput<LogicProblem, Ecore2Logic_Trace> initialModelLogic = this.instanceModel2Logic.transform(metamodelLogic, initialModel);
        final ViatraQuerySetDescriptor queries = this.loadQueries();
        Viatra2LogicConfiguration _viatra2LogicConfiguration = new Viatra2LogicConfiguration();
        final TracedOutput<LogicProblem, Viatra2LogicTrace> logic = this.viatra2Logic.transformQueries(queries, initialModelLogic, _viatra2LogicConfiguration);
        ViatraReasonerConfiguration _viatraReasonerConfiguration = new ViatraReasonerConfiguration();
        final Procedure1<ViatraReasonerConfiguration> _function_2 = (ViatraReasonerConfiguration it) -> {
          it.runtimeLimit = 3600;
          final Procedure1<TypeScopes> _function_3 = (TypeScopes it_1) -> {
            it_1.minNewElements = this.modelSize;
            it_1.maxNewElements = this.modelSize;
            final Procedure1<Map<Type, Integer>> _function_4 = (Map<Type, Integer> it_2) -> {
              it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTurnout()), Integer.valueOf(1));
            };
            ObjectExtensions.<Map<Type, Integer>>operator_doubleArrow(
              it_1.minNewElementsByType, _function_4);
            final Procedure1<Map<Type, Integer>> _function_5 = (Map<Type, Integer> it_2) -> {
              it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTrain()), Integer.valueOf(5));
            };
            ObjectExtensions.<Map<Type, Integer>>operator_doubleArrow(
              it_1.maxNewElementsByType, _function_5);
          };
          ObjectExtensions.<TypeScopes>operator_doubleArrow(
            it.typeScopes, _function_3);
          it.solutionScope.numberOfRequiredSolutions = 1;
          it.nameNewElements = false;
          it.typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis;
          it.stateCoderStrategy = StateCoderStrategy.Neighbourhood;
          ScopePropagatorStrategy.Polyhedral _polyhedral = new ScopePropagatorStrategy.Polyhedral(
            PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp);
          it.scopePropagatorStrategy = _polyhedral;
          it.debugConfiguration.partialInterpretatioVisualiser = null;
        };
        final ViatraReasonerConfiguration config = ObjectExtensions.<ViatraReasonerConfiguration>operator_doubleArrow(_viatraReasonerConfiguration, _function_2);
        final FileSystemWorkspace workspace = new FileSystemWorkspace("output/", "");
        final LogicResult solution = this.solver.solve(logic.getOutput(), config, workspace);
        URI _xifexpression = null;
        if ((solution instanceof ModelResult)) {
          InputOutput.<String>println("Saving generated solutions");
          final EList<Object> representations = ((ModelResult)solution).getRepresentation();
          int _size = representations.size();
          ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true);
          for (final Integer representationIndex : _doubleDotLessThan) {
            {
              final Object representation = representations.get((representationIndex).intValue());
              final int representationNumber = ((representationIndex).intValue() + 1);
              if ((representation instanceof PartialInterpretation)) {
                StringConcatenation _builder_1 = new StringConcatenation();
                _builder_1.append("solution");
                _builder_1.append(representationNumber);
                _builder_1.append(".partialinterpretation");
                workspace.writeModel(((EObject)representation), _builder_1.toString());
                final PartialInterpretation2Gml partialInterpretation2GML = new PartialInterpretation2Gml();
                final String gml = partialInterpretation2GML.transform(((PartialInterpretation)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 Consumer<Type> _function_3 = (Type it) -> {
                      InputOutput.<String>println(it.getName());
                    };
                    ((PartialInterpretation)representation).getProblem().getTypes().forEach(_function_3);
                    final Function1<Type, Boolean> _function_4 = (Type it) -> {
                      String _name_2 = it.getName();
                      return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class DefinedPart"));
                    };
                    Type _findFirst = IterableExtensions.<Type>findFirst(((PartialInterpretation)representation).getProblem().getTypes(), _function_4);
                    final TypeDefinition rootType = ((TypeDefinition) _findFirst);
                    final Function1<PartialComplexTypeInterpretation, Boolean> _function_5 = (PartialComplexTypeInterpretation it) -> {
                      String _name_2 = it.getInterpretationOf().getName();
                      return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class"));
                    };
                    final PartialComplexTypeInterpretation rootIntepretation = IterableExtensions.<PartialComplexTypeInterpretation>findFirst(Iterables.<PartialComplexTypeInterpretation>filter(((PartialInterpretation)representation).getPartialtypeinterpratation(), 
                      PartialComplexTypeInterpretation.class), _function_5);
                    rootIntepretation.getElements().removeAll(rootType.getElements());
                    ((PartialInterpretation)representation).getProblem().getElements().removeAll(rootType.getElements());
                    EList<PartialRelationInterpretation> _partialrelationinterpretation = ((PartialInterpretation)representation).getPartialrelationinterpretation();
                    for (final PartialRelationInterpretation relationInterpretation : _partialrelationinterpretation) {
                      final Predicate<RelationLink> _function_6 = (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_6);
                    }
                    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());
                }
              } 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());
              }
            }
          }
        } else {
          URI _xblockexpression_1 = null;
          {
            InputOutput.<String>println("Failed to solver problem");
            final LogicProblem partial = logic.getOutput();
            _xblockexpression_1 = workspace.writeModel(partial, "solution.partialinterpretation");
          }
          _xifexpression = _xblockexpression_1;
        }
        _xblockexpression = _xifexpression;
      }
      return _xblockexpression;
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
    }
  }
  
  public static EcoreMetamodelDescriptor createMetamodelDescriptor() {
    EcoreMetamodelDescriptor _xblockexpression = null;
    {
      final ImmutableList<EClass> eClasses = ImmutableList.<EClass>copyOf(Iterables.<EClass>filter(Modes3Package.eINSTANCE.getEClassifiers(), EClass.class));
      Set<EClass> _emptySet = CollectionLiterals.<EClass>emptySet();
      List<EEnum> _emptyList = CollectionLiterals.<EEnum>emptyList();
      List<EEnumLiteral> _emptyList_1 = CollectionLiterals.<EEnumLiteral>emptyList();
      final Function1<EClass, EList<EReference>> _function = (EClass it) -> {
        return it.getEReferences();
      };
      ImmutableList<EReference> _copyOf = ImmutableList.<EReference>copyOf(IterableExtensions.<EClass, EReference>flatMap(eClasses, _function));
      List<EAttribute> _emptyList_2 = CollectionLiterals.<EAttribute>emptyList();
      _xblockexpression = new EcoreMetamodelDescriptor(eClasses, _emptySet, 
        false, _emptyList, _emptyList_1, _copyOf, _emptyList_2);
    }
    return _xblockexpression;
  }
  
  public static List<EObject> loadInitialModel() {
    Modes3ModelRoot _createModes3ModelRoot = Modes3Factory.eINSTANCE.createModes3ModelRoot();
    return Collections.<EObject>unmodifiableList(CollectionLiterals.<EObject>newArrayList(_createModes3ModelRoot));
  }
  
  public ViatraQuerySetDescriptor loadQueries() {
    ViatraQuerySetDescriptor _xblockexpression = null;
    {
      final ImmutableList.Builder<IQuerySpecification<?>> patternsBuilder = ImmutableList.<IQuerySpecification<?>>builder();
      patternsBuilder.addAll(Modes3Queries.instance().getSpecifications());
      final ImmutableList<IQuerySpecification<?>> patterns = patternsBuilder.build();
      final Function1<IQuerySpecification<?>, Boolean> _function = (IQuerySpecification<?> pattern) -> {
        final Function1<PAnnotation, Boolean> _function_1 = (PAnnotation it) -> {
          String _name = it.getName();
          return Boolean.valueOf(Objects.equal(_name, "Constraint"));
        };
        return Boolean.valueOf(IterableExtensions.<PAnnotation>exists(pattern.getAllAnnotations(), _function_1));
      };
      final ImmutableSet<IQuerySpecification<?>> validationPatterns = ImmutableSet.<IQuerySpecification<?>>copyOf(IterableExtensions.<IQuerySpecification<?>>filter(patterns, _function));
      Map<IQuerySpecification<?>, EStructuralFeature> _emptyMap = CollectionLiterals.<IQuerySpecification<?>, EStructuralFeature>emptyMap();
      _xblockexpression = new ViatraQuerySetDescriptor(patterns, validationPatterns, _emptyMap);
    }
    return _xblockexpression;
  }
  
  public static Object init() {
    Object _xblockexpression = null;
    {
      EMFPatternLanguageStandaloneSetup.doSetup();
      ViatraQueryEngineOptions.setSystemDefaultBackends(ReteBackendFactory.INSTANCE, ReteBackendFactory.INSTANCE, 
        LocalSearchEMFBackendFactory.INSTANCE);
      LogiclanguagePackage.eINSTANCE.getClass();
      LogicproblemPackage.eINSTANCE.getClass();
      PartialinterpretationPackage.eINSTANCE.getClass();
      Ecore2logicannotationsPackage.eINSTANCE.getClass();
      Viatra2LogicAnnotationsPackage.eINSTANCE.getClass();
      Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap();
      XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl();
      _extensionToFactoryMap.put("ecore", _xMIResourceFactoryImpl);
      Map<String, Object> _extensionToFactoryMap_1 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap();
      XMIResourceFactoryImpl _xMIResourceFactoryImpl_1 = new XMIResourceFactoryImpl();
      _extensionToFactoryMap_1.put("logicproblem", _xMIResourceFactoryImpl_1);
      Map<String, Object> _extensionToFactoryMap_2 = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap();
      XMIResourceFactoryImpl _xMIResourceFactoryImpl_2 = new XMIResourceFactoryImpl();
      _xblockexpression = _extensionToFactoryMap_2.put("partialinterpretation", _xMIResourceFactoryImpl_2);
    }
    return _xblockexpression;
  }
  
  public static void main(final String[] args) {
    int _length = args.length;
    boolean _notEquals = (_length != 2);
    if (_notEquals) {
      System.err.println("Usage: <query> <model size>");
    }
    final Modes3ModelGenerator.MonitoringQuery monitoringQuery = Modes3ModelGenerator.MonitoringQuery.valueOf(args[0]);
    final int modelSize = Integer.parseInt(args[1]);
    Modes3ModelGenerator.init();
    final Modes3ModelGenerator generator = new Modes3ModelGenerator(monitoringQuery, modelSize);
    generator.generate();
  }
  
  public Modes3ModelGenerator(final Modes3ModelGenerator.MonitoringQuery monitoringQuery, final int modelSize) {
    super();
    this.monitoringQuery = monitoringQuery;
    this.modelSize = modelSize;
  }
}