diff options
151 files changed, 26066 insertions, 1170 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin index 96d7f77b..1c86e38f 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin +++ b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin | |||
Binary files differ | |||
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin index 85768640..57c8ab25 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin +++ b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin | |||
Binary files differ | |||
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ui/META-INF/MANIFEST.MF b/Application/hu.bme.mit.inf.dslreasoner.application.ui/META-INF/MANIFEST.MF index 38bb7dbd..2f2c83ef 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application.ui/META-INF/MANIFEST.MF +++ b/Application/hu.bme.mit.inf.dslreasoner.application.ui/META-INF/MANIFEST.MF | |||
@@ -22,7 +22,8 @@ Require-Bundle: hu.bme.mit.inf.dslreasoner.application, | |||
22 | org.eclipse.xtext.builder, | 22 | org.eclipse.xtext.builder, |
23 | org.eclipse.xtend.lib;bundle-version="2.14.0";resolution:=optional, | 23 | org.eclipse.xtend.lib;bundle-version="2.14.0";resolution:=optional, |
24 | org.eclipse.xtext.xbase.lib;bundle-version="2.14.0", | 24 | org.eclipse.xtext.xbase.lib;bundle-version="2.14.0", |
25 | org.eclipse.viatra.addon.validation.runtime.ui;bundle-version="1.7.0" | 25 | org.eclipse.viatra.addon.validation.runtime.ui;bundle-version="1.7.0", |
26 | org.eclipse.viatra.query.patternlanguage.emf.ui;bundle-version="2.4.1" | ||
26 | Import-Package: org.apache.log4j | 27 | Import-Package: org.apache.log4j |
27 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 | 28 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 |
28 | Export-Package: hu.bme.mit.inf.dslreasoner.application.ui.quickfix, | 29 | Export-Package: hu.bme.mit.inf.dslreasoner.application.ui.quickfix, |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ui/plugin.xml b/Application/hu.bme.mit.inf.dslreasoner.application.ui/plugin.xml index 304df098..2895983e 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application.ui/plugin.xml +++ b/Application/hu.bme.mit.inf.dslreasoner.application.ui/plugin.xml | |||
@@ -410,7 +410,7 @@ | |||
410 | <extension | 410 | <extension |
411 | point="org.eclipse.ui.commands"> | 411 | point="org.eclipse.ui.commands"> |
412 | <command | 412 | <command |
413 | defaultHandler="hu.bme.mit.inf.dslreasoner.application.ui.execute.ExecuteScriptHandler" | 413 | defaultHandler="org.eclipse.viatra.query.patternlanguage.emf.ui.ReusablePatternLanguageExecutableExtensionFactory:hu.bme.mit.inf.dslreasoner.application.ui.execute.ExecuteScriptHandler" |
414 | id="hu.bme.mit.inf.dslreasoner.application.ui.executescript" | 414 | id="hu.bme.mit.inf.dslreasoner.application.ui.executescript" |
415 | name="ExecuteScript"> | 415 | name="ExecuteScript"> |
416 | </command> | 416 | </command> |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ui/src/hu/bme/mit/inf/dslreasoner/application/ui/execute/ExecuteScriptHandler.java b/Application/hu.bme.mit.inf.dslreasoner.application.ui/src/hu/bme/mit/inf/dslreasoner/application/ui/execute/ExecuteScriptHandler.java index 380410d0..8d9d07a6 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application.ui/src/hu/bme/mit/inf/dslreasoner/application/ui/execute/ExecuteScriptHandler.java +++ b/Application/hu.bme.mit.inf.dslreasoner.application.ui/src/hu/bme/mit/inf/dslreasoner/application/ui/execute/ExecuteScriptHandler.java | |||
@@ -12,14 +12,23 @@ import org.eclipse.jface.viewers.ISelection; | |||
12 | import org.eclipse.jface.viewers.StructuredSelection; | 12 | import org.eclipse.jface.viewers.StructuredSelection; |
13 | import org.eclipse.ui.handlers.HandlerUtil; | 13 | import org.eclipse.ui.handlers.HandlerUtil; |
14 | 14 | ||
15 | import com.google.inject.Inject; | ||
16 | import com.google.inject.Injector; | ||
17 | |||
15 | import hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor; | 18 | import hu.bme.mit.inf.dslreasoner.application.execution.ScriptExecutor; |
16 | 19 | ||
17 | public class ExecuteScriptHandler extends AbstractHandler implements IHandler { | 20 | public class ExecuteScriptHandler extends AbstractHandler implements IHandler { |
18 | 21 | ||
19 | ScriptExecutor scriptExecutor = new ScriptExecutor(RuntimeConsoleBasedScriptConsole.FACTORY); | 22 | ScriptExecutor scriptExecutor; |
23 | |||
24 | @Inject | ||
25 | public void setInjector(Injector injector) { | ||
26 | scriptExecutor = new ScriptExecutor(RuntimeConsoleBasedScriptConsole.FACTORY, injector); | ||
27 | } | ||
20 | 28 | ||
21 | @Override | 29 | @Override |
22 | public Object execute(ExecutionEvent event) throws ExecutionException { | 30 | public Object execute(ExecutionEvent event) throws ExecutionException { |
31 | assert scriptExecutor != null : "Injector must be set"; | ||
23 | ISelection selection = HandlerUtil.getCurrentSelection(event); | 32 | ISelection selection = HandlerUtil.getCurrentSelection(event); |
24 | if(selection instanceof StructuredSelection) { | 33 | if(selection instanceof StructuredSelection) { |
25 | StructuredSelection structuredSelection = (StructuredSelection) selection; | 34 | StructuredSelection structuredSelection = (StructuredSelection) selection; |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/Eclipse Application.launch b/Application/hu.bme.mit.inf.dslreasoner.application/Eclipse Application.launch index 07eb0292..01894594 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/Eclipse Application.launch +++ b/Application/hu.bme.mit.inf.dslreasoner.application/Eclipse Application.launch | |||
@@ -25,8 +25,1150 @@ | |||
25 | <booleanAttribute key="pde.generated.config" value="false"/> | 25 | <booleanAttribute key="pde.generated.config" value="false"/> |
26 | <stringAttribute key="pde.version" value="3.3"/> | 26 | <stringAttribute key="pde.version" value="3.3"/> |
27 | <stringAttribute key="product" value="org.eclipse.platform.ide"/> | 27 | <stringAttribute key="product" value="org.eclipse.platform.ide"/> |
28 | <stringAttribute key="selected_target_plugins" value="com.eclipsesource.j2v8.linux_x86_64@default:default,com.github.mifmif.generex@default:default,com.google.gson@default:default,com.google.guava@default:default,com.google.inject.multibindings@default:false,com.google.inject@default:default,com.ibm.icu@default:default,com.jcraft.jsch@default:default,com.jcraft.jzlib@default:default,com.sun.el@default:default,de.tuberlin.eecs.agg@default:default,dk.brics.automaton@default:default,guru.nidi.graphviz-java@default:default,javaewah@default:default,javax.activation@default:default,javax.annotation@default:default,javax.el@default:default,javax.inject@default:default,javax.servlet.jsp@default:default,javax.servlet@default:default,javax.xml.bind@default:default,javax.xml@default:default,lpg.runtime.java@default:default,net.i2p.crypto.eddsa@default:default,org.antlr.runtime*3.2.0.v201101311130@default:default,org.antlr.runtime*4.3.0.v201502022030@default:default,org.apache.ant@default:default,org.apache.batik.bridge@default:default,org.apache.batik.constants@default:default,org.apache.batik.css*1.10.0.v20180703-1553@default:default,org.apache.batik.css*1.6.0.v201011041432@default:default,org.apache.batik.dom.svg@default:default,org.apache.batik.dom@default:default,org.apache.batik.ext.awt@default:default,org.apache.batik.i18n@default:default,org.apache.batik.parser@default:default,org.apache.batik.pdf@default:default,org.apache.batik.svggen@default:default,org.apache.batik.transcoder@default:default,org.apache.batik.util*1.10.0.v20180703-1553@default:default,org.apache.batik.util*1.6.0.v201011041432@default:default,org.apache.batik.util.gui@default:default,org.apache.batik.xml@default:default,org.apache.commons.cli@default:default,org.apache.commons.codec*1.10.0.v20180409-1845@default:default,org.apache.commons.codec*1.9.0.v20170208-1614@default:default,org.apache.commons.compress@default:default,org.apache.commons.exec@default:default,org.apache.commons.httpclient@default:default,org.apache.commons.io@default:default,org.apache.commons.jxpath@default:default,org.apache.commons.lang3@default:default,org.apache.commons.lang@default:default,org.apache.commons.logging*1.1.1.v201101211721@default:default,org.apache.commons.logging*1.2.0.v20180409-1502@default:default,org.apache.commons.math3@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.apache.felix.scr@1:true,org.apache.httpcomponents.httpclient@default:default,org.apache.httpcomponents.httpcore@default:default,org.apache.jasper.glassfish@default:default,org.apache.log4j@default:default,org.apache.lucene.analyzers-common*6.1.0.v20161115-1612@default:default,org.apache.lucene.analyzers-common*7.5.0.v20181003-1532@default:default,org.apache.lucene.analyzers-smartcn@default:default,org.apache.lucene.core*6.1.0.v20170814-1820@default:default,org.apache.lucene.core*7.5.0.v20181003-1532@default:default,org.apache.lucene.queryparser@default:default,org.apache.sshd.core@default:default,org.apache.sshd.sftp@default:default,org.apache.ws.commons.util@default:default,org.apache.xerces@default:default,org.apache.xml.resolver@default:default,org.apache.xml.serializer@default:default,org.apache.xmlgraphics@default:default,org.apache.xmlrpc@default:default,org.apiguardian@default:default,org.bouncycastle.bcpg@default:default,org.bouncycastle.bcpkix@default:default,org.bouncycastle.bcprov@default:default,org.eclipse.acceleo.annotations@default:default,org.eclipse.acceleo.query@default:default,org.eclipse.acceleo.ui.interpreter@default:default,org.eclipse.ant.core@default:default,org.eclipse.ant.launching@default:default,org.eclipse.ant.ui@default:default,org.eclipse.collections@default:default,org.eclipse.compare.core@default:default,org.eclipse.compare@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.beans@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.externaltools@default:default,org.eclipse.core.filebuffers@default:default,org.eclipse.core.filesystem.linux.x86_64@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.net.linux.x86_64@default:false,org.eclipse.core.net@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.debug.core@default:default,org.eclipse.debug.ui@default:default,org.eclipse.draw2d.doc.isv@default:default,org.eclipse.draw2d@default:default,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.annotations@default:default,org.eclipse.e4.core.di.extensions.supplier@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.emf.xpath@default:default,org.eclipse.e4.tools.compat@default:default,org.eclipse.e4.tools.emf.editor3x@default:default,org.eclipse.e4.tools.emf.ui@default:default,org.eclipse.e4.tools.jdt.templates@default:default,org.eclipse.e4.tools.services@default:default,org.eclipse.e4.tools@default:default,org.eclipse.e4.ui.bindings@default:default,org.eclipse.e4.ui.css.core@default:default,org.eclipse.e4.ui.css.swt.theme@default:default,org.eclipse.e4.ui.css.swt@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.dialogs@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.e4.ui.swt.gtk@default:false,org.eclipse.e4.ui.widgets@default:default,org.eclipse.e4.ui.workbench.addons.swt@default:default,org.eclipse.e4.ui.workbench.renderers.swt@default:default,org.eclipse.e4.ui.workbench.swt@default:default,org.eclipse.e4.ui.workbench3@default:default,org.eclipse.e4.ui.workbench@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.ecf.provider.filetransfer.httpclient4.ssl@default:false,org.eclipse.ecf.provider.filetransfer.httpclient4@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.ecf@default:default,org.eclipse.eef.common.ui@default:default,org.eclipse.eef.common@default:default,org.eclipse.eef.core.ext.widgets.reference@default:default,org.eclipse.eef.core@default:default,org.eclipse.eef.ext.widgets.reference@default:default,org.eclipse.eef.ide.ui.ext.widgets.reference@default:default,org.eclipse.eef.ide.ui.properties@default:default,org.eclipse.eef.ide.ui@default:default,org.eclipse.eef.properties.ui.legacy@default:default,org.eclipse.eef.properties.ui@default:default,org.eclipse.eef@default:default,org.eclipse.egit.core@default:default,org.eclipse.egit.doc@default:default,org.eclipse.egit.ui@default:default,org.eclipse.egit@default:default,org.eclipse.emf.ant@default:default,org.eclipse.emf.cdo.admin@default:default,org.eclipse.emf.cdo.common.db@default:default,org.eclipse.emf.cdo.common@default:default,org.eclipse.emf.cdo.compare@default:default,org.eclipse.emf.cdo.doc@default:default,org.eclipse.emf.cdo.edit@default:default,org.eclipse.emf.cdo.examples.installer@default:default,org.eclipse.emf.cdo.explorer.ui@default:default,org.eclipse.emf.cdo.explorer@default:default,org.eclipse.emf.cdo.expressions.edit@default:default,org.eclipse.emf.cdo.expressions.editor@default:default,org.eclipse.emf.cdo.expressions@default:default,org.eclipse.emf.cdo.migrator@default:default,org.eclipse.emf.cdo.net4j@default:default,org.eclipse.emf.cdo.security.edit@default:default,org.eclipse.emf.cdo.security.editor@default:default,org.eclipse.emf.cdo.security.ui@default:default,org.eclipse.emf.cdo.security@default:default,org.eclipse.emf.cdo.server.admin@default:default,org.eclipse.emf.cdo.server.db@default:default,org.eclipse.emf.cdo.server.net4j@default:default,org.eclipse.emf.cdo.server.ocl@default:default,org.eclipse.emf.cdo.server.product@default:default,org.eclipse.emf.cdo.server.security@default:default,org.eclipse.emf.cdo.server@default:default,org.eclipse.emf.cdo.transfer.repository@default:default,org.eclipse.emf.cdo.transfer.ui@default:default,org.eclipse.emf.cdo.transfer.workspace.ui@default:default,org.eclipse.emf.cdo.transfer.workspace@default:default,org.eclipse.emf.cdo.transfer@default:default,org.eclipse.emf.cdo.ui.admin@default:default,org.eclipse.emf.cdo.ui.compare@default:default,org.eclipse.emf.cdo.ui.shared@default:default,org.eclipse.emf.cdo.ui.team@default:default,org.eclipse.emf.cdo.ui@default:default,org.eclipse.emf.cdo.workspace@default:default,org.eclipse.emf.cdo@default:default,org.eclipse.emf.cheatsheets@default:default,org.eclipse.emf.codegen.ecore.ui@default:default,org.eclipse.emf.codegen.ecore@default:default,org.eclipse.emf.codegen.ui@default:default,org.eclipse.emf.codegen@default:default,org.eclipse.emf.common.ui@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.compare.diagram.edit@default:default,org.eclipse.emf.compare.diagram.ide.ui.sirius@default:default,org.eclipse.emf.compare.diagram.ide.ui@default:default,org.eclipse.emf.compare.diagram.sirius@default:default,org.eclipse.emf.compare.diagram@default:default,org.eclipse.emf.compare.doc@default:default,org.eclipse.emf.compare.edit@default:default,org.eclipse.emf.compare.egit.ui@default:default,org.eclipse.emf.compare.egit@default:default,org.eclipse.emf.compare.ide.ui@default:default,org.eclipse.emf.compare.ide@default:default,org.eclipse.emf.compare.rcp.ui@default:default,org.eclipse.emf.compare.rcp@default:default,org.eclipse.emf.compare@default:default,org.eclipse.emf.converter@default:default,org.eclipse.emf.databinding.edit@default:default,org.eclipse.emf.databinding@default:default,org.eclipse.emf.doc@default:default,org.eclipse.emf.ecore.change.edit@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.edit@default:default,org.eclipse.emf.ecore.editor@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.emf.ecoretools.design.ui@default:default,org.eclipse.emf.ecoretools.design@default:default,org.eclipse.emf.ecoretools.doc@default:default,org.eclipse.emf.ecoretools.ui@default:default,org.eclipse.emf.ecoretools@default:default,org.eclipse.emf.ecp.application.e3@default:default,org.eclipse.emf.ecp.application.e4@default:default,org.eclipse.emf.ecp.cdo.core@default:default,org.eclipse.emf.ecp.cdo.ui@default:default,org.eclipse.emf.ecp.common.ui@default:default,org.eclipse.emf.ecp.common@default:default,org.eclipse.emf.ecp.core.emffilter@default:default,org.eclipse.emf.ecp.core@default:default,org.eclipse.emf.ecp.edit.swt@default:default,org.eclipse.emf.ecp.edit@default:default,org.eclipse.emf.ecp.editor.e3@default:default,org.eclipse.emf.ecp.emf2web.json@default:default,org.eclipse.emf.ecp.emf2web.ui.json@default:default,org.eclipse.emf.ecp.emf2web.ui@default:default,org.eclipse.emf.ecp.emf2web@default:default,org.eclipse.emf.ecp.emfstore.core@default:default,org.eclipse.emf.ecp.emfstore.ui.e3@default:default,org.eclipse.emf.ecp.emfstore.ui.e4@default:default,org.eclipse.emf.ecp.emfstore.ui.search@default:default,org.eclipse.emf.ecp.emfstore.ui@default:default,org.eclipse.emf.ecp.explorereditorbridge@default:default,org.eclipse.emf.ecp.ide.editor.view.templatebridge@default:default,org.eclipse.emf.ecp.ide.editor.view@default:default,org.eclipse.emf.ecp.ide.editor.viewmodel@default:default,org.eclipse.emf.ecp.ide.util@default:default,org.eclipse.emf.ecp.ide.view.service@default:default,org.eclipse.emf.ecp.makeithappen.wizards@default:default,org.eclipse.emf.ecp.ui.e3@default:default,org.eclipse.emf.ecp.ui.e4@default:default,org.eclipse.emf.ecp.ui.rcp@default:default,org.eclipse.emf.ecp.ui.view.editor.controls@default:default,org.eclipse.emf.ecp.ui.view.linewrapper@default:default,org.eclipse.emf.ecp.ui.view.swt@default:default,org.eclipse.emf.ecp.ui.view@default:default,org.eclipse.emf.ecp.ui@default:default,org.eclipse.emf.ecp.validation.connector@default:default,org.eclipse.emf.ecp.validation@default:default,org.eclipse.emf.ecp.view.categorization.model.edit@default:default,org.eclipse.emf.ecp.view.categorization.model@default:default,org.eclipse.emf.ecp.view.categorization.swt@default:default,org.eclipse.emf.ecp.view.compoundcontrol.model.edit@default:default,org.eclipse.emf.ecp.view.compoundcontrol.model@default:default,org.eclipse.emf.ecp.view.compoundcontrol.swt@default:default,org.eclipse.emf.ecp.view.compoundcontrol.tooling@default:default,org.eclipse.emf.ecp.view.context.locale@default:default,org.eclipse.emf.ecp.view.context@default:default,org.eclipse.emf.ecp.view.control.multireference@default:default,org.eclipse.emf.ecp.view.core.swt@default:default,org.eclipse.emf.ecp.view.custom.model.edit@default:default,org.eclipse.emf.ecp.view.custom.model@default:default,org.eclipse.emf.ecp.view.custom.ui.swt@default:default,org.eclipse.emf.ecp.view.edapt@default:default,org.eclipse.emf.ecp.view.group.model.edit@default:default,org.eclipse.emf.ecp.view.group.model@default:default,org.eclipse.emf.ecp.view.group.swt.collapsable@default:default,org.eclipse.emf.ecp.view.group.swt.embedded@default:default,org.eclipse.emf.ecp.view.group.ui.swt@default:default,org.eclipse.emf.ecp.view.horizontal.model.edit@default:default,org.eclipse.emf.ecp.view.horizontal.model@default:default,org.eclipse.emf.ecp.view.horizontal.ui.swt@default:default,org.eclipse.emf.ecp.view.indexdmr.model@default:default,org.eclipse.emf.ecp.view.label.model.edit@default:default,org.eclipse.emf.ecp.view.label.model@default:default,org.eclipse.emf.ecp.view.label.ui.swt@default:default,org.eclipse.emf.ecp.view.mappingdmr.model@default:default,org.eclipse.emf.ecp.view.migrator@default:default,org.eclipse.emf.ecp.view.model.common@default:default,org.eclipse.emf.ecp.view.model.edapt@default:default,org.eclipse.emf.ecp.view.model.edit@default:default,org.eclipse.emf.ecp.view.model.editor@default:default,org.eclipse.emf.ecp.view.model.preview.common@default:default,org.eclipse.emf.ecp.view.model.preview.e3@default:default,org.eclipse.emf.ecp.view.model.project.installer@default:default,org.eclipse.emf.ecp.view.model.provider.generator@default:default,org.eclipse.emf.ecp.view.model.provider.xmi@default:default,org.eclipse.emf.ecp.view.model@default:default,org.eclipse.emf.ecp.view.rule.model.edit@default:default,org.eclipse.emf.ecp.view.rule.model@default:default,org.eclipse.emf.ecp.view.rule@default:default,org.eclipse.emf.ecp.view.stack.model.edit@default:default,org.eclipse.emf.ecp.view.stack.model@default:default,org.eclipse.emf.ecp.view.stack.ui.swt@default:default,org.eclipse.emf.ecp.view.stack.viewmodel@default:default,org.eclipse.emf.ecp.view.swt.layout@default:default,org.eclipse.emf.ecp.view.table.columnservice@default:default,org.eclipse.emf.ecp.view.table.edapt@default:default,org.eclipse.emf.ecp.view.table.model.edit@default:default,org.eclipse.emf.ecp.view.table.model@default:default,org.eclipse.emf.ecp.view.table.ui.swt@default:default,org.eclipse.emf.ecp.view.template.annotation.model.edit@default:default,org.eclipse.emf.ecp.view.template.annotation.model@default:default,org.eclipse.emf.ecp.view.template.model.edit@default:default,org.eclipse.emf.ecp.view.template.model@default:default,org.eclipse.emf.ecp.view.template.service@default:default,org.eclipse.emf.ecp.view.template.tooling@default:default,org.eclipse.emf.ecp.view.treemasterdetail.model.edit@default:default,org.eclipse.emf.ecp.view.treemasterdetail.model@default:default,org.eclipse.emf.ecp.view.treemasterdetail.ui.swt@default:default,org.eclipse.emf.ecp.view.treemasterdetail.validation@default:default,org.eclipse.emf.ecp.view.unset@default:default,org.eclipse.emf.ecp.view.util.swt@default:default,org.eclipse.emf.ecp.view.validation@default:default,org.eclipse.emf.ecp.view.vertical.model.edit@default:default,org.eclipse.emf.ecp.view.vertical.model@default:default,org.eclipse.emf.ecp.view.vertical.ui.swt@default:default,org.eclipse.emf.ecp.view.viewproxy.model.edit@default:default,org.eclipse.emf.ecp.view.viewproxy.model@default:default,org.eclipse.emf.ecp.view.workspace.migrator@default:default,org.eclipse.emf.ecp.workspace.core@default:default,org.eclipse.emf.ecp.workspace.ui@default:default,org.eclipse.emf.edapt.common@default:default,org.eclipse.emf.edapt.declaration@default:default,org.eclipse.emf.edapt.history@default:default,org.eclipse.emf.edapt.migration@default:default,org.eclipse.emf.edit.ui@default:default,org.eclipse.emf.edit@default:default,org.eclipse.emf.emfstore.client.model.edit@default:default,org.eclipse.emf.emfstore.client.ui.rcp@default:false,org.eclipse.emf.emfstore.client.ui@default:default,org.eclipse.emf.emfstore.client@default:default,org.eclipse.emf.emfstore.common.model.edit@default:default,org.eclipse.emf.emfstore.common.model@default:default,org.eclipse.emf.emfstore.common@default:default,org.eclipse.emf.emfstore.example.installer@default:default,org.eclipse.emf.emfstore.examplemodel.edit@default:default,org.eclipse.emf.emfstore.examplemodel@default:default,org.eclipse.emf.emfstore.migration@default:default,org.eclipse.emf.emfstore.server.model.edit@default:default,org.eclipse.emf.emfstore.server.model@default:default,org.eclipse.emf.emfstore.server@default:default,org.eclipse.emf.example.installer@default:default,org.eclipse.emf.exporter@default:default,org.eclipse.emf.henshin.diagram@default:default,org.eclipse.emf.henshin.edit@default:default,org.eclipse.emf.henshin.editor@default:default,org.eclipse.emf.henshin.examples@default:default,org.eclipse.emf.henshin.giraph@default:default,org.eclipse.emf.henshin.interpreter.ui@default:default,org.eclipse.emf.henshin.interpreter@default:default,org.eclipse.emf.henshin.model@default:default,org.eclipse.emf.henshin.multicda.cda@default:default,org.eclipse.emf.henshin.multicda.cpa.ui@default:default,org.eclipse.emf.henshin.multicda.cpa@default:default,org.eclipse.emf.henshin.rulegen.ui@default:default,org.eclipse.emf.henshin.rulegen@default:default,org.eclipse.emf.henshin.statespace.explorer@default:default,org.eclipse.emf.henshin.statespace.external@default:default,org.eclipse.emf.henshin.statespace@default:default,org.eclipse.emf.henshin.text.ide@default:default,org.eclipse.emf.henshin.text.transformation@default:default,org.eclipse.emf.henshin.text.ui@default:default,org.eclipse.emf.henshin.text@default:default,org.eclipse.emf.henshin.trace@default:default,org.eclipse.emf.henshin.wrap@default:default,org.eclipse.emf.importer.ecore@default:default,org.eclipse.emf.importer.java@default:default,org.eclipse.emf.importer.rose@default:default,org.eclipse.emf.importer@default:default,org.eclipse.emf.mapping.ecore.editor@default:default,org.eclipse.emf.mapping.ecore2ecore.editor@default:default,org.eclipse.emf.mapping.ecore2ecore@default:default,org.eclipse.emf.mapping.ecore2xml.ui@default:default,org.eclipse.emf.mapping.ecore2xml@default:default,org.eclipse.emf.mapping.ecore@default:default,org.eclipse.emf.mapping.ui@default:default,org.eclipse.emf.mapping.xsd2ecore.editor@default:default,org.eclipse.emf.mapping.xsd2ecore@default:default,org.eclipse.emf.mapping@default:default,org.eclipse.emf.mwe.core@default:default,org.eclipse.emf.mwe.utils@default:default,org.eclipse.emf.mwe2.language.ide@default:default,org.eclipse.emf.mwe2.language.ui@default:default,org.eclipse.emf.mwe2.language@default:default,org.eclipse.emf.mwe2.launch.ui@default:default,org.eclipse.emf.mwe2.launch@default:default,org.eclipse.emf.mwe2.lib@default:default,org.eclipse.emf.mwe2.runtime@default:default,org.eclipse.emf.parsley.cdo.common@default:default,org.eclipse.emf.parsley.cdo@default:default,org.eclipse.emf.parsley.common@default:default,org.eclipse.emf.parsley.doc@default:default,org.eclipse.emf.parsley.dsl.additional.builder@default:default,org.eclipse.emf.parsley.dsl.ide@default:default,org.eclipse.emf.parsley.dsl.ui@default:default,org.eclipse.emf.parsley.dsl@default:default,org.eclipse.emf.parsley.editors.common@default:default,org.eclipse.emf.parsley.editors@default:default,org.eclipse.emf.parsley.generator.common@default:default,org.eclipse.emf.parsley.junit4@default:default,org.eclipse.emf.parsley.runtime.common@default:default,org.eclipse.emf.parsley.runtime@default:default,org.eclipse.emf.parsley.ui.examples@default:default,org.eclipse.emf.parsley.views.common@default:default,org.eclipse.emf.parsley.views@default:default,org.eclipse.emf.parsley.wizards@default:default,org.eclipse.emf.parsley@default:default,org.eclipse.emf.query.doc@default:default,org.eclipse.emf.query.examples@default:default,org.eclipse.emf.query.ocl@default:default,org.eclipse.emf.query@default:default,org.eclipse.emf.transaction.doc@default:default,org.eclipse.emf.transaction.examples@default:default,org.eclipse.emf.transaction.ui@default:default,org.eclipse.emf.transaction@default:default,org.eclipse.emf.validation.doc@default:default,org.eclipse.emf.validation.examples@default:default,org.eclipse.emf.validation.ocl@default:default,org.eclipse.emf.validation.ui.ide@default:default,org.eclipse.emf.validation.ui@default:default,org.eclipse.emf.validation@default:default,org.eclipse.emf.workspace.doc@default:default,org.eclipse.emf.workspace.ui@default:default,org.eclipse.emf.workspace@default:default,org.eclipse.emf@default:default,org.eclipse.emfforms.coffee.wizards@default:default,org.eclipse.emfforms.common.validation@default:default,org.eclipse.emfforms.common@default:default,org.eclipse.emfforms.core.bazaar@default:default,org.eclipse.emfforms.core.services.databinding.featurepath@default:default,org.eclipse.emfforms.core.services.databinding.index@default:default,org.eclipse.emfforms.core.services.databinding.mapping@default:default,org.eclipse.emfforms.core.services.domainexpander.default@default:default,org.eclipse.emfforms.core.services.domainexpander.index@default:default,org.eclipse.emfforms.core.services.domainexpander.mapping@default:default,org.eclipse.emfforms.core.services.domainexpander.table@default:default,org.eclipse.emfforms.core.services.editsupport@default:default,org.eclipse.emfforms.core.services.emf@default:default,org.eclipse.emfforms.core.services.emfspecificservice@default:default,org.eclipse.emfforms.core.services.legacy@default:default,org.eclipse.emfforms.core.services.locale.default@default:default,org.eclipse.emfforms.core.services.mappingprovider.default@default:default,org.eclipse.emfforms.core.services.mappingprovider.table.panel@default:default,org.eclipse.emfforms.core.services.mappingprovider.table@default:default,org.eclipse.emfforms.core.services.segments.featurepath@default:default,org.eclipse.emfforms.core.services.segments.index@default:default,org.eclipse.emfforms.core.services.segments.mapping@default:default,org.eclipse.emfforms.core.services.segments.multi@default:default,org.eclipse.emfforms.core.services.segments@default:default,org.eclipse.emfforms.core.services.structuralchange.default@default:default,org.eclipse.emfforms.core.services.structuralchange.index@default:default,org.eclipse.emfforms.core.services.structuralchange.mapping@default:default,org.eclipse.emfforms.core.services.structuralchange.table@default:default,org.eclipse.emfforms.core.services.structuralchange@default:default,org.eclipse.emfforms.core.services@default:default,org.eclipse.emfforms.editor.ecore@default:default,org.eclipse.emfforms.editor.genmodel@default:default,org.eclipse.emfforms.editor@default:default,org.eclipse.emfforms.example.common.wizards@default:default,org.eclipse.emfforms.ide.builder@default:default,org.eclipse.emfforms.ide.viewtemplate.builder@default:default,org.eclipse.emfforms.localization@default:default,org.eclipse.emfforms.setup.base@default:default,org.eclipse.emfforms.swt.control.multiattribute@default:default,org.eclipse.emfforms.swt.core.di.extension@default:default,org.eclipse.emfforms.swt.core.di@default:default,org.eclipse.emfforms.swt.core.plugin@default:default,org.eclipse.emfforms.swt.core@default:default,org.eclipse.emfforms.swt.table@default:default,org.eclipse.emfforms.swt.treemasterdetail.decorator.validation.default@default:default,org.eclipse.emfforms.swt.treemasterdetail@default:default,org.eclipse.emfforms.view.annotation.model.edit@default:default,org.eclipse.emfforms.view.annotation.model@default:default,org.eclipse.emfforms.view.indexsegment.model@default:default,org.eclipse.emfforms.view.mappingsegment.model@default:default,org.eclipse.emfforms.view.model.localization@default:default,org.eclipse.emfforms.view.multisegment.model.edit@default:default,org.eclipse.emfforms.view.multisegment.model@default:default,org.eclipse.epp.logging.aeri.core@default:default,org.eclipse.epp.logging.aeri.ide@default:default,org.eclipse.epp.mpc.core@default:default,org.eclipse.epp.mpc.help.ui@default:default,org.eclipse.epp.mpc.ui.css@default:default,org.eclipse.epp.mpc.ui@default:default,org.eclipse.epp.package.common@default:default,org.eclipse.epp.package.modeling@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.bidi@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.concurrent@default:default,org.eclipse.equinox.console@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.http.jetty@default:default,org.eclipse.equinox.http.registry@default:default,org.eclipse.equinox.http.servlet@default:default,org.eclipse.equinox.jsp.jasper.registry@default:default,org.eclipse.equinox.jsp.jasper@default:default,org.eclipse.equinox.launcher.gtk.linux.x86_64@default:false,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.p2.console@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.director.app@default:default,org.eclipse.equinox.p2.director@default:default,org.eclipse.equinox.p2.directorywatcher@default:default,org.eclipse.equinox.p2.discovery.compatibility@default:default,org.eclipse.equinox.p2.discovery@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.p2.extensionlocation@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.operations@default:default,org.eclipse.equinox.p2.publisher.eclipse@default:default,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.equinox.p2.reconciler.dropins@default:default,org.eclipse.equinox.p2.repository.tools@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.equinox.p2.transport.ecf@default:default,org.eclipse.equinox.p2.ui.discovery@default:default,org.eclipse.equinox.p2.ui.importexport@default:default,org.eclipse.equinox.p2.ui.sdk.scheduler@default:default,org.eclipse.equinox.p2.ui.sdk@default:default,org.eclipse.equinox.p2.ui@default:default,org.eclipse.equinox.p2.updatechecker@default:default,org.eclipse.equinox.p2.updatesite@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.security.linux.x86_64@default:false,org.eclipse.equinox.security.ui@default:default,org.eclipse.equinox.security@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.equinox.util@default:default,org.eclipse.fx.osgi@default:false,org.eclipse.gef.common@default:default,org.eclipse.gef.doc.isv@default:default,org.eclipse.gef.examples.ui.pde@default:default,org.eclipse.gef.fx.swt@default:default,org.eclipse.gef.fx@default:default,org.eclipse.gef.geometry.convert.fx@default:default,org.eclipse.gef.geometry@default:default,org.eclipse.gef.graph@default:default,org.eclipse.gef.layout@default:default,org.eclipse.gef.mvc.fx@default:default,org.eclipse.gef.zest.fx.jface@default:default,org.eclipse.gef.zest.fx@default:default,org.eclipse.gef@default:default,org.eclipse.gmf.examples.runtime.diagram.geoshapes@default:default,org.eclipse.gmf.examples.runtime.diagram.logic.model.edit@default:default,org.eclipse.gmf.examples.runtime.diagram.logic.model.editor@default:default,org.eclipse.gmf.examples.runtime.diagram.logic.model@default:default,org.eclipse.gmf.examples.runtime.diagram.logic@default:default,org.eclipse.gmf.examples.runtime.ui.pde@default:default,org.eclipse.gmf.examples.runtime@default:default,org.eclipse.gmf.runtime.common.core@default:default,org.eclipse.gmf.runtime.common.ui.action.ide@default:default,org.eclipse.gmf.runtime.common.ui.action@default:default,org.eclipse.gmf.runtime.common.ui.printing.win32@default:false,org.eclipse.gmf.runtime.common.ui.printing@default:default,org.eclipse.gmf.runtime.common.ui.services.action@default:default,org.eclipse.gmf.runtime.common.ui.services.dnd.ide@default:default,org.eclipse.gmf.runtime.common.ui.services.dnd@default:default,org.eclipse.gmf.runtime.common.ui.services.properties@default:default,org.eclipse.gmf.runtime.common.ui.services@default:default,org.eclipse.gmf.runtime.common.ui@default:default,org.eclipse.gmf.runtime.diagram.core@default:default,org.eclipse.gmf.runtime.diagram.ui.actions@default:default,org.eclipse.gmf.runtime.diagram.ui.dnd@default:default,org.eclipse.gmf.runtime.diagram.ui.geoshapes@default:default,org.eclipse.gmf.runtime.diagram.ui.printing.render@default:default,org.eclipse.gmf.runtime.diagram.ui.printing@default:default,org.eclipse.gmf.runtime.diagram.ui.properties@default:default,org.eclipse.gmf.runtime.diagram.ui.providers.ide@default:default,org.eclipse.gmf.runtime.diagram.ui.providers@default:default,org.eclipse.gmf.runtime.diagram.ui.render@default:default,org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide@default:default,org.eclipse.gmf.runtime.diagram.ui.resources.editor@default:default,org.eclipse.gmf.runtime.diagram.ui@default:default,org.eclipse.gmf.runtime.draw2d.ui.render.awt@default:default,org.eclipse.gmf.runtime.draw2d.ui.render@default:default,org.eclipse.gmf.runtime.draw2d.ui@default:default,org.eclipse.gmf.runtime.emf.clipboard.core@default:default,org.eclipse.gmf.runtime.emf.commands.core@default:default,org.eclipse.gmf.runtime.emf.core@default:default,org.eclipse.gmf.runtime.emf.type.core@default:default,org.eclipse.gmf.runtime.emf.type.ui@default:default,org.eclipse.gmf.runtime.emf.ui.properties@default:default,org.eclipse.gmf.runtime.emf.ui@default:default,org.eclipse.gmf.runtime.gef.ui@default:default,org.eclipse.gmf.runtime.notation.edit@default:default,org.eclipse.gmf.runtime.notation.providers@default:default,org.eclipse.gmf.runtime.notation.sdk@default:default,org.eclipse.gmf.runtime.notation@default:default,org.eclipse.gmf.runtime.sdk@default:default,org.eclipse.gmf@default:default,org.eclipse.help.base@default:default,org.eclipse.help.ui@default:default,org.eclipse.help.webapp@default:default,org.eclipse.help@default:default,org.eclipse.jdt.annotation*1.1.400.v20180921-1416@default:default,org.eclipse.jdt.annotation*2.2.200.v20180921-1416@default:default,org.eclipse.jdt.apt.core@default:default,org.eclipse.jdt.apt.pluggable.core@default:default,org.eclipse.jdt.apt.ui@default:default,org.eclipse.jdt.compiler.apt@default:false,org.eclipse.jdt.compiler.tool@default:false,org.eclipse.jdt.core.manipulation@default:default,org.eclipse.jdt.core@default:default,org.eclipse.jdt.debug.ui@default:default,org.eclipse.jdt.debug@default:default,org.eclipse.jdt.doc.isv@default:default,org.eclipse.jdt.doc.user@default:default,org.eclipse.jdt.junit.core@default:default,org.eclipse.jdt.junit.runtime@default:default,org.eclipse.jdt.junit4.runtime@default:default,org.eclipse.jdt.junit5.runtime@default:default,org.eclipse.jdt.junit@default:default,org.eclipse.jdt.launching@default:default,org.eclipse.jdt.ui@default:default,org.eclipse.jdt@default:default,org.eclipse.jem.util@default:default,org.eclipse.jetty.continuation@default:default,org.eclipse.jetty.http@default:default,org.eclipse.jetty.io@default:default,org.eclipse.jetty.security@default:default,org.eclipse.jetty.server@default:default,org.eclipse.jetty.servlet@default:default,org.eclipse.jetty.util@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.jface.text@default:default,org.eclipse.jface@default:default,org.eclipse.jgit.archive@default:default,org.eclipse.jgit.ssh.apache@default:default,org.eclipse.jgit@default:default,org.eclipse.jsch.core@default:default,org.eclipse.jsch.ui@default:default,org.eclipse.ltk.core.refactoring@default:default,org.eclipse.ltk.ui.refactoring@default:default,org.eclipse.m2e.archetype.common@default:default,org.eclipse.m2e.core.ui@default:default,org.eclipse.m2e.core@default:default,org.eclipse.m2e.launching@default:default,org.eclipse.m2e.maven.indexer@default:default,org.eclipse.m2e.maven.runtime.slf4j.simple@default:default,org.eclipse.m2e.maven.runtime@default:default,org.eclipse.m2e.model.edit@default:default,org.eclipse.m2e.workspace.cli@default:default,org.eclipse.m2m.qvt.oml.common@default:default,org.eclipse.m2m.qvt.oml.cst.parser@default:default,org.eclipse.m2m.qvt.oml.ecore.imperativeocl@default:default,org.eclipse.m2m.qvt.oml.emf.util@default:default,org.eclipse.m2m.qvt.oml@default:default,org.eclipse.mylyn.bugzilla.core@default:default,org.eclipse.mylyn.bugzilla.ide@default:default,org.eclipse.mylyn.bugzilla.ui@default:default,org.eclipse.mylyn.commons.core@default:default,org.eclipse.mylyn.commons.identity.core@default:default,org.eclipse.mylyn.commons.net@default:default,org.eclipse.mylyn.commons.notifications.core@default:default,org.eclipse.mylyn.commons.notifications.feed@default:default,org.eclipse.mylyn.commons.notifications.ui@default:default,org.eclipse.mylyn.commons.repositories.core@default:default,org.eclipse.mylyn.commons.repositories.ui@default:default,org.eclipse.mylyn.commons.screenshots@default:default,org.eclipse.mylyn.commons.ui@default:default,org.eclipse.mylyn.commons.workbench@default:default,org.eclipse.mylyn.commons.xmlrpc@default:default,org.eclipse.mylyn.context.core@default:default,org.eclipse.mylyn.context.tasks.ui@default:default,org.eclipse.mylyn.context.ui@default:default,org.eclipse.mylyn.debug.ui@default:default,org.eclipse.mylyn.discovery.core@default:default,org.eclipse.mylyn.discovery.ui@default:default,org.eclipse.mylyn.help.ui@default:default,org.eclipse.mylyn.ide.ant@default:default,org.eclipse.mylyn.ide.ui@default:default,org.eclipse.mylyn.java.tasks@default:default,org.eclipse.mylyn.java.ui@default:default,org.eclipse.mylyn.monitor.core@default:default,org.eclipse.mylyn.monitor.ui@default:default,org.eclipse.mylyn.pde.ui@default:default,org.eclipse.mylyn.resources.ui@default:default,org.eclipse.mylyn.tasks.bugs@default:default,org.eclipse.mylyn.tasks.core@default:default,org.eclipse.mylyn.tasks.index.core@default:default,org.eclipse.mylyn.tasks.index.ui@default:default,org.eclipse.mylyn.tasks.search@default:default,org.eclipse.mylyn.tasks.ui@default:default,org.eclipse.mylyn.team.ui@default:default,org.eclipse.mylyn.wikitext.ant@default:default,org.eclipse.mylyn.wikitext.asciidoc.ui@default:default,org.eclipse.mylyn.wikitext.asciidoc@default:default,org.eclipse.mylyn.wikitext.confluence.ui@default:default,org.eclipse.mylyn.wikitext.confluence@default:default,org.eclipse.mylyn.wikitext.context.ui@default:default,org.eclipse.mylyn.wikitext.help.ui@default:default,org.eclipse.mylyn.wikitext.html@default:default,org.eclipse.mylyn.wikitext.markdown.ui@default:default,org.eclipse.mylyn.wikitext.markdown@default:default,org.eclipse.mylyn.wikitext.mediawiki.ui@default:default,org.eclipse.mylyn.wikitext.mediawiki@default:default,org.eclipse.mylyn.wikitext.osgi@default:default,org.eclipse.mylyn.wikitext.tasks.ui@default:default,org.eclipse.mylyn.wikitext.textile.ui@default:default,org.eclipse.mylyn.wikitext.textile@default:default,org.eclipse.mylyn.wikitext.tracwiki.ui@default:default,org.eclipse.mylyn.wikitext.tracwiki@default:default,org.eclipse.mylyn.wikitext.twiki.ui@default:default,org.eclipse.mylyn.wikitext.twiki@default:default,org.eclipse.mylyn.wikitext.ui@default:default,org.eclipse.mylyn.wikitext@default:default,org.eclipse.nebula.widgets.tablecombo@default:default,org.eclipse.net4j.db.h2@default:default,org.eclipse.net4j.db.jdbc@default:default,org.eclipse.net4j.db@default:default,org.eclipse.net4j.debug@default:default,org.eclipse.net4j.examples.installer@default:default,org.eclipse.net4j.http.common@default:default,org.eclipse.net4j.http.server@default:default,org.eclipse.net4j.http@default:default,org.eclipse.net4j.jvm@default:default,org.eclipse.net4j.tcp@default:default,org.eclipse.net4j.ui.shared@default:default,org.eclipse.net4j.ui@default:default,org.eclipse.net4j.util.ui@default:default,org.eclipse.net4j.util@default:default,org.eclipse.net4j@default:default,org.eclipse.ocl.common.ui@default:default,org.eclipse.ocl.common@default:default,org.eclipse.ocl.doc@default:default,org.eclipse.ocl.ecore.edit@default:default,org.eclipse.ocl.ecore@default:default,org.eclipse.ocl.edit@default:default,org.eclipse.ocl.ui@default:default,org.eclipse.ocl.uml.edit@default:default,org.eclipse.ocl.uml.ui@default:default,org.eclipse.ocl.uml@default:default,org.eclipse.ocl@default:default,org.eclipse.oomph.base.edit@default:default,org.eclipse.oomph.base@default:default,org.eclipse.oomph.extractor.lib@default:default,org.eclipse.oomph.jreinfo.ui@default:default,org.eclipse.oomph.jreinfo@default:default,org.eclipse.oomph.p2.core@default:default,org.eclipse.oomph.p2.doc@default:default,org.eclipse.oomph.p2.edit@default:default,org.eclipse.oomph.p2.ui@default:default,org.eclipse.oomph.p2@default:default,org.eclipse.oomph.predicates.edit@default:default,org.eclipse.oomph.predicates@default:default,org.eclipse.oomph.preferences@default:default,org.eclipse.oomph.resources.edit@default:default,org.eclipse.oomph.resources@default:default,org.eclipse.oomph.setup.core@default:default,org.eclipse.oomph.setup.doc@default:default,org.eclipse.oomph.setup.edit@default:default,org.eclipse.oomph.setup.editor@default:default,org.eclipse.oomph.setup.p2.edit@default:default,org.eclipse.oomph.setup.p2@default:default,org.eclipse.oomph.setup.sync@default:default,org.eclipse.oomph.setup.ui.questionnaire@default:default,org.eclipse.oomph.setup.ui@default:default,org.eclipse.oomph.setup@default:default,org.eclipse.oomph.ui@default:default,org.eclipse.oomph.util@default:default,org.eclipse.oomph.workingsets.edit@default:default,org.eclipse.oomph.workingsets.editor@default:default,org.eclipse.oomph.workingsets@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi.util@default:default,org.eclipse.osgi@-1:true,org.eclipse.papyrus.infra.gmfdiag.tooling.runtime@default:default,org.eclipse.pde.api.tools.annotations@default:default,org.eclipse.pde.api.tools.ui@default:default,org.eclipse.pde.api.tools@default:default,org.eclipse.pde.build@default:default,org.eclipse.pde.core@default:default,org.eclipse.pde.doc.user@default:default,org.eclipse.pde.ds.annotations@default:default,org.eclipse.pde.ds.core@default:default,org.eclipse.pde.ds.lib@default:default,org.eclipse.pde.ds.ui@default:default,org.eclipse.pde.ds1_2.lib@default:default,org.eclipse.pde.genericeditor.extension@default:default,org.eclipse.pde.junit.runtime@default:default,org.eclipse.pde.launching@default:default,org.eclipse.pde.runtime@default:default,org.eclipse.pde.ua.core@default:default,org.eclipse.pde.ua.ui@default:default,org.eclipse.pde.ui.templates@default:default,org.eclipse.pde.ui@default:default,org.eclipse.pde@default:default,org.eclipse.platform.doc.isv@default:default,org.eclipse.platform.doc.user@default:default,org.eclipse.platform@default:default,org.eclipse.rcp@default:default,org.eclipse.sdk@default:default,org.eclipse.search@default:default,org.eclipse.sirius.common.acceleo.aql@default:default,org.eclipse.sirius.common.interpreter@default:default,org.eclipse.sirius.common.ui.ext@default:default,org.eclipse.sirius.common.ui@default:default,org.eclipse.sirius.common.xtext@default:default,org.eclipse.sirius.common@default:default,org.eclipse.sirius.diagram.formatdata@default:default,org.eclipse.sirius.diagram.layoutdata@default:default,org.eclipse.sirius.diagram.sequence.edit@default:default,org.eclipse.sirius.diagram.sequence.ui@default:default,org.eclipse.sirius.diagram.sequence@default:default,org.eclipse.sirius.diagram.ui.ext@default:default,org.eclipse.sirius.diagram.ui@default:default,org.eclipse.sirius.diagram@default:default,org.eclipse.sirius.ecore.extender@default:default,org.eclipse.sirius.editor.properties.ext.widgets.reference@default:default,org.eclipse.sirius.editor.properties@default:default,org.eclipse.sirius.editor@default:default,org.eclipse.sirius.ext.base@default:default,org.eclipse.sirius.ext.draw2d@default:default,org.eclipse.sirius.ext.e3.ui@default:default,org.eclipse.sirius.ext.e3@default:default,org.eclipse.sirius.ext.emf.edit@default:default,org.eclipse.sirius.ext.emf.tx@default:default,org.eclipse.sirius.ext.emf.ui@default:default,org.eclipse.sirius.ext.emf@default:default,org.eclipse.sirius.ext.gef@default:default,org.eclipse.sirius.ext.gmf.notation@default:default,org.eclipse.sirius.ext.gmf.runtime@default:default,org.eclipse.sirius.ext.ide@default:default,org.eclipse.sirius.ext.jface@default:default,org.eclipse.sirius.ext.swt@default:default,org.eclipse.sirius.interpreter@default:default,org.eclipse.sirius.properties.core@default:default,org.eclipse.sirius.properties.defaultrules@default:default,org.eclipse.sirius.properties.edit@default:default,org.eclipse.sirius.properties.ext.widgets.reference.edit@default:default,org.eclipse.sirius.properties.ext.widgets.reference@default:default,org.eclipse.sirius.properties@default:default,org.eclipse.sirius.synchronizer@default:default,org.eclipse.sirius.table.ui.ext@default:default,org.eclipse.sirius.table.ui@default:default,org.eclipse.sirius.table@default:default,org.eclipse.sirius.tree.ui.ext@default:default,org.eclipse.sirius.tree.ui@default:default,org.eclipse.sirius.tree@default:default,org.eclipse.sirius.ui.editor@default:default,org.eclipse.sirius.ui.ext@default:default,org.eclipse.sirius.ui.properties.ext.widgets.reference@default:default,org.eclipse.sirius.ui.properties@default:default,org.eclipse.sirius.ui@default:default,org.eclipse.sirius@default:default,org.eclipse.swt.gtk.linux.x86_64@default:false,org.eclipse.swt@default:default,org.eclipse.team.core@default:default,org.eclipse.team.genericeditor.diff.extension@default:default,org.eclipse.team.ui@default:default,org.eclipse.text@default:default,org.eclipse.tips.core@default:default,org.eclipse.tips.ide@default:default,org.eclipse.tips.json@default:default,org.eclipse.tips.ui@default:default,org.eclipse.tools.layout.spy@default:default,org.eclipse.ui.browser@default:default,org.eclipse.ui.cheatsheets@default:default,org.eclipse.ui.console@default:default,org.eclipse.ui.editors@default:default,org.eclipse.ui.externaltools@default:default,org.eclipse.ui.forms@default:default,org.eclipse.ui.genericeditor@default:default,org.eclipse.ui.ide.application@default:default,org.eclipse.ui.ide@default:default,org.eclipse.ui.intro.quicklinks@default:default,org.eclipse.ui.intro.universal@default:default,org.eclipse.ui.intro@default:default,org.eclipse.ui.monitoring@default:default,org.eclipse.ui.navigator.resources@default:default,org.eclipse.ui.navigator@default:default,org.eclipse.ui.net@default:default,org.eclipse.ui.themes@default:default,org.eclipse.ui.trace@default:default,org.eclipse.ui.views.log@default:default,org.eclipse.ui.views.properties.tabbed@default:default,org.eclipse.ui.views@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ui@default:default,org.eclipse.uml2.ant@default:default,org.eclipse.uml2.codegen.ecore.ui@default:default,org.eclipse.uml2.codegen.ecore@default:default,org.eclipse.uml2.common.edit@default:default,org.eclipse.uml2.common@default:default,org.eclipse.uml2.doc@default:default,org.eclipse.uml2.examples.uml.ui@default:default,org.eclipse.uml2.examples@default:default,org.eclipse.uml2.types@default:default,org.eclipse.uml2.uml.ecore.exporter@default:default,org.eclipse.uml2.uml.ecore.importer@default:default,org.eclipse.uml2.uml.edit@default:default,org.eclipse.uml2.uml.editor@default:default,org.eclipse.uml2.uml.profile.standard@default:default,org.eclipse.uml2.uml.resources@default:default,org.eclipse.uml2.uml.validation@default:default,org.eclipse.uml2.uml@default:default,org.eclipse.uml2@default:default,org.eclipse.update.configurator@3:true,org.eclipse.urischeme@default:default,org.eclipse.userstorage.oauth@default:default,org.eclipse.userstorage.ui@default:default,org.eclipse.userstorage@default:default,org.eclipse.viatra.addon.databinding.runtime.validation@default:false,org.eclipse.viatra.addon.databinding.runtime@default:default,org.eclipse.viatra.addon.querybasedfeatures.runtime.validation@default:false,org.eclipse.viatra.addon.querybasedfeatures.runtime@default:default,org.eclipse.viatra.addon.querybasedfeatures.tooling@default:default,org.eclipse.viatra.addon.validation.core@default:default,org.eclipse.viatra.addon.validation.runtime.ui@default:default,org.eclipse.viatra.addon.validation.runtime.validation@default:false,org.eclipse.viatra.addon.validation.runtime@default:default,org.eclipse.viatra.addon.validation.tooling@default:default,org.eclipse.viatra.addon.viewers.runtime.validation@default:false,org.eclipse.viatra.addon.viewers.runtime.zest@default:default,org.eclipse.viatra.addon.viewers.runtime@default:default,org.eclipse.viatra.addon.viewers.tooling.ui.zest@default:default,org.eclipse.viatra.addon.viewers.tooling.ui@default:default,org.eclipse.viatra.documentation.help@default:default,org.eclipse.viatra.dse.genetic@default:default,org.eclipse.viatra.dse@default:default,org.eclipse.viatra.integration.zest@default:default,org.eclipse.viatra.query.patternlanguage.emf.ide@default:default,org.eclipse.viatra.query.patternlanguage.emf.ui@default:default,org.eclipse.viatra.query.patternlanguage.emf@default:default,org.eclipse.viatra.query.runtime.base.itc@default:default,org.eclipse.viatra.query.runtime.base@default:default,org.eclipse.viatra.query.runtime.localsearch@default:default,org.eclipse.viatra.query.runtime.matchers@default:default,org.eclipse.viatra.query.runtime.rete.recipes@default:default,org.eclipse.viatra.query.runtime.rete@default:default,org.eclipse.viatra.query.runtime.ui@default:default,org.eclipse.viatra.query.runtime@default:default,org.eclipse.viatra.query.testing.core@default:default,org.eclipse.viatra.query.testing.snapshot@default:default,org.eclipse.viatra.query.testing.ui@default:default,org.eclipse.viatra.query.tooling.core@default:default,org.eclipse.viatra.query.tooling.debug@default:default,org.eclipse.viatra.query.tooling.generator.model.ui@default:default,org.eclipse.viatra.query.tooling.generator.model@default:default,org.eclipse.viatra.query.tooling.localsearch.ui@default:default,org.eclipse.viatra.query.tooling.ui.retevis@default:default,org.eclipse.viatra.query.tooling.ui@default:default,org.eclipse.viatra.transformation.evm.transactions@default:default,org.eclipse.viatra.transformation.evm@default:default,org.eclipse.viatra.transformation.runtime.debug@default:default,org.eclipse.viatra.transformation.runtime.emf@default:default,org.eclipse.viatra.transformation.runtime.tracer@default:default,org.eclipse.viatra.transformation.runtime.transformationtrace@default:default,org.eclipse.viatra.transformation.tooling.debug.ui@default:default,org.eclipse.viatra.transformation.tooling.debug@default:default,org.eclipse.viatra.transformation.ui@default:default,org.eclipse.viatra.transformation.views@default:default,org.eclipse.wst.common.core@default:default,org.eclipse.wst.common.emf@default:default,org.eclipse.wst.common.environment@default:default,org.eclipse.wst.common.frameworks@default:default,org.eclipse.wst.common.project.facet.core@default:default,org.eclipse.wst.common.uriresolver@default:default,org.eclipse.wst.sse.core@default:default,org.eclipse.wst.validation@default:default,org.eclipse.wst.xml.core@default:default,org.eclipse.wst.xsd.core@default:default,org.eclipse.xpand@default:default,org.eclipse.xsd.cheatsheets@default:default,org.eclipse.xsd.doc@default:default,org.eclipse.xsd.ecore.converter@default:default,org.eclipse.xsd.ecore.exporter@default:default,org.eclipse.xsd.ecore.importer@default:default,org.eclipse.xsd.edit@default:default,org.eclipse.xsd.editor@default:default,org.eclipse.xsd.example.installer@default:default,org.eclipse.xsd.mapping.editor@default:default,org.eclipse.xsd.mapping@default:default,org.eclipse.xsd@default:default,org.eclipse.xtend.core@default:default,org.eclipse.xtend.doc@default:default,org.eclipse.xtend.examples@default:default,org.eclipse.xtend.ide.common@default:default,org.eclipse.xtend.ide@default:default,org.eclipse.xtend.lib.macro@default:default,org.eclipse.xtend.lib@default:default,org.eclipse.xtend.m2e@default:default,org.eclipse.xtend.standalone@default:default,org.eclipse.xtend.typesystem.emf@default:default,org.eclipse.xtend@default:default,org.eclipse.xtext.activities@default:default,org.eclipse.xtext.builder.standalone@default:default,org.eclipse.xtext.builder@default:default,org.eclipse.xtext.common.types.edit@default:default,org.eclipse.xtext.common.types.shared.jdt38@default:false,org.eclipse.xtext.common.types.shared@default:default,org.eclipse.xtext.common.types.ui@default:default,org.eclipse.xtext.common.types@default:default,org.eclipse.xtext.doc@default:default,org.eclipse.xtext.ecore@default:default,org.eclipse.xtext.generator@default:default,org.eclipse.xtext.ide@default:default,org.eclipse.xtext.idea.generator@default:default,org.eclipse.xtext.java@default:default,org.eclipse.xtext.junit4@default:default,org.eclipse.xtext.logging@default:false,org.eclipse.xtext.m2e@default:default,org.eclipse.xtext.purexbase.ide@default:default,org.eclipse.xtext.purexbase.ui@default:default,org.eclipse.xtext.purexbase@default:default,org.eclipse.xtext.smap@default:default,org.eclipse.xtext.testing@default:default,org.eclipse.xtext.ui.codemining@default:default,org.eclipse.xtext.ui.codetemplates.ide@default:default,org.eclipse.xtext.ui.codetemplates.ui@default:default,org.eclipse.xtext.ui.codetemplates@default:default,org.eclipse.xtext.ui.ecore@default:default,org.eclipse.xtext.ui.shared@default:default,org.eclipse.xtext.ui.testing@default:default,org.eclipse.xtext.ui@default:default,org.eclipse.xtext.util@default:default,org.eclipse.xtext.xbase.ide@default:default,org.eclipse.xtext.xbase.junit@default:default,org.eclipse.xtext.xbase.lib@default:default,org.eclipse.xtext.xbase.testing@default:default,org.eclipse.xtext.xbase.ui.testing@default:default,org.eclipse.xtext.xbase.ui@default:default,org.eclipse.xtext.xbase@default:default,org.eclipse.xtext.xtext.generator@default:default,org.eclipse.xtext.xtext.ide@default:default,org.eclipse.xtext.xtext.ui.examples@default:default,org.eclipse.xtext.xtext.ui.graph@default:default,org.eclipse.xtext.xtext.ui@default:default,org.eclipse.xtext.xtext.wizard@default:default,org.eclipse.xtext@default:default,org.h2@default:default,org.hamcrest.core@default:default,org.jfree.jcommon@default:default,org.jsoup@default:default,org.junit.jupiter.api@default:default,org.junit.jupiter.engine@default:default,org.junit.jupiter.migrationsupport@default:default,org.junit.jupiter.params@default:default,org.junit.platform.commons@default:default,org.junit.platform.engine@default:default,org.junit.platform.launcher@default:default,org.junit.platform.runner@default:default,org.junit.platform.suite.api@default:default,org.junit.vintage.engine@default:default,org.junit@default:default,org.moeaframework@default:default,org.objectweb.asm.tree@default:default,org.objectweb.asm@default:default,org.opentest4j@default:default,org.sat4j.core@default:default,org.sat4j.pb@default:default,org.sidiff.common.emf.extensions@default:default,org.sidiff.common.emf@default:default,org.sidiff.common.henshin@default:default,org.sidiff.common@default:default,org.sidiff.serge@default:default,org.silift.common.util@default:default,org.slf4j.api@default:default,org.slf4j.impl.log4j12@default:false,org.tukaani.xz@default:default,org.w3c.css.sac@default:default,org.w3c.dom.events@default:default,org.w3c.dom.smil@default:default,org.w3c.dom.svg@default:default,uk.ac.kcl.inf.mdeoptimiser.interfaces.cli@default:default,uk.ac.kcl.inf.mdeoptimiser.interfaces.eclipse.ui@default:default,uk.ac.kcl.inf.mdeoptimiser.languages.mopt.xtext@default:default,uk.ac.kcl.inf.mdeoptimiser.libraries.core@default:default,uk.ac.kcl.inf.mdeoptimiser.libraries.rulegen@default:default"/> | 28 | <setAttribute key="selected_target_bundles"> |
29 | <stringAttribute key="selected_workspace_plugins" value="com.microsoft.z3@default:true,hu.bme.mit.inf.dlsreasoner.alloy.reasoner@default:default,hu.bme.mit.inf.dslreasoner.alloy.language.ui@default:default,hu.bme.mit.inf.dslreasoner.alloy.language@default:default,hu.bme.mit.inf.dslreasoner.application.ide@default:default,hu.bme.mit.inf.dslreasoner.application.ui@default:default,hu.bme.mit.inf.dslreasoner.application@default:default,hu.bme.mit.inf.dslreasoner.domains.cps.validation@default:default,hu.bme.mit.inf.dslreasoner.domains.cps@default:default,hu.bme.mit.inf.dslreasoner.domains.satellite.validation@default:default,hu.bme.mit.inf.dslreasoner.domains.satellite@default:default,hu.bme.mit.inf.dslreasoner.ecore2logic@default:default,hu.bme.mit.inf.dslreasoner.faulttree.components.ide@default:default,hu.bme.mit.inf.dslreasoner.faulttree.components.ui@default:default,hu.bme.mit.inf.dslreasoner.faulttree.components@default:default,hu.bme.mit.inf.dslreasoner.faulttree.model@default:default,hu.bme.mit.inf.dslreasoner.faulttree.transformation@default:default,hu.bme.mit.inf.dslreasoner.faulttree.ui@default:default,hu.bme.mit.inf.dslreasoner.logic.model.validation@default:default,hu.bme.mit.inf.dslreasoner.logic.model@default:default,hu.bme.mit.inf.dslreasoner.logic2ecore@default:default,hu.bme.mit.inf.dslreasoner.smt.language.ui@default:default,hu.bme.mit.inf.dslreasoner.smt.language@default:default,hu.bme.mit.inf.dslreasoner.smt.reasoner@default:default,hu.bme.mit.inf.dslreasoner.viatra2logic@default:default,hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.tests@default:default,hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatraquery@default:default,hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage@default:default,hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner@default:default,hu.bme.mit.inf.dslreasoner.visualisation@default:default"/> | 29 | <setEntry value="com.eclipsesource.j2v8.linux_x86_64@default:default"/> |
30 | <setEntry value="com.github.mifmif.generex@default:default"/> | ||
31 | <setEntry value="com.google.gson@default:default"/> | ||
32 | <setEntry value="com.google.guava@default:default"/> | ||
33 | <setEntry value="com.google.inject.multibindings@default:false"/> | ||
34 | <setEntry value="com.google.inject@default:default"/> | ||
35 | <setEntry value="com.ibm.icu@default:default"/> | ||
36 | <setEntry value="com.jcraft.jsch@default:default"/> | ||
37 | <setEntry value="com.jcraft.jzlib@default:default"/> | ||
38 | <setEntry value="com.sun.el@default:default"/> | ||
39 | <setEntry value="de.tuberlin.eecs.agg@default:default"/> | ||
40 | <setEntry value="dk.brics.automaton@default:default"/> | ||
41 | <setEntry value="guru.nidi.graphviz-java@default:default"/> | ||
42 | <setEntry value="javaewah@default:default"/> | ||
43 | <setEntry value="javax.activation@default:default"/> | ||
44 | <setEntry value="javax.annotation@default:default"/> | ||
45 | <setEntry value="javax.el@default:default"/> | ||
46 | <setEntry value="javax.inject@default:default"/> | ||
47 | <setEntry value="javax.servlet.jsp@default:default"/> | ||
48 | <setEntry value="javax.servlet@default:default"/> | ||
49 | <setEntry value="javax.xml.bind@default:default"/> | ||
50 | <setEntry value="javax.xml@default:default"/> | ||
51 | <setEntry value="lpg.runtime.java@default:default"/> | ||
52 | <setEntry value="net.i2p.crypto.eddsa@default:default"/> | ||
53 | <setEntry value="org.antlr.runtime*3.2.0.v201101311130@default:default"/> | ||
54 | <setEntry value="org.antlr.runtime*4.3.0.v201502022030@default:default"/> | ||
55 | <setEntry value="org.apache.ant@default:default"/> | ||
56 | <setEntry value="org.apache.batik.bridge@default:default"/> | ||
57 | <setEntry value="org.apache.batik.constants@default:default"/> | ||
58 | <setEntry value="org.apache.batik.css*1.10.0.v20180703-1553@default:default"/> | ||
59 | <setEntry value="org.apache.batik.css*1.6.0.v201011041432@default:default"/> | ||
60 | <setEntry value="org.apache.batik.dom.svg@default:default"/> | ||
61 | <setEntry value="org.apache.batik.dom@default:default"/> | ||
62 | <setEntry value="org.apache.batik.ext.awt@default:default"/> | ||
63 | <setEntry value="org.apache.batik.i18n@default:default"/> | ||
64 | <setEntry value="org.apache.batik.parser@default:default"/> | ||
65 | <setEntry value="org.apache.batik.pdf@default:default"/> | ||
66 | <setEntry value="org.apache.batik.svggen@default:default"/> | ||
67 | <setEntry value="org.apache.batik.transcoder@default:default"/> | ||
68 | <setEntry value="org.apache.batik.util*1.10.0.v20180703-1553@default:default"/> | ||
69 | <setEntry value="org.apache.batik.util*1.6.0.v201011041432@default:default"/> | ||
70 | <setEntry value="org.apache.batik.util.gui@default:default"/> | ||
71 | <setEntry value="org.apache.batik.xml@default:default"/> | ||
72 | <setEntry value="org.apache.commons.cli@default:default"/> | ||
73 | <setEntry value="org.apache.commons.codec*1.10.0.v20180409-1845@default:default"/> | ||
74 | <setEntry value="org.apache.commons.codec*1.9.0.v20170208-1614@default:default"/> | ||
75 | <setEntry value="org.apache.commons.compress@default:default"/> | ||
76 | <setEntry value="org.apache.commons.exec@default:default"/> | ||
77 | <setEntry value="org.apache.commons.httpclient@default:default"/> | ||
78 | <setEntry value="org.apache.commons.io@default:default"/> | ||
79 | <setEntry value="org.apache.commons.jxpath@default:default"/> | ||
80 | <setEntry value="org.apache.commons.lang3@default:default"/> | ||
81 | <setEntry value="org.apache.commons.lang@default:default"/> | ||
82 | <setEntry value="org.apache.commons.logging*1.1.1.v201101211721@default:default"/> | ||
83 | <setEntry value="org.apache.commons.logging*1.2.0.v20180409-1502@default:default"/> | ||
84 | <setEntry value="org.apache.commons.math3@default:default"/> | ||
85 | <setEntry value="org.apache.felix.gogo.command@default:default"/> | ||
86 | <setEntry value="org.apache.felix.gogo.runtime@default:default"/> | ||
87 | <setEntry value="org.apache.felix.gogo.shell@default:default"/> | ||
88 | <setEntry value="org.apache.felix.scr@1:true"/> | ||
89 | <setEntry value="org.apache.httpcomponents.httpclient@default:default"/> | ||
90 | <setEntry value="org.apache.httpcomponents.httpcore@default:default"/> | ||
91 | <setEntry value="org.apache.jasper.glassfish@default:default"/> | ||
92 | <setEntry value="org.apache.log4j@default:default"/> | ||
93 | <setEntry value="org.apache.lucene.analyzers-common*6.1.0.v20161115-1612@default:default"/> | ||
94 | <setEntry value="org.apache.lucene.analyzers-common*7.5.0.v20181003-1532@default:default"/> | ||
95 | <setEntry value="org.apache.lucene.analyzers-smartcn@default:default"/> | ||
96 | <setEntry value="org.apache.lucene.core*6.1.0.v20170814-1820@default:default"/> | ||
97 | <setEntry value="org.apache.lucene.core*7.5.0.v20181003-1532@default:default"/> | ||
98 | <setEntry value="org.apache.lucene.queryparser@default:default"/> | ||
99 | <setEntry value="org.apache.sshd.core@default:default"/> | ||
100 | <setEntry value="org.apache.sshd.sftp@default:default"/> | ||
101 | <setEntry value="org.apache.ws.commons.util@default:default"/> | ||
102 | <setEntry value="org.apache.xerces@default:default"/> | ||
103 | <setEntry value="org.apache.xml.resolver@default:default"/> | ||
104 | <setEntry value="org.apache.xml.serializer@default:default"/> | ||
105 | <setEntry value="org.apache.xmlgraphics@default:default"/> | ||
106 | <setEntry value="org.apache.xmlrpc@default:default"/> | ||
107 | <setEntry value="org.apiguardian@default:default"/> | ||
108 | <setEntry value="org.bouncycastle.bcpg@default:default"/> | ||
109 | <setEntry value="org.bouncycastle.bcpkix@default:default"/> | ||
110 | <setEntry value="org.bouncycastle.bcprov@default:default"/> | ||
111 | <setEntry value="org.eclipse.acceleo.annotations@default:default"/> | ||
112 | <setEntry value="org.eclipse.acceleo.query@default:default"/> | ||
113 | <setEntry value="org.eclipse.acceleo.ui.interpreter@default:default"/> | ||
114 | <setEntry value="org.eclipse.ant.core@default:default"/> | ||
115 | <setEntry value="org.eclipse.ant.launching@default:default"/> | ||
116 | <setEntry value="org.eclipse.ant.ui@default:default"/> | ||
117 | <setEntry value="org.eclipse.collections@default:default"/> | ||
118 | <setEntry value="org.eclipse.compare.core@default:default"/> | ||
119 | <setEntry value="org.eclipse.compare@default:default"/> | ||
120 | <setEntry value="org.eclipse.core.commands@default:default"/> | ||
121 | <setEntry value="org.eclipse.core.contenttype@default:default"/> | ||
122 | <setEntry value="org.eclipse.core.databinding.beans@default:default"/> | ||
123 | <setEntry value="org.eclipse.core.databinding.observable@default:default"/> | ||
124 | <setEntry value="org.eclipse.core.databinding.property@default:default"/> | ||
125 | <setEntry value="org.eclipse.core.databinding@default:default"/> | ||
126 | <setEntry value="org.eclipse.core.expressions@default:default"/> | ||
127 | <setEntry value="org.eclipse.core.externaltools@default:default"/> | ||
128 | <setEntry value="org.eclipse.core.filebuffers@default:default"/> | ||
129 | <setEntry value="org.eclipse.core.filesystem.linux.x86_64@default:false"/> | ||
130 | <setEntry value="org.eclipse.core.filesystem@default:default"/> | ||
131 | <setEntry value="org.eclipse.core.jobs@default:default"/> | ||
132 | <setEntry value="org.eclipse.core.net.linux.x86_64@default:false"/> | ||
133 | <setEntry value="org.eclipse.core.net@default:default"/> | ||
134 | <setEntry value="org.eclipse.core.resources@default:default"/> | ||
135 | <setEntry value="org.eclipse.core.runtime@default:true"/> | ||
136 | <setEntry value="org.eclipse.core.variables@default:default"/> | ||
137 | <setEntry value="org.eclipse.debug.core@default:default"/> | ||
138 | <setEntry value="org.eclipse.debug.ui@default:default"/> | ||
139 | <setEntry value="org.eclipse.draw2d.doc.isv@default:default"/> | ||
140 | <setEntry value="org.eclipse.draw2d@default:default"/> | ||
141 | <setEntry value="org.eclipse.e4.core.commands@default:default"/> | ||
142 | <setEntry value="org.eclipse.e4.core.contexts@default:default"/> | ||
143 | <setEntry value="org.eclipse.e4.core.di.annotations@default:default"/> | ||
144 | <setEntry value="org.eclipse.e4.core.di.extensions.supplier@default:default"/> | ||
145 | <setEntry value="org.eclipse.e4.core.di.extensions@default:default"/> | ||
146 | <setEntry value="org.eclipse.e4.core.di@default:default"/> | ||
147 | <setEntry value="org.eclipse.e4.core.services@default:default"/> | ||
148 | <setEntry value="org.eclipse.e4.emf.xpath@default:default"/> | ||
149 | <setEntry value="org.eclipse.e4.tools.compat@default:default"/> | ||
150 | <setEntry value="org.eclipse.e4.tools.emf.editor3x@default:default"/> | ||
151 | <setEntry value="org.eclipse.e4.tools.emf.ui@default:default"/> | ||
152 | <setEntry value="org.eclipse.e4.tools.jdt.templates@default:default"/> | ||
153 | <setEntry value="org.eclipse.e4.tools.services@default:default"/> | ||
154 | <setEntry value="org.eclipse.e4.tools@default:default"/> | ||
155 | <setEntry value="org.eclipse.e4.ui.bindings@default:default"/> | ||
156 | <setEntry value="org.eclipse.e4.ui.css.core@default:default"/> | ||
157 | <setEntry value="org.eclipse.e4.ui.css.swt.theme@default:default"/> | ||
158 | <setEntry value="org.eclipse.e4.ui.css.swt@default:default"/> | ||
159 | <setEntry value="org.eclipse.e4.ui.di@default:default"/> | ||
160 | <setEntry value="org.eclipse.e4.ui.dialogs@default:default"/> | ||
161 | <setEntry value="org.eclipse.e4.ui.model.workbench@default:default"/> | ||
162 | <setEntry value="org.eclipse.e4.ui.services@default:default"/> | ||
163 | <setEntry value="org.eclipse.e4.ui.swt.gtk@default:false"/> | ||
164 | <setEntry value="org.eclipse.e4.ui.widgets@default:default"/> | ||
165 | <setEntry value="org.eclipse.e4.ui.workbench.addons.swt@default:default"/> | ||
166 | <setEntry value="org.eclipse.e4.ui.workbench.renderers.swt@default:default"/> | ||
167 | <setEntry value="org.eclipse.e4.ui.workbench.swt@default:default"/> | ||
168 | <setEntry value="org.eclipse.e4.ui.workbench3@default:default"/> | ||
169 | <setEntry value="org.eclipse.e4.ui.workbench@default:default"/> | ||
170 | <setEntry value="org.eclipse.ecf.filetransfer@default:default"/> | ||
171 | <setEntry value="org.eclipse.ecf.identity@default:default"/> | ||
172 | <setEntry value="org.eclipse.ecf.provider.filetransfer.httpclient4.ssl@default:false"/> | ||
173 | <setEntry value="org.eclipse.ecf.provider.filetransfer.httpclient4@default:default"/> | ||
174 | <setEntry value="org.eclipse.ecf.provider.filetransfer.ssl@default:false"/> | ||
175 | <setEntry value="org.eclipse.ecf.provider.filetransfer@default:default"/> | ||
176 | <setEntry value="org.eclipse.ecf.ssl@default:false"/> | ||
177 | <setEntry value="org.eclipse.ecf@default:default"/> | ||
178 | <setEntry value="org.eclipse.eef.common.ui@default:default"/> | ||
179 | <setEntry value="org.eclipse.eef.common@default:default"/> | ||
180 | <setEntry value="org.eclipse.eef.core.ext.widgets.reference@default:default"/> | ||
181 | <setEntry value="org.eclipse.eef.core@default:default"/> | ||
182 | <setEntry value="org.eclipse.eef.ext.widgets.reference@default:default"/> | ||
183 | <setEntry value="org.eclipse.eef.ide.ui.ext.widgets.reference@default:default"/> | ||
184 | <setEntry value="org.eclipse.eef.ide.ui.properties@default:default"/> | ||
185 | <setEntry value="org.eclipse.eef.ide.ui@default:default"/> | ||
186 | <setEntry value="org.eclipse.eef.properties.ui.legacy@default:default"/> | ||
187 | <setEntry value="org.eclipse.eef.properties.ui@default:default"/> | ||
188 | <setEntry value="org.eclipse.eef@default:default"/> | ||
189 | <setEntry value="org.eclipse.egit.core@default:default"/> | ||
190 | <setEntry value="org.eclipse.egit.doc@default:default"/> | ||
191 | <setEntry value="org.eclipse.egit.ui@default:default"/> | ||
192 | <setEntry value="org.eclipse.egit@default:default"/> | ||
193 | <setEntry value="org.eclipse.emf.ant@default:default"/> | ||
194 | <setEntry value="org.eclipse.emf.cdo.admin@default:default"/> | ||
195 | <setEntry value="org.eclipse.emf.cdo.common.db@default:default"/> | ||
196 | <setEntry value="org.eclipse.emf.cdo.common@default:default"/> | ||
197 | <setEntry value="org.eclipse.emf.cdo.compare@default:default"/> | ||
198 | <setEntry value="org.eclipse.emf.cdo.doc@default:default"/> | ||
199 | <setEntry value="org.eclipse.emf.cdo.edit@default:default"/> | ||
200 | <setEntry value="org.eclipse.emf.cdo.examples.installer@default:default"/> | ||
201 | <setEntry value="org.eclipse.emf.cdo.explorer.ui@default:default"/> | ||
202 | <setEntry value="org.eclipse.emf.cdo.explorer@default:default"/> | ||
203 | <setEntry value="org.eclipse.emf.cdo.expressions.edit@default:default"/> | ||
204 | <setEntry value="org.eclipse.emf.cdo.expressions.editor@default:default"/> | ||
205 | <setEntry value="org.eclipse.emf.cdo.expressions@default:default"/> | ||
206 | <setEntry value="org.eclipse.emf.cdo.migrator@default:default"/> | ||
207 | <setEntry value="org.eclipse.emf.cdo.net4j@default:default"/> | ||
208 | <setEntry value="org.eclipse.emf.cdo.security.edit@default:default"/> | ||
209 | <setEntry value="org.eclipse.emf.cdo.security.editor@default:default"/> | ||
210 | <setEntry value="org.eclipse.emf.cdo.security.ui@default:default"/> | ||
211 | <setEntry value="org.eclipse.emf.cdo.security@default:default"/> | ||
212 | <setEntry value="org.eclipse.emf.cdo.server.admin@default:default"/> | ||
213 | <setEntry value="org.eclipse.emf.cdo.server.db@default:default"/> | ||
214 | <setEntry value="org.eclipse.emf.cdo.server.net4j@default:default"/> | ||
215 | <setEntry value="org.eclipse.emf.cdo.server.ocl@default:default"/> | ||
216 | <setEntry value="org.eclipse.emf.cdo.server.product@default:default"/> | ||
217 | <setEntry value="org.eclipse.emf.cdo.server.security@default:default"/> | ||
218 | <setEntry value="org.eclipse.emf.cdo.server@default:default"/> | ||
219 | <setEntry value="org.eclipse.emf.cdo.transfer.repository@default:default"/> | ||
220 | <setEntry value="org.eclipse.emf.cdo.transfer.ui@default:default"/> | ||
221 | <setEntry value="org.eclipse.emf.cdo.transfer.workspace.ui@default:default"/> | ||
222 | <setEntry value="org.eclipse.emf.cdo.transfer.workspace@default:default"/> | ||
223 | <setEntry value="org.eclipse.emf.cdo.transfer@default:default"/> | ||
224 | <setEntry value="org.eclipse.emf.cdo.ui.admin@default:default"/> | ||
225 | <setEntry value="org.eclipse.emf.cdo.ui.compare@default:default"/> | ||
226 | <setEntry value="org.eclipse.emf.cdo.ui.shared@default:default"/> | ||
227 | <setEntry value="org.eclipse.emf.cdo.ui.team@default:default"/> | ||
228 | <setEntry value="org.eclipse.emf.cdo.ui@default:default"/> | ||
229 | <setEntry value="org.eclipse.emf.cdo.workspace@default:default"/> | ||
230 | <setEntry value="org.eclipse.emf.cdo@default:default"/> | ||
231 | <setEntry value="org.eclipse.emf.cheatsheets@default:default"/> | ||
232 | <setEntry value="org.eclipse.emf.codegen.ecore.ui@default:default"/> | ||
233 | <setEntry value="org.eclipse.emf.codegen.ecore@default:default"/> | ||
234 | <setEntry value="org.eclipse.emf.codegen.ui@default:default"/> | ||
235 | <setEntry value="org.eclipse.emf.codegen@default:default"/> | ||
236 | <setEntry value="org.eclipse.emf.common.ui@default:default"/> | ||
237 | <setEntry value="org.eclipse.emf.common@default:default"/> | ||
238 | <setEntry value="org.eclipse.emf.compare.diagram.edit@default:default"/> | ||
239 | <setEntry value="org.eclipse.emf.compare.diagram.ide.ui.sirius@default:default"/> | ||
240 | <setEntry value="org.eclipse.emf.compare.diagram.ide.ui@default:default"/> | ||
241 | <setEntry value="org.eclipse.emf.compare.diagram.sirius@default:default"/> | ||
242 | <setEntry value="org.eclipse.emf.compare.diagram@default:default"/> | ||
243 | <setEntry value="org.eclipse.emf.compare.doc@default:default"/> | ||
244 | <setEntry value="org.eclipse.emf.compare.edit@default:default"/> | ||
245 | <setEntry value="org.eclipse.emf.compare.egit.ui@default:default"/> | ||
246 | <setEntry value="org.eclipse.emf.compare.egit@default:default"/> | ||
247 | <setEntry value="org.eclipse.emf.compare.ide.ui@default:default"/> | ||
248 | <setEntry value="org.eclipse.emf.compare.ide@default:default"/> | ||
249 | <setEntry value="org.eclipse.emf.compare.rcp.ui@default:default"/> | ||
250 | <setEntry value="org.eclipse.emf.compare.rcp@default:default"/> | ||
251 | <setEntry value="org.eclipse.emf.compare@default:default"/> | ||
252 | <setEntry value="org.eclipse.emf.converter@default:default"/> | ||
253 | <setEntry value="org.eclipse.emf.databinding.edit@default:default"/> | ||
254 | <setEntry value="org.eclipse.emf.databinding@default:default"/> | ||
255 | <setEntry value="org.eclipse.emf.doc@default:default"/> | ||
256 | <setEntry value="org.eclipse.emf.ecore.change.edit@default:default"/> | ||
257 | <setEntry value="org.eclipse.emf.ecore.change@default:default"/> | ||
258 | <setEntry value="org.eclipse.emf.ecore.edit@default:default"/> | ||
259 | <setEntry value="org.eclipse.emf.ecore.editor@default:default"/> | ||
260 | <setEntry value="org.eclipse.emf.ecore.xmi@default:default"/> | ||
261 | <setEntry value="org.eclipse.emf.ecore@default:default"/> | ||
262 | <setEntry value="org.eclipse.emf.ecoretools.design.ui@default:default"/> | ||
263 | <setEntry value="org.eclipse.emf.ecoretools.design@default:default"/> | ||
264 | <setEntry value="org.eclipse.emf.ecoretools.doc@default:default"/> | ||
265 | <setEntry value="org.eclipse.emf.ecoretools.ui@default:default"/> | ||
266 | <setEntry value="org.eclipse.emf.ecoretools@default:default"/> | ||
267 | <setEntry value="org.eclipse.emf.ecp.application.e3@default:default"/> | ||
268 | <setEntry value="org.eclipse.emf.ecp.application.e4@default:default"/> | ||
269 | <setEntry value="org.eclipse.emf.ecp.cdo.core@default:default"/> | ||
270 | <setEntry value="org.eclipse.emf.ecp.cdo.ui@default:default"/> | ||
271 | <setEntry value="org.eclipse.emf.ecp.common.ui@default:default"/> | ||
272 | <setEntry value="org.eclipse.emf.ecp.common@default:default"/> | ||
273 | <setEntry value="org.eclipse.emf.ecp.core.emffilter@default:default"/> | ||
274 | <setEntry value="org.eclipse.emf.ecp.core@default:default"/> | ||
275 | <setEntry value="org.eclipse.emf.ecp.edit.swt@default:default"/> | ||
276 | <setEntry value="org.eclipse.emf.ecp.edit@default:default"/> | ||
277 | <setEntry value="org.eclipse.emf.ecp.editor.e3@default:default"/> | ||
278 | <setEntry value="org.eclipse.emf.ecp.emf2web.json@default:default"/> | ||
279 | <setEntry value="org.eclipse.emf.ecp.emf2web.ui.json@default:default"/> | ||
280 | <setEntry value="org.eclipse.emf.ecp.emf2web.ui@default:default"/> | ||
281 | <setEntry value="org.eclipse.emf.ecp.emf2web@default:default"/> | ||
282 | <setEntry value="org.eclipse.emf.ecp.emfstore.core@default:default"/> | ||
283 | <setEntry value="org.eclipse.emf.ecp.emfstore.ui.e3@default:default"/> | ||
284 | <setEntry value="org.eclipse.emf.ecp.emfstore.ui.e4@default:default"/> | ||
285 | <setEntry value="org.eclipse.emf.ecp.emfstore.ui.search@default:default"/> | ||
286 | <setEntry value="org.eclipse.emf.ecp.emfstore.ui@default:default"/> | ||
287 | <setEntry value="org.eclipse.emf.ecp.explorereditorbridge@default:default"/> | ||
288 | <setEntry value="org.eclipse.emf.ecp.ide.editor.view.templatebridge@default:default"/> | ||
289 | <setEntry value="org.eclipse.emf.ecp.ide.editor.view@default:default"/> | ||
290 | <setEntry value="org.eclipse.emf.ecp.ide.editor.viewmodel@default:default"/> | ||
291 | <setEntry value="org.eclipse.emf.ecp.ide.util@default:default"/> | ||
292 | <setEntry value="org.eclipse.emf.ecp.ide.view.service@default:default"/> | ||
293 | <setEntry value="org.eclipse.emf.ecp.makeithappen.wizards@default:default"/> | ||
294 | <setEntry value="org.eclipse.emf.ecp.ui.e3@default:default"/> | ||
295 | <setEntry value="org.eclipse.emf.ecp.ui.e4@default:default"/> | ||
296 | <setEntry value="org.eclipse.emf.ecp.ui.rcp@default:default"/> | ||
297 | <setEntry value="org.eclipse.emf.ecp.ui.view.editor.controls@default:default"/> | ||
298 | <setEntry value="org.eclipse.emf.ecp.ui.view.linewrapper@default:default"/> | ||
299 | <setEntry value="org.eclipse.emf.ecp.ui.view.swt@default:default"/> | ||
300 | <setEntry value="org.eclipse.emf.ecp.ui.view@default:default"/> | ||
301 | <setEntry value="org.eclipse.emf.ecp.ui@default:default"/> | ||
302 | <setEntry value="org.eclipse.emf.ecp.validation.connector@default:default"/> | ||
303 | <setEntry value="org.eclipse.emf.ecp.validation@default:default"/> | ||
304 | <setEntry value="org.eclipse.emf.ecp.view.categorization.model.edit@default:default"/> | ||
305 | <setEntry value="org.eclipse.emf.ecp.view.categorization.model@default:default"/> | ||
306 | <setEntry value="org.eclipse.emf.ecp.view.categorization.swt@default:default"/> | ||
307 | <setEntry value="org.eclipse.emf.ecp.view.compoundcontrol.model.edit@default:default"/> | ||
308 | <setEntry value="org.eclipse.emf.ecp.view.compoundcontrol.model@default:default"/> | ||
309 | <setEntry value="org.eclipse.emf.ecp.view.compoundcontrol.swt@default:default"/> | ||
310 | <setEntry value="org.eclipse.emf.ecp.view.compoundcontrol.tooling@default:default"/> | ||
311 | <setEntry value="org.eclipse.emf.ecp.view.context.locale@default:default"/> | ||
312 | <setEntry value="org.eclipse.emf.ecp.view.context@default:default"/> | ||
313 | <setEntry value="org.eclipse.emf.ecp.view.control.multireference@default:default"/> | ||
314 | <setEntry value="org.eclipse.emf.ecp.view.core.swt@default:default"/> | ||
315 | <setEntry value="org.eclipse.emf.ecp.view.custom.model.edit@default:default"/> | ||
316 | <setEntry value="org.eclipse.emf.ecp.view.custom.model@default:default"/> | ||
317 | <setEntry value="org.eclipse.emf.ecp.view.custom.ui.swt@default:default"/> | ||
318 | <setEntry value="org.eclipse.emf.ecp.view.edapt@default:default"/> | ||
319 | <setEntry value="org.eclipse.emf.ecp.view.group.model.edit@default:default"/> | ||
320 | <setEntry value="org.eclipse.emf.ecp.view.group.model@default:default"/> | ||
321 | <setEntry value="org.eclipse.emf.ecp.view.group.swt.collapsable@default:default"/> | ||
322 | <setEntry value="org.eclipse.emf.ecp.view.group.swt.embedded@default:default"/> | ||
323 | <setEntry value="org.eclipse.emf.ecp.view.group.ui.swt@default:default"/> | ||
324 | <setEntry value="org.eclipse.emf.ecp.view.horizontal.model.edit@default:default"/> | ||
325 | <setEntry value="org.eclipse.emf.ecp.view.horizontal.model@default:default"/> | ||
326 | <setEntry value="org.eclipse.emf.ecp.view.horizontal.ui.swt@default:default"/> | ||
327 | <setEntry value="org.eclipse.emf.ecp.view.indexdmr.model@default:default"/> | ||
328 | <setEntry value="org.eclipse.emf.ecp.view.label.model.edit@default:default"/> | ||
329 | <setEntry value="org.eclipse.emf.ecp.view.label.model@default:default"/> | ||
330 | <setEntry value="org.eclipse.emf.ecp.view.label.ui.swt@default:default"/> | ||
331 | <setEntry value="org.eclipse.emf.ecp.view.mappingdmr.model@default:default"/> | ||
332 | <setEntry value="org.eclipse.emf.ecp.view.migrator@default:default"/> | ||
333 | <setEntry value="org.eclipse.emf.ecp.view.model.common@default:default"/> | ||
334 | <setEntry value="org.eclipse.emf.ecp.view.model.edapt@default:default"/> | ||
335 | <setEntry value="org.eclipse.emf.ecp.view.model.edit@default:default"/> | ||
336 | <setEntry value="org.eclipse.emf.ecp.view.model.editor@default:default"/> | ||
337 | <setEntry value="org.eclipse.emf.ecp.view.model.preview.common@default:default"/> | ||
338 | <setEntry value="org.eclipse.emf.ecp.view.model.preview.e3@default:default"/> | ||
339 | <setEntry value="org.eclipse.emf.ecp.view.model.project.installer@default:default"/> | ||
340 | <setEntry value="org.eclipse.emf.ecp.view.model.provider.generator@default:default"/> | ||
341 | <setEntry value="org.eclipse.emf.ecp.view.model.provider.xmi@default:default"/> | ||
342 | <setEntry value="org.eclipse.emf.ecp.view.model@default:default"/> | ||
343 | <setEntry value="org.eclipse.emf.ecp.view.rule.model.edit@default:default"/> | ||
344 | <setEntry value="org.eclipse.emf.ecp.view.rule.model@default:default"/> | ||
345 | <setEntry value="org.eclipse.emf.ecp.view.rule@default:default"/> | ||
346 | <setEntry value="org.eclipse.emf.ecp.view.stack.model.edit@default:default"/> | ||
347 | <setEntry value="org.eclipse.emf.ecp.view.stack.model@default:default"/> | ||
348 | <setEntry value="org.eclipse.emf.ecp.view.stack.ui.swt@default:default"/> | ||
349 | <setEntry value="org.eclipse.emf.ecp.view.stack.viewmodel@default:default"/> | ||
350 | <setEntry value="org.eclipse.emf.ecp.view.swt.layout@default:default"/> | ||
351 | <setEntry value="org.eclipse.emf.ecp.view.table.columnservice@default:default"/> | ||
352 | <setEntry value="org.eclipse.emf.ecp.view.table.edapt@default:default"/> | ||
353 | <setEntry value="org.eclipse.emf.ecp.view.table.model.edit@default:default"/> | ||
354 | <setEntry value="org.eclipse.emf.ecp.view.table.model@default:default"/> | ||
355 | <setEntry value="org.eclipse.emf.ecp.view.table.ui.swt@default:default"/> | ||
356 | <setEntry value="org.eclipse.emf.ecp.view.template.annotation.model.edit@default:default"/> | ||
357 | <setEntry value="org.eclipse.emf.ecp.view.template.annotation.model@default:default"/> | ||
358 | <setEntry value="org.eclipse.emf.ecp.view.template.model.edit@default:default"/> | ||
359 | <setEntry value="org.eclipse.emf.ecp.view.template.model@default:default"/> | ||
360 | <setEntry value="org.eclipse.emf.ecp.view.template.service@default:default"/> | ||
361 | <setEntry value="org.eclipse.emf.ecp.view.template.tooling@default:default"/> | ||
362 | <setEntry value="org.eclipse.emf.ecp.view.treemasterdetail.model.edit@default:default"/> | ||
363 | <setEntry value="org.eclipse.emf.ecp.view.treemasterdetail.model@default:default"/> | ||
364 | <setEntry value="org.eclipse.emf.ecp.view.treemasterdetail.ui.swt@default:default"/> | ||
365 | <setEntry value="org.eclipse.emf.ecp.view.treemasterdetail.validation@default:default"/> | ||
366 | <setEntry value="org.eclipse.emf.ecp.view.unset@default:default"/> | ||
367 | <setEntry value="org.eclipse.emf.ecp.view.util.swt@default:default"/> | ||
368 | <setEntry value="org.eclipse.emf.ecp.view.validation@default:default"/> | ||
369 | <setEntry value="org.eclipse.emf.ecp.view.vertical.model.edit@default:default"/> | ||
370 | <setEntry value="org.eclipse.emf.ecp.view.vertical.model@default:default"/> | ||
371 | <setEntry value="org.eclipse.emf.ecp.view.vertical.ui.swt@default:default"/> | ||
372 | <setEntry value="org.eclipse.emf.ecp.view.viewproxy.model.edit@default:default"/> | ||
373 | <setEntry value="org.eclipse.emf.ecp.view.viewproxy.model@default:default"/> | ||
374 | <setEntry value="org.eclipse.emf.ecp.view.workspace.migrator@default:default"/> | ||
375 | <setEntry value="org.eclipse.emf.ecp.workspace.core@default:default"/> | ||
376 | <setEntry value="org.eclipse.emf.ecp.workspace.ui@default:default"/> | ||
377 | <setEntry value="org.eclipse.emf.edapt.common@default:default"/> | ||
378 | <setEntry value="org.eclipse.emf.edapt.declaration@default:default"/> | ||
379 | <setEntry value="org.eclipse.emf.edapt.history@default:default"/> | ||
380 | <setEntry value="org.eclipse.emf.edapt.migration@default:default"/> | ||
381 | <setEntry value="org.eclipse.emf.edit.ui@default:default"/> | ||
382 | <setEntry value="org.eclipse.emf.edit@default:default"/> | ||
383 | <setEntry value="org.eclipse.emf.emfstore.client.model.edit@default:default"/> | ||
384 | <setEntry value="org.eclipse.emf.emfstore.client.ui.rcp@default:false"/> | ||
385 | <setEntry value="org.eclipse.emf.emfstore.client.ui@default:default"/> | ||
386 | <setEntry value="org.eclipse.emf.emfstore.client@default:default"/> | ||
387 | <setEntry value="org.eclipse.emf.emfstore.common.model.edit@default:default"/> | ||
388 | <setEntry value="org.eclipse.emf.emfstore.common.model@default:default"/> | ||
389 | <setEntry value="org.eclipse.emf.emfstore.common@default:default"/> | ||
390 | <setEntry value="org.eclipse.emf.emfstore.example.installer@default:default"/> | ||
391 | <setEntry value="org.eclipse.emf.emfstore.examplemodel.edit@default:default"/> | ||
392 | <setEntry value="org.eclipse.emf.emfstore.examplemodel@default:default"/> | ||
393 | <setEntry value="org.eclipse.emf.emfstore.migration@default:default"/> | ||
394 | <setEntry value="org.eclipse.emf.emfstore.server.model.edit@default:default"/> | ||
395 | <setEntry value="org.eclipse.emf.emfstore.server.model@default:default"/> | ||
396 | <setEntry value="org.eclipse.emf.emfstore.server@default:default"/> | ||
397 | <setEntry value="org.eclipse.emf.example.installer@default:default"/> | ||
398 | <setEntry value="org.eclipse.emf.exporter@default:default"/> | ||
399 | <setEntry value="org.eclipse.emf.henshin.diagram@default:default"/> | ||
400 | <setEntry value="org.eclipse.emf.henshin.edit@default:default"/> | ||
401 | <setEntry value="org.eclipse.emf.henshin.editor@default:default"/> | ||
402 | <setEntry value="org.eclipse.emf.henshin.examples@default:default"/> | ||
403 | <setEntry value="org.eclipse.emf.henshin.giraph@default:default"/> | ||
404 | <setEntry value="org.eclipse.emf.henshin.interpreter.ui@default:default"/> | ||
405 | <setEntry value="org.eclipse.emf.henshin.interpreter@default:default"/> | ||
406 | <setEntry value="org.eclipse.emf.henshin.model@default:default"/> | ||
407 | <setEntry value="org.eclipse.emf.henshin.multicda.cda@default:default"/> | ||
408 | <setEntry value="org.eclipse.emf.henshin.multicda.cpa.ui@default:default"/> | ||
409 | <setEntry value="org.eclipse.emf.henshin.multicda.cpa@default:default"/> | ||
410 | <setEntry value="org.eclipse.emf.henshin.rulegen.ui@default:default"/> | ||
411 | <setEntry value="org.eclipse.emf.henshin.rulegen@default:default"/> | ||
412 | <setEntry value="org.eclipse.emf.henshin.statespace.explorer@default:default"/> | ||
413 | <setEntry value="org.eclipse.emf.henshin.statespace.external@default:default"/> | ||
414 | <setEntry value="org.eclipse.emf.henshin.statespace@default:default"/> | ||
415 | <setEntry value="org.eclipse.emf.henshin.text.ide@default:default"/> | ||
416 | <setEntry value="org.eclipse.emf.henshin.text.transformation@default:default"/> | ||
417 | <setEntry value="org.eclipse.emf.henshin.text.ui@default:default"/> | ||
418 | <setEntry value="org.eclipse.emf.henshin.text@default:default"/> | ||
419 | <setEntry value="org.eclipse.emf.henshin.trace@default:default"/> | ||
420 | <setEntry value="org.eclipse.emf.henshin.wrap@default:default"/> | ||
421 | <setEntry value="org.eclipse.emf.importer.ecore@default:default"/> | ||
422 | <setEntry value="org.eclipse.emf.importer.java@default:default"/> | ||
423 | <setEntry value="org.eclipse.emf.importer.rose@default:default"/> | ||
424 | <setEntry value="org.eclipse.emf.importer@default:default"/> | ||
425 | <setEntry value="org.eclipse.emf.mapping.ecore.editor@default:default"/> | ||
426 | <setEntry value="org.eclipse.emf.mapping.ecore2ecore.editor@default:default"/> | ||
427 | <setEntry value="org.eclipse.emf.mapping.ecore2ecore@default:default"/> | ||
428 | <setEntry value="org.eclipse.emf.mapping.ecore2xml.ui@default:default"/> | ||
429 | <setEntry value="org.eclipse.emf.mapping.ecore2xml@default:default"/> | ||
430 | <setEntry value="org.eclipse.emf.mapping.ecore@default:default"/> | ||
431 | <setEntry value="org.eclipse.emf.mapping.ui@default:default"/> | ||
432 | <setEntry value="org.eclipse.emf.mapping.xsd2ecore.editor@default:default"/> | ||
433 | <setEntry value="org.eclipse.emf.mapping.xsd2ecore@default:default"/> | ||
434 | <setEntry value="org.eclipse.emf.mapping@default:default"/> | ||
435 | <setEntry value="org.eclipse.emf.mwe.core@default:default"/> | ||
436 | <setEntry value="org.eclipse.emf.mwe.utils@default:default"/> | ||
437 | <setEntry value="org.eclipse.emf.mwe2.language.ide@default:default"/> | ||
438 | <setEntry value="org.eclipse.emf.mwe2.language.ui@default:default"/> | ||
439 | <setEntry value="org.eclipse.emf.mwe2.language@default:default"/> | ||
440 | <setEntry value="org.eclipse.emf.mwe2.launch.ui@default:default"/> | ||
441 | <setEntry value="org.eclipse.emf.mwe2.launch@default:default"/> | ||
442 | <setEntry value="org.eclipse.emf.mwe2.lib@default:default"/> | ||
443 | <setEntry value="org.eclipse.emf.mwe2.runtime@default:default"/> | ||
444 | <setEntry value="org.eclipse.emf.parsley.cdo.common@default:default"/> | ||
445 | <setEntry value="org.eclipse.emf.parsley.cdo@default:default"/> | ||
446 | <setEntry value="org.eclipse.emf.parsley.common@default:default"/> | ||
447 | <setEntry value="org.eclipse.emf.parsley.doc@default:default"/> | ||
448 | <setEntry value="org.eclipse.emf.parsley.dsl.additional.builder@default:default"/> | ||
449 | <setEntry value="org.eclipse.emf.parsley.dsl.ide@default:default"/> | ||
450 | <setEntry value="org.eclipse.emf.parsley.dsl.ui@default:default"/> | ||
451 | <setEntry value="org.eclipse.emf.parsley.dsl@default:default"/> | ||
452 | <setEntry value="org.eclipse.emf.parsley.editors.common@default:default"/> | ||
453 | <setEntry value="org.eclipse.emf.parsley.editors@default:default"/> | ||
454 | <setEntry value="org.eclipse.emf.parsley.generator.common@default:default"/> | ||
455 | <setEntry value="org.eclipse.emf.parsley.junit4@default:default"/> | ||
456 | <setEntry value="org.eclipse.emf.parsley.runtime.common@default:default"/> | ||
457 | <setEntry value="org.eclipse.emf.parsley.runtime@default:default"/> | ||
458 | <setEntry value="org.eclipse.emf.parsley.ui.examples@default:default"/> | ||
459 | <setEntry value="org.eclipse.emf.parsley.views.common@default:default"/> | ||
460 | <setEntry value="org.eclipse.emf.parsley.views@default:default"/> | ||
461 | <setEntry value="org.eclipse.emf.parsley.wizards@default:default"/> | ||
462 | <setEntry value="org.eclipse.emf.parsley@default:default"/> | ||
463 | <setEntry value="org.eclipse.emf.query.doc@default:default"/> | ||
464 | <setEntry value="org.eclipse.emf.query.examples@default:default"/> | ||
465 | <setEntry value="org.eclipse.emf.query.ocl@default:default"/> | ||
466 | <setEntry value="org.eclipse.emf.query@default:default"/> | ||
467 | <setEntry value="org.eclipse.emf.transaction.doc@default:default"/> | ||
468 | <setEntry value="org.eclipse.emf.transaction.examples@default:default"/> | ||
469 | <setEntry value="org.eclipse.emf.transaction.ui@default:default"/> | ||
470 | <setEntry value="org.eclipse.emf.transaction@default:default"/> | ||
471 | <setEntry value="org.eclipse.emf.validation.doc@default:default"/> | ||
472 | <setEntry value="org.eclipse.emf.validation.examples@default:default"/> | ||
473 | <setEntry value="org.eclipse.emf.validation.ocl@default:default"/> | ||
474 | <setEntry value="org.eclipse.emf.validation.ui.ide@default:default"/> | ||
475 | <setEntry value="org.eclipse.emf.validation.ui@default:default"/> | ||
476 | <setEntry value="org.eclipse.emf.validation@default:default"/> | ||
477 | <setEntry value="org.eclipse.emf.workspace.doc@default:default"/> | ||
478 | <setEntry value="org.eclipse.emf.workspace.ui@default:default"/> | ||
479 | <setEntry value="org.eclipse.emf.workspace@default:default"/> | ||
480 | <setEntry value="org.eclipse.emf@default:default"/> | ||
481 | <setEntry value="org.eclipse.emfforms.coffee.wizards@default:default"/> | ||
482 | <setEntry value="org.eclipse.emfforms.common.validation@default:default"/> | ||
483 | <setEntry value="org.eclipse.emfforms.common@default:default"/> | ||
484 | <setEntry value="org.eclipse.emfforms.core.bazaar@default:default"/> | ||
485 | <setEntry value="org.eclipse.emfforms.core.services.databinding.featurepath@default:default"/> | ||
486 | <setEntry value="org.eclipse.emfforms.core.services.databinding.index@default:default"/> | ||
487 | <setEntry value="org.eclipse.emfforms.core.services.databinding.mapping@default:default"/> | ||
488 | <setEntry value="org.eclipse.emfforms.core.services.domainexpander.default@default:default"/> | ||
489 | <setEntry value="org.eclipse.emfforms.core.services.domainexpander.index@default:default"/> | ||
490 | <setEntry value="org.eclipse.emfforms.core.services.domainexpander.mapping@default:default"/> | ||
491 | <setEntry value="org.eclipse.emfforms.core.services.domainexpander.table@default:default"/> | ||
492 | <setEntry value="org.eclipse.emfforms.core.services.editsupport@default:default"/> | ||
493 | <setEntry value="org.eclipse.emfforms.core.services.emf@default:default"/> | ||
494 | <setEntry value="org.eclipse.emfforms.core.services.emfspecificservice@default:default"/> | ||
495 | <setEntry value="org.eclipse.emfforms.core.services.legacy@default:default"/> | ||
496 | <setEntry value="org.eclipse.emfforms.core.services.locale.default@default:default"/> | ||
497 | <setEntry value="org.eclipse.emfforms.core.services.mappingprovider.default@default:default"/> | ||
498 | <setEntry value="org.eclipse.emfforms.core.services.mappingprovider.table.panel@default:default"/> | ||
499 | <setEntry value="org.eclipse.emfforms.core.services.mappingprovider.table@default:default"/> | ||
500 | <setEntry value="org.eclipse.emfforms.core.services.segments.featurepath@default:default"/> | ||
501 | <setEntry value="org.eclipse.emfforms.core.services.segments.index@default:default"/> | ||
502 | <setEntry value="org.eclipse.emfforms.core.services.segments.mapping@default:default"/> | ||
503 | <setEntry value="org.eclipse.emfforms.core.services.segments.multi@default:default"/> | ||
504 | <setEntry value="org.eclipse.emfforms.core.services.segments@default:default"/> | ||
505 | <setEntry value="org.eclipse.emfforms.core.services.structuralchange.default@default:default"/> | ||
506 | <setEntry value="org.eclipse.emfforms.core.services.structuralchange.index@default:default"/> | ||
507 | <setEntry value="org.eclipse.emfforms.core.services.structuralchange.mapping@default:default"/> | ||
508 | <setEntry value="org.eclipse.emfforms.core.services.structuralchange.table@default:default"/> | ||
509 | <setEntry value="org.eclipse.emfforms.core.services.structuralchange@default:default"/> | ||
510 | <setEntry value="org.eclipse.emfforms.core.services@default:default"/> | ||
511 | <setEntry value="org.eclipse.emfforms.editor.ecore@default:default"/> | ||
512 | <setEntry value="org.eclipse.emfforms.editor.genmodel@default:default"/> | ||
513 | <setEntry value="org.eclipse.emfforms.editor@default:default"/> | ||
514 | <setEntry value="org.eclipse.emfforms.example.common.wizards@default:default"/> | ||
515 | <setEntry value="org.eclipse.emfforms.ide.builder@default:default"/> | ||
516 | <setEntry value="org.eclipse.emfforms.ide.viewtemplate.builder@default:default"/> | ||
517 | <setEntry value="org.eclipse.emfforms.localization@default:default"/> | ||
518 | <setEntry value="org.eclipse.emfforms.setup.base@default:default"/> | ||
519 | <setEntry value="org.eclipse.emfforms.swt.control.multiattribute@default:default"/> | ||
520 | <setEntry value="org.eclipse.emfforms.swt.core.di.extension@default:default"/> | ||
521 | <setEntry value="org.eclipse.emfforms.swt.core.di@default:default"/> | ||
522 | <setEntry value="org.eclipse.emfforms.swt.core.plugin@default:default"/> | ||
523 | <setEntry value="org.eclipse.emfforms.swt.core@default:default"/> | ||
524 | <setEntry value="org.eclipse.emfforms.swt.table@default:default"/> | ||
525 | <setEntry value="org.eclipse.emfforms.swt.treemasterdetail.decorator.validation.default@default:default"/> | ||
526 | <setEntry value="org.eclipse.emfforms.swt.treemasterdetail@default:default"/> | ||
527 | <setEntry value="org.eclipse.emfforms.view.annotation.model.edit@default:default"/> | ||
528 | <setEntry value="org.eclipse.emfforms.view.annotation.model@default:default"/> | ||
529 | <setEntry value="org.eclipse.emfforms.view.indexsegment.model@default:default"/> | ||
530 | <setEntry value="org.eclipse.emfforms.view.mappingsegment.model@default:default"/> | ||
531 | <setEntry value="org.eclipse.emfforms.view.model.localization@default:default"/> | ||
532 | <setEntry value="org.eclipse.emfforms.view.multisegment.model.edit@default:default"/> | ||
533 | <setEntry value="org.eclipse.emfforms.view.multisegment.model@default:default"/> | ||
534 | <setEntry value="org.eclipse.epp.logging.aeri.core@default:default"/> | ||
535 | <setEntry value="org.eclipse.epp.logging.aeri.ide@default:default"/> | ||
536 | <setEntry value="org.eclipse.epp.mpc.core@default:default"/> | ||
537 | <setEntry value="org.eclipse.epp.mpc.help.ui@default:default"/> | ||
538 | <setEntry value="org.eclipse.epp.mpc.ui.css@default:default"/> | ||
539 | <setEntry value="org.eclipse.epp.mpc.ui@default:default"/> | ||
540 | <setEntry value="org.eclipse.epp.package.common@default:default"/> | ||
541 | <setEntry value="org.eclipse.epp.package.modeling@default:default"/> | ||
542 | <setEntry value="org.eclipse.equinox.app@default:default"/> | ||
543 | <setEntry value="org.eclipse.equinox.bidi@default:default"/> | ||
544 | <setEntry value="org.eclipse.equinox.common@2:true"/> | ||
545 | <setEntry value="org.eclipse.equinox.concurrent@default:default"/> | ||
546 | <setEntry value="org.eclipse.equinox.console@default:default"/> | ||
547 | <setEntry value="org.eclipse.equinox.ds@1:true"/> | ||
548 | <setEntry value="org.eclipse.equinox.event@default:default"/> | ||
549 | <setEntry value="org.eclipse.equinox.frameworkadmin.equinox@default:default"/> | ||
550 | <setEntry value="org.eclipse.equinox.frameworkadmin@default:default"/> | ||
551 | <setEntry value="org.eclipse.equinox.http.jetty@default:default"/> | ||
552 | <setEntry value="org.eclipse.equinox.http.registry@default:default"/> | ||
553 | <setEntry value="org.eclipse.equinox.http.servlet@default:default"/> | ||
554 | <setEntry value="org.eclipse.equinox.jsp.jasper.registry@default:default"/> | ||
555 | <setEntry value="org.eclipse.equinox.jsp.jasper@default:default"/> | ||
556 | <setEntry value="org.eclipse.equinox.launcher.gtk.linux.x86_64@default:false"/> | ||
557 | <setEntry value="org.eclipse.equinox.launcher@default:default"/> | ||
558 | <setEntry value="org.eclipse.equinox.p2.artifact.repository@default:default"/> | ||
559 | <setEntry value="org.eclipse.equinox.p2.console@default:default"/> | ||
560 | <setEntry value="org.eclipse.equinox.p2.core@default:default"/> | ||
561 | <setEntry value="org.eclipse.equinox.p2.director.app@default:default"/> | ||
562 | <setEntry value="org.eclipse.equinox.p2.director@default:default"/> | ||
563 | <setEntry value="org.eclipse.equinox.p2.directorywatcher@default:default"/> | ||
564 | <setEntry value="org.eclipse.equinox.p2.discovery.compatibility@default:default"/> | ||
565 | <setEntry value="org.eclipse.equinox.p2.discovery@default:default"/> | ||
566 | <setEntry value="org.eclipse.equinox.p2.engine@default:default"/> | ||
567 | <setEntry value="org.eclipse.equinox.p2.extensionlocation@default:default"/> | ||
568 | <setEntry value="org.eclipse.equinox.p2.garbagecollector@default:default"/> | ||
569 | <setEntry value="org.eclipse.equinox.p2.jarprocessor@default:default"/> | ||
570 | <setEntry value="org.eclipse.equinox.p2.metadata.repository@default:default"/> | ||
571 | <setEntry value="org.eclipse.equinox.p2.metadata@default:default"/> | ||
572 | <setEntry value="org.eclipse.equinox.p2.operations@default:default"/> | ||
573 | <setEntry value="org.eclipse.equinox.p2.publisher.eclipse@default:default"/> | ||
574 | <setEntry value="org.eclipse.equinox.p2.publisher@default:default"/> | ||
575 | <setEntry value="org.eclipse.equinox.p2.reconciler.dropins@default:default"/> | ||
576 | <setEntry value="org.eclipse.equinox.p2.repository.tools@default:default"/> | ||
577 | <setEntry value="org.eclipse.equinox.p2.repository@default:default"/> | ||
578 | <setEntry value="org.eclipse.equinox.p2.touchpoint.eclipse@default:default"/> | ||
579 | <setEntry value="org.eclipse.equinox.p2.touchpoint.natives@default:default"/> | ||
580 | <setEntry value="org.eclipse.equinox.p2.transport.ecf@default:default"/> | ||
581 | <setEntry value="org.eclipse.equinox.p2.ui.discovery@default:default"/> | ||
582 | <setEntry value="org.eclipse.equinox.p2.ui.importexport@default:default"/> | ||
583 | <setEntry value="org.eclipse.equinox.p2.ui.sdk.scheduler@default:default"/> | ||
584 | <setEntry value="org.eclipse.equinox.p2.ui.sdk@default:default"/> | ||
585 | <setEntry value="org.eclipse.equinox.p2.ui@default:default"/> | ||
586 | <setEntry value="org.eclipse.equinox.p2.updatechecker@default:default"/> | ||
587 | <setEntry value="org.eclipse.equinox.p2.updatesite@default:default"/> | ||
588 | <setEntry value="org.eclipse.equinox.preferences@default:default"/> | ||
589 | <setEntry value="org.eclipse.equinox.registry@default:default"/> | ||
590 | <setEntry value="org.eclipse.equinox.security.linux.x86_64@default:false"/> | ||
591 | <setEntry value="org.eclipse.equinox.security.ui@default:default"/> | ||
592 | <setEntry value="org.eclipse.equinox.security@default:default"/> | ||
593 | <setEntry value="org.eclipse.equinox.simpleconfigurator.manipulator@default:default"/> | ||
594 | <setEntry value="org.eclipse.equinox.simpleconfigurator@1:true"/> | ||
595 | <setEntry value="org.eclipse.equinox.util@default:default"/> | ||
596 | <setEntry value="org.eclipse.fx.osgi@default:false"/> | ||
597 | <setEntry value="org.eclipse.gef.common@default:default"/> | ||
598 | <setEntry value="org.eclipse.gef.doc.isv@default:default"/> | ||
599 | <setEntry value="org.eclipse.gef.examples.ui.pde@default:default"/> | ||
600 | <setEntry value="org.eclipse.gef.fx.swt@default:default"/> | ||
601 | <setEntry value="org.eclipse.gef.fx@default:default"/> | ||
602 | <setEntry value="org.eclipse.gef.geometry.convert.fx@default:default"/> | ||
603 | <setEntry value="org.eclipse.gef.geometry@default:default"/> | ||
604 | <setEntry value="org.eclipse.gef.graph@default:default"/> | ||
605 | <setEntry value="org.eclipse.gef.layout@default:default"/> | ||
606 | <setEntry value="org.eclipse.gef.mvc.fx@default:default"/> | ||
607 | <setEntry value="org.eclipse.gef.zest.fx.jface@default:default"/> | ||
608 | <setEntry value="org.eclipse.gef.zest.fx@default:default"/> | ||
609 | <setEntry value="org.eclipse.gef@default:default"/> | ||
610 | <setEntry value="org.eclipse.gmf.examples.runtime.diagram.geoshapes@default:default"/> | ||
611 | <setEntry value="org.eclipse.gmf.examples.runtime.diagram.logic.model.edit@default:default"/> | ||
612 | <setEntry value="org.eclipse.gmf.examples.runtime.diagram.logic.model.editor@default:default"/> | ||
613 | <setEntry value="org.eclipse.gmf.examples.runtime.diagram.logic.model@default:default"/> | ||
614 | <setEntry value="org.eclipse.gmf.examples.runtime.diagram.logic@default:default"/> | ||
615 | <setEntry value="org.eclipse.gmf.examples.runtime.ui.pde@default:default"/> | ||
616 | <setEntry value="org.eclipse.gmf.examples.runtime@default:default"/> | ||
617 | <setEntry value="org.eclipse.gmf.runtime.common.core@default:default"/> | ||
618 | <setEntry value="org.eclipse.gmf.runtime.common.ui.action.ide@default:default"/> | ||
619 | <setEntry value="org.eclipse.gmf.runtime.common.ui.action@default:default"/> | ||
620 | <setEntry value="org.eclipse.gmf.runtime.common.ui.printing.win32@default:false"/> | ||
621 | <setEntry value="org.eclipse.gmf.runtime.common.ui.printing@default:default"/> | ||
622 | <setEntry value="org.eclipse.gmf.runtime.common.ui.services.action@default:default"/> | ||
623 | <setEntry value="org.eclipse.gmf.runtime.common.ui.services.dnd.ide@default:default"/> | ||
624 | <setEntry value="org.eclipse.gmf.runtime.common.ui.services.dnd@default:default"/> | ||
625 | <setEntry value="org.eclipse.gmf.runtime.common.ui.services.properties@default:default"/> | ||
626 | <setEntry value="org.eclipse.gmf.runtime.common.ui.services@default:default"/> | ||
627 | <setEntry value="org.eclipse.gmf.runtime.common.ui@default:default"/> | ||
628 | <setEntry value="org.eclipse.gmf.runtime.diagram.core@default:default"/> | ||
629 | <setEntry value="org.eclipse.gmf.runtime.diagram.ui.actions@default:default"/> | ||
630 | <setEntry value="org.eclipse.gmf.runtime.diagram.ui.dnd@default:default"/> | ||
631 | <setEntry value="org.eclipse.gmf.runtime.diagram.ui.geoshapes@default:default"/> | ||
632 | <setEntry value="org.eclipse.gmf.runtime.diagram.ui.printing.render@default:default"/> | ||
633 | <setEntry value="org.eclipse.gmf.runtime.diagram.ui.printing@default:default"/> | ||
634 | <setEntry value="org.eclipse.gmf.runtime.diagram.ui.properties@default:default"/> | ||
635 | <setEntry value="org.eclipse.gmf.runtime.diagram.ui.providers.ide@default:default"/> | ||
636 | <setEntry value="org.eclipse.gmf.runtime.diagram.ui.providers@default:default"/> | ||
637 | <setEntry value="org.eclipse.gmf.runtime.diagram.ui.render@default:default"/> | ||
638 | <setEntry value="org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide@default:default"/> | ||
639 | <setEntry value="org.eclipse.gmf.runtime.diagram.ui.resources.editor@default:default"/> | ||
640 | <setEntry value="org.eclipse.gmf.runtime.diagram.ui@default:default"/> | ||
641 | <setEntry value="org.eclipse.gmf.runtime.draw2d.ui.render.awt@default:default"/> | ||
642 | <setEntry value="org.eclipse.gmf.runtime.draw2d.ui.render@default:default"/> | ||
643 | <setEntry value="org.eclipse.gmf.runtime.draw2d.ui@default:default"/> | ||
644 | <setEntry value="org.eclipse.gmf.runtime.emf.clipboard.core@default:default"/> | ||
645 | <setEntry value="org.eclipse.gmf.runtime.emf.commands.core@default:default"/> | ||
646 | <setEntry value="org.eclipse.gmf.runtime.emf.core@default:default"/> | ||
647 | <setEntry value="org.eclipse.gmf.runtime.emf.type.core@default:default"/> | ||
648 | <setEntry value="org.eclipse.gmf.runtime.emf.type.ui@default:default"/> | ||
649 | <setEntry value="org.eclipse.gmf.runtime.emf.ui.properties@default:default"/> | ||
650 | <setEntry value="org.eclipse.gmf.runtime.emf.ui@default:default"/> | ||
651 | <setEntry value="org.eclipse.gmf.runtime.gef.ui@default:default"/> | ||
652 | <setEntry value="org.eclipse.gmf.runtime.notation.edit@default:default"/> | ||
653 | <setEntry value="org.eclipse.gmf.runtime.notation.providers@default:default"/> | ||
654 | <setEntry value="org.eclipse.gmf.runtime.notation.sdk@default:default"/> | ||
655 | <setEntry value="org.eclipse.gmf.runtime.notation@default:default"/> | ||
656 | <setEntry value="org.eclipse.gmf.runtime.sdk@default:default"/> | ||
657 | <setEntry value="org.eclipse.gmf@default:default"/> | ||
658 | <setEntry value="org.eclipse.help.base@default:default"/> | ||
659 | <setEntry value="org.eclipse.help.ui@default:default"/> | ||
660 | <setEntry value="org.eclipse.help.webapp@default:default"/> | ||
661 | <setEntry value="org.eclipse.help@default:default"/> | ||
662 | <setEntry value="org.eclipse.jdt.annotation*1.1.400.v20180921-1416@default:default"/> | ||
663 | <setEntry value="org.eclipse.jdt.annotation*2.2.200.v20180921-1416@default:default"/> | ||
664 | <setEntry value="org.eclipse.jdt.apt.core@default:default"/> | ||
665 | <setEntry value="org.eclipse.jdt.apt.pluggable.core@default:default"/> | ||
666 | <setEntry value="org.eclipse.jdt.apt.ui@default:default"/> | ||
667 | <setEntry value="org.eclipse.jdt.compiler.apt@default:false"/> | ||
668 | <setEntry value="org.eclipse.jdt.compiler.tool@default:false"/> | ||
669 | <setEntry value="org.eclipse.jdt.core.manipulation@default:default"/> | ||
670 | <setEntry value="org.eclipse.jdt.core@default:default"/> | ||
671 | <setEntry value="org.eclipse.jdt.debug.ui@default:default"/> | ||
672 | <setEntry value="org.eclipse.jdt.debug@default:default"/> | ||
673 | <setEntry value="org.eclipse.jdt.doc.isv@default:default"/> | ||
674 | <setEntry value="org.eclipse.jdt.doc.user@default:default"/> | ||
675 | <setEntry value="org.eclipse.jdt.junit.core@default:default"/> | ||
676 | <setEntry value="org.eclipse.jdt.junit.runtime@default:default"/> | ||
677 | <setEntry value="org.eclipse.jdt.junit4.runtime@default:default"/> | ||
678 | <setEntry value="org.eclipse.jdt.junit5.runtime@default:default"/> | ||
679 | <setEntry value="org.eclipse.jdt.junit@default:default"/> | ||
680 | <setEntry value="org.eclipse.jdt.launching@default:default"/> | ||
681 | <setEntry value="org.eclipse.jdt.ui@default:default"/> | ||
682 | <setEntry value="org.eclipse.jdt@default:default"/> | ||
683 | <setEntry value="org.eclipse.jem.util@default:default"/> | ||
684 | <setEntry value="org.eclipse.jetty.continuation@default:default"/> | ||
685 | <setEntry value="org.eclipse.jetty.http@default:default"/> | ||
686 | <setEntry value="org.eclipse.jetty.io@default:default"/> | ||
687 | <setEntry value="org.eclipse.jetty.security@default:default"/> | ||
688 | <setEntry value="org.eclipse.jetty.server@default:default"/> | ||
689 | <setEntry value="org.eclipse.jetty.servlet@default:default"/> | ||
690 | <setEntry value="org.eclipse.jetty.util@default:default"/> | ||
691 | <setEntry value="org.eclipse.jface.databinding@default:default"/> | ||
692 | <setEntry value="org.eclipse.jface.text@default:default"/> | ||
693 | <setEntry value="org.eclipse.jface@default:default"/> | ||
694 | <setEntry value="org.eclipse.jgit.archive@default:default"/> | ||
695 | <setEntry value="org.eclipse.jgit.ssh.apache@default:default"/> | ||
696 | <setEntry value="org.eclipse.jgit@default:default"/> | ||
697 | <setEntry value="org.eclipse.jsch.core@default:default"/> | ||
698 | <setEntry value="org.eclipse.jsch.ui@default:default"/> | ||
699 | <setEntry value="org.eclipse.ltk.core.refactoring@default:default"/> | ||
700 | <setEntry value="org.eclipse.ltk.ui.refactoring@default:default"/> | ||
701 | <setEntry value="org.eclipse.m2e.archetype.common@default:default"/> | ||
702 | <setEntry value="org.eclipse.m2e.core.ui@default:default"/> | ||
703 | <setEntry value="org.eclipse.m2e.core@default:default"/> | ||
704 | <setEntry value="org.eclipse.m2e.launching@default:default"/> | ||
705 | <setEntry value="org.eclipse.m2e.maven.indexer@default:default"/> | ||
706 | <setEntry value="org.eclipse.m2e.maven.runtime.slf4j.simple@default:default"/> | ||
707 | <setEntry value="org.eclipse.m2e.maven.runtime@default:default"/> | ||
708 | <setEntry value="org.eclipse.m2e.model.edit@default:default"/> | ||
709 | <setEntry value="org.eclipse.m2e.workspace.cli@default:default"/> | ||
710 | <setEntry value="org.eclipse.m2m.qvt.oml.common@default:default"/> | ||
711 | <setEntry value="org.eclipse.m2m.qvt.oml.cst.parser@default:default"/> | ||
712 | <setEntry value="org.eclipse.m2m.qvt.oml.ecore.imperativeocl@default:default"/> | ||
713 | <setEntry value="org.eclipse.m2m.qvt.oml.emf.util@default:default"/> | ||
714 | <setEntry value="org.eclipse.m2m.qvt.oml@default:default"/> | ||
715 | <setEntry value="org.eclipse.mylyn.bugzilla.core@default:default"/> | ||
716 | <setEntry value="org.eclipse.mylyn.bugzilla.ide@default:default"/> | ||
717 | <setEntry value="org.eclipse.mylyn.bugzilla.ui@default:default"/> | ||
718 | <setEntry value="org.eclipse.mylyn.commons.core@default:default"/> | ||
719 | <setEntry value="org.eclipse.mylyn.commons.identity.core@default:default"/> | ||
720 | <setEntry value="org.eclipse.mylyn.commons.net@default:default"/> | ||
721 | <setEntry value="org.eclipse.mylyn.commons.notifications.core@default:default"/> | ||
722 | <setEntry value="org.eclipse.mylyn.commons.notifications.feed@default:default"/> | ||
723 | <setEntry value="org.eclipse.mylyn.commons.notifications.ui@default:default"/> | ||
724 | <setEntry value="org.eclipse.mylyn.commons.repositories.core@default:default"/> | ||
725 | <setEntry value="org.eclipse.mylyn.commons.repositories.ui@default:default"/> | ||
726 | <setEntry value="org.eclipse.mylyn.commons.screenshots@default:default"/> | ||
727 | <setEntry value="org.eclipse.mylyn.commons.ui@default:default"/> | ||
728 | <setEntry value="org.eclipse.mylyn.commons.workbench@default:default"/> | ||
729 | <setEntry value="org.eclipse.mylyn.commons.xmlrpc@default:default"/> | ||
730 | <setEntry value="org.eclipse.mylyn.context.core@default:default"/> | ||
731 | <setEntry value="org.eclipse.mylyn.context.tasks.ui@default:default"/> | ||
732 | <setEntry value="org.eclipse.mylyn.context.ui@default:default"/> | ||
733 | <setEntry value="org.eclipse.mylyn.debug.ui@default:default"/> | ||
734 | <setEntry value="org.eclipse.mylyn.discovery.core@default:default"/> | ||
735 | <setEntry value="org.eclipse.mylyn.discovery.ui@default:default"/> | ||
736 | <setEntry value="org.eclipse.mylyn.help.ui@default:default"/> | ||
737 | <setEntry value="org.eclipse.mylyn.ide.ant@default:default"/> | ||
738 | <setEntry value="org.eclipse.mylyn.ide.ui@default:default"/> | ||
739 | <setEntry value="org.eclipse.mylyn.java.tasks@default:default"/> | ||
740 | <setEntry value="org.eclipse.mylyn.java.ui@default:default"/> | ||
741 | <setEntry value="org.eclipse.mylyn.monitor.core@default:default"/> | ||
742 | <setEntry value="org.eclipse.mylyn.monitor.ui@default:default"/> | ||
743 | <setEntry value="org.eclipse.mylyn.pde.ui@default:default"/> | ||
744 | <setEntry value="org.eclipse.mylyn.resources.ui@default:default"/> | ||
745 | <setEntry value="org.eclipse.mylyn.tasks.bugs@default:default"/> | ||
746 | <setEntry value="org.eclipse.mylyn.tasks.core@default:default"/> | ||
747 | <setEntry value="org.eclipse.mylyn.tasks.index.core@default:default"/> | ||
748 | <setEntry value="org.eclipse.mylyn.tasks.index.ui@default:default"/> | ||
749 | <setEntry value="org.eclipse.mylyn.tasks.search@default:default"/> | ||
750 | <setEntry value="org.eclipse.mylyn.tasks.ui@default:default"/> | ||
751 | <setEntry value="org.eclipse.mylyn.team.ui@default:default"/> | ||
752 | <setEntry value="org.eclipse.mylyn.wikitext.ant@default:default"/> | ||
753 | <setEntry value="org.eclipse.mylyn.wikitext.asciidoc.ui@default:default"/> | ||
754 | <setEntry value="org.eclipse.mylyn.wikitext.asciidoc@default:default"/> | ||
755 | <setEntry value="org.eclipse.mylyn.wikitext.confluence.ui@default:default"/> | ||
756 | <setEntry value="org.eclipse.mylyn.wikitext.confluence@default:default"/> | ||
757 | <setEntry value="org.eclipse.mylyn.wikitext.context.ui@default:default"/> | ||
758 | <setEntry value="org.eclipse.mylyn.wikitext.help.ui@default:default"/> | ||
759 | <setEntry value="org.eclipse.mylyn.wikitext.html@default:default"/> | ||
760 | <setEntry value="org.eclipse.mylyn.wikitext.markdown.ui@default:default"/> | ||
761 | <setEntry value="org.eclipse.mylyn.wikitext.markdown@default:default"/> | ||
762 | <setEntry value="org.eclipse.mylyn.wikitext.mediawiki.ui@default:default"/> | ||
763 | <setEntry value="org.eclipse.mylyn.wikitext.mediawiki@default:default"/> | ||
764 | <setEntry value="org.eclipse.mylyn.wikitext.osgi@default:default"/> | ||
765 | <setEntry value="org.eclipse.mylyn.wikitext.tasks.ui@default:default"/> | ||
766 | <setEntry value="org.eclipse.mylyn.wikitext.textile.ui@default:default"/> | ||
767 | <setEntry value="org.eclipse.mylyn.wikitext.textile@default:default"/> | ||
768 | <setEntry value="org.eclipse.mylyn.wikitext.tracwiki.ui@default:default"/> | ||
769 | <setEntry value="org.eclipse.mylyn.wikitext.tracwiki@default:default"/> | ||
770 | <setEntry value="org.eclipse.mylyn.wikitext.twiki.ui@default:default"/> | ||
771 | <setEntry value="org.eclipse.mylyn.wikitext.twiki@default:default"/> | ||
772 | <setEntry value="org.eclipse.mylyn.wikitext.ui@default:default"/> | ||
773 | <setEntry value="org.eclipse.mylyn.wikitext@default:default"/> | ||
774 | <setEntry value="org.eclipse.nebula.widgets.tablecombo@default:default"/> | ||
775 | <setEntry value="org.eclipse.net4j.db.h2@default:default"/> | ||
776 | <setEntry value="org.eclipse.net4j.db.jdbc@default:default"/> | ||
777 | <setEntry value="org.eclipse.net4j.db@default:default"/> | ||
778 | <setEntry value="org.eclipse.net4j.debug@default:default"/> | ||
779 | <setEntry value="org.eclipse.net4j.examples.installer@default:default"/> | ||
780 | <setEntry value="org.eclipse.net4j.http.common@default:default"/> | ||
781 | <setEntry value="org.eclipse.net4j.http.server@default:default"/> | ||
782 | <setEntry value="org.eclipse.net4j.http@default:default"/> | ||
783 | <setEntry value="org.eclipse.net4j.jvm@default:default"/> | ||
784 | <setEntry value="org.eclipse.net4j.tcp@default:default"/> | ||
785 | <setEntry value="org.eclipse.net4j.ui.shared@default:default"/> | ||
786 | <setEntry value="org.eclipse.net4j.ui@default:default"/> | ||
787 | <setEntry value="org.eclipse.net4j.util.ui@default:default"/> | ||
788 | <setEntry value="org.eclipse.net4j.util@default:default"/> | ||
789 | <setEntry value="org.eclipse.net4j@default:default"/> | ||
790 | <setEntry value="org.eclipse.ocl.common.ui@default:default"/> | ||
791 | <setEntry value="org.eclipse.ocl.common@default:default"/> | ||
792 | <setEntry value="org.eclipse.ocl.doc@default:default"/> | ||
793 | <setEntry value="org.eclipse.ocl.ecore.edit@default:default"/> | ||
794 | <setEntry value="org.eclipse.ocl.ecore@default:default"/> | ||
795 | <setEntry value="org.eclipse.ocl.edit@default:default"/> | ||
796 | <setEntry value="org.eclipse.ocl.ui@default:default"/> | ||
797 | <setEntry value="org.eclipse.ocl.uml.edit@default:default"/> | ||
798 | <setEntry value="org.eclipse.ocl.uml.ui@default:default"/> | ||
799 | <setEntry value="org.eclipse.ocl.uml@default:default"/> | ||
800 | <setEntry value="org.eclipse.ocl@default:default"/> | ||
801 | <setEntry value="org.eclipse.oomph.base.edit@default:default"/> | ||
802 | <setEntry value="org.eclipse.oomph.base@default:default"/> | ||
803 | <setEntry value="org.eclipse.oomph.extractor.lib@default:default"/> | ||
804 | <setEntry value="org.eclipse.oomph.jreinfo.ui@default:default"/> | ||
805 | <setEntry value="org.eclipse.oomph.jreinfo@default:default"/> | ||
806 | <setEntry value="org.eclipse.oomph.p2.core@default:default"/> | ||
807 | <setEntry value="org.eclipse.oomph.p2.doc@default:default"/> | ||
808 | <setEntry value="org.eclipse.oomph.p2.edit@default:default"/> | ||
809 | <setEntry value="org.eclipse.oomph.p2.ui@default:default"/> | ||
810 | <setEntry value="org.eclipse.oomph.p2@default:default"/> | ||
811 | <setEntry value="org.eclipse.oomph.predicates.edit@default:default"/> | ||
812 | <setEntry value="org.eclipse.oomph.predicates@default:default"/> | ||
813 | <setEntry value="org.eclipse.oomph.preferences@default:default"/> | ||
814 | <setEntry value="org.eclipse.oomph.resources.edit@default:default"/> | ||
815 | <setEntry value="org.eclipse.oomph.resources@default:default"/> | ||
816 | <setEntry value="org.eclipse.oomph.setup.core@default:default"/> | ||
817 | <setEntry value="org.eclipse.oomph.setup.doc@default:default"/> | ||
818 | <setEntry value="org.eclipse.oomph.setup.edit@default:default"/> | ||
819 | <setEntry value="org.eclipse.oomph.setup.editor@default:default"/> | ||
820 | <setEntry value="org.eclipse.oomph.setup.p2.edit@default:default"/> | ||
821 | <setEntry value="org.eclipse.oomph.setup.p2@default:default"/> | ||
822 | <setEntry value="org.eclipse.oomph.setup.sync@default:default"/> | ||
823 | <setEntry value="org.eclipse.oomph.setup.ui.questionnaire@default:default"/> | ||
824 | <setEntry value="org.eclipse.oomph.setup.ui@default:default"/> | ||
825 | <setEntry value="org.eclipse.oomph.setup@default:default"/> | ||
826 | <setEntry value="org.eclipse.oomph.ui@default:default"/> | ||
827 | <setEntry value="org.eclipse.oomph.util@default:default"/> | ||
828 | <setEntry value="org.eclipse.oomph.workingsets.edit@default:default"/> | ||
829 | <setEntry value="org.eclipse.oomph.workingsets.editor@default:default"/> | ||
830 | <setEntry value="org.eclipse.oomph.workingsets@default:default"/> | ||
831 | <setEntry value="org.eclipse.osgi.compatibility.state@default:false"/> | ||
832 | <setEntry value="org.eclipse.osgi.services@default:default"/> | ||
833 | <setEntry value="org.eclipse.osgi.util@default:default"/> | ||
834 | <setEntry value="org.eclipse.osgi@-1:true"/> | ||
835 | <setEntry value="org.eclipse.papyrus.infra.gmfdiag.tooling.runtime@default:default"/> | ||
836 | <setEntry value="org.eclipse.pde.api.tools.annotations@default:default"/> | ||
837 | <setEntry value="org.eclipse.pde.api.tools.ui@default:default"/> | ||
838 | <setEntry value="org.eclipse.pde.api.tools@default:default"/> | ||
839 | <setEntry value="org.eclipse.pde.build@default:default"/> | ||
840 | <setEntry value="org.eclipse.pde.core@default:default"/> | ||
841 | <setEntry value="org.eclipse.pde.doc.user@default:default"/> | ||
842 | <setEntry value="org.eclipse.pde.ds.annotations@default:default"/> | ||
843 | <setEntry value="org.eclipse.pde.ds.core@default:default"/> | ||
844 | <setEntry value="org.eclipse.pde.ds.lib@default:default"/> | ||
845 | <setEntry value="org.eclipse.pde.ds.ui@default:default"/> | ||
846 | <setEntry value="org.eclipse.pde.ds1_2.lib@default:default"/> | ||
847 | <setEntry value="org.eclipse.pde.genericeditor.extension@default:default"/> | ||
848 | <setEntry value="org.eclipse.pde.junit.runtime@default:default"/> | ||
849 | <setEntry value="org.eclipse.pde.launching@default:default"/> | ||
850 | <setEntry value="org.eclipse.pde.runtime@default:default"/> | ||
851 | <setEntry value="org.eclipse.pde.ua.core@default:default"/> | ||
852 | <setEntry value="org.eclipse.pde.ua.ui@default:default"/> | ||
853 | <setEntry value="org.eclipse.pde.ui.templates@default:default"/> | ||
854 | <setEntry value="org.eclipse.pde.ui@default:default"/> | ||
855 | <setEntry value="org.eclipse.pde@default:default"/> | ||
856 | <setEntry value="org.eclipse.platform.doc.isv@default:default"/> | ||
857 | <setEntry value="org.eclipse.platform.doc.user@default:default"/> | ||
858 | <setEntry value="org.eclipse.platform@default:default"/> | ||
859 | <setEntry value="org.eclipse.rcp@default:default"/> | ||
860 | <setEntry value="org.eclipse.sdk@default:default"/> | ||
861 | <setEntry value="org.eclipse.search@default:default"/> | ||
862 | <setEntry value="org.eclipse.sirius.common.acceleo.aql@default:default"/> | ||
863 | <setEntry value="org.eclipse.sirius.common.interpreter@default:default"/> | ||
864 | <setEntry value="org.eclipse.sirius.common.ui.ext@default:default"/> | ||
865 | <setEntry value="org.eclipse.sirius.common.ui@default:default"/> | ||
866 | <setEntry value="org.eclipse.sirius.common.xtext@default:default"/> | ||
867 | <setEntry value="org.eclipse.sirius.common@default:default"/> | ||
868 | <setEntry value="org.eclipse.sirius.diagram.formatdata@default:default"/> | ||
869 | <setEntry value="org.eclipse.sirius.diagram.layoutdata@default:default"/> | ||
870 | <setEntry value="org.eclipse.sirius.diagram.sequence.edit@default:default"/> | ||
871 | <setEntry value="org.eclipse.sirius.diagram.sequence.ui@default:default"/> | ||
872 | <setEntry value="org.eclipse.sirius.diagram.sequence@default:default"/> | ||
873 | <setEntry value="org.eclipse.sirius.diagram.ui.ext@default:default"/> | ||
874 | <setEntry value="org.eclipse.sirius.diagram.ui@default:default"/> | ||
875 | <setEntry value="org.eclipse.sirius.diagram@default:default"/> | ||
876 | <setEntry value="org.eclipse.sirius.ecore.extender@default:default"/> | ||
877 | <setEntry value="org.eclipse.sirius.editor.properties.ext.widgets.reference@default:default"/> | ||
878 | <setEntry value="org.eclipse.sirius.editor.properties@default:default"/> | ||
879 | <setEntry value="org.eclipse.sirius.editor@default:default"/> | ||
880 | <setEntry value="org.eclipse.sirius.ext.base@default:default"/> | ||
881 | <setEntry value="org.eclipse.sirius.ext.draw2d@default:default"/> | ||
882 | <setEntry value="org.eclipse.sirius.ext.e3.ui@default:default"/> | ||
883 | <setEntry value="org.eclipse.sirius.ext.e3@default:default"/> | ||
884 | <setEntry value="org.eclipse.sirius.ext.emf.edit@default:default"/> | ||
885 | <setEntry value="org.eclipse.sirius.ext.emf.tx@default:default"/> | ||
886 | <setEntry value="org.eclipse.sirius.ext.emf.ui@default:default"/> | ||
887 | <setEntry value="org.eclipse.sirius.ext.emf@default:default"/> | ||
888 | <setEntry value="org.eclipse.sirius.ext.gef@default:default"/> | ||
889 | <setEntry value="org.eclipse.sirius.ext.gmf.notation@default:default"/> | ||
890 | <setEntry value="org.eclipse.sirius.ext.gmf.runtime@default:default"/> | ||
891 | <setEntry value="org.eclipse.sirius.ext.ide@default:default"/> | ||
892 | <setEntry value="org.eclipse.sirius.ext.jface@default:default"/> | ||
893 | <setEntry value="org.eclipse.sirius.ext.swt@default:default"/> | ||
894 | <setEntry value="org.eclipse.sirius.interpreter@default:default"/> | ||
895 | <setEntry value="org.eclipse.sirius.properties.core@default:default"/> | ||
896 | <setEntry value="org.eclipse.sirius.properties.defaultrules@default:default"/> | ||
897 | <setEntry value="org.eclipse.sirius.properties.edit@default:default"/> | ||
898 | <setEntry value="org.eclipse.sirius.properties.ext.widgets.reference.edit@default:default"/> | ||
899 | <setEntry value="org.eclipse.sirius.properties.ext.widgets.reference@default:default"/> | ||
900 | <setEntry value="org.eclipse.sirius.properties@default:default"/> | ||
901 | <setEntry value="org.eclipse.sirius.synchronizer@default:default"/> | ||
902 | <setEntry value="org.eclipse.sirius.table.ui.ext@default:default"/> | ||
903 | <setEntry value="org.eclipse.sirius.table.ui@default:default"/> | ||
904 | <setEntry value="org.eclipse.sirius.table@default:default"/> | ||
905 | <setEntry value="org.eclipse.sirius.tree.ui.ext@default:default"/> | ||
906 | <setEntry value="org.eclipse.sirius.tree.ui@default:default"/> | ||
907 | <setEntry value="org.eclipse.sirius.tree@default:default"/> | ||
908 | <setEntry value="org.eclipse.sirius.ui.editor@default:default"/> | ||
909 | <setEntry value="org.eclipse.sirius.ui.ext@default:default"/> | ||
910 | <setEntry value="org.eclipse.sirius.ui.properties.ext.widgets.reference@default:default"/> | ||
911 | <setEntry value="org.eclipse.sirius.ui.properties@default:default"/> | ||
912 | <setEntry value="org.eclipse.sirius.ui@default:default"/> | ||
913 | <setEntry value="org.eclipse.sirius@default:default"/> | ||
914 | <setEntry value="org.eclipse.swt.gtk.linux.x86_64@default:false"/> | ||
915 | <setEntry value="org.eclipse.swt@default:default"/> | ||
916 | <setEntry value="org.eclipse.team.core@default:default"/> | ||
917 | <setEntry value="org.eclipse.team.genericeditor.diff.extension@default:default"/> | ||
918 | <setEntry value="org.eclipse.team.ui@default:default"/> | ||
919 | <setEntry value="org.eclipse.text@default:default"/> | ||
920 | <setEntry value="org.eclipse.tips.core@default:default"/> | ||
921 | <setEntry value="org.eclipse.tips.ide@default:default"/> | ||
922 | <setEntry value="org.eclipse.tips.json@default:default"/> | ||
923 | <setEntry value="org.eclipse.tips.ui@default:default"/> | ||
924 | <setEntry value="org.eclipse.tools.layout.spy@default:default"/> | ||
925 | <setEntry value="org.eclipse.ui.browser@default:default"/> | ||
926 | <setEntry value="org.eclipse.ui.cheatsheets@default:default"/> | ||
927 | <setEntry value="org.eclipse.ui.console@default:default"/> | ||
928 | <setEntry value="org.eclipse.ui.editors@default:default"/> | ||
929 | <setEntry value="org.eclipse.ui.externaltools@default:default"/> | ||
930 | <setEntry value="org.eclipse.ui.forms@default:default"/> | ||
931 | <setEntry value="org.eclipse.ui.genericeditor@default:default"/> | ||
932 | <setEntry value="org.eclipse.ui.ide.application@default:default"/> | ||
933 | <setEntry value="org.eclipse.ui.ide@default:default"/> | ||
934 | <setEntry value="org.eclipse.ui.intro.quicklinks@default:default"/> | ||
935 | <setEntry value="org.eclipse.ui.intro.universal@default:default"/> | ||
936 | <setEntry value="org.eclipse.ui.intro@default:default"/> | ||
937 | <setEntry value="org.eclipse.ui.monitoring@default:default"/> | ||
938 | <setEntry value="org.eclipse.ui.navigator.resources@default:default"/> | ||
939 | <setEntry value="org.eclipse.ui.navigator@default:default"/> | ||
940 | <setEntry value="org.eclipse.ui.net@default:default"/> | ||
941 | <setEntry value="org.eclipse.ui.themes@default:default"/> | ||
942 | <setEntry value="org.eclipse.ui.trace@default:default"/> | ||
943 | <setEntry value="org.eclipse.ui.views.log@default:default"/> | ||
944 | <setEntry value="org.eclipse.ui.views.properties.tabbed@default:default"/> | ||
945 | <setEntry value="org.eclipse.ui.views@default:default"/> | ||
946 | <setEntry value="org.eclipse.ui.workbench.texteditor@default:default"/> | ||
947 | <setEntry value="org.eclipse.ui.workbench@default:default"/> | ||
948 | <setEntry value="org.eclipse.ui@default:default"/> | ||
949 | <setEntry value="org.eclipse.uml2.ant@default:default"/> | ||
950 | <setEntry value="org.eclipse.uml2.codegen.ecore.ui@default:default"/> | ||
951 | <setEntry value="org.eclipse.uml2.codegen.ecore@default:default"/> | ||
952 | <setEntry value="org.eclipse.uml2.common.edit@default:default"/> | ||
953 | <setEntry value="org.eclipse.uml2.common@default:default"/> | ||
954 | <setEntry value="org.eclipse.uml2.doc@default:default"/> | ||
955 | <setEntry value="org.eclipse.uml2.examples.uml.ui@default:default"/> | ||
956 | <setEntry value="org.eclipse.uml2.examples@default:default"/> | ||
957 | <setEntry value="org.eclipse.uml2.types@default:default"/> | ||
958 | <setEntry value="org.eclipse.uml2.uml.ecore.exporter@default:default"/> | ||
959 | <setEntry value="org.eclipse.uml2.uml.ecore.importer@default:default"/> | ||
960 | <setEntry value="org.eclipse.uml2.uml.edit@default:default"/> | ||
961 | <setEntry value="org.eclipse.uml2.uml.editor@default:default"/> | ||
962 | <setEntry value="org.eclipse.uml2.uml.profile.standard@default:default"/> | ||
963 | <setEntry value="org.eclipse.uml2.uml.resources@default:default"/> | ||
964 | <setEntry value="org.eclipse.uml2.uml.validation@default:default"/> | ||
965 | <setEntry value="org.eclipse.uml2.uml@default:default"/> | ||
966 | <setEntry value="org.eclipse.uml2@default:default"/> | ||
967 | <setEntry value="org.eclipse.update.configurator@3:true"/> | ||
968 | <setEntry value="org.eclipse.urischeme@default:default"/> | ||
969 | <setEntry value="org.eclipse.userstorage.oauth@default:default"/> | ||
970 | <setEntry value="org.eclipse.userstorage.ui@default:default"/> | ||
971 | <setEntry value="org.eclipse.userstorage@default:default"/> | ||
972 | <setEntry value="org.eclipse.viatra.addon.databinding.runtime.validation@default:false"/> | ||
973 | <setEntry value="org.eclipse.viatra.addon.databinding.runtime@default:default"/> | ||
974 | <setEntry value="org.eclipse.viatra.addon.querybasedfeatures.runtime.validation@default:false"/> | ||
975 | <setEntry value="org.eclipse.viatra.addon.querybasedfeatures.runtime@default:default"/> | ||
976 | <setEntry value="org.eclipse.viatra.addon.querybasedfeatures.tooling@default:default"/> | ||
977 | <setEntry value="org.eclipse.viatra.addon.validation.core@default:default"/> | ||
978 | <setEntry value="org.eclipse.viatra.addon.validation.runtime.ui@default:default"/> | ||
979 | <setEntry value="org.eclipse.viatra.addon.validation.runtime.validation@default:false"/> | ||
980 | <setEntry value="org.eclipse.viatra.addon.validation.runtime@default:default"/> | ||
981 | <setEntry value="org.eclipse.viatra.addon.validation.tooling@default:default"/> | ||
982 | <setEntry value="org.eclipse.viatra.addon.viewers.runtime.validation@default:false"/> | ||
983 | <setEntry value="org.eclipse.viatra.addon.viewers.runtime.zest@default:default"/> | ||
984 | <setEntry value="org.eclipse.viatra.addon.viewers.runtime@default:default"/> | ||
985 | <setEntry value="org.eclipse.viatra.addon.viewers.tooling.ui.zest@default:default"/> | ||
986 | <setEntry value="org.eclipse.viatra.addon.viewers.tooling.ui@default:default"/> | ||
987 | <setEntry value="org.eclipse.viatra.documentation.help@default:default"/> | ||
988 | <setEntry value="org.eclipse.viatra.dse.genetic@default:default"/> | ||
989 | <setEntry value="org.eclipse.viatra.dse@default:default"/> | ||
990 | <setEntry value="org.eclipse.viatra.integration.zest@default:default"/> | ||
991 | <setEntry value="org.eclipse.viatra.query.patternlanguage.emf.ide@default:default"/> | ||
992 | <setEntry value="org.eclipse.viatra.query.patternlanguage.emf.ui@default:default"/> | ||
993 | <setEntry value="org.eclipse.viatra.query.patternlanguage.emf@default:default"/> | ||
994 | <setEntry value="org.eclipse.viatra.query.runtime.base.itc@default:default"/> | ||
995 | <setEntry value="org.eclipse.viatra.query.runtime.base@default:default"/> | ||
996 | <setEntry value="org.eclipse.viatra.query.runtime.localsearch@default:default"/> | ||
997 | <setEntry value="org.eclipse.viatra.query.runtime.matchers@default:default"/> | ||
998 | <setEntry value="org.eclipse.viatra.query.runtime.rete.recipes@default:default"/> | ||
999 | <setEntry value="org.eclipse.viatra.query.runtime.rete@default:default"/> | ||
1000 | <setEntry value="org.eclipse.viatra.query.runtime.ui@default:default"/> | ||
1001 | <setEntry value="org.eclipse.viatra.query.runtime@default:default"/> | ||
1002 | <setEntry value="org.eclipse.viatra.query.testing.core@default:default"/> | ||
1003 | <setEntry value="org.eclipse.viatra.query.testing.snapshot@default:default"/> | ||
1004 | <setEntry value="org.eclipse.viatra.query.testing.ui@default:default"/> | ||
1005 | <setEntry value="org.eclipse.viatra.query.tooling.core@default:default"/> | ||
1006 | <setEntry value="org.eclipse.viatra.query.tooling.debug@default:default"/> | ||
1007 | <setEntry value="org.eclipse.viatra.query.tooling.generator.model.ui@default:default"/> | ||
1008 | <setEntry value="org.eclipse.viatra.query.tooling.generator.model@default:default"/> | ||
1009 | <setEntry value="org.eclipse.viatra.query.tooling.localsearch.ui@default:default"/> | ||
1010 | <setEntry value="org.eclipse.viatra.query.tooling.ui.retevis@default:default"/> | ||
1011 | <setEntry value="org.eclipse.viatra.query.tooling.ui@default:default"/> | ||
1012 | <setEntry value="org.eclipse.viatra.transformation.evm.transactions@default:default"/> | ||
1013 | <setEntry value="org.eclipse.viatra.transformation.evm@default:default"/> | ||
1014 | <setEntry value="org.eclipse.viatra.transformation.runtime.debug@default:default"/> | ||
1015 | <setEntry value="org.eclipse.viatra.transformation.runtime.emf@default:default"/> | ||
1016 | <setEntry value="org.eclipse.viatra.transformation.runtime.tracer@default:default"/> | ||
1017 | <setEntry value="org.eclipse.viatra.transformation.runtime.transformationtrace@default:default"/> | ||
1018 | <setEntry value="org.eclipse.viatra.transformation.tooling.debug.ui@default:default"/> | ||
1019 | <setEntry value="org.eclipse.viatra.transformation.tooling.debug@default:default"/> | ||
1020 | <setEntry value="org.eclipse.viatra.transformation.ui@default:default"/> | ||
1021 | <setEntry value="org.eclipse.viatra.transformation.views@default:default"/> | ||
1022 | <setEntry value="org.eclipse.wst.common.core@default:default"/> | ||
1023 | <setEntry value="org.eclipse.wst.common.emf@default:default"/> | ||
1024 | <setEntry value="org.eclipse.wst.common.environment@default:default"/> | ||
1025 | <setEntry value="org.eclipse.wst.common.frameworks@default:default"/> | ||
1026 | <setEntry value="org.eclipse.wst.common.project.facet.core@default:default"/> | ||
1027 | <setEntry value="org.eclipse.wst.common.uriresolver@default:default"/> | ||
1028 | <setEntry value="org.eclipse.wst.sse.core@default:default"/> | ||
1029 | <setEntry value="org.eclipse.wst.validation@default:default"/> | ||
1030 | <setEntry value="org.eclipse.wst.xml.core@default:default"/> | ||
1031 | <setEntry value="org.eclipse.wst.xsd.core@default:default"/> | ||
1032 | <setEntry value="org.eclipse.xpand@default:default"/> | ||
1033 | <setEntry value="org.eclipse.xsd.cheatsheets@default:default"/> | ||
1034 | <setEntry value="org.eclipse.xsd.doc@default:default"/> | ||
1035 | <setEntry value="org.eclipse.xsd.ecore.converter@default:default"/> | ||
1036 | <setEntry value="org.eclipse.xsd.ecore.exporter@default:default"/> | ||
1037 | <setEntry value="org.eclipse.xsd.ecore.importer@default:default"/> | ||
1038 | <setEntry value="org.eclipse.xsd.edit@default:default"/> | ||
1039 | <setEntry value="org.eclipse.xsd.editor@default:default"/> | ||
1040 | <setEntry value="org.eclipse.xsd.example.installer@default:default"/> | ||
1041 | <setEntry value="org.eclipse.xsd.mapping.editor@default:default"/> | ||
1042 | <setEntry value="org.eclipse.xsd.mapping@default:default"/> | ||
1043 | <setEntry value="org.eclipse.xsd@default:default"/> | ||
1044 | <setEntry value="org.eclipse.xtend.core@default:default"/> | ||
1045 | <setEntry value="org.eclipse.xtend.doc@default:default"/> | ||
1046 | <setEntry value="org.eclipse.xtend.examples@default:default"/> | ||
1047 | <setEntry value="org.eclipse.xtend.ide.common@default:default"/> | ||
1048 | <setEntry value="org.eclipse.xtend.ide@default:default"/> | ||
1049 | <setEntry value="org.eclipse.xtend.lib.macro@default:default"/> | ||
1050 | <setEntry value="org.eclipse.xtend.lib@default:default"/> | ||
1051 | <setEntry value="org.eclipse.xtend.m2e@default:default"/> | ||
1052 | <setEntry value="org.eclipse.xtend.standalone@default:default"/> | ||
1053 | <setEntry value="org.eclipse.xtend.typesystem.emf@default:default"/> | ||
1054 | <setEntry value="org.eclipse.xtend@default:default"/> | ||
1055 | <setEntry value="org.eclipse.xtext.activities@default:default"/> | ||
1056 | <setEntry value="org.eclipse.xtext.builder.standalone@default:default"/> | ||
1057 | <setEntry value="org.eclipse.xtext.builder@default:default"/> | ||
1058 | <setEntry value="org.eclipse.xtext.common.types.edit@default:default"/> | ||
1059 | <setEntry value="org.eclipse.xtext.common.types.shared.jdt38@default:false"/> | ||
1060 | <setEntry value="org.eclipse.xtext.common.types.shared@default:default"/> | ||
1061 | <setEntry value="org.eclipse.xtext.common.types.ui@default:default"/> | ||
1062 | <setEntry value="org.eclipse.xtext.common.types@default:default"/> | ||
1063 | <setEntry value="org.eclipse.xtext.doc@default:default"/> | ||
1064 | <setEntry value="org.eclipse.xtext.ecore@default:default"/> | ||
1065 | <setEntry value="org.eclipse.xtext.generator@default:default"/> | ||
1066 | <setEntry value="org.eclipse.xtext.ide@default:default"/> | ||
1067 | <setEntry value="org.eclipse.xtext.idea.generator@default:default"/> | ||
1068 | <setEntry value="org.eclipse.xtext.java@default:default"/> | ||
1069 | <setEntry value="org.eclipse.xtext.junit4@default:default"/> | ||
1070 | <setEntry value="org.eclipse.xtext.logging@default:false"/> | ||
1071 | <setEntry value="org.eclipse.xtext.m2e@default:default"/> | ||
1072 | <setEntry value="org.eclipse.xtext.purexbase.ide@default:default"/> | ||
1073 | <setEntry value="org.eclipse.xtext.purexbase.ui@default:default"/> | ||
1074 | <setEntry value="org.eclipse.xtext.purexbase@default:default"/> | ||
1075 | <setEntry value="org.eclipse.xtext.smap@default:default"/> | ||
1076 | <setEntry value="org.eclipse.xtext.testing@default:default"/> | ||
1077 | <setEntry value="org.eclipse.xtext.ui.codemining@default:default"/> | ||
1078 | <setEntry value="org.eclipse.xtext.ui.codetemplates.ide@default:default"/> | ||
1079 | <setEntry value="org.eclipse.xtext.ui.codetemplates.ui@default:default"/> | ||
1080 | <setEntry value="org.eclipse.xtext.ui.codetemplates@default:default"/> | ||
1081 | <setEntry value="org.eclipse.xtext.ui.ecore@default:default"/> | ||
1082 | <setEntry value="org.eclipse.xtext.ui.shared@default:default"/> | ||
1083 | <setEntry value="org.eclipse.xtext.ui.testing@default:default"/> | ||
1084 | <setEntry value="org.eclipse.xtext.ui@default:default"/> | ||
1085 | <setEntry value="org.eclipse.xtext.util@default:default"/> | ||
1086 | <setEntry value="org.eclipse.xtext.xbase.ide@default:default"/> | ||
1087 | <setEntry value="org.eclipse.xtext.xbase.junit@default:default"/> | ||
1088 | <setEntry value="org.eclipse.xtext.xbase.lib@default:default"/> | ||
1089 | <setEntry value="org.eclipse.xtext.xbase.testing@default:default"/> | ||
1090 | <setEntry value="org.eclipse.xtext.xbase.ui.testing@default:default"/> | ||
1091 | <setEntry value="org.eclipse.xtext.xbase.ui@default:default"/> | ||
1092 | <setEntry value="org.eclipse.xtext.xbase@default:default"/> | ||
1093 | <setEntry value="org.eclipse.xtext.xtext.generator@default:default"/> | ||
1094 | <setEntry value="org.eclipse.xtext.xtext.ide@default:default"/> | ||
1095 | <setEntry value="org.eclipse.xtext.xtext.ui.examples@default:default"/> | ||
1096 | <setEntry value="org.eclipse.xtext.xtext.ui.graph@default:default"/> | ||
1097 | <setEntry value="org.eclipse.xtext.xtext.ui@default:default"/> | ||
1098 | <setEntry value="org.eclipse.xtext.xtext.wizard@default:default"/> | ||
1099 | <setEntry value="org.eclipse.xtext@default:default"/> | ||
1100 | <setEntry value="org.h2@default:default"/> | ||
1101 | <setEntry value="org.hamcrest.core@default:default"/> | ||
1102 | <setEntry value="org.jfree.jcommon@default:default"/> | ||
1103 | <setEntry value="org.jsoup@default:default"/> | ||
1104 | <setEntry value="org.junit.jupiter.api@default:default"/> | ||
1105 | <setEntry value="org.junit.jupiter.engine@default:default"/> | ||
1106 | <setEntry value="org.junit.jupiter.migrationsupport@default:default"/> | ||
1107 | <setEntry value="org.junit.jupiter.params@default:default"/> | ||
1108 | <setEntry value="org.junit.platform.commons@default:default"/> | ||
1109 | <setEntry value="org.junit.platform.engine@default:default"/> | ||
1110 | <setEntry value="org.junit.platform.launcher@default:default"/> | ||
1111 | <setEntry value="org.junit.platform.runner@default:default"/> | ||
1112 | <setEntry value="org.junit.platform.suite.api@default:default"/> | ||
1113 | <setEntry value="org.junit.vintage.engine@default:default"/> | ||
1114 | <setEntry value="org.junit@default:default"/> | ||
1115 | <setEntry value="org.moeaframework@default:default"/> | ||
1116 | <setEntry value="org.objectweb.asm.tree@default:default"/> | ||
1117 | <setEntry value="org.objectweb.asm@default:default"/> | ||
1118 | <setEntry value="org.opentest4j@default:default"/> | ||
1119 | <setEntry value="org.sat4j.core@default:default"/> | ||
1120 | <setEntry value="org.sat4j.pb@default:default"/> | ||
1121 | <setEntry value="org.sidiff.common.emf.extensions@default:default"/> | ||
1122 | <setEntry value="org.sidiff.common.emf@default:default"/> | ||
1123 | <setEntry value="org.sidiff.common.henshin@default:default"/> | ||
1124 | <setEntry value="org.sidiff.common@default:default"/> | ||
1125 | <setEntry value="org.sidiff.serge@default:default"/> | ||
1126 | <setEntry value="org.silift.common.util@default:default"/> | ||
1127 | <setEntry value="org.slf4j.api@default:default"/> | ||
1128 | <setEntry value="org.slf4j.impl.log4j12@default:false"/> | ||
1129 | <setEntry value="org.tukaani.xz@default:default"/> | ||
1130 | <setEntry value="org.w3c.css.sac@default:default"/> | ||
1131 | <setEntry value="org.w3c.dom.events@default:default"/> | ||
1132 | <setEntry value="org.w3c.dom.smil@default:default"/> | ||
1133 | <setEntry value="org.w3c.dom.svg@default:default"/> | ||
1134 | <setEntry value="uk.ac.kcl.inf.mdeoptimiser.interfaces.cli@default:default"/> | ||
1135 | <setEntry value="uk.ac.kcl.inf.mdeoptimiser.interfaces.eclipse.ui@default:default"/> | ||
1136 | <setEntry value="uk.ac.kcl.inf.mdeoptimiser.languages.mopt.xtext@default:default"/> | ||
1137 | <setEntry value="uk.ac.kcl.inf.mdeoptimiser.libraries.core@default:default"/> | ||
1138 | <setEntry value="uk.ac.kcl.inf.mdeoptimiser.libraries.rulegen@default:default"/> | ||
1139 | </setAttribute> | ||
1140 | <setAttribute key="selected_workspace_bundles"> | ||
1141 | <setEntry value="com.microsoft.z3@default:true"/> | ||
1142 | <setEntry value="hu.bme.mit.inf.dlsreasoner.alloy.reasoner@default:default"/> | ||
1143 | <setEntry value="hu.bme.mit.inf.dslreasoner.alloy.language.ui@default:default"/> | ||
1144 | <setEntry value="hu.bme.mit.inf.dslreasoner.alloy.language@default:default"/> | ||
1145 | <setEntry value="hu.bme.mit.inf.dslreasoner.application.ide@default:default"/> | ||
1146 | <setEntry value="hu.bme.mit.inf.dslreasoner.application.ui@default:default"/> | ||
1147 | <setEntry value="hu.bme.mit.inf.dslreasoner.application@default:default"/> | ||
1148 | <setEntry value="hu.bme.mit.inf.dslreasoner.domains.cps.validation@default:default"/> | ||
1149 | <setEntry value="hu.bme.mit.inf.dslreasoner.domains.cps@default:default"/> | ||
1150 | <setEntry value="hu.bme.mit.inf.dslreasoner.domains.satellite.validation@default:default"/> | ||
1151 | <setEntry value="hu.bme.mit.inf.dslreasoner.domains.satellite@default:default"/> | ||
1152 | <setEntry value="hu.bme.mit.inf.dslreasoner.ecore2logic@default:default"/> | ||
1153 | <setEntry value="hu.bme.mit.inf.dslreasoner.faulttree.components.ide@default:default"/> | ||
1154 | <setEntry value="hu.bme.mit.inf.dslreasoner.faulttree.components.ui@default:default"/> | ||
1155 | <setEntry value="hu.bme.mit.inf.dslreasoner.faulttree.components@default:default"/> | ||
1156 | <setEntry value="hu.bme.mit.inf.dslreasoner.faulttree.model@default:default"/> | ||
1157 | <setEntry value="hu.bme.mit.inf.dslreasoner.faulttree.transformation@default:default"/> | ||
1158 | <setEntry value="hu.bme.mit.inf.dslreasoner.faulttree.ui@default:default"/> | ||
1159 | <setEntry value="hu.bme.mit.inf.dslreasoner.logic.model.validation@default:default"/> | ||
1160 | <setEntry value="hu.bme.mit.inf.dslreasoner.logic.model@default:default"/> | ||
1161 | <setEntry value="hu.bme.mit.inf.dslreasoner.logic2ecore@default:default"/> | ||
1162 | <setEntry value="hu.bme.mit.inf.dslreasoner.smt.language.ui@default:default"/> | ||
1163 | <setEntry value="hu.bme.mit.inf.dslreasoner.smt.language@default:default"/> | ||
1164 | <setEntry value="hu.bme.mit.inf.dslreasoner.smt.reasoner@default:default"/> | ||
1165 | <setEntry value="hu.bme.mit.inf.dslreasoner.viatra2logic@default:default"/> | ||
1166 | <setEntry value="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.tests@default:default"/> | ||
1167 | <setEntry value="hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatraquery@default:default"/> | ||
1168 | <setEntry value="hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage@default:default"/> | ||
1169 | <setEntry value="hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner@default:default"/> | ||
1170 | <setEntry value="hu.bme.mit.inf.dslreasoner.visualisation@default:default"/> | ||
1171 | </setAttribute> | ||
30 | <booleanAttribute key="show_selected_only" value="false"/> | 1172 | <booleanAttribute key="show_selected_only" value="false"/> |
31 | <booleanAttribute key="tracing" value="false"/> | 1173 | <booleanAttribute key="tracing" value="false"/> |
32 | <booleanAttribute key="useCustomFeatures" value="false"/> | 1174 | <booleanAttribute key="useCustomFeatures" value="false"/> |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend index c3ba9f81..d718bb91 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend | |||
@@ -1,5 +1,6 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.execution | 1 | package hu.bme.mit.inf.dslreasoner.application.execution |
2 | 2 | ||
3 | import com.google.inject.Injector | ||
3 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigurationScript | 4 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigurationScript |
4 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.GenerationTask | 5 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.GenerationTask |
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | 6 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic |
@@ -24,7 +25,9 @@ import java.util.LinkedList | |||
24 | import java.util.Optional | 25 | import java.util.Optional |
25 | import org.eclipse.core.runtime.IProgressMonitor | 26 | import org.eclipse.core.runtime.IProgressMonitor |
26 | import org.eclipse.emf.common.util.URI | 27 | import org.eclipse.emf.common.util.URI |
28 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor | ||
27 | 29 | ||
30 | @FinalFieldsConstructor | ||
28 | class GenerationTaskExecutor { | 31 | class GenerationTaskExecutor { |
29 | val metamodelLoader = new MetamodelLoader | 32 | val metamodelLoader = new MetamodelLoader |
30 | val modelLoader = new ModelLoader | 33 | val modelLoader = new ModelLoader |
@@ -32,6 +35,7 @@ class GenerationTaskExecutor { | |||
32 | val solverLoader = new SolverLoader | 35 | val solverLoader = new SolverLoader |
33 | val scopeLoader = new ScopeLoader | 36 | val scopeLoader = new ScopeLoader |
34 | val statisticsUtil = new StatisticSections2CSV | 37 | val statisticsUtil = new StatisticSections2CSV |
38 | val Injector injector | ||
35 | 39 | ||
36 | def executeGenerationTask( | 40 | def executeGenerationTask( |
37 | GenerationTask task, | 41 | GenerationTask task, |
@@ -102,7 +106,7 @@ class GenerationTaskExecutor { | |||
102 | var domain2LogicTransformationTime = System.nanoTime | 106 | var domain2LogicTransformationTime = System.nanoTime |
103 | val Ecore2Logic ecore2Logic = new Ecore2Logic | 107 | val Ecore2Logic ecore2Logic = new Ecore2Logic |
104 | val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic) | 108 | val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic) |
105 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) | 109 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic, injector) |
106 | val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic | 110 | val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic |
107 | 111 | ||
108 | var modelGeneration = ecore2Logic.transformMetamodel(metamodelDescriptor,new Ecore2LogicConfiguration()) | 112 | var modelGeneration = ecore2Logic.transformMetamodel(metamodelDescriptor,new Ecore2LogicConfiguration()) |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/PatternLanguageWithRSSetup.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/PatternLanguageWithRSSetup.xtend index c209cde5..371f6f8c 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/PatternLanguageWithRSSetup.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/PatternLanguageWithRSSetup.xtend | |||
@@ -1,11 +1,7 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.execution | 1 | package hu.bme.mit.inf.dslreasoner.application.execution |
2 | 2 | ||
3 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetupGenerated | ||
4 | import com.google.inject.Injector | ||
5 | import com.google.inject.Guice | 3 | import com.google.inject.Guice |
6 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageRuntimeModule | 4 | import com.google.inject.Injector |
7 | import com.google.inject.Guice; | ||
8 | import com.google.inject.Injector; | ||
9 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup | 5 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup |
10 | 6 | ||
11 | class PatternLanguageWithRSSetup extends EMFPatternLanguageStandaloneSetup{ | 7 | class PatternLanguageWithRSSetup extends EMFPatternLanguageStandaloneSetup{ |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptExecutor.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptExecutor.xtend index 3dea677f..9d0985d2 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptExecutor.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ScriptExecutor.xtend | |||
@@ -1,5 +1,7 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.execution | 1 | package hu.bme.mit.inf.dslreasoner.application.execution |
2 | 2 | ||
3 | import com.google.inject.Inject | ||
4 | import com.google.inject.Injector | ||
3 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigReference | 5 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigReference |
4 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigSpecification | 6 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigSpecification |
5 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigurationScript | 7 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ConfigurationScript |
@@ -33,11 +35,19 @@ import org.eclipse.core.runtime.jobs.Job | |||
33 | import org.eclipse.emf.common.util.URI | 35 | import org.eclipse.emf.common.util.URI |
34 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor | 36 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor |
35 | 37 | ||
36 | @FinalFieldsConstructor | ||
37 | class ScriptExecutor { | 38 | class ScriptExecutor { |
38 | val parser = new ApplicationConfigurationParser | 39 | val parser = new ApplicationConfigurationParser |
39 | 40 | ||
40 | val ScriptConsole.Factory scriptConsoleFactory | 41 | val ScriptConsole.Factory scriptConsoleFactory |
42 | val Injector injector | ||
43 | |||
44 | @FinalFieldsConstructor | ||
45 | new() { | ||
46 | } | ||
47 | |||
48 | new(ScriptConsole.Factory scriptConsoleFactory) { | ||
49 | this(scriptConsoleFactory, null) | ||
50 | } | ||
41 | 51 | ||
42 | /** | 52 | /** |
43 | * Executes a script | 53 | * Executes a script |
@@ -101,7 +111,7 @@ class ScriptExecutor { | |||
101 | } | 111 | } |
102 | 112 | ||
103 | def dispatch void execute(GenerationTask task, IProgressMonitor monitor) { | 113 | def dispatch void execute(GenerationTask task, IProgressMonitor monitor) { |
104 | val generationTaskExecutor = new GenerationTaskExecutor | 114 | val generationTaskExecutor = new GenerationTaskExecutor(injector) |
105 | generationTaskExecutor.executeGenerationTask(task,this,scriptConsoleFactory,monitor) | 115 | generationTaskExecutor.executeGenerationTask(task,this,scriptConsoleFactory,monitor) |
106 | } | 116 | } |
107 | 117 | ||
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/SolverLoader.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/SolverLoader.xtend index a549df00..fd50ad51 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/SolverLoader.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/SolverLoader.xtend | |||
@@ -28,6 +28,7 @@ import java.util.Optional | |||
28 | import org.eclipse.viatra.query.patternlanguage.emf.vql.PatternModel | 28 | import org.eclipse.viatra.query.patternlanguage.emf.vql.PatternModel |
29 | import org.eclipse.xtext.EcoreUtil2 | 29 | import org.eclipse.xtext.EcoreUtil2 |
30 | import org.eclipse.xtext.xbase.lib.Functions.Function1 | 30 | import org.eclipse.xtext.xbase.lib.Functions.Function1 |
31 | import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloyBackendSolver | ||
31 | 32 | ||
32 | class SolverLoader { | 33 | class SolverLoader { |
33 | def loadSolver(Solver solver, Map<String, String> config) { | 34 | def loadSolver(Solver solver, Map<String, String> config) { |
@@ -73,9 +74,9 @@ class SolverLoader { | |||
73 | if (!objectiveEntries.empty) { | 74 | if (!objectiveEntries.empty) { |
74 | throw new IllegalArgumentException("Objectives are not supported by Alloy.") | 75 | throw new IllegalArgumentException("Objectives are not supported by Alloy.") |
75 | } | 76 | } |
76 | val c = new SmtSolverConfiguration | 77 | val c = new AlloySolverConfiguration |
77 | config.getAsBoolean("fixRandomSeed", console).ifPresent[c.fixRandomSeed = it] | 78 | config.getAsInteger("symmetry", console).ifPresent[c.symmetry = it] |
78 | config.getAsType("path", console, [it], String).ifPresent[c.solverPath = it] | 79 | config.getAsType("solver",console,[x|AlloyBackendSolver::valueOf(x)],AlloyBackendSolver).ifPresent[c.solver = it] |
79 | c | 80 | c |
80 | } | 81 | } |
81 | case SMT_SOLVER: { | 82 | case SMT_SOLVER: { |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend index 42be3ed7..23c76758 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.xtend | |||
@@ -12,6 +12,8 @@ import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | |||
12 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup | 12 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup |
13 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine | 13 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine |
14 | import org.eclipse.xtext.resource.XtextResourceSet | 14 | import org.eclipse.xtext.resource.XtextResourceSet |
15 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions | ||
16 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory | ||
15 | 17 | ||
16 | class StandaloneScriptExecutor { | 18 | class StandaloneScriptExecutor { |
17 | def static void main(String[] args) { | 19 | def static void main(String[] args) { |
@@ -44,7 +46,10 @@ class StandaloneScriptExecutor { | |||
44 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi",new XMIResourceFactoryImpl) | 46 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("xmi",new XMIResourceFactoryImpl) |
45 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("logicproblem",new XMIResourceFactoryImpl) | 47 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("logicproblem",new XMIResourceFactoryImpl) |
46 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("partialmodel",new XMIResourceFactoryImpl) | 48 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("partialmodel",new XMIResourceFactoryImpl) |
47 | ReteEngine.getClass | 49 | //ReteEngine.getClass |
50 | |||
51 | ViatraQueryEngineOptions.setSystemDefaultBackends(ReteBackendFactory.INSTANCE, ReteBackendFactory.INSTANCE, | ||
52 | ReteBackendFactory.INSTANCE) | ||
48 | 53 | ||
49 | val ext = path.split("\\.").last | 54 | val ext = path.split("\\.").last |
50 | if(ext.equals("vsconfig")) { | 55 | if(ext.equals("vsconfig")) { |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/linking/ApplicationConfigurationLinkingService.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/linking/ApplicationConfigurationLinkingService.xtend index fafba1d7..c876f3be 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/linking/ApplicationConfigurationLinkingService.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/linking/ApplicationConfigurationLinkingService.xtend | |||
@@ -71,28 +71,29 @@ class ApplicationConfigurationLinkingService extends DefaultLinkingService { | |||
71 | } | 71 | } |
72 | 72 | ||
73 | private def getByUri(EObject context, EReference ref, INode node) { | 73 | private def getByUri(EObject context, EReference ref, INode node) { |
74 | val linkedObjects = super.getLinkedObjects(context, ref, node) | ||
75 | if (!linkedObjects.empty) { | ||
76 | return linkedObjects | ||
77 | } | ||
74 | val uri = getNSUri(node) | 78 | val uri = getNSUri(node) |
75 | if (uri.present) { | 79 | if (uri.present) { |
76 | var URI createdURI | 80 | var URI createdURI |
77 | try { | 81 | try { |
78 | createdURI = URI.createURI(uri.get) | 82 | createdURI = URI.createURI(uri.get) |
79 | } catch (IllegalArgumentException e) { | 83 | } catch (IllegalArgumentException e) { |
80 | return super.getLinkedObjects(context, ref, node) | 84 | return #[] |
81 | } | 85 | } |
82 | var Resource res | 86 | var Resource res |
83 | try { | 87 | try { |
84 | res = context.eResource.resourceSet.getResource(createdURI, true); | 88 | res = context.eResource.resourceSet.getResource(createdURI, true); |
85 | } catch (RuntimeException e) { | 89 | } catch (RuntimeException e) { |
86 | return super.getLinkedObjects(context, ref, node) | 90 | return #[] |
87 | } | 91 | } |
88 | if (res !== null && res.contents !== null) { | 92 | if (res !== null && res.contents !== null) { |
89 | return res.contents.filter[ref.EType.isInstance(it)].toList | 93 | return res.contents.filter[ref.EType.isInstance(it)].toList |
90 | } else { | ||
91 | return super.getLinkedObjects(context, ref, node) | ||
92 | } | 94 | } |
93 | } else { | ||
94 | return super.getLinkedObjects(context, ref, node) | ||
95 | } | 95 | } |
96 | return #[] | ||
96 | } | 97 | } |
97 | 98 | ||
98 | private def getNSUri(INode node) { | 99 | private def getNSUri(INode node) { |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/start-standalone.launch b/Application/hu.bme.mit.inf.dslreasoner.application/start-standalone.launch index 1f3744a7..437bc6e2 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/start-standalone.launch +++ b/Application/hu.bme.mit.inf.dslreasoner.application/start-standalone.launch | |||
@@ -1,12 +1,15 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
2 | <launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> | 2 | <launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> |
3 | <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> | 3 | <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> |
4 | <listEntry value="/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.java"/> | 4 | <listEntry value="/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/execution/StandaloneScriptExecutor.java"/> |
5 | </listAttribute> | 5 | </listAttribute> |
6 | <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> | 6 | <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> |
7 | <listEntry value="1"/> | 7 | <listEntry value="1"/> |
8 | </listAttribute> | 8 | </listAttribute> |
9 | <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor"/> | 9 | <booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/> |
10 | <stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="hu.bme.mit.inf.dslreasoner.application"/> | 10 | <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor"/> |
11 | <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="hu.bme.mit.inf.dslreasoner.application"/> | 11 | <stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="hu.bme.mit.inf.dslreasoner.application"/> |
12 | <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="EcoreGeneration.vsconfig"/> | ||
13 | <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="hu.bme.mit.inf.dslreasoner.application"/> | ||
14 | <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:Ecore-Plugin}"/> | ||
12 | </launchConfiguration> | 15 | </launchConfiguration> |
diff --git a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticHighlightCalculator.xtendbin b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticHighlightCalculator.xtendbin index 287aa50d..a107bf27 100644 --- a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticHighlightCalculator.xtendbin +++ b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticHighlightCalculator.xtendbin | |||
Binary files differ | |||
diff --git a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticTextAttributeProvider.xtendbin b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticTextAttributeProvider.xtendbin index e9b25b0a..994dbd52 100644 --- a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticTextAttributeProvider.xtendbin +++ b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticTextAttributeProvider.xtendbin | |||
Binary files differ | |||
diff --git a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.gitignore b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.gitignore index 1764b462..61ce5bef 100644 --- a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.gitignore +++ b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.gitignore | |||
@@ -1,2 +1,6 @@ | |||
1 | /.SolverSemanticHighlightCalculator.java._trace | 1 | /.SolverSemanticHighlightCalculator.java._trace |
2 | /.SolverSemanticTextAttributeProvider.java._trace | 2 | /.SolverSemanticTextAttributeProvider.java._trace |
3 | /.SolverSemanticHighlightCalculator.xtendbin | ||
4 | /.SolverSemanticTextAttributeProvider.xtendbin | ||
5 | /SolverSemanticHighlightCalculator.java | ||
6 | /SolverSemanticTextAttributeProvider.java | ||
diff --git a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.SolverLanguageValidator.xtendbin b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.SolverLanguageValidator.xtendbin index 79d18e32..9839769e 100644 --- a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.SolverLanguageValidator.xtendbin +++ b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.SolverLanguageValidator.xtendbin | |||
Binary files differ | |||
diff --git a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.gitignore b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.gitignore index f1cb387a..565d4b27 100644 --- a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.gitignore +++ b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.gitignore | |||
@@ -1 +1,3 @@ | |||
1 | /.SolverLanguageValidator.java._trace | 1 | /.SolverLanguageValidator.java._trace |
2 | /.SolverLanguageValidator.xtendbin | ||
3 | /SolverLanguageValidator.java | ||
diff --git a/Application/org.eclipse.viatra.solver.language/.launch/Launch Runtime Eclipse.launch b/Application/org.eclipse.viatra.solver.language/.launch/Launch Runtime Eclipse.launch index 1e189f24..d9fb69f1 100644 --- a/Application/org.eclipse.viatra.solver.language/.launch/Launch Runtime Eclipse.launch +++ b/Application/org.eclipse.viatra.solver.language/.launch/Launch Runtime Eclipse.launch | |||
@@ -1,35 +1,38 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
2 | <launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench"> | 2 | <launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench"> |
3 | <booleanAttribute key="append.args" value="true"/> | 3 | <booleanAttribute key="append.args" value="true"/> |
4 | <booleanAttribute key="askclear" value="true"/> | 4 | <booleanAttribute key="askclear" value="true"/> |
5 | <booleanAttribute key="automaticAdd" value="true"/> | 5 | <booleanAttribute key="automaticAdd" value="true"/> |
6 | <booleanAttribute key="automaticValidate" value="false"/> | 6 | <booleanAttribute key="automaticValidate" value="false"/> |
7 | <stringAttribute key="bad_container_name" value="/org.eclipse.viatra.solver.language/.launch/"/> | 7 | <stringAttribute key="bad_container_name" value="/org.eclipse.viatra.solver.language/.launch/"/> |
8 | <stringAttribute key="bootstrap" value=""/> | 8 | <stringAttribute key="bootstrap" value=""/> |
9 | <stringAttribute key="checked" value="[NONE]"/> | 9 | <stringAttribute key="checked" value="[NONE]"/> |
10 | <booleanAttribute key="clearConfig" value="false"/> | 10 | <booleanAttribute key="clearConfig" value="false"/> |
11 | <booleanAttribute key="clearws" value="false"/> | 11 | <booleanAttribute key="clearws" value="false"/> |
12 | <booleanAttribute key="clearwslog" value="false"/> | 12 | <booleanAttribute key="clearwslog" value="false"/> |
13 | <stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/Launch Runtime Eclipse"/> | 13 | <stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/Launch Runtime Eclipse"/> |
14 | <booleanAttribute key="default" value="true"/> | 14 | <booleanAttribute key="default" value="true"/> |
15 | <booleanAttribute key="includeOptional" value="true"/> | 15 | <booleanAttribute key="includeOptional" value="true"/> |
16 | <stringAttribute key="location" value="${workspace_loc}/../eclipse-2020-03-runtime"/> | 16 | <stringAttribute key="location" value="${workspace_loc}/../eclipse-2020-09-runtime"/> |
17 | <listAttribute key="org.eclipse.debug.ui.favoriteGroups"> | 17 | <mapAttribute key="org.eclipse.debug.core.environmentVariables"> |
18 | <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> | 18 | <mapEntry key="LD_LIBRARY_PATH" value="${resource_loc:/hu.bme.mit.inf.dslreasoner.ilp.cbc/lib}"/> |
19 | <listEntry value="org.eclipse.debug.ui.launchGroup.run"/> | 19 | </mapAttribute> |
20 | </listAttribute> | 20 | <listAttribute key="org.eclipse.debug.ui.favoriteGroups"> |
21 | <stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | 21 | <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> |
22 | <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/> | 22 | <listEntry value="org.eclipse.debug.ui.launchGroup.run"/> |
23 | <stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> | 23 | </listAttribute> |
24 | <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx512m"/> | 24 | <stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-11-openjdk"/> |
25 | <stringAttribute key="pde.version" value="3.3"/> | 25 | <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/> |
26 | <stringAttribute key="product" value="org.eclipse.platform.ide"/> | 26 | <stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> |
27 | <booleanAttribute key="show_selected_only" value="false"/> | 27 | <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m -Xmx16g"/> |
28 | <stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/> | 28 | <stringAttribute key="pde.version" value="3.3"/> |
29 | <booleanAttribute key="tracing" value="false"/> | 29 | <stringAttribute key="product" value="org.eclipse.platform.ide"/> |
30 | <booleanAttribute key="useCustomFeatures" value="false"/> | 30 | <booleanAttribute key="show_selected_only" value="false"/> |
31 | <booleanAttribute key="useDefaultConfig" value="true"/> | 31 | <stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/> |
32 | <booleanAttribute key="useDefaultConfigArea" value="true"/> | 32 | <booleanAttribute key="tracing" value="false"/> |
33 | <booleanAttribute key="useProduct" value="true"/> | 33 | <booleanAttribute key="useCustomFeatures" value="false"/> |
34 | <booleanAttribute key="usefeatures" value="false"/> | 34 | <booleanAttribute key="useDefaultConfig" value="true"/> |
35 | <booleanAttribute key="useDefaultConfigArea" value="true"/> | ||
36 | <booleanAttribute key="useProduct" value="true"/> | ||
37 | <booleanAttribute key="usefeatures" value="false"/> | ||
35 | </launchConfiguration> | 38 | </launchConfiguration> |
diff --git a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.SolverLanguageTokenDefInjectingParser.xtendbin b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.SolverLanguageTokenDefInjectingParser.xtendbin index c529b829..d2fd056e 100644 --- a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.SolverLanguageTokenDefInjectingParser.xtendbin +++ b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.SolverLanguageTokenDefInjectingParser.xtendbin | |||
Binary files differ | |||
diff --git a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.gitignore b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.gitignore index 9cf14147..5fbb81c3 100644 --- a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.gitignore +++ b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.gitignore | |||
@@ -5,3 +5,5 @@ | |||
5 | /.SolverLanguageSyntheticTokenParser.java._trace | 5 | /.SolverLanguageSyntheticTokenParser.java._trace |
6 | /.SolverLanguageTokenSource.java._trace | 6 | /.SolverLanguageTokenSource.java._trace |
7 | /.SolverLanguageTokenDefInjectingParser.java._trace | 7 | /.SolverLanguageTokenDefInjectingParser.java._trace |
8 | /.SolverLanguageTokenDefInjectingParser.xtendbin | ||
9 | /SolverLanguageTokenDefInjectingParser.java | ||
diff --git a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.SolverLanguageSyntheticTokenSyntacticSequencer.xtendbin b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.SolverLanguageSyntheticTokenSyntacticSequencer.xtendbin index 9ff56ed9..30cf1dbd 100644 --- a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.SolverLanguageSyntheticTokenSyntacticSequencer.xtendbin +++ b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.SolverLanguageSyntheticTokenSyntacticSequencer.xtendbin | |||
Binary files differ | |||
diff --git a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.gitignore b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.gitignore index b8132d70..1f04090d 100644 --- a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.gitignore +++ b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.gitignore | |||
@@ -1 +1,3 @@ | |||
1 | /.SolverLanguageSyntheticTokenSyntacticSequencer.java._trace | 1 | /.SolverLanguageSyntheticTokenSyntacticSequencer.java._trace |
2 | /.SolverLanguageSyntheticTokenSyntacticSequencer.xtendbin | ||
3 | /SolverLanguageSyntheticTokenSyntacticSequencer.java | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/.classpath b/Domains/ca.mcgill.rtgmrt.example.modes3/.classpath new file mode 100644 index 00000000..73ebde52 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/.classpath | |||
@@ -0,0 +1,10 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <classpath> | ||
3 | <classpathentry kind="src" path="ecore-gen"/> | ||
4 | <classpathentry kind="src" path="src"/> | ||
5 | <classpathentry kind="src" path="xtend-gen"/> | ||
6 | <classpathentry kind="src" path="vql-gen"/> | ||
7 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/> | ||
8 | <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
9 | <classpathentry kind="output" path="bin"/> | ||
10 | </classpath> | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/.gitignore b/Domains/ca.mcgill.rtgmrt.example.modes3/.gitignore new file mode 100644 index 00000000..6cef8ea6 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/.gitignore | |||
@@ -0,0 +1,2 @@ | |||
1 | /bin/ | ||
2 | output/ | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/.project b/Domains/ca.mcgill.rtgmrt.example.modes3/.project new file mode 100644 index 00000000..5e0fbc45 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/.project | |||
@@ -0,0 +1,40 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <projectDescription> | ||
3 | <name>ca.mcgill.rtgmrt.example.modes3</name> | ||
4 | <comment></comment> | ||
5 | <projects> | ||
6 | </projects> | ||
7 | <buildSpec> | ||
8 | <buildCommand> | ||
9 | <name>org.eclipse.viatra.query.tooling.ui.projectbuilder</name> | ||
10 | <arguments> | ||
11 | </arguments> | ||
12 | </buildCommand> | ||
13 | <buildCommand> | ||
14 | <name>org.eclipse.xtext.ui.shared.xtextBuilder</name> | ||
15 | <arguments> | ||
16 | </arguments> | ||
17 | </buildCommand> | ||
18 | <buildCommand> | ||
19 | <name>org.eclipse.jdt.core.javabuilder</name> | ||
20 | <arguments> | ||
21 | </arguments> | ||
22 | </buildCommand> | ||
23 | <buildCommand> | ||
24 | <name>org.eclipse.pde.ManifestBuilder</name> | ||
25 | <arguments> | ||
26 | </arguments> | ||
27 | </buildCommand> | ||
28 | <buildCommand> | ||
29 | <name>org.eclipse.pde.SchemaBuilder</name> | ||
30 | <arguments> | ||
31 | </arguments> | ||
32 | </buildCommand> | ||
33 | </buildSpec> | ||
34 | <natures> | ||
35 | <nature>org.eclipse.jdt.core.javanature</nature> | ||
36 | <nature>org.eclipse.pde.PluginNature</nature> | ||
37 | <nature>org.eclipse.xtext.ui.shared.xtextNature</nature> | ||
38 | <nature>org.eclipse.viatra.query.projectnature</nature> | ||
39 | </natures> | ||
40 | </projectDescription> | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/.settings/org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguage.prefs b/Domains/ca.mcgill.rtgmrt.example.modes3/.settings/org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguage.prefs new file mode 100644 index 00000000..31cda49a --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/.settings/org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguage.prefs | |||
@@ -0,0 +1,27 @@ | |||
1 | BuilderConfiguration.is_project_specific=true | ||
2 | autobuilding=true | ||
3 | eclipse.preferences.version=1 | ||
4 | generateEclipseExtensions=true | ||
5 | generateGeneratedAnnotation=false | ||
6 | generateManifestEntries=true | ||
7 | generateMatchProcessors=false | ||
8 | generateMatchers=NESTED_CLASS | ||
9 | generateSuppressWarnings=true | ||
10 | generatedAnnotationComment= | ||
11 | includeDateInGenerated=false | ||
12 | outlet.DEFAULT_OUTPUT.cleanDirectory=false | ||
13 | outlet.DEFAULT_OUTPUT.cleanupDerived=true | ||
14 | outlet.DEFAULT_OUTPUT.createDirectory=true | ||
15 | outlet.DEFAULT_OUTPUT.derived=true | ||
16 | outlet.DEFAULT_OUTPUT.directory=./vql-gen | ||
17 | outlet.DEFAULT_OUTPUT.hideLocalSyntheticVariables=true | ||
18 | outlet.DEFAULT_OUTPUT.installDslAsPrimarySource=false | ||
19 | outlet.DEFAULT_OUTPUT.keepLocalHistory=true | ||
20 | outlet.DEFAULT_OUTPUT.override=true | ||
21 | outlet.DEFAULT_OUTPUT.sourceFolder.ecore-gen.directory= | ||
22 | outlet.DEFAULT_OUTPUT.sourceFolder.ecore-gen.ignore= | ||
23 | outlet.DEFAULT_OUTPUT.sourceFolder.src.directory= | ||
24 | outlet.DEFAULT_OUTPUT.sourceFolder.src.ignore= | ||
25 | outlet.DEFAULT_OUTPUT.userOutputPerSourceFolder= | ||
26 | targetJavaVersion=JAVA5 | ||
27 | useJavaCompilerCompliance=true | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/META-INF/MANIFEST.MF b/Domains/ca.mcgill.rtgmrt.example.modes3/META-INF/MANIFEST.MF new file mode 100644 index 00000000..8f900199 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/META-INF/MANIFEST.MF | |||
@@ -0,0 +1,36 @@ | |||
1 | Manifest-Version: 1.0 | ||
2 | Bundle-ManifestVersion: 2 | ||
3 | Bundle-Name: %pluginName | ||
4 | Bundle-SymbolicName: ca.mcgill.rtgmrt.example.modes3;singleton:=true | ||
5 | Bundle-Version: 0.1.0.qualifier | ||
6 | Bundle-ClassPath: . | ||
7 | Bundle-Vendor: %providerName | ||
8 | Bundle-Localization: plugin | ||
9 | Export-Package: modes3, | ||
10 | modes3.impl, | ||
11 | modes3.queries, | ||
12 | modes3.util | ||
13 | Require-Bundle: org.eclipse.viatra.query.runtime, | ||
14 | org.eclipse.viatra.query.runtime.rete, | ||
15 | org.eclipse.viatra.query.runtime.localsearch, | ||
16 | org.eclipse.xtext.xbase.lib, | ||
17 | org.eclipse.emf.ecore;visibility:=reexport, | ||
18 | org.eclipse.core.runtime, | ||
19 | org.eclipse.xtend.lib;bundle-version="2.21.0", | ||
20 | org.eclipse.xtend.lib.macro;bundle-version="2.21.0", | ||
21 | hu.bme.mit.inf.dslreasoner.application;bundle-version="1.0.0", | ||
22 | hu.bme.mit.inf.dslreasoner.logic.model;bundle-version="1.0.0", | ||
23 | hu.bme.mit.inf.dslreasoner.logic2ecore;bundle-version="1.0.0", | ||
24 | hu.bme.mit.inf.dslreasoner.viatra2logic;bundle-version="1.0.0", | ||
25 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatraquery;bundle-version="1.0.0", | ||
26 | hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage;bundle-version="1.0.0", | ||
27 | hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner;bundle-version="1.0.0", | ||
28 | hu.bme.mit.inf.dslreasoner.ecore2logic;bundle-version="1.0.0", | ||
29 | org.eclipse.emf.ecore.xmi;bundle-version="2.16.0", | ||
30 | hu.bme.mit.inf.dslreasoner.visualisation;bundle-version="1.0.0", | ||
31 | org.eclipse.viatra.query.patternlanguage.emf;bundle-version="2.4.0", | ||
32 | org.eclipse.viatra.dse;bundle-version="0.24.0" | ||
33 | Import-Package: org.apache.log4j | ||
34 | Automatic-Module-Name: ca.mcgill.rtgmrt.example.modes3 | ||
35 | Bundle-ActivationPolicy: lazy | ||
36 | Bundle-RequiredExecutionEnvironment: J2SE-1.5 | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/build.properties b/Domains/ca.mcgill.rtgmrt.example.modes3/build.properties new file mode 100644 index 00000000..a431f6b2 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/build.properties | |||
@@ -0,0 +1,11 @@ | |||
1 | bin.includes = .,\ | ||
2 | model/,\ | ||
3 | META-INF/,\ | ||
4 | plugin.xml,\ | ||
5 | plugin.properties | ||
6 | jars.compile.order = . | ||
7 | source.. = src/,\ | ||
8 | ecore-gen/,\ | ||
9 | vql-gen/,\ | ||
10 | xtend-gen/ | ||
11 | output.. = bin/ | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Factory.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Factory.java new file mode 100644 index 00000000..10ce47a1 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Factory.java | |||
@@ -0,0 +1,78 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3; | ||
4 | |||
5 | import org.eclipse.emf.ecore.EFactory; | ||
6 | |||
7 | /** | ||
8 | * <!-- begin-user-doc --> | ||
9 | * The <b>Factory</b> for the model. | ||
10 | * It provides a create method for each non-abstract class of the model. | ||
11 | * <!-- end-user-doc --> | ||
12 | * @see modes3.Modes3Package | ||
13 | * @generated | ||
14 | */ | ||
15 | public interface Modes3Factory extends EFactory { | ||
16 | /** | ||
17 | * The singleton instance of the factory. | ||
18 | * <!-- begin-user-doc --> | ||
19 | * <!-- end-user-doc --> | ||
20 | * @generated | ||
21 | */ | ||
22 | Modes3Factory eINSTANCE = modes3.impl.Modes3FactoryImpl.init(); | ||
23 | |||
24 | /** | ||
25 | * Returns a new object of class '<em>Segment</em>'. | ||
26 | * <!-- begin-user-doc --> | ||
27 | * <!-- end-user-doc --> | ||
28 | * @return a new object of class '<em>Segment</em>'. | ||
29 | * @generated | ||
30 | */ | ||
31 | Segment createSegment(); | ||
32 | |||
33 | /** | ||
34 | * Returns a new object of class '<em>Model Root</em>'. | ||
35 | * <!-- begin-user-doc --> | ||
36 | * <!-- end-user-doc --> | ||
37 | * @return a new object of class '<em>Model Root</em>'. | ||
38 | * @generated | ||
39 | */ | ||
40 | Modes3ModelRoot createModes3ModelRoot(); | ||
41 | |||
42 | /** | ||
43 | * Returns a new object of class '<em>Turnout</em>'. | ||
44 | * <!-- begin-user-doc --> | ||
45 | * <!-- end-user-doc --> | ||
46 | * @return a new object of class '<em>Turnout</em>'. | ||
47 | * @generated | ||
48 | */ | ||
49 | Turnout createTurnout(); | ||
50 | |||
51 | /** | ||
52 | * Returns a new object of class '<em>Train</em>'. | ||
53 | * <!-- begin-user-doc --> | ||
54 | * <!-- end-user-doc --> | ||
55 | * @return a new object of class '<em>Train</em>'. | ||
56 | * @generated | ||
57 | */ | ||
58 | Train createTrain(); | ||
59 | |||
60 | /** | ||
61 | * Returns a new object of class '<em>Simple Segment</em>'. | ||
62 | * <!-- begin-user-doc --> | ||
63 | * <!-- end-user-doc --> | ||
64 | * @return a new object of class '<em>Simple Segment</em>'. | ||
65 | * @generated | ||
66 | */ | ||
67 | SimpleSegment createSimpleSegment(); | ||
68 | |||
69 | /** | ||
70 | * Returns the package supported by this factory. | ||
71 | * <!-- begin-user-doc --> | ||
72 | * <!-- end-user-doc --> | ||
73 | * @return the package supported by this factory. | ||
74 | * @generated | ||
75 | */ | ||
76 | Modes3Package getModes3Package(); | ||
77 | |||
78 | } //Modes3Factory | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3ModelRoot.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3ModelRoot.java new file mode 100644 index 00000000..d46ee305 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3ModelRoot.java | |||
@@ -0,0 +1,87 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3; | ||
4 | |||
5 | import org.eclipse.emf.common.util.EList; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | |||
9 | /** | ||
10 | * <!-- begin-user-doc --> | ||
11 | * A representation of the model object '<em><b>Model Root</b></em>'. | ||
12 | * <!-- end-user-doc --> | ||
13 | * | ||
14 | * <p> | ||
15 | * The following features are supported: | ||
16 | * </p> | ||
17 | * <ul> | ||
18 | * <li>{@link modes3.Modes3ModelRoot#getId <em>Id</em>}</li> | ||
19 | * <li>{@link modes3.Modes3ModelRoot#getTrains <em>Trains</em>}</li> | ||
20 | * <li>{@link modes3.Modes3ModelRoot#getSegments <em>Segments</em>}</li> | ||
21 | * <li>{@link modes3.Modes3ModelRoot#getTurnouts <em>Turnouts</em>}</li> | ||
22 | * </ul> | ||
23 | * | ||
24 | * @see modes3.Modes3Package#getModes3ModelRoot() | ||
25 | * @model | ||
26 | * @generated | ||
27 | */ | ||
28 | public interface Modes3ModelRoot extends EObject { | ||
29 | /** | ||
30 | * Returns the value of the '<em><b>Id</b></em>' attribute. | ||
31 | * <!-- begin-user-doc --> | ||
32 | * <!-- end-user-doc --> | ||
33 | * @return the value of the '<em>Id</em>' attribute. | ||
34 | * @see #setId(int) | ||
35 | * @see modes3.Modes3Package#getModes3ModelRoot_Id() | ||
36 | * @model | ||
37 | * @generated | ||
38 | */ | ||
39 | int getId(); | ||
40 | |||
41 | /** | ||
42 | * Sets the value of the '{@link modes3.Modes3ModelRoot#getId <em>Id</em>}' attribute. | ||
43 | * <!-- begin-user-doc --> | ||
44 | * <!-- end-user-doc --> | ||
45 | * @param value the new value of the '<em>Id</em>' attribute. | ||
46 | * @see #getId() | ||
47 | * @generated | ||
48 | */ | ||
49 | void setId(int value); | ||
50 | |||
51 | /** | ||
52 | * Returns the value of the '<em><b>Trains</b></em>' containment reference list. | ||
53 | * The list contents are of type {@link modes3.Train}. | ||
54 | * <!-- begin-user-doc --> | ||
55 | * <!-- end-user-doc --> | ||
56 | * @return the value of the '<em>Trains</em>' containment reference list. | ||
57 | * @see modes3.Modes3Package#getModes3ModelRoot_Trains() | ||
58 | * @model containment="true" | ||
59 | * @generated | ||
60 | */ | ||
61 | EList<Train> getTrains(); | ||
62 | |||
63 | /** | ||
64 | * Returns the value of the '<em><b>Segments</b></em>' containment reference list. | ||
65 | * The list contents are of type {@link modes3.SimpleSegment}. | ||
66 | * <!-- begin-user-doc --> | ||
67 | * <!-- end-user-doc --> | ||
68 | * @return the value of the '<em>Segments</em>' containment reference list. | ||
69 | * @see modes3.Modes3Package#getModes3ModelRoot_Segments() | ||
70 | * @model containment="true" | ||
71 | * @generated | ||
72 | */ | ||
73 | EList<SimpleSegment> getSegments(); | ||
74 | |||
75 | /** | ||
76 | * Returns the value of the '<em><b>Turnouts</b></em>' containment reference list. | ||
77 | * The list contents are of type {@link modes3.Turnout}. | ||
78 | * <!-- begin-user-doc --> | ||
79 | * <!-- end-user-doc --> | ||
80 | * @return the value of the '<em>Turnouts</em>' containment reference list. | ||
81 | * @see modes3.Modes3Package#getModes3ModelRoot_Turnouts() | ||
82 | * @model containment="true" | ||
83 | * @generated | ||
84 | */ | ||
85 | EList<Turnout> getTurnouts(); | ||
86 | |||
87 | } // Modes3ModelRoot | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Package.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Package.java new file mode 100644 index 00000000..a19c1955 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Modes3Package.java | |||
@@ -0,0 +1,716 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3; | ||
4 | |||
5 | import org.eclipse.emf.ecore.EAttribute; | ||
6 | import org.eclipse.emf.ecore.EClass; | ||
7 | import org.eclipse.emf.ecore.EPackage; | ||
8 | import org.eclipse.emf.ecore.EReference; | ||
9 | |||
10 | /** | ||
11 | * <!-- begin-user-doc --> | ||
12 | * The <b>Package</b> for the model. | ||
13 | * It contains accessors for the meta objects to represent | ||
14 | * <ul> | ||
15 | * <li>each class,</li> | ||
16 | * <li>each feature of each class,</li> | ||
17 | * <li>each operation of each class,</li> | ||
18 | * <li>each enum,</li> | ||
19 | * <li>and each data type</li> | ||
20 | * </ul> | ||
21 | * <!-- end-user-doc --> | ||
22 | * @see modes3.Modes3Factory | ||
23 | * @model kind="package" | ||
24 | * @generated | ||
25 | */ | ||
26 | public interface Modes3Package extends EPackage { | ||
27 | /** | ||
28 | * The package name. | ||
29 | * <!-- begin-user-doc --> | ||
30 | * <!-- end-user-doc --> | ||
31 | * @generated | ||
32 | */ | ||
33 | String eNAME = "modes3"; | ||
34 | |||
35 | /** | ||
36 | * The package namespace URI. | ||
37 | * <!-- begin-user-doc --> | ||
38 | * <!-- end-user-doc --> | ||
39 | * @generated | ||
40 | */ | ||
41 | String eNS_URI = "http://www.ece.mcgill.ca/wcet/modes3"; | ||
42 | |||
43 | /** | ||
44 | * The package namespace name. | ||
45 | * <!-- begin-user-doc --> | ||
46 | * <!-- end-user-doc --> | ||
47 | * @generated | ||
48 | */ | ||
49 | String eNS_PREFIX = "modes3"; | ||
50 | |||
51 | /** | ||
52 | * The singleton instance of the package. | ||
53 | * <!-- begin-user-doc --> | ||
54 | * <!-- end-user-doc --> | ||
55 | * @generated | ||
56 | */ | ||
57 | Modes3Package eINSTANCE = modes3.impl.Modes3PackageImpl.init(); | ||
58 | |||
59 | /** | ||
60 | * The meta object id for the '{@link modes3.impl.SegmentImpl <em>Segment</em>}' class. | ||
61 | * <!-- begin-user-doc --> | ||
62 | * <!-- end-user-doc --> | ||
63 | * @see modes3.impl.SegmentImpl | ||
64 | * @see modes3.impl.Modes3PackageImpl#getSegment() | ||
65 | * @generated | ||
66 | */ | ||
67 | int SEGMENT = 0; | ||
68 | |||
69 | /** | ||
70 | * The feature id for the '<em><b>Connected To</b></em>' reference list. | ||
71 | * <!-- begin-user-doc --> | ||
72 | * <!-- end-user-doc --> | ||
73 | * @generated | ||
74 | * @ordered | ||
75 | */ | ||
76 | int SEGMENT__CONNECTED_TO = 0; | ||
77 | |||
78 | /** | ||
79 | * The feature id for the '<em><b>Occupied By</b></em>' reference. | ||
80 | * <!-- begin-user-doc --> | ||
81 | * <!-- end-user-doc --> | ||
82 | * @generated | ||
83 | * @ordered | ||
84 | */ | ||
85 | int SEGMENT__OCCUPIED_BY = 1; | ||
86 | |||
87 | /** | ||
88 | * The feature id for the '<em><b>Id</b></em>' attribute. | ||
89 | * <!-- begin-user-doc --> | ||
90 | * <!-- end-user-doc --> | ||
91 | * @generated | ||
92 | * @ordered | ||
93 | */ | ||
94 | int SEGMENT__ID = 2; | ||
95 | |||
96 | /** | ||
97 | * The number of structural features of the '<em>Segment</em>' class. | ||
98 | * <!-- begin-user-doc --> | ||
99 | * <!-- end-user-doc --> | ||
100 | * @generated | ||
101 | * @ordered | ||
102 | */ | ||
103 | int SEGMENT_FEATURE_COUNT = 3; | ||
104 | |||
105 | /** | ||
106 | * The number of operations of the '<em>Segment</em>' class. | ||
107 | * <!-- begin-user-doc --> | ||
108 | * <!-- end-user-doc --> | ||
109 | * @generated | ||
110 | * @ordered | ||
111 | */ | ||
112 | int SEGMENT_OPERATION_COUNT = 0; | ||
113 | |||
114 | /** | ||
115 | * The meta object id for the '{@link modes3.impl.Modes3ModelRootImpl <em>Model Root</em>}' class. | ||
116 | * <!-- begin-user-doc --> | ||
117 | * <!-- end-user-doc --> | ||
118 | * @see modes3.impl.Modes3ModelRootImpl | ||
119 | * @see modes3.impl.Modes3PackageImpl#getModes3ModelRoot() | ||
120 | * @generated | ||
121 | */ | ||
122 | int MODES3_MODEL_ROOT = 1; | ||
123 | |||
124 | /** | ||
125 | * The feature id for the '<em><b>Id</b></em>' attribute. | ||
126 | * <!-- begin-user-doc --> | ||
127 | * <!-- end-user-doc --> | ||
128 | * @generated | ||
129 | * @ordered | ||
130 | */ | ||
131 | int MODES3_MODEL_ROOT__ID = 0; | ||
132 | |||
133 | /** | ||
134 | * The feature id for the '<em><b>Trains</b></em>' containment reference list. | ||
135 | * <!-- begin-user-doc --> | ||
136 | * <!-- end-user-doc --> | ||
137 | * @generated | ||
138 | * @ordered | ||
139 | */ | ||
140 | int MODES3_MODEL_ROOT__TRAINS = 1; | ||
141 | |||
142 | /** | ||
143 | * The feature id for the '<em><b>Segments</b></em>' containment reference list. | ||
144 | * <!-- begin-user-doc --> | ||
145 | * <!-- end-user-doc --> | ||
146 | * @generated | ||
147 | * @ordered | ||
148 | */ | ||
149 | int MODES3_MODEL_ROOT__SEGMENTS = 2; | ||
150 | |||
151 | /** | ||
152 | * The feature id for the '<em><b>Turnouts</b></em>' containment reference list. | ||
153 | * <!-- begin-user-doc --> | ||
154 | * <!-- end-user-doc --> | ||
155 | * @generated | ||
156 | * @ordered | ||
157 | */ | ||
158 | int MODES3_MODEL_ROOT__TURNOUTS = 3; | ||
159 | |||
160 | /** | ||
161 | * The number of structural features of the '<em>Model Root</em>' class. | ||
162 | * <!-- begin-user-doc --> | ||
163 | * <!-- end-user-doc --> | ||
164 | * @generated | ||
165 | * @ordered | ||
166 | */ | ||
167 | int MODES3_MODEL_ROOT_FEATURE_COUNT = 4; | ||
168 | |||
169 | /** | ||
170 | * The number of operations of the '<em>Model Root</em>' class. | ||
171 | * <!-- begin-user-doc --> | ||
172 | * <!-- end-user-doc --> | ||
173 | * @generated | ||
174 | * @ordered | ||
175 | */ | ||
176 | int MODES3_MODEL_ROOT_OPERATION_COUNT = 0; | ||
177 | |||
178 | /** | ||
179 | * The meta object id for the '{@link modes3.impl.TurnoutImpl <em>Turnout</em>}' class. | ||
180 | * <!-- begin-user-doc --> | ||
181 | * <!-- end-user-doc --> | ||
182 | * @see modes3.impl.TurnoutImpl | ||
183 | * @see modes3.impl.Modes3PackageImpl#getTurnout() | ||
184 | * @generated | ||
185 | */ | ||
186 | int TURNOUT = 2; | ||
187 | |||
188 | /** | ||
189 | * The feature id for the '<em><b>Connected To</b></em>' reference list. | ||
190 | * <!-- begin-user-doc --> | ||
191 | * <!-- end-user-doc --> | ||
192 | * @generated | ||
193 | * @ordered | ||
194 | */ | ||
195 | int TURNOUT__CONNECTED_TO = SEGMENT__CONNECTED_TO; | ||
196 | |||
197 | /** | ||
198 | * The feature id for the '<em><b>Occupied By</b></em>' reference. | ||
199 | * <!-- begin-user-doc --> | ||
200 | * <!-- end-user-doc --> | ||
201 | * @generated | ||
202 | * @ordered | ||
203 | */ | ||
204 | int TURNOUT__OCCUPIED_BY = SEGMENT__OCCUPIED_BY; | ||
205 | |||
206 | /** | ||
207 | * The feature id for the '<em><b>Id</b></em>' attribute. | ||
208 | * <!-- begin-user-doc --> | ||
209 | * <!-- end-user-doc --> | ||
210 | * @generated | ||
211 | * @ordered | ||
212 | */ | ||
213 | int TURNOUT__ID = SEGMENT__ID; | ||
214 | |||
215 | /** | ||
216 | * The feature id for the '<em><b>Straight</b></em>' reference. | ||
217 | * <!-- begin-user-doc --> | ||
218 | * <!-- end-user-doc --> | ||
219 | * @generated | ||
220 | * @ordered | ||
221 | */ | ||
222 | int TURNOUT__STRAIGHT = SEGMENT_FEATURE_COUNT + 0; | ||
223 | |||
224 | /** | ||
225 | * The feature id for the '<em><b>Divergent</b></em>' reference. | ||
226 | * <!-- begin-user-doc --> | ||
227 | * <!-- end-user-doc --> | ||
228 | * @generated | ||
229 | * @ordered | ||
230 | */ | ||
231 | int TURNOUT__DIVERGENT = SEGMENT_FEATURE_COUNT + 1; | ||
232 | |||
233 | /** | ||
234 | * The number of structural features of the '<em>Turnout</em>' class. | ||
235 | * <!-- begin-user-doc --> | ||
236 | * <!-- end-user-doc --> | ||
237 | * @generated | ||
238 | * @ordered | ||
239 | */ | ||
240 | int TURNOUT_FEATURE_COUNT = SEGMENT_FEATURE_COUNT + 2; | ||
241 | |||
242 | /** | ||
243 | * The number of operations of the '<em>Turnout</em>' class. | ||
244 | * <!-- begin-user-doc --> | ||
245 | * <!-- end-user-doc --> | ||
246 | * @generated | ||
247 | * @ordered | ||
248 | */ | ||
249 | int TURNOUT_OPERATION_COUNT = SEGMENT_OPERATION_COUNT + 0; | ||
250 | |||
251 | /** | ||
252 | * The meta object id for the '{@link modes3.impl.TrainImpl <em>Train</em>}' class. | ||
253 | * <!-- begin-user-doc --> | ||
254 | * <!-- end-user-doc --> | ||
255 | * @see modes3.impl.TrainImpl | ||
256 | * @see modes3.impl.Modes3PackageImpl#getTrain() | ||
257 | * @generated | ||
258 | */ | ||
259 | int TRAIN = 3; | ||
260 | |||
261 | /** | ||
262 | * The feature id for the '<em><b>Location</b></em>' reference. | ||
263 | * <!-- begin-user-doc --> | ||
264 | * <!-- end-user-doc --> | ||
265 | * @generated | ||
266 | * @ordered | ||
267 | */ | ||
268 | int TRAIN__LOCATION = 0; | ||
269 | |||
270 | /** | ||
271 | * The feature id for the '<em><b>Id</b></em>' attribute. | ||
272 | * <!-- begin-user-doc --> | ||
273 | * <!-- end-user-doc --> | ||
274 | * @generated | ||
275 | * @ordered | ||
276 | */ | ||
277 | int TRAIN__ID = 1; | ||
278 | |||
279 | /** | ||
280 | * The feature id for the '<em><b>Speed</b></em>' attribute. | ||
281 | * <!-- begin-user-doc --> | ||
282 | * <!-- end-user-doc --> | ||
283 | * @generated | ||
284 | * @ordered | ||
285 | */ | ||
286 | int TRAIN__SPEED = 2; | ||
287 | |||
288 | /** | ||
289 | * The number of structural features of the '<em>Train</em>' class. | ||
290 | * <!-- begin-user-doc --> | ||
291 | * <!-- end-user-doc --> | ||
292 | * @generated | ||
293 | * @ordered | ||
294 | */ | ||
295 | int TRAIN_FEATURE_COUNT = 3; | ||
296 | |||
297 | /** | ||
298 | * The number of operations of the '<em>Train</em>' class. | ||
299 | * <!-- begin-user-doc --> | ||
300 | * <!-- end-user-doc --> | ||
301 | * @generated | ||
302 | * @ordered | ||
303 | */ | ||
304 | int TRAIN_OPERATION_COUNT = 0; | ||
305 | |||
306 | |||
307 | /** | ||
308 | * The meta object id for the '{@link modes3.impl.SimpleSegmentImpl <em>Simple Segment</em>}' class. | ||
309 | * <!-- begin-user-doc --> | ||
310 | * <!-- end-user-doc --> | ||
311 | * @see modes3.impl.SimpleSegmentImpl | ||
312 | * @see modes3.impl.Modes3PackageImpl#getSimpleSegment() | ||
313 | * @generated | ||
314 | */ | ||
315 | int SIMPLE_SEGMENT = 4; | ||
316 | |||
317 | /** | ||
318 | * The feature id for the '<em><b>Connected To</b></em>' reference list. | ||
319 | * <!-- begin-user-doc --> | ||
320 | * <!-- end-user-doc --> | ||
321 | * @generated | ||
322 | * @ordered | ||
323 | */ | ||
324 | int SIMPLE_SEGMENT__CONNECTED_TO = SEGMENT__CONNECTED_TO; | ||
325 | |||
326 | /** | ||
327 | * The feature id for the '<em><b>Occupied By</b></em>' reference. | ||
328 | * <!-- begin-user-doc --> | ||
329 | * <!-- end-user-doc --> | ||
330 | * @generated | ||
331 | * @ordered | ||
332 | */ | ||
333 | int SIMPLE_SEGMENT__OCCUPIED_BY = SEGMENT__OCCUPIED_BY; | ||
334 | |||
335 | /** | ||
336 | * The feature id for the '<em><b>Id</b></em>' attribute. | ||
337 | * <!-- begin-user-doc --> | ||
338 | * <!-- end-user-doc --> | ||
339 | * @generated | ||
340 | * @ordered | ||
341 | */ | ||
342 | int SIMPLE_SEGMENT__ID = SEGMENT__ID; | ||
343 | |||
344 | /** | ||
345 | * The number of structural features of the '<em>Simple Segment</em>' class. | ||
346 | * <!-- begin-user-doc --> | ||
347 | * <!-- end-user-doc --> | ||
348 | * @generated | ||
349 | * @ordered | ||
350 | */ | ||
351 | int SIMPLE_SEGMENT_FEATURE_COUNT = SEGMENT_FEATURE_COUNT + 0; | ||
352 | |||
353 | /** | ||
354 | * The number of operations of the '<em>Simple Segment</em>' class. | ||
355 | * <!-- begin-user-doc --> | ||
356 | * <!-- end-user-doc --> | ||
357 | * @generated | ||
358 | * @ordered | ||
359 | */ | ||
360 | int SIMPLE_SEGMENT_OPERATION_COUNT = SEGMENT_OPERATION_COUNT + 0; | ||
361 | |||
362 | |||
363 | /** | ||
364 | * Returns the meta object for class '{@link modes3.Segment <em>Segment</em>}'. | ||
365 | * <!-- begin-user-doc --> | ||
366 | * <!-- end-user-doc --> | ||
367 | * @return the meta object for class '<em>Segment</em>'. | ||
368 | * @see modes3.Segment | ||
369 | * @generated | ||
370 | */ | ||
371 | EClass getSegment(); | ||
372 | |||
373 | /** | ||
374 | * Returns the meta object for the reference list '{@link modes3.Segment#getConnectedTo <em>Connected To</em>}'. | ||
375 | * <!-- begin-user-doc --> | ||
376 | * <!-- end-user-doc --> | ||
377 | * @return the meta object for the reference list '<em>Connected To</em>'. | ||
378 | * @see modes3.Segment#getConnectedTo() | ||
379 | * @see #getSegment() | ||
380 | * @generated | ||
381 | */ | ||
382 | EReference getSegment_ConnectedTo(); | ||
383 | |||
384 | /** | ||
385 | * Returns the meta object for the reference '{@link modes3.Segment#getOccupiedBy <em>Occupied By</em>}'. | ||
386 | * <!-- begin-user-doc --> | ||
387 | * <!-- end-user-doc --> | ||
388 | * @return the meta object for the reference '<em>Occupied By</em>'. | ||
389 | * @see modes3.Segment#getOccupiedBy() | ||
390 | * @see #getSegment() | ||
391 | * @generated | ||
392 | */ | ||
393 | EReference getSegment_OccupiedBy(); | ||
394 | |||
395 | /** | ||
396 | * Returns the meta object for the attribute '{@link modes3.Segment#getId <em>Id</em>}'. | ||
397 | * <!-- begin-user-doc --> | ||
398 | * <!-- end-user-doc --> | ||
399 | * @return the meta object for the attribute '<em>Id</em>'. | ||
400 | * @see modes3.Segment#getId() | ||
401 | * @see #getSegment() | ||
402 | * @generated | ||
403 | */ | ||
404 | EAttribute getSegment_Id(); | ||
405 | |||
406 | /** | ||
407 | * Returns the meta object for class '{@link modes3.Modes3ModelRoot <em>Model Root</em>}'. | ||
408 | * <!-- begin-user-doc --> | ||
409 | * <!-- end-user-doc --> | ||
410 | * @return the meta object for class '<em>Model Root</em>'. | ||
411 | * @see modes3.Modes3ModelRoot | ||
412 | * @generated | ||
413 | */ | ||
414 | EClass getModes3ModelRoot(); | ||
415 | |||
416 | /** | ||
417 | * Returns the meta object for the attribute '{@link modes3.Modes3ModelRoot#getId <em>Id</em>}'. | ||
418 | * <!-- begin-user-doc --> | ||
419 | * <!-- end-user-doc --> | ||
420 | * @return the meta object for the attribute '<em>Id</em>'. | ||
421 | * @see modes3.Modes3ModelRoot#getId() | ||
422 | * @see #getModes3ModelRoot() | ||
423 | * @generated | ||
424 | */ | ||
425 | EAttribute getModes3ModelRoot_Id(); | ||
426 | |||
427 | /** | ||
428 | * Returns the meta object for the containment reference list '{@link modes3.Modes3ModelRoot#getTrains <em>Trains</em>}'. | ||
429 | * <!-- begin-user-doc --> | ||
430 | * <!-- end-user-doc --> | ||
431 | * @return the meta object for the containment reference list '<em>Trains</em>'. | ||
432 | * @see modes3.Modes3ModelRoot#getTrains() | ||
433 | * @see #getModes3ModelRoot() | ||
434 | * @generated | ||
435 | */ | ||
436 | EReference getModes3ModelRoot_Trains(); | ||
437 | |||
438 | /** | ||
439 | * Returns the meta object for the containment reference list '{@link modes3.Modes3ModelRoot#getSegments <em>Segments</em>}'. | ||
440 | * <!-- begin-user-doc --> | ||
441 | * <!-- end-user-doc --> | ||
442 | * @return the meta object for the containment reference list '<em>Segments</em>'. | ||
443 | * @see modes3.Modes3ModelRoot#getSegments() | ||
444 | * @see #getModes3ModelRoot() | ||
445 | * @generated | ||
446 | */ | ||
447 | EReference getModes3ModelRoot_Segments(); | ||
448 | |||
449 | /** | ||
450 | * Returns the meta object for the containment reference list '{@link modes3.Modes3ModelRoot#getTurnouts <em>Turnouts</em>}'. | ||
451 | * <!-- begin-user-doc --> | ||
452 | * <!-- end-user-doc --> | ||
453 | * @return the meta object for the containment reference list '<em>Turnouts</em>'. | ||
454 | * @see modes3.Modes3ModelRoot#getTurnouts() | ||
455 | * @see #getModes3ModelRoot() | ||
456 | * @generated | ||
457 | */ | ||
458 | EReference getModes3ModelRoot_Turnouts(); | ||
459 | |||
460 | /** | ||
461 | * Returns the meta object for class '{@link modes3.Turnout <em>Turnout</em>}'. | ||
462 | * <!-- begin-user-doc --> | ||
463 | * <!-- end-user-doc --> | ||
464 | * @return the meta object for class '<em>Turnout</em>'. | ||
465 | * @see modes3.Turnout | ||
466 | * @generated | ||
467 | */ | ||
468 | EClass getTurnout(); | ||
469 | |||
470 | /** | ||
471 | * Returns the meta object for the reference '{@link modes3.Turnout#getStraight <em>Straight</em>}'. | ||
472 | * <!-- begin-user-doc --> | ||
473 | * <!-- end-user-doc --> | ||
474 | * @return the meta object for the reference '<em>Straight</em>'. | ||
475 | * @see modes3.Turnout#getStraight() | ||
476 | * @see #getTurnout() | ||
477 | * @generated | ||
478 | */ | ||
479 | EReference getTurnout_Straight(); | ||
480 | |||
481 | /** | ||
482 | * Returns the meta object for the reference '{@link modes3.Turnout#getDivergent <em>Divergent</em>}'. | ||
483 | * <!-- begin-user-doc --> | ||
484 | * <!-- end-user-doc --> | ||
485 | * @return the meta object for the reference '<em>Divergent</em>'. | ||
486 | * @see modes3.Turnout#getDivergent() | ||
487 | * @see #getTurnout() | ||
488 | * @generated | ||
489 | */ | ||
490 | EReference getTurnout_Divergent(); | ||
491 | |||
492 | /** | ||
493 | * Returns the meta object for class '{@link modes3.Train <em>Train</em>}'. | ||
494 | * <!-- begin-user-doc --> | ||
495 | * <!-- end-user-doc --> | ||
496 | * @return the meta object for class '<em>Train</em>'. | ||
497 | * @see modes3.Train | ||
498 | * @generated | ||
499 | */ | ||
500 | EClass getTrain(); | ||
501 | |||
502 | /** | ||
503 | * Returns the meta object for the reference '{@link modes3.Train#getLocation <em>Location</em>}'. | ||
504 | * <!-- begin-user-doc --> | ||
505 | * <!-- end-user-doc --> | ||
506 | * @return the meta object for the reference '<em>Location</em>'. | ||
507 | * @see modes3.Train#getLocation() | ||
508 | * @see #getTrain() | ||
509 | * @generated | ||
510 | */ | ||
511 | EReference getTrain_Location(); | ||
512 | |||
513 | /** | ||
514 | * Returns the meta object for the attribute '{@link modes3.Train#getId <em>Id</em>}'. | ||
515 | * <!-- begin-user-doc --> | ||
516 | * <!-- end-user-doc --> | ||
517 | * @return the meta object for the attribute '<em>Id</em>'. | ||
518 | * @see modes3.Train#getId() | ||
519 | * @see #getTrain() | ||
520 | * @generated | ||
521 | */ | ||
522 | EAttribute getTrain_Id(); | ||
523 | |||
524 | /** | ||
525 | * Returns the meta object for the attribute '{@link modes3.Train#getSpeed <em>Speed</em>}'. | ||
526 | * <!-- begin-user-doc --> | ||
527 | * <!-- end-user-doc --> | ||
528 | * @return the meta object for the attribute '<em>Speed</em>'. | ||
529 | * @see modes3.Train#getSpeed() | ||
530 | * @see #getTrain() | ||
531 | * @generated | ||
532 | */ | ||
533 | EAttribute getTrain_Speed(); | ||
534 | |||
535 | /** | ||
536 | * Returns the meta object for class '{@link modes3.SimpleSegment <em>Simple Segment</em>}'. | ||
537 | * <!-- begin-user-doc --> | ||
538 | * <!-- end-user-doc --> | ||
539 | * @return the meta object for class '<em>Simple Segment</em>'. | ||
540 | * @see modes3.SimpleSegment | ||
541 | * @generated | ||
542 | */ | ||
543 | EClass getSimpleSegment(); | ||
544 | |||
545 | /** | ||
546 | * Returns the factory that creates the instances of the model. | ||
547 | * <!-- begin-user-doc --> | ||
548 | * <!-- end-user-doc --> | ||
549 | * @return the factory that creates the instances of the model. | ||
550 | * @generated | ||
551 | */ | ||
552 | Modes3Factory getModes3Factory(); | ||
553 | |||
554 | /** | ||
555 | * <!-- begin-user-doc --> | ||
556 | * Defines literals for the meta objects that represent | ||
557 | * <ul> | ||
558 | * <li>each class,</li> | ||
559 | * <li>each feature of each class,</li> | ||
560 | * <li>each operation of each class,</li> | ||
561 | * <li>each enum,</li> | ||
562 | * <li>and each data type</li> | ||
563 | * </ul> | ||
564 | * <!-- end-user-doc --> | ||
565 | * @generated | ||
566 | */ | ||
567 | interface Literals { | ||
568 | /** | ||
569 | * The meta object literal for the '{@link modes3.impl.SegmentImpl <em>Segment</em>}' class. | ||
570 | * <!-- begin-user-doc --> | ||
571 | * <!-- end-user-doc --> | ||
572 | * @see modes3.impl.SegmentImpl | ||
573 | * @see modes3.impl.Modes3PackageImpl#getSegment() | ||
574 | * @generated | ||
575 | */ | ||
576 | EClass SEGMENT = eINSTANCE.getSegment(); | ||
577 | |||
578 | /** | ||
579 | * The meta object literal for the '<em><b>Connected To</b></em>' reference list feature. | ||
580 | * <!-- begin-user-doc --> | ||
581 | * <!-- end-user-doc --> | ||
582 | * @generated | ||
583 | */ | ||
584 | EReference SEGMENT__CONNECTED_TO = eINSTANCE.getSegment_ConnectedTo(); | ||
585 | |||
586 | /** | ||
587 | * The meta object literal for the '<em><b>Occupied By</b></em>' reference feature. | ||
588 | * <!-- begin-user-doc --> | ||
589 | * <!-- end-user-doc --> | ||
590 | * @generated | ||
591 | */ | ||
592 | EReference SEGMENT__OCCUPIED_BY = eINSTANCE.getSegment_OccupiedBy(); | ||
593 | |||
594 | /** | ||
595 | * The meta object literal for the '<em><b>Id</b></em>' attribute feature. | ||
596 | * <!-- begin-user-doc --> | ||
597 | * <!-- end-user-doc --> | ||
598 | * @generated | ||
599 | */ | ||
600 | EAttribute SEGMENT__ID = eINSTANCE.getSegment_Id(); | ||
601 | |||
602 | /** | ||
603 | * The meta object literal for the '{@link modes3.impl.Modes3ModelRootImpl <em>Model Root</em>}' class. | ||
604 | * <!-- begin-user-doc --> | ||
605 | * <!-- end-user-doc --> | ||
606 | * @see modes3.impl.Modes3ModelRootImpl | ||
607 | * @see modes3.impl.Modes3PackageImpl#getModes3ModelRoot() | ||
608 | * @generated | ||
609 | */ | ||
610 | EClass MODES3_MODEL_ROOT = eINSTANCE.getModes3ModelRoot(); | ||
611 | |||
612 | /** | ||
613 | * The meta object literal for the '<em><b>Id</b></em>' attribute feature. | ||
614 | * <!-- begin-user-doc --> | ||
615 | * <!-- end-user-doc --> | ||
616 | * @generated | ||
617 | */ | ||
618 | EAttribute MODES3_MODEL_ROOT__ID = eINSTANCE.getModes3ModelRoot_Id(); | ||
619 | |||
620 | /** | ||
621 | * The meta object literal for the '<em><b>Trains</b></em>' containment reference list feature. | ||
622 | * <!-- begin-user-doc --> | ||
623 | * <!-- end-user-doc --> | ||
624 | * @generated | ||
625 | */ | ||
626 | EReference MODES3_MODEL_ROOT__TRAINS = eINSTANCE.getModes3ModelRoot_Trains(); | ||
627 | |||
628 | /** | ||
629 | * The meta object literal for the '<em><b>Segments</b></em>' containment reference list feature. | ||
630 | * <!-- begin-user-doc --> | ||
631 | * <!-- end-user-doc --> | ||
632 | * @generated | ||
633 | */ | ||
634 | EReference MODES3_MODEL_ROOT__SEGMENTS = eINSTANCE.getModes3ModelRoot_Segments(); | ||
635 | |||
636 | /** | ||
637 | * The meta object literal for the '<em><b>Turnouts</b></em>' containment reference list feature. | ||
638 | * <!-- begin-user-doc --> | ||
639 | * <!-- end-user-doc --> | ||
640 | * @generated | ||
641 | */ | ||
642 | EReference MODES3_MODEL_ROOT__TURNOUTS = eINSTANCE.getModes3ModelRoot_Turnouts(); | ||
643 | |||
644 | /** | ||
645 | * The meta object literal for the '{@link modes3.impl.TurnoutImpl <em>Turnout</em>}' class. | ||
646 | * <!-- begin-user-doc --> | ||
647 | * <!-- end-user-doc --> | ||
648 | * @see modes3.impl.TurnoutImpl | ||
649 | * @see modes3.impl.Modes3PackageImpl#getTurnout() | ||
650 | * @generated | ||
651 | */ | ||
652 | EClass TURNOUT = eINSTANCE.getTurnout(); | ||
653 | |||
654 | /** | ||
655 | * The meta object literal for the '<em><b>Straight</b></em>' reference feature. | ||
656 | * <!-- begin-user-doc --> | ||
657 | * <!-- end-user-doc --> | ||
658 | * @generated | ||
659 | */ | ||
660 | EReference TURNOUT__STRAIGHT = eINSTANCE.getTurnout_Straight(); | ||
661 | |||
662 | /** | ||
663 | * The meta object literal for the '<em><b>Divergent</b></em>' reference feature. | ||
664 | * <!-- begin-user-doc --> | ||
665 | * <!-- end-user-doc --> | ||
666 | * @generated | ||
667 | */ | ||
668 | EReference TURNOUT__DIVERGENT = eINSTANCE.getTurnout_Divergent(); | ||
669 | |||
670 | /** | ||
671 | * The meta object literal for the '{@link modes3.impl.TrainImpl <em>Train</em>}' class. | ||
672 | * <!-- begin-user-doc --> | ||
673 | * <!-- end-user-doc --> | ||
674 | * @see modes3.impl.TrainImpl | ||
675 | * @see modes3.impl.Modes3PackageImpl#getTrain() | ||
676 | * @generated | ||
677 | */ | ||
678 | EClass TRAIN = eINSTANCE.getTrain(); | ||
679 | |||
680 | /** | ||
681 | * The meta object literal for the '<em><b>Location</b></em>' reference feature. | ||
682 | * <!-- begin-user-doc --> | ||
683 | * <!-- end-user-doc --> | ||
684 | * @generated | ||
685 | */ | ||
686 | EReference TRAIN__LOCATION = eINSTANCE.getTrain_Location(); | ||
687 | |||
688 | /** | ||
689 | * The meta object literal for the '<em><b>Id</b></em>' attribute feature. | ||
690 | * <!-- begin-user-doc --> | ||
691 | * <!-- end-user-doc --> | ||
692 | * @generated | ||
693 | */ | ||
694 | EAttribute TRAIN__ID = eINSTANCE.getTrain_Id(); | ||
695 | |||
696 | /** | ||
697 | * The meta object literal for the '<em><b>Speed</b></em>' attribute feature. | ||
698 | * <!-- begin-user-doc --> | ||
699 | * <!-- end-user-doc --> | ||
700 | * @generated | ||
701 | */ | ||
702 | EAttribute TRAIN__SPEED = eINSTANCE.getTrain_Speed(); | ||
703 | |||
704 | /** | ||
705 | * The meta object literal for the '{@link modes3.impl.SimpleSegmentImpl <em>Simple Segment</em>}' class. | ||
706 | * <!-- begin-user-doc --> | ||
707 | * <!-- end-user-doc --> | ||
708 | * @see modes3.impl.SimpleSegmentImpl | ||
709 | * @see modes3.impl.Modes3PackageImpl#getSimpleSegment() | ||
710 | * @generated | ||
711 | */ | ||
712 | EClass SIMPLE_SEGMENT = eINSTANCE.getSimpleSegment(); | ||
713 | |||
714 | } | ||
715 | |||
716 | } //Modes3Package | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Segment.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Segment.java new file mode 100644 index 00000000..002f25a5 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Segment.java | |||
@@ -0,0 +1,86 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3; | ||
4 | |||
5 | import org.eclipse.emf.common.util.EList; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | |||
9 | /** | ||
10 | * <!-- begin-user-doc --> | ||
11 | * A representation of the model object '<em><b>Segment</b></em>'. | ||
12 | * <!-- end-user-doc --> | ||
13 | * | ||
14 | * <p> | ||
15 | * The following features are supported: | ||
16 | * </p> | ||
17 | * <ul> | ||
18 | * <li>{@link modes3.Segment#getConnectedTo <em>Connected To</em>}</li> | ||
19 | * <li>{@link modes3.Segment#getOccupiedBy <em>Occupied By</em>}</li> | ||
20 | * <li>{@link modes3.Segment#getId <em>Id</em>}</li> | ||
21 | * </ul> | ||
22 | * | ||
23 | * @see modes3.Modes3Package#getSegment() | ||
24 | * @model | ||
25 | * @generated | ||
26 | */ | ||
27 | public interface Segment extends EObject { | ||
28 | /** | ||
29 | * Returns the value of the '<em><b>Connected To</b></em>' reference list. | ||
30 | * The list contents are of type {@link modes3.Segment}. | ||
31 | * <!-- begin-user-doc --> | ||
32 | * <!-- end-user-doc --> | ||
33 | * @return the value of the '<em>Connected To</em>' reference list. | ||
34 | * @see modes3.Modes3Package#getSegment_ConnectedTo() | ||
35 | * @model upper="2" | ||
36 | * @generated | ||
37 | */ | ||
38 | EList<Segment> getConnectedTo(); | ||
39 | |||
40 | /** | ||
41 | * Returns the value of the '<em><b>Occupied By</b></em>' reference. | ||
42 | * It is bidirectional and its opposite is '{@link modes3.Train#getLocation <em>Location</em>}'. | ||
43 | * <!-- begin-user-doc --> | ||
44 | * <!-- end-user-doc --> | ||
45 | * @return the value of the '<em>Occupied By</em>' reference. | ||
46 | * @see #setOccupiedBy(Train) | ||
47 | * @see modes3.Modes3Package#getSegment_OccupiedBy() | ||
48 | * @see modes3.Train#getLocation | ||
49 | * @model opposite="location" | ||
50 | * @generated | ||
51 | */ | ||
52 | Train getOccupiedBy(); | ||
53 | |||
54 | /** | ||
55 | * Sets the value of the '{@link modes3.Segment#getOccupiedBy <em>Occupied By</em>}' reference. | ||
56 | * <!-- begin-user-doc --> | ||
57 | * <!-- end-user-doc --> | ||
58 | * @param value the new value of the '<em>Occupied By</em>' reference. | ||
59 | * @see #getOccupiedBy() | ||
60 | * @generated | ||
61 | */ | ||
62 | void setOccupiedBy(Train value); | ||
63 | |||
64 | /** | ||
65 | * Returns the value of the '<em><b>Id</b></em>' attribute. | ||
66 | * <!-- begin-user-doc --> | ||
67 | * <!-- end-user-doc --> | ||
68 | * @return the value of the '<em>Id</em>' attribute. | ||
69 | * @see #setId(int) | ||
70 | * @see modes3.Modes3Package#getSegment_Id() | ||
71 | * @model | ||
72 | * @generated | ||
73 | */ | ||
74 | int getId(); | ||
75 | |||
76 | /** | ||
77 | * Sets the value of the '{@link modes3.Segment#getId <em>Id</em>}' attribute. | ||
78 | * <!-- begin-user-doc --> | ||
79 | * <!-- end-user-doc --> | ||
80 | * @param value the new value of the '<em>Id</em>' attribute. | ||
81 | * @see #getId() | ||
82 | * @generated | ||
83 | */ | ||
84 | void setId(int value); | ||
85 | |||
86 | } // Segment | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/SimpleSegment.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/SimpleSegment.java new file mode 100644 index 00000000..da77510f --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/SimpleSegment.java | |||
@@ -0,0 +1,17 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3; | ||
4 | |||
5 | |||
6 | /** | ||
7 | * <!-- begin-user-doc --> | ||
8 | * A representation of the model object '<em><b>Simple Segment</b></em>'. | ||
9 | * <!-- end-user-doc --> | ||
10 | * | ||
11 | * | ||
12 | * @see modes3.Modes3Package#getSimpleSegment() | ||
13 | * @model | ||
14 | * @generated | ||
15 | */ | ||
16 | public interface SimpleSegment extends Segment { | ||
17 | } // SimpleSegment | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Train.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Train.java new file mode 100644 index 00000000..1829586d --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Train.java | |||
@@ -0,0 +1,94 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3; | ||
4 | |||
5 | import org.eclipse.emf.ecore.EObject; | ||
6 | |||
7 | /** | ||
8 | * <!-- begin-user-doc --> | ||
9 | * A representation of the model object '<em><b>Train</b></em>'. | ||
10 | * <!-- end-user-doc --> | ||
11 | * | ||
12 | * <p> | ||
13 | * The following features are supported: | ||
14 | * </p> | ||
15 | * <ul> | ||
16 | * <li>{@link modes3.Train#getLocation <em>Location</em>}</li> | ||
17 | * <li>{@link modes3.Train#getId <em>Id</em>}</li> | ||
18 | * <li>{@link modes3.Train#getSpeed <em>Speed</em>}</li> | ||
19 | * </ul> | ||
20 | * | ||
21 | * @see modes3.Modes3Package#getTrain() | ||
22 | * @model | ||
23 | * @generated | ||
24 | */ | ||
25 | public interface Train extends EObject { | ||
26 | /** | ||
27 | * Returns the value of the '<em><b>Location</b></em>' reference. | ||
28 | * It is bidirectional and its opposite is '{@link modes3.Segment#getOccupiedBy <em>Occupied By</em>}'. | ||
29 | * <!-- begin-user-doc --> | ||
30 | * <!-- end-user-doc --> | ||
31 | * @return the value of the '<em>Location</em>' reference. | ||
32 | * @see #setLocation(Segment) | ||
33 | * @see modes3.Modes3Package#getTrain_Location() | ||
34 | * @see modes3.Segment#getOccupiedBy | ||
35 | * @model opposite="occupiedBy" required="true" | ||
36 | * @generated | ||
37 | */ | ||
38 | Segment getLocation(); | ||
39 | |||
40 | /** | ||
41 | * Sets the value of the '{@link modes3.Train#getLocation <em>Location</em>}' reference. | ||
42 | * <!-- begin-user-doc --> | ||
43 | * <!-- end-user-doc --> | ||
44 | * @param value the new value of the '<em>Location</em>' reference. | ||
45 | * @see #getLocation() | ||
46 | * @generated | ||
47 | */ | ||
48 | void setLocation(Segment value); | ||
49 | |||
50 | /** | ||
51 | * Returns the value of the '<em><b>Id</b></em>' attribute. | ||
52 | * <!-- begin-user-doc --> | ||
53 | * <!-- end-user-doc --> | ||
54 | * @return the value of the '<em>Id</em>' attribute. | ||
55 | * @see #setId(int) | ||
56 | * @see modes3.Modes3Package#getTrain_Id() | ||
57 | * @model | ||
58 | * @generated | ||
59 | */ | ||
60 | int getId(); | ||
61 | |||
62 | /** | ||
63 | * Sets the value of the '{@link modes3.Train#getId <em>Id</em>}' attribute. | ||
64 | * <!-- begin-user-doc --> | ||
65 | * <!-- end-user-doc --> | ||
66 | * @param value the new value of the '<em>Id</em>' attribute. | ||
67 | * @see #getId() | ||
68 | * @generated | ||
69 | */ | ||
70 | void setId(int value); | ||
71 | |||
72 | /** | ||
73 | * Returns the value of the '<em><b>Speed</b></em>' attribute. | ||
74 | * <!-- begin-user-doc --> | ||
75 | * <!-- end-user-doc --> | ||
76 | * @return the value of the '<em>Speed</em>' attribute. | ||
77 | * @see #setSpeed(double) | ||
78 | * @see modes3.Modes3Package#getTrain_Speed() | ||
79 | * @model | ||
80 | * @generated | ||
81 | */ | ||
82 | double getSpeed(); | ||
83 | |||
84 | /** | ||
85 | * Sets the value of the '{@link modes3.Train#getSpeed <em>Speed</em>}' attribute. | ||
86 | * <!-- begin-user-doc --> | ||
87 | * <!-- end-user-doc --> | ||
88 | * @param value the new value of the '<em>Speed</em>' attribute. | ||
89 | * @see #getSpeed() | ||
90 | * @generated | ||
91 | */ | ||
92 | void setSpeed(double value); | ||
93 | |||
94 | } // Train | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Turnout.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Turnout.java new file mode 100644 index 00000000..799f8d7b --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/Turnout.java | |||
@@ -0,0 +1,68 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3; | ||
4 | |||
5 | |||
6 | /** | ||
7 | * <!-- begin-user-doc --> | ||
8 | * A representation of the model object '<em><b>Turnout</b></em>'. | ||
9 | * <!-- end-user-doc --> | ||
10 | * | ||
11 | * <p> | ||
12 | * The following features are supported: | ||
13 | * </p> | ||
14 | * <ul> | ||
15 | * <li>{@link modes3.Turnout#getStraight <em>Straight</em>}</li> | ||
16 | * <li>{@link modes3.Turnout#getDivergent <em>Divergent</em>}</li> | ||
17 | * </ul> | ||
18 | * | ||
19 | * @see modes3.Modes3Package#getTurnout() | ||
20 | * @model | ||
21 | * @generated | ||
22 | */ | ||
23 | public interface Turnout extends Segment { | ||
24 | /** | ||
25 | * Returns the value of the '<em><b>Straight</b></em>' reference. | ||
26 | * <!-- begin-user-doc --> | ||
27 | * <!-- end-user-doc --> | ||
28 | * @return the value of the '<em>Straight</em>' reference. | ||
29 | * @see #setStraight(Segment) | ||
30 | * @see modes3.Modes3Package#getTurnout_Straight() | ||
31 | * @model required="true" | ||
32 | * @generated | ||
33 | */ | ||
34 | Segment getStraight(); | ||
35 | |||
36 | /** | ||
37 | * Sets the value of the '{@link modes3.Turnout#getStraight <em>Straight</em>}' reference. | ||
38 | * <!-- begin-user-doc --> | ||
39 | * <!-- end-user-doc --> | ||
40 | * @param value the new value of the '<em>Straight</em>' reference. | ||
41 | * @see #getStraight() | ||
42 | * @generated | ||
43 | */ | ||
44 | void setStraight(Segment value); | ||
45 | |||
46 | /** | ||
47 | * Returns the value of the '<em><b>Divergent</b></em>' reference. | ||
48 | * <!-- begin-user-doc --> | ||
49 | * <!-- end-user-doc --> | ||
50 | * @return the value of the '<em>Divergent</em>' reference. | ||
51 | * @see #setDivergent(Segment) | ||
52 | * @see modes3.Modes3Package#getTurnout_Divergent() | ||
53 | * @model required="true" | ||
54 | * @generated | ||
55 | */ | ||
56 | Segment getDivergent(); | ||
57 | |||
58 | /** | ||
59 | * Sets the value of the '{@link modes3.Turnout#getDivergent <em>Divergent</em>}' reference. | ||
60 | * <!-- begin-user-doc --> | ||
61 | * <!-- end-user-doc --> | ||
62 | * @param value the new value of the '<em>Divergent</em>' reference. | ||
63 | * @see #getDivergent() | ||
64 | * @generated | ||
65 | */ | ||
66 | void setDivergent(Segment value); | ||
67 | |||
68 | } // Turnout | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3FactoryImpl.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3FactoryImpl.java new file mode 100644 index 00000000..60947533 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3FactoryImpl.java | |||
@@ -0,0 +1,139 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.impl; | ||
4 | |||
5 | import modes3.*; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EClass; | ||
8 | import org.eclipse.emf.ecore.EObject; | ||
9 | import org.eclipse.emf.ecore.EPackage; | ||
10 | |||
11 | import org.eclipse.emf.ecore.impl.EFactoryImpl; | ||
12 | |||
13 | import org.eclipse.emf.ecore.plugin.EcorePlugin; | ||
14 | |||
15 | /** | ||
16 | * <!-- begin-user-doc --> | ||
17 | * An implementation of the model <b>Factory</b>. | ||
18 | * <!-- end-user-doc --> | ||
19 | * @generated | ||
20 | */ | ||
21 | public class Modes3FactoryImpl extends EFactoryImpl implements Modes3Factory { | ||
22 | /** | ||
23 | * Creates the default factory implementation. | ||
24 | * <!-- begin-user-doc --> | ||
25 | * <!-- end-user-doc --> | ||
26 | * @generated | ||
27 | */ | ||
28 | public static Modes3Factory init() { | ||
29 | try { | ||
30 | Modes3Factory theModes3Factory = (Modes3Factory)EPackage.Registry.INSTANCE.getEFactory(Modes3Package.eNS_URI); | ||
31 | if (theModes3Factory != null) { | ||
32 | return theModes3Factory; | ||
33 | } | ||
34 | } | ||
35 | catch (Exception exception) { | ||
36 | EcorePlugin.INSTANCE.log(exception); | ||
37 | } | ||
38 | return new Modes3FactoryImpl(); | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * Creates an instance of the factory. | ||
43 | * <!-- begin-user-doc --> | ||
44 | * <!-- end-user-doc --> | ||
45 | * @generated | ||
46 | */ | ||
47 | public Modes3FactoryImpl() { | ||
48 | super(); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * <!-- begin-user-doc --> | ||
53 | * <!-- end-user-doc --> | ||
54 | * @generated | ||
55 | */ | ||
56 | @Override | ||
57 | public EObject create(EClass eClass) { | ||
58 | switch (eClass.getClassifierID()) { | ||
59 | case Modes3Package.SEGMENT: return createSegment(); | ||
60 | case Modes3Package.MODES3_MODEL_ROOT: return createModes3ModelRoot(); | ||
61 | case Modes3Package.TURNOUT: return createTurnout(); | ||
62 | case Modes3Package.TRAIN: return createTrain(); | ||
63 | case Modes3Package.SIMPLE_SEGMENT: return createSimpleSegment(); | ||
64 | default: | ||
65 | throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); | ||
66 | } | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * <!-- begin-user-doc --> | ||
71 | * <!-- end-user-doc --> | ||
72 | * @generated | ||
73 | */ | ||
74 | public Segment createSegment() { | ||
75 | SegmentImpl segment = new SegmentImpl(); | ||
76 | return segment; | ||
77 | } | ||
78 | |||
79 | /** | ||
80 | * <!-- begin-user-doc --> | ||
81 | * <!-- end-user-doc --> | ||
82 | * @generated | ||
83 | */ | ||
84 | public Modes3ModelRoot createModes3ModelRoot() { | ||
85 | Modes3ModelRootImpl modes3ModelRoot = new Modes3ModelRootImpl(); | ||
86 | return modes3ModelRoot; | ||
87 | } | ||
88 | |||
89 | /** | ||
90 | * <!-- begin-user-doc --> | ||
91 | * <!-- end-user-doc --> | ||
92 | * @generated | ||
93 | */ | ||
94 | public Turnout createTurnout() { | ||
95 | TurnoutImpl turnout = new TurnoutImpl(); | ||
96 | return turnout; | ||
97 | } | ||
98 | |||
99 | /** | ||
100 | * <!-- begin-user-doc --> | ||
101 | * <!-- end-user-doc --> | ||
102 | * @generated | ||
103 | */ | ||
104 | public Train createTrain() { | ||
105 | TrainImpl train = new TrainImpl(); | ||
106 | return train; | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * <!-- begin-user-doc --> | ||
111 | * <!-- end-user-doc --> | ||
112 | * @generated | ||
113 | */ | ||
114 | public SimpleSegment createSimpleSegment() { | ||
115 | SimpleSegmentImpl simpleSegment = new SimpleSegmentImpl(); | ||
116 | return simpleSegment; | ||
117 | } | ||
118 | |||
119 | /** | ||
120 | * <!-- begin-user-doc --> | ||
121 | * <!-- end-user-doc --> | ||
122 | * @generated | ||
123 | */ | ||
124 | public Modes3Package getModes3Package() { | ||
125 | return (Modes3Package)getEPackage(); | ||
126 | } | ||
127 | |||
128 | /** | ||
129 | * <!-- begin-user-doc --> | ||
130 | * <!-- end-user-doc --> | ||
131 | * @deprecated | ||
132 | * @generated | ||
133 | */ | ||
134 | @Deprecated | ||
135 | public static Modes3Package getPackage() { | ||
136 | return Modes3Package.eINSTANCE; | ||
137 | } | ||
138 | |||
139 | } //Modes3FactoryImpl | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3ModelRootImpl.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3ModelRootImpl.java new file mode 100644 index 00000000..ccab1f29 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3ModelRootImpl.java | |||
@@ -0,0 +1,296 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.impl; | ||
4 | |||
5 | import java.util.Collection; | ||
6 | |||
7 | import modes3.Modes3ModelRoot; | ||
8 | import modes3.Modes3Package; | ||
9 | import modes3.SimpleSegment; | ||
10 | import modes3.Train; | ||
11 | import modes3.Turnout; | ||
12 | |||
13 | import org.eclipse.emf.common.notify.Notification; | ||
14 | import org.eclipse.emf.common.notify.NotificationChain; | ||
15 | |||
16 | import org.eclipse.emf.common.util.EList; | ||
17 | |||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.emf.ecore.InternalEObject; | ||
20 | |||
21 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
22 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; | ||
23 | |||
24 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; | ||
25 | import org.eclipse.emf.ecore.util.InternalEList; | ||
26 | |||
27 | /** | ||
28 | * <!-- begin-user-doc --> | ||
29 | * An implementation of the model object '<em><b>Model Root</b></em>'. | ||
30 | * <!-- end-user-doc --> | ||
31 | * <p> | ||
32 | * The following features are implemented: | ||
33 | * </p> | ||
34 | * <ul> | ||
35 | * <li>{@link modes3.impl.Modes3ModelRootImpl#getId <em>Id</em>}</li> | ||
36 | * <li>{@link modes3.impl.Modes3ModelRootImpl#getTrains <em>Trains</em>}</li> | ||
37 | * <li>{@link modes3.impl.Modes3ModelRootImpl#getSegments <em>Segments</em>}</li> | ||
38 | * <li>{@link modes3.impl.Modes3ModelRootImpl#getTurnouts <em>Turnouts</em>}</li> | ||
39 | * </ul> | ||
40 | * | ||
41 | * @generated | ||
42 | */ | ||
43 | public class Modes3ModelRootImpl extends MinimalEObjectImpl.Container implements Modes3ModelRoot { | ||
44 | /** | ||
45 | * The default value of the '{@link #getId() <em>Id</em>}' attribute. | ||
46 | * <!-- begin-user-doc --> | ||
47 | * <!-- end-user-doc --> | ||
48 | * @see #getId() | ||
49 | * @generated | ||
50 | * @ordered | ||
51 | */ | ||
52 | protected static final int ID_EDEFAULT = 0; | ||
53 | |||
54 | /** | ||
55 | * The cached value of the '{@link #getId() <em>Id</em>}' attribute. | ||
56 | * <!-- begin-user-doc --> | ||
57 | * <!-- end-user-doc --> | ||
58 | * @see #getId() | ||
59 | * @generated | ||
60 | * @ordered | ||
61 | */ | ||
62 | protected int id = ID_EDEFAULT; | ||
63 | |||
64 | /** | ||
65 | * The cached value of the '{@link #getTrains() <em>Trains</em>}' containment reference list. | ||
66 | * <!-- begin-user-doc --> | ||
67 | * <!-- end-user-doc --> | ||
68 | * @see #getTrains() | ||
69 | * @generated | ||
70 | * @ordered | ||
71 | */ | ||
72 | protected EList<Train> trains; | ||
73 | |||
74 | /** | ||
75 | * The cached value of the '{@link #getSegments() <em>Segments</em>}' containment reference list. | ||
76 | * <!-- begin-user-doc --> | ||
77 | * <!-- end-user-doc --> | ||
78 | * @see #getSegments() | ||
79 | * @generated | ||
80 | * @ordered | ||
81 | */ | ||
82 | protected EList<SimpleSegment> segments; | ||
83 | |||
84 | /** | ||
85 | * The cached value of the '{@link #getTurnouts() <em>Turnouts</em>}' containment reference list. | ||
86 | * <!-- begin-user-doc --> | ||
87 | * <!-- end-user-doc --> | ||
88 | * @see #getTurnouts() | ||
89 | * @generated | ||
90 | * @ordered | ||
91 | */ | ||
92 | protected EList<Turnout> turnouts; | ||
93 | |||
94 | /** | ||
95 | * <!-- begin-user-doc --> | ||
96 | * <!-- end-user-doc --> | ||
97 | * @generated | ||
98 | */ | ||
99 | protected Modes3ModelRootImpl() { | ||
100 | super(); | ||
101 | } | ||
102 | |||
103 | /** | ||
104 | * <!-- begin-user-doc --> | ||
105 | * <!-- end-user-doc --> | ||
106 | * @generated | ||
107 | */ | ||
108 | @Override | ||
109 | protected EClass eStaticClass() { | ||
110 | return Modes3Package.Literals.MODES3_MODEL_ROOT; | ||
111 | } | ||
112 | |||
113 | /** | ||
114 | * <!-- begin-user-doc --> | ||
115 | * <!-- end-user-doc --> | ||
116 | * @generated | ||
117 | */ | ||
118 | public int getId() { | ||
119 | return id; | ||
120 | } | ||
121 | |||
122 | /** | ||
123 | * <!-- begin-user-doc --> | ||
124 | * <!-- end-user-doc --> | ||
125 | * @generated | ||
126 | */ | ||
127 | public void setId(int newId) { | ||
128 | int oldId = id; | ||
129 | id = newId; | ||
130 | if (eNotificationRequired()) | ||
131 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.MODES3_MODEL_ROOT__ID, oldId, id)); | ||
132 | } | ||
133 | |||
134 | /** | ||
135 | * <!-- begin-user-doc --> | ||
136 | * <!-- end-user-doc --> | ||
137 | * @generated | ||
138 | */ | ||
139 | public EList<Train> getTrains() { | ||
140 | if (trains == null) { | ||
141 | trains = new EObjectContainmentEList<Train>(Train.class, this, Modes3Package.MODES3_MODEL_ROOT__TRAINS); | ||
142 | } | ||
143 | return trains; | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * <!-- begin-user-doc --> | ||
148 | * <!-- end-user-doc --> | ||
149 | * @generated | ||
150 | */ | ||
151 | public EList<SimpleSegment> getSegments() { | ||
152 | if (segments == null) { | ||
153 | segments = new EObjectContainmentEList<SimpleSegment>(SimpleSegment.class, this, Modes3Package.MODES3_MODEL_ROOT__SEGMENTS); | ||
154 | } | ||
155 | return segments; | ||
156 | } | ||
157 | |||
158 | /** | ||
159 | * <!-- begin-user-doc --> | ||
160 | * <!-- end-user-doc --> | ||
161 | * @generated | ||
162 | */ | ||
163 | public EList<Turnout> getTurnouts() { | ||
164 | if (turnouts == null) { | ||
165 | turnouts = new EObjectContainmentEList<Turnout>(Turnout.class, this, Modes3Package.MODES3_MODEL_ROOT__TURNOUTS); | ||
166 | } | ||
167 | return turnouts; | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * <!-- begin-user-doc --> | ||
172 | * <!-- end-user-doc --> | ||
173 | * @generated | ||
174 | */ | ||
175 | @Override | ||
176 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
177 | switch (featureID) { | ||
178 | case Modes3Package.MODES3_MODEL_ROOT__TRAINS: | ||
179 | return ((InternalEList<?>)getTrains()).basicRemove(otherEnd, msgs); | ||
180 | case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: | ||
181 | return ((InternalEList<?>)getSegments()).basicRemove(otherEnd, msgs); | ||
182 | case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: | ||
183 | return ((InternalEList<?>)getTurnouts()).basicRemove(otherEnd, msgs); | ||
184 | } | ||
185 | return super.eInverseRemove(otherEnd, featureID, msgs); | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * <!-- begin-user-doc --> | ||
190 | * <!-- end-user-doc --> | ||
191 | * @generated | ||
192 | */ | ||
193 | @Override | ||
194 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
195 | switch (featureID) { | ||
196 | case Modes3Package.MODES3_MODEL_ROOT__ID: | ||
197 | return getId(); | ||
198 | case Modes3Package.MODES3_MODEL_ROOT__TRAINS: | ||
199 | return getTrains(); | ||
200 | case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: | ||
201 | return getSegments(); | ||
202 | case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: | ||
203 | return getTurnouts(); | ||
204 | } | ||
205 | return super.eGet(featureID, resolve, coreType); | ||
206 | } | ||
207 | |||
208 | /** | ||
209 | * <!-- begin-user-doc --> | ||
210 | * <!-- end-user-doc --> | ||
211 | * @generated | ||
212 | */ | ||
213 | @SuppressWarnings("unchecked") | ||
214 | @Override | ||
215 | public void eSet(int featureID, Object newValue) { | ||
216 | switch (featureID) { | ||
217 | case Modes3Package.MODES3_MODEL_ROOT__ID: | ||
218 | setId((Integer)newValue); | ||
219 | return; | ||
220 | case Modes3Package.MODES3_MODEL_ROOT__TRAINS: | ||
221 | getTrains().clear(); | ||
222 | getTrains().addAll((Collection<? extends Train>)newValue); | ||
223 | return; | ||
224 | case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: | ||
225 | getSegments().clear(); | ||
226 | getSegments().addAll((Collection<? extends SimpleSegment>)newValue); | ||
227 | return; | ||
228 | case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: | ||
229 | getTurnouts().clear(); | ||
230 | getTurnouts().addAll((Collection<? extends Turnout>)newValue); | ||
231 | return; | ||
232 | } | ||
233 | super.eSet(featureID, newValue); | ||
234 | } | ||
235 | |||
236 | /** | ||
237 | * <!-- begin-user-doc --> | ||
238 | * <!-- end-user-doc --> | ||
239 | * @generated | ||
240 | */ | ||
241 | @Override | ||
242 | public void eUnset(int featureID) { | ||
243 | switch (featureID) { | ||
244 | case Modes3Package.MODES3_MODEL_ROOT__ID: | ||
245 | setId(ID_EDEFAULT); | ||
246 | return; | ||
247 | case Modes3Package.MODES3_MODEL_ROOT__TRAINS: | ||
248 | getTrains().clear(); | ||
249 | return; | ||
250 | case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: | ||
251 | getSegments().clear(); | ||
252 | return; | ||
253 | case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: | ||
254 | getTurnouts().clear(); | ||
255 | return; | ||
256 | } | ||
257 | super.eUnset(featureID); | ||
258 | } | ||
259 | |||
260 | /** | ||
261 | * <!-- begin-user-doc --> | ||
262 | * <!-- end-user-doc --> | ||
263 | * @generated | ||
264 | */ | ||
265 | @Override | ||
266 | public boolean eIsSet(int featureID) { | ||
267 | switch (featureID) { | ||
268 | case Modes3Package.MODES3_MODEL_ROOT__ID: | ||
269 | return id != ID_EDEFAULT; | ||
270 | case Modes3Package.MODES3_MODEL_ROOT__TRAINS: | ||
271 | return trains != null && !trains.isEmpty(); | ||
272 | case Modes3Package.MODES3_MODEL_ROOT__SEGMENTS: | ||
273 | return segments != null && !segments.isEmpty(); | ||
274 | case Modes3Package.MODES3_MODEL_ROOT__TURNOUTS: | ||
275 | return turnouts != null && !turnouts.isEmpty(); | ||
276 | } | ||
277 | return super.eIsSet(featureID); | ||
278 | } | ||
279 | |||
280 | /** | ||
281 | * <!-- begin-user-doc --> | ||
282 | * <!-- end-user-doc --> | ||
283 | * @generated | ||
284 | */ | ||
285 | @Override | ||
286 | public String toString() { | ||
287 | if (eIsProxy()) return super.toString(); | ||
288 | |||
289 | StringBuilder result = new StringBuilder(super.toString()); | ||
290 | result.append(" (id: "); | ||
291 | result.append(id); | ||
292 | result.append(')'); | ||
293 | return result.toString(); | ||
294 | } | ||
295 | |||
296 | } //Modes3ModelRootImpl | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3PackageImpl.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3PackageImpl.java new file mode 100644 index 00000000..557da4c1 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/Modes3PackageImpl.java | |||
@@ -0,0 +1,385 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.impl; | ||
4 | |||
5 | import modes3.Modes3Factory; | ||
6 | import modes3.Modes3ModelRoot; | ||
7 | import modes3.Modes3Package; | ||
8 | import modes3.Segment; | ||
9 | import modes3.SimpleSegment; | ||
10 | import modes3.Train; | ||
11 | import modes3.Turnout; | ||
12 | |||
13 | import org.eclipse.emf.ecore.EAttribute; | ||
14 | import org.eclipse.emf.ecore.EClass; | ||
15 | import org.eclipse.emf.ecore.EPackage; | ||
16 | import org.eclipse.emf.ecore.EReference; | ||
17 | |||
18 | import org.eclipse.emf.ecore.impl.EPackageImpl; | ||
19 | |||
20 | /** | ||
21 | * <!-- begin-user-doc --> | ||
22 | * An implementation of the model <b>Package</b>. | ||
23 | * <!-- end-user-doc --> | ||
24 | * @generated | ||
25 | */ | ||
26 | public class Modes3PackageImpl extends EPackageImpl implements Modes3Package { | ||
27 | /** | ||
28 | * <!-- begin-user-doc --> | ||
29 | * <!-- end-user-doc --> | ||
30 | * @generated | ||
31 | */ | ||
32 | private EClass segmentEClass = null; | ||
33 | |||
34 | /** | ||
35 | * <!-- begin-user-doc --> | ||
36 | * <!-- end-user-doc --> | ||
37 | * @generated | ||
38 | */ | ||
39 | private EClass modes3ModelRootEClass = null; | ||
40 | |||
41 | /** | ||
42 | * <!-- begin-user-doc --> | ||
43 | * <!-- end-user-doc --> | ||
44 | * @generated | ||
45 | */ | ||
46 | private EClass turnoutEClass = null; | ||
47 | |||
48 | /** | ||
49 | * <!-- begin-user-doc --> | ||
50 | * <!-- end-user-doc --> | ||
51 | * @generated | ||
52 | */ | ||
53 | private EClass trainEClass = null; | ||
54 | |||
55 | /** | ||
56 | * <!-- begin-user-doc --> | ||
57 | * <!-- end-user-doc --> | ||
58 | * @generated | ||
59 | */ | ||
60 | private EClass simpleSegmentEClass = null; | ||
61 | |||
62 | /** | ||
63 | * Creates an instance of the model <b>Package</b>, registered with | ||
64 | * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package | ||
65 | * package URI value. | ||
66 | * <p>Note: the correct way to create the package is via the static | ||
67 | * factory method {@link #init init()}, which also performs | ||
68 | * initialization of the package, or returns the registered package, | ||
69 | * if one already exists. | ||
70 | * <!-- begin-user-doc --> | ||
71 | * <!-- end-user-doc --> | ||
72 | * @see org.eclipse.emf.ecore.EPackage.Registry | ||
73 | * @see modes3.Modes3Package#eNS_URI | ||
74 | * @see #init() | ||
75 | * @generated | ||
76 | */ | ||
77 | private Modes3PackageImpl() { | ||
78 | super(eNS_URI, Modes3Factory.eINSTANCE); | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * <!-- begin-user-doc --> | ||
83 | * <!-- end-user-doc --> | ||
84 | * @generated | ||
85 | */ | ||
86 | private static boolean isInited = false; | ||
87 | |||
88 | /** | ||
89 | * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. | ||
90 | * | ||
91 | * <p>This method is used to initialize {@link Modes3Package#eINSTANCE} when that field is accessed. | ||
92 | * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. | ||
93 | * <!-- begin-user-doc --> | ||
94 | * <!-- end-user-doc --> | ||
95 | * @see #eNS_URI | ||
96 | * @see #createPackageContents() | ||
97 | * @see #initializePackageContents() | ||
98 | * @generated | ||
99 | */ | ||
100 | public static Modes3Package init() { | ||
101 | if (isInited) return (Modes3Package)EPackage.Registry.INSTANCE.getEPackage(Modes3Package.eNS_URI); | ||
102 | |||
103 | // Obtain or create and register package | ||
104 | Object registeredModes3Package = EPackage.Registry.INSTANCE.get(eNS_URI); | ||
105 | Modes3PackageImpl theModes3Package = registeredModes3Package instanceof Modes3PackageImpl ? (Modes3PackageImpl)registeredModes3Package : new Modes3PackageImpl(); | ||
106 | |||
107 | isInited = true; | ||
108 | |||
109 | // Create package meta-data objects | ||
110 | theModes3Package.createPackageContents(); | ||
111 | |||
112 | // Initialize created meta-data | ||
113 | theModes3Package.initializePackageContents(); | ||
114 | |||
115 | // Mark meta-data to indicate it can't be changed | ||
116 | theModes3Package.freeze(); | ||
117 | |||
118 | // Update the registry and return the package | ||
119 | EPackage.Registry.INSTANCE.put(Modes3Package.eNS_URI, theModes3Package); | ||
120 | return theModes3Package; | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * <!-- begin-user-doc --> | ||
125 | * <!-- end-user-doc --> | ||
126 | * @generated | ||
127 | */ | ||
128 | public EClass getSegment() { | ||
129 | return segmentEClass; | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * <!-- begin-user-doc --> | ||
134 | * <!-- end-user-doc --> | ||
135 | * @generated | ||
136 | */ | ||
137 | public EReference getSegment_ConnectedTo() { | ||
138 | return (EReference)segmentEClass.getEStructuralFeatures().get(0); | ||
139 | } | ||
140 | |||
141 | /** | ||
142 | * <!-- begin-user-doc --> | ||
143 | * <!-- end-user-doc --> | ||
144 | * @generated | ||
145 | */ | ||
146 | public EReference getSegment_OccupiedBy() { | ||
147 | return (EReference)segmentEClass.getEStructuralFeatures().get(1); | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * <!-- begin-user-doc --> | ||
152 | * <!-- end-user-doc --> | ||
153 | * @generated | ||
154 | */ | ||
155 | public EAttribute getSegment_Id() { | ||
156 | return (EAttribute)segmentEClass.getEStructuralFeatures().get(2); | ||
157 | } | ||
158 | |||
159 | /** | ||
160 | * <!-- begin-user-doc --> | ||
161 | * <!-- end-user-doc --> | ||
162 | * @generated | ||
163 | */ | ||
164 | public EClass getModes3ModelRoot() { | ||
165 | return modes3ModelRootEClass; | ||
166 | } | ||
167 | |||
168 | /** | ||
169 | * <!-- begin-user-doc --> | ||
170 | * <!-- end-user-doc --> | ||
171 | * @generated | ||
172 | */ | ||
173 | public EAttribute getModes3ModelRoot_Id() { | ||
174 | return (EAttribute)modes3ModelRootEClass.getEStructuralFeatures().get(0); | ||
175 | } | ||
176 | |||
177 | /** | ||
178 | * <!-- begin-user-doc --> | ||
179 | * <!-- end-user-doc --> | ||
180 | * @generated | ||
181 | */ | ||
182 | public EReference getModes3ModelRoot_Trains() { | ||
183 | return (EReference)modes3ModelRootEClass.getEStructuralFeatures().get(1); | ||
184 | } | ||
185 | |||
186 | /** | ||
187 | * <!-- begin-user-doc --> | ||
188 | * <!-- end-user-doc --> | ||
189 | * @generated | ||
190 | */ | ||
191 | public EReference getModes3ModelRoot_Segments() { | ||
192 | return (EReference)modes3ModelRootEClass.getEStructuralFeatures().get(2); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * <!-- begin-user-doc --> | ||
197 | * <!-- end-user-doc --> | ||
198 | * @generated | ||
199 | */ | ||
200 | public EReference getModes3ModelRoot_Turnouts() { | ||
201 | return (EReference)modes3ModelRootEClass.getEStructuralFeatures().get(3); | ||
202 | } | ||
203 | |||
204 | /** | ||
205 | * <!-- begin-user-doc --> | ||
206 | * <!-- end-user-doc --> | ||
207 | * @generated | ||
208 | */ | ||
209 | public EClass getTurnout() { | ||
210 | return turnoutEClass; | ||
211 | } | ||
212 | |||
213 | /** | ||
214 | * <!-- begin-user-doc --> | ||
215 | * <!-- end-user-doc --> | ||
216 | * @generated | ||
217 | */ | ||
218 | public EReference getTurnout_Straight() { | ||
219 | return (EReference)turnoutEClass.getEStructuralFeatures().get(0); | ||
220 | } | ||
221 | |||
222 | /** | ||
223 | * <!-- begin-user-doc --> | ||
224 | * <!-- end-user-doc --> | ||
225 | * @generated | ||
226 | */ | ||
227 | public EReference getTurnout_Divergent() { | ||
228 | return (EReference)turnoutEClass.getEStructuralFeatures().get(1); | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * <!-- begin-user-doc --> | ||
233 | * <!-- end-user-doc --> | ||
234 | * @generated | ||
235 | */ | ||
236 | public EClass getTrain() { | ||
237 | return trainEClass; | ||
238 | } | ||
239 | |||
240 | /** | ||
241 | * <!-- begin-user-doc --> | ||
242 | * <!-- end-user-doc --> | ||
243 | * @generated | ||
244 | */ | ||
245 | public EReference getTrain_Location() { | ||
246 | return (EReference)trainEClass.getEStructuralFeatures().get(0); | ||
247 | } | ||
248 | |||
249 | /** | ||
250 | * <!-- begin-user-doc --> | ||
251 | * <!-- end-user-doc --> | ||
252 | * @generated | ||
253 | */ | ||
254 | public EAttribute getTrain_Id() { | ||
255 | return (EAttribute)trainEClass.getEStructuralFeatures().get(1); | ||
256 | } | ||
257 | |||
258 | /** | ||
259 | * <!-- begin-user-doc --> | ||
260 | * <!-- end-user-doc --> | ||
261 | * @generated | ||
262 | */ | ||
263 | public EAttribute getTrain_Speed() { | ||
264 | return (EAttribute)trainEClass.getEStructuralFeatures().get(2); | ||
265 | } | ||
266 | |||
267 | /** | ||
268 | * <!-- begin-user-doc --> | ||
269 | * <!-- end-user-doc --> | ||
270 | * @generated | ||
271 | */ | ||
272 | public EClass getSimpleSegment() { | ||
273 | return simpleSegmentEClass; | ||
274 | } | ||
275 | |||
276 | /** | ||
277 | * <!-- begin-user-doc --> | ||
278 | * <!-- end-user-doc --> | ||
279 | * @generated | ||
280 | */ | ||
281 | public Modes3Factory getModes3Factory() { | ||
282 | return (Modes3Factory)getEFactoryInstance(); | ||
283 | } | ||
284 | |||
285 | /** | ||
286 | * <!-- begin-user-doc --> | ||
287 | * <!-- end-user-doc --> | ||
288 | * @generated | ||
289 | */ | ||
290 | private boolean isCreated = false; | ||
291 | |||
292 | /** | ||
293 | * Creates the meta-model objects for the package. This method is | ||
294 | * guarded to have no affect on any invocation but its first. | ||
295 | * <!-- begin-user-doc --> | ||
296 | * <!-- end-user-doc --> | ||
297 | * @generated | ||
298 | */ | ||
299 | public void createPackageContents() { | ||
300 | if (isCreated) return; | ||
301 | isCreated = true; | ||
302 | |||
303 | // Create classes and their features | ||
304 | segmentEClass = createEClass(SEGMENT); | ||
305 | createEReference(segmentEClass, SEGMENT__CONNECTED_TO); | ||
306 | createEReference(segmentEClass, SEGMENT__OCCUPIED_BY); | ||
307 | createEAttribute(segmentEClass, SEGMENT__ID); | ||
308 | |||
309 | modes3ModelRootEClass = createEClass(MODES3_MODEL_ROOT); | ||
310 | createEAttribute(modes3ModelRootEClass, MODES3_MODEL_ROOT__ID); | ||
311 | createEReference(modes3ModelRootEClass, MODES3_MODEL_ROOT__TRAINS); | ||
312 | createEReference(modes3ModelRootEClass, MODES3_MODEL_ROOT__SEGMENTS); | ||
313 | createEReference(modes3ModelRootEClass, MODES3_MODEL_ROOT__TURNOUTS); | ||
314 | |||
315 | turnoutEClass = createEClass(TURNOUT); | ||
316 | createEReference(turnoutEClass, TURNOUT__STRAIGHT); | ||
317 | createEReference(turnoutEClass, TURNOUT__DIVERGENT); | ||
318 | |||
319 | trainEClass = createEClass(TRAIN); | ||
320 | createEReference(trainEClass, TRAIN__LOCATION); | ||
321 | createEAttribute(trainEClass, TRAIN__ID); | ||
322 | createEAttribute(trainEClass, TRAIN__SPEED); | ||
323 | |||
324 | simpleSegmentEClass = createEClass(SIMPLE_SEGMENT); | ||
325 | } | ||
326 | |||
327 | /** | ||
328 | * <!-- begin-user-doc --> | ||
329 | * <!-- end-user-doc --> | ||
330 | * @generated | ||
331 | */ | ||
332 | private boolean isInitialized = false; | ||
333 | |||
334 | /** | ||
335 | * Complete the initialization of the package and its meta-model. This | ||
336 | * method is guarded to have no affect on any invocation but its first. | ||
337 | * <!-- begin-user-doc --> | ||
338 | * <!-- end-user-doc --> | ||
339 | * @generated | ||
340 | */ | ||
341 | public void initializePackageContents() { | ||
342 | if (isInitialized) return; | ||
343 | isInitialized = true; | ||
344 | |||
345 | // Initialize package | ||
346 | setName(eNAME); | ||
347 | setNsPrefix(eNS_PREFIX); | ||
348 | setNsURI(eNS_URI); | ||
349 | |||
350 | // Create type parameters | ||
351 | |||
352 | // Set bounds for type parameters | ||
353 | |||
354 | // Add supertypes to classes | ||
355 | turnoutEClass.getESuperTypes().add(this.getSegment()); | ||
356 | simpleSegmentEClass.getESuperTypes().add(this.getSegment()); | ||
357 | |||
358 | // Initialize classes, features, and operations; add parameters | ||
359 | initEClass(segmentEClass, Segment.class, "Segment", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | ||
360 | initEReference(getSegment_ConnectedTo(), this.getSegment(), null, "connectedTo", null, 0, 2, Segment.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
361 | initEReference(getSegment_OccupiedBy(), this.getTrain(), this.getTrain_Location(), "occupiedBy", null, 0, 1, Segment.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
362 | initEAttribute(getSegment_Id(), ecorePackage.getEInt(), "id", null, 0, 1, Segment.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
363 | |||
364 | initEClass(modes3ModelRootEClass, Modes3ModelRoot.class, "Modes3ModelRoot", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | ||
365 | initEAttribute(getModes3ModelRoot_Id(), ecorePackage.getEInt(), "id", null, 0, 1, Modes3ModelRoot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
366 | initEReference(getModes3ModelRoot_Trains(), this.getTrain(), null, "trains", null, 0, -1, Modes3ModelRoot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
367 | initEReference(getModes3ModelRoot_Segments(), this.getSimpleSegment(), null, "segments", null, 0, -1, Modes3ModelRoot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
368 | initEReference(getModes3ModelRoot_Turnouts(), this.getTurnout(), null, "turnouts", null, 0, -1, Modes3ModelRoot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
369 | |||
370 | initEClass(turnoutEClass, Turnout.class, "Turnout", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | ||
371 | initEReference(getTurnout_Straight(), this.getSegment(), null, "straight", null, 1, 1, Turnout.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
372 | initEReference(getTurnout_Divergent(), this.getSegment(), null, "divergent", null, 1, 1, Turnout.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
373 | |||
374 | initEClass(trainEClass, Train.class, "Train", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | ||
375 | initEReference(getTrain_Location(), this.getSegment(), this.getSegment_OccupiedBy(), "location", null, 1, 1, Train.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
376 | initEAttribute(getTrain_Id(), ecorePackage.getEInt(), "id", null, 0, 1, Train.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
377 | initEAttribute(getTrain_Speed(), ecorePackage.getEDouble(), "speed", null, 0, 1, Train.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); | ||
378 | |||
379 | initEClass(simpleSegmentEClass, SimpleSegment.class, "SimpleSegment", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); | ||
380 | |||
381 | // Create resource | ||
382 | createResource(eNS_URI); | ||
383 | } | ||
384 | |||
385 | } //Modes3PackageImpl | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/SegmentImpl.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/SegmentImpl.java new file mode 100644 index 00000000..905bcec1 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/SegmentImpl.java | |||
@@ -0,0 +1,319 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.impl; | ||
4 | |||
5 | import java.util.Collection; | ||
6 | |||
7 | import modes3.Modes3Package; | ||
8 | import modes3.Segment; | ||
9 | import modes3.Train; | ||
10 | |||
11 | import org.eclipse.emf.common.notify.Notification; | ||
12 | import org.eclipse.emf.common.notify.NotificationChain; | ||
13 | |||
14 | import org.eclipse.emf.common.util.EList; | ||
15 | |||
16 | import org.eclipse.emf.ecore.EClass; | ||
17 | import org.eclipse.emf.ecore.InternalEObject; | ||
18 | |||
19 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
20 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; | ||
21 | |||
22 | import org.eclipse.emf.ecore.util.EObjectResolvingEList; | ||
23 | |||
24 | /** | ||
25 | * <!-- begin-user-doc --> | ||
26 | * An implementation of the model object '<em><b>Segment</b></em>'. | ||
27 | * <!-- end-user-doc --> | ||
28 | * <p> | ||
29 | * The following features are implemented: | ||
30 | * </p> | ||
31 | * <ul> | ||
32 | * <li>{@link modes3.impl.SegmentImpl#getConnectedTo <em>Connected To</em>}</li> | ||
33 | * <li>{@link modes3.impl.SegmentImpl#getOccupiedBy <em>Occupied By</em>}</li> | ||
34 | * <li>{@link modes3.impl.SegmentImpl#getId <em>Id</em>}</li> | ||
35 | * </ul> | ||
36 | * | ||
37 | * @generated | ||
38 | */ | ||
39 | public class SegmentImpl extends MinimalEObjectImpl.Container implements Segment { | ||
40 | /** | ||
41 | * The cached value of the '{@link #getConnectedTo() <em>Connected To</em>}' reference list. | ||
42 | * <!-- begin-user-doc --> | ||
43 | * <!-- end-user-doc --> | ||
44 | * @see #getConnectedTo() | ||
45 | * @generated | ||
46 | * @ordered | ||
47 | */ | ||
48 | protected EList<Segment> connectedTo; | ||
49 | |||
50 | /** | ||
51 | * The cached value of the '{@link #getOccupiedBy() <em>Occupied By</em>}' reference. | ||
52 | * <!-- begin-user-doc --> | ||
53 | * <!-- end-user-doc --> | ||
54 | * @see #getOccupiedBy() | ||
55 | * @generated | ||
56 | * @ordered | ||
57 | */ | ||
58 | protected Train occupiedBy; | ||
59 | |||
60 | /** | ||
61 | * The default value of the '{@link #getId() <em>Id</em>}' attribute. | ||
62 | * <!-- begin-user-doc --> | ||
63 | * <!-- end-user-doc --> | ||
64 | * @see #getId() | ||
65 | * @generated | ||
66 | * @ordered | ||
67 | */ | ||
68 | protected static final int ID_EDEFAULT = 0; | ||
69 | |||
70 | /** | ||
71 | * The cached value of the '{@link #getId() <em>Id</em>}' attribute. | ||
72 | * <!-- begin-user-doc --> | ||
73 | * <!-- end-user-doc --> | ||
74 | * @see #getId() | ||
75 | * @generated | ||
76 | * @ordered | ||
77 | */ | ||
78 | protected int id = ID_EDEFAULT; | ||
79 | |||
80 | /** | ||
81 | * <!-- begin-user-doc --> | ||
82 | * <!-- end-user-doc --> | ||
83 | * @generated | ||
84 | */ | ||
85 | protected SegmentImpl() { | ||
86 | super(); | ||
87 | } | ||
88 | |||
89 | /** | ||
90 | * <!-- begin-user-doc --> | ||
91 | * <!-- end-user-doc --> | ||
92 | * @generated | ||
93 | */ | ||
94 | @Override | ||
95 | protected EClass eStaticClass() { | ||
96 | return Modes3Package.Literals.SEGMENT; | ||
97 | } | ||
98 | |||
99 | /** | ||
100 | * <!-- begin-user-doc --> | ||
101 | * <!-- end-user-doc --> | ||
102 | * @generated | ||
103 | */ | ||
104 | public EList<Segment> getConnectedTo() { | ||
105 | if (connectedTo == null) { | ||
106 | connectedTo = new EObjectResolvingEList<Segment>(Segment.class, this, Modes3Package.SEGMENT__CONNECTED_TO); | ||
107 | } | ||
108 | return connectedTo; | ||
109 | } | ||
110 | |||
111 | /** | ||
112 | * <!-- begin-user-doc --> | ||
113 | * <!-- end-user-doc --> | ||
114 | * @generated | ||
115 | */ | ||
116 | public Train getOccupiedBy() { | ||
117 | if (occupiedBy != null && occupiedBy.eIsProxy()) { | ||
118 | InternalEObject oldOccupiedBy = (InternalEObject)occupiedBy; | ||
119 | occupiedBy = (Train)eResolveProxy(oldOccupiedBy); | ||
120 | if (occupiedBy != oldOccupiedBy) { | ||
121 | if (eNotificationRequired()) | ||
122 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, Modes3Package.SEGMENT__OCCUPIED_BY, oldOccupiedBy, occupiedBy)); | ||
123 | } | ||
124 | } | ||
125 | return occupiedBy; | ||
126 | } | ||
127 | |||
128 | /** | ||
129 | * <!-- begin-user-doc --> | ||
130 | * <!-- end-user-doc --> | ||
131 | * @generated | ||
132 | */ | ||
133 | public Train basicGetOccupiedBy() { | ||
134 | return occupiedBy; | ||
135 | } | ||
136 | |||
137 | /** | ||
138 | * <!-- begin-user-doc --> | ||
139 | * <!-- end-user-doc --> | ||
140 | * @generated | ||
141 | */ | ||
142 | public NotificationChain basicSetOccupiedBy(Train newOccupiedBy, NotificationChain msgs) { | ||
143 | Train oldOccupiedBy = occupiedBy; | ||
144 | occupiedBy = newOccupiedBy; | ||
145 | if (eNotificationRequired()) { | ||
146 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Modes3Package.SEGMENT__OCCUPIED_BY, oldOccupiedBy, newOccupiedBy); | ||
147 | if (msgs == null) msgs = notification; else msgs.add(notification); | ||
148 | } | ||
149 | return msgs; | ||
150 | } | ||
151 | |||
152 | /** | ||
153 | * <!-- begin-user-doc --> | ||
154 | * <!-- end-user-doc --> | ||
155 | * @generated | ||
156 | */ | ||
157 | public void setOccupiedBy(Train newOccupiedBy) { | ||
158 | if (newOccupiedBy != occupiedBy) { | ||
159 | NotificationChain msgs = null; | ||
160 | if (occupiedBy != null) | ||
161 | msgs = ((InternalEObject)occupiedBy).eInverseRemove(this, Modes3Package.TRAIN__LOCATION, Train.class, msgs); | ||
162 | if (newOccupiedBy != null) | ||
163 | msgs = ((InternalEObject)newOccupiedBy).eInverseAdd(this, Modes3Package.TRAIN__LOCATION, Train.class, msgs); | ||
164 | msgs = basicSetOccupiedBy(newOccupiedBy, msgs); | ||
165 | if (msgs != null) msgs.dispatch(); | ||
166 | } | ||
167 | else if (eNotificationRequired()) | ||
168 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.SEGMENT__OCCUPIED_BY, newOccupiedBy, newOccupiedBy)); | ||
169 | } | ||
170 | |||
171 | /** | ||
172 | * <!-- begin-user-doc --> | ||
173 | * <!-- end-user-doc --> | ||
174 | * @generated | ||
175 | */ | ||
176 | public int getId() { | ||
177 | return id; | ||
178 | } | ||
179 | |||
180 | /** | ||
181 | * <!-- begin-user-doc --> | ||
182 | * <!-- end-user-doc --> | ||
183 | * @generated | ||
184 | */ | ||
185 | public void setId(int newId) { | ||
186 | int oldId = id; | ||
187 | id = newId; | ||
188 | if (eNotificationRequired()) | ||
189 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.SEGMENT__ID, oldId, id)); | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * <!-- begin-user-doc --> | ||
194 | * <!-- end-user-doc --> | ||
195 | * @generated | ||
196 | */ | ||
197 | @Override | ||
198 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
199 | switch (featureID) { | ||
200 | case Modes3Package.SEGMENT__OCCUPIED_BY: | ||
201 | if (occupiedBy != null) | ||
202 | msgs = ((InternalEObject)occupiedBy).eInverseRemove(this, Modes3Package.TRAIN__LOCATION, Train.class, msgs); | ||
203 | return basicSetOccupiedBy((Train)otherEnd, msgs); | ||
204 | } | ||
205 | return super.eInverseAdd(otherEnd, featureID, msgs); | ||
206 | } | ||
207 | |||
208 | /** | ||
209 | * <!-- begin-user-doc --> | ||
210 | * <!-- end-user-doc --> | ||
211 | * @generated | ||
212 | */ | ||
213 | @Override | ||
214 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
215 | switch (featureID) { | ||
216 | case Modes3Package.SEGMENT__OCCUPIED_BY: | ||
217 | return basicSetOccupiedBy(null, msgs); | ||
218 | } | ||
219 | return super.eInverseRemove(otherEnd, featureID, msgs); | ||
220 | } | ||
221 | |||
222 | /** | ||
223 | * <!-- begin-user-doc --> | ||
224 | * <!-- end-user-doc --> | ||
225 | * @generated | ||
226 | */ | ||
227 | @Override | ||
228 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
229 | switch (featureID) { | ||
230 | case Modes3Package.SEGMENT__CONNECTED_TO: | ||
231 | return getConnectedTo(); | ||
232 | case Modes3Package.SEGMENT__OCCUPIED_BY: | ||
233 | if (resolve) return getOccupiedBy(); | ||
234 | return basicGetOccupiedBy(); | ||
235 | case Modes3Package.SEGMENT__ID: | ||
236 | return getId(); | ||
237 | } | ||
238 | return super.eGet(featureID, resolve, coreType); | ||
239 | } | ||
240 | |||
241 | /** | ||
242 | * <!-- begin-user-doc --> | ||
243 | * <!-- end-user-doc --> | ||
244 | * @generated | ||
245 | */ | ||
246 | @SuppressWarnings("unchecked") | ||
247 | @Override | ||
248 | public void eSet(int featureID, Object newValue) { | ||
249 | switch (featureID) { | ||
250 | case Modes3Package.SEGMENT__CONNECTED_TO: | ||
251 | getConnectedTo().clear(); | ||
252 | getConnectedTo().addAll((Collection<? extends Segment>)newValue); | ||
253 | return; | ||
254 | case Modes3Package.SEGMENT__OCCUPIED_BY: | ||
255 | setOccupiedBy((Train)newValue); | ||
256 | return; | ||
257 | case Modes3Package.SEGMENT__ID: | ||
258 | setId((Integer)newValue); | ||
259 | return; | ||
260 | } | ||
261 | super.eSet(featureID, newValue); | ||
262 | } | ||
263 | |||
264 | /** | ||
265 | * <!-- begin-user-doc --> | ||
266 | * <!-- end-user-doc --> | ||
267 | * @generated | ||
268 | */ | ||
269 | @Override | ||
270 | public void eUnset(int featureID) { | ||
271 | switch (featureID) { | ||
272 | case Modes3Package.SEGMENT__CONNECTED_TO: | ||
273 | getConnectedTo().clear(); | ||
274 | return; | ||
275 | case Modes3Package.SEGMENT__OCCUPIED_BY: | ||
276 | setOccupiedBy((Train)null); | ||
277 | return; | ||
278 | case Modes3Package.SEGMENT__ID: | ||
279 | setId(ID_EDEFAULT); | ||
280 | return; | ||
281 | } | ||
282 | super.eUnset(featureID); | ||
283 | } | ||
284 | |||
285 | /** | ||
286 | * <!-- begin-user-doc --> | ||
287 | * <!-- end-user-doc --> | ||
288 | * @generated | ||
289 | */ | ||
290 | @Override | ||
291 | public boolean eIsSet(int featureID) { | ||
292 | switch (featureID) { | ||
293 | case Modes3Package.SEGMENT__CONNECTED_TO: | ||
294 | return connectedTo != null && !connectedTo.isEmpty(); | ||
295 | case Modes3Package.SEGMENT__OCCUPIED_BY: | ||
296 | return occupiedBy != null; | ||
297 | case Modes3Package.SEGMENT__ID: | ||
298 | return id != ID_EDEFAULT; | ||
299 | } | ||
300 | return super.eIsSet(featureID); | ||
301 | } | ||
302 | |||
303 | /** | ||
304 | * <!-- begin-user-doc --> | ||
305 | * <!-- end-user-doc --> | ||
306 | * @generated | ||
307 | */ | ||
308 | @Override | ||
309 | public String toString() { | ||
310 | if (eIsProxy()) return super.toString(); | ||
311 | |||
312 | StringBuilder result = new StringBuilder(super.toString()); | ||
313 | result.append(" (id: "); | ||
314 | result.append(id); | ||
315 | result.append(')'); | ||
316 | return result.toString(); | ||
317 | } | ||
318 | |||
319 | } //SegmentImpl | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/SimpleSegmentImpl.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/SimpleSegmentImpl.java new file mode 100644 index 00000000..e3fd6c34 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/SimpleSegmentImpl.java | |||
@@ -0,0 +1,37 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.impl; | ||
4 | |||
5 | import modes3.Modes3Package; | ||
6 | import modes3.SimpleSegment; | ||
7 | |||
8 | import org.eclipse.emf.ecore.EClass; | ||
9 | |||
10 | /** | ||
11 | * <!-- begin-user-doc --> | ||
12 | * An implementation of the model object '<em><b>Simple Segment</b></em>'. | ||
13 | * <!-- end-user-doc --> | ||
14 | * | ||
15 | * @generated | ||
16 | */ | ||
17 | public class SimpleSegmentImpl extends SegmentImpl implements SimpleSegment { | ||
18 | /** | ||
19 | * <!-- begin-user-doc --> | ||
20 | * <!-- end-user-doc --> | ||
21 | * @generated | ||
22 | */ | ||
23 | protected SimpleSegmentImpl() { | ||
24 | super(); | ||
25 | } | ||
26 | |||
27 | /** | ||
28 | * <!-- begin-user-doc --> | ||
29 | * <!-- end-user-doc --> | ||
30 | * @generated | ||
31 | */ | ||
32 | @Override | ||
33 | protected EClass eStaticClass() { | ||
34 | return Modes3Package.Literals.SIMPLE_SEGMENT; | ||
35 | } | ||
36 | |||
37 | } //SimpleSegmentImpl | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/TrainImpl.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/TrainImpl.java new file mode 100644 index 00000000..f096dca8 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/TrainImpl.java | |||
@@ -0,0 +1,332 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.impl; | ||
4 | |||
5 | import modes3.Modes3Package; | ||
6 | import modes3.Segment; | ||
7 | import modes3.Train; | ||
8 | |||
9 | import org.eclipse.emf.common.notify.Notification; | ||
10 | import org.eclipse.emf.common.notify.NotificationChain; | ||
11 | |||
12 | import org.eclipse.emf.ecore.EClass; | ||
13 | import org.eclipse.emf.ecore.InternalEObject; | ||
14 | |||
15 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
16 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; | ||
17 | |||
18 | /** | ||
19 | * <!-- begin-user-doc --> | ||
20 | * An implementation of the model object '<em><b>Train</b></em>'. | ||
21 | * <!-- end-user-doc --> | ||
22 | * <p> | ||
23 | * The following features are implemented: | ||
24 | * </p> | ||
25 | * <ul> | ||
26 | * <li>{@link modes3.impl.TrainImpl#getLocation <em>Location</em>}</li> | ||
27 | * <li>{@link modes3.impl.TrainImpl#getId <em>Id</em>}</li> | ||
28 | * <li>{@link modes3.impl.TrainImpl#getSpeed <em>Speed</em>}</li> | ||
29 | * </ul> | ||
30 | * | ||
31 | * @generated | ||
32 | */ | ||
33 | public class TrainImpl extends MinimalEObjectImpl.Container implements Train { | ||
34 | /** | ||
35 | * The cached value of the '{@link #getLocation() <em>Location</em>}' reference. | ||
36 | * <!-- begin-user-doc --> | ||
37 | * <!-- end-user-doc --> | ||
38 | * @see #getLocation() | ||
39 | * @generated | ||
40 | * @ordered | ||
41 | */ | ||
42 | protected Segment location; | ||
43 | |||
44 | /** | ||
45 | * The default value of the '{@link #getId() <em>Id</em>}' attribute. | ||
46 | * <!-- begin-user-doc --> | ||
47 | * <!-- end-user-doc --> | ||
48 | * @see #getId() | ||
49 | * @generated | ||
50 | * @ordered | ||
51 | */ | ||
52 | protected static final int ID_EDEFAULT = 0; | ||
53 | |||
54 | /** | ||
55 | * The cached value of the '{@link #getId() <em>Id</em>}' attribute. | ||
56 | * <!-- begin-user-doc --> | ||
57 | * <!-- end-user-doc --> | ||
58 | * @see #getId() | ||
59 | * @generated | ||
60 | * @ordered | ||
61 | */ | ||
62 | protected int id = ID_EDEFAULT; | ||
63 | |||
64 | /** | ||
65 | * The default value of the '{@link #getSpeed() <em>Speed</em>}' attribute. | ||
66 | * <!-- begin-user-doc --> | ||
67 | * <!-- end-user-doc --> | ||
68 | * @see #getSpeed() | ||
69 | * @generated | ||
70 | * @ordered | ||
71 | */ | ||
72 | protected static final double SPEED_EDEFAULT = 0.0; | ||
73 | |||
74 | /** | ||
75 | * The cached value of the '{@link #getSpeed() <em>Speed</em>}' attribute. | ||
76 | * <!-- begin-user-doc --> | ||
77 | * <!-- end-user-doc --> | ||
78 | * @see #getSpeed() | ||
79 | * @generated | ||
80 | * @ordered | ||
81 | */ | ||
82 | protected double speed = SPEED_EDEFAULT; | ||
83 | |||
84 | /** | ||
85 | * <!-- begin-user-doc --> | ||
86 | * <!-- end-user-doc --> | ||
87 | * @generated | ||
88 | */ | ||
89 | protected TrainImpl() { | ||
90 | super(); | ||
91 | } | ||
92 | |||
93 | /** | ||
94 | * <!-- begin-user-doc --> | ||
95 | * <!-- end-user-doc --> | ||
96 | * @generated | ||
97 | */ | ||
98 | @Override | ||
99 | protected EClass eStaticClass() { | ||
100 | return Modes3Package.Literals.TRAIN; | ||
101 | } | ||
102 | |||
103 | /** | ||
104 | * <!-- begin-user-doc --> | ||
105 | * <!-- end-user-doc --> | ||
106 | * @generated | ||
107 | */ | ||
108 | public Segment getLocation() { | ||
109 | if (location != null && location.eIsProxy()) { | ||
110 | InternalEObject oldLocation = (InternalEObject)location; | ||
111 | location = (Segment)eResolveProxy(oldLocation); | ||
112 | if (location != oldLocation) { | ||
113 | if (eNotificationRequired()) | ||
114 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, Modes3Package.TRAIN__LOCATION, oldLocation, location)); | ||
115 | } | ||
116 | } | ||
117 | return location; | ||
118 | } | ||
119 | |||
120 | /** | ||
121 | * <!-- begin-user-doc --> | ||
122 | * <!-- end-user-doc --> | ||
123 | * @generated | ||
124 | */ | ||
125 | public Segment basicGetLocation() { | ||
126 | return location; | ||
127 | } | ||
128 | |||
129 | /** | ||
130 | * <!-- begin-user-doc --> | ||
131 | * <!-- end-user-doc --> | ||
132 | * @generated | ||
133 | */ | ||
134 | public NotificationChain basicSetLocation(Segment newLocation, NotificationChain msgs) { | ||
135 | Segment oldLocation = location; | ||
136 | location = newLocation; | ||
137 | if (eNotificationRequired()) { | ||
138 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__LOCATION, oldLocation, newLocation); | ||
139 | if (msgs == null) msgs = notification; else msgs.add(notification); | ||
140 | } | ||
141 | return msgs; | ||
142 | } | ||
143 | |||
144 | /** | ||
145 | * <!-- begin-user-doc --> | ||
146 | * <!-- end-user-doc --> | ||
147 | * @generated | ||
148 | */ | ||
149 | public void setLocation(Segment newLocation) { | ||
150 | if (newLocation != location) { | ||
151 | NotificationChain msgs = null; | ||
152 | if (location != null) | ||
153 | msgs = ((InternalEObject)location).eInverseRemove(this, Modes3Package.SEGMENT__OCCUPIED_BY, Segment.class, msgs); | ||
154 | if (newLocation != null) | ||
155 | msgs = ((InternalEObject)newLocation).eInverseAdd(this, Modes3Package.SEGMENT__OCCUPIED_BY, Segment.class, msgs); | ||
156 | msgs = basicSetLocation(newLocation, msgs); | ||
157 | if (msgs != null) msgs.dispatch(); | ||
158 | } | ||
159 | else if (eNotificationRequired()) | ||
160 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__LOCATION, newLocation, newLocation)); | ||
161 | } | ||
162 | |||
163 | /** | ||
164 | * <!-- begin-user-doc --> | ||
165 | * <!-- end-user-doc --> | ||
166 | * @generated | ||
167 | */ | ||
168 | public int getId() { | ||
169 | return id; | ||
170 | } | ||
171 | |||
172 | /** | ||
173 | * <!-- begin-user-doc --> | ||
174 | * <!-- end-user-doc --> | ||
175 | * @generated | ||
176 | */ | ||
177 | public void setId(int newId) { | ||
178 | int oldId = id; | ||
179 | id = newId; | ||
180 | if (eNotificationRequired()) | ||
181 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__ID, oldId, id)); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * <!-- begin-user-doc --> | ||
186 | * <!-- end-user-doc --> | ||
187 | * @generated | ||
188 | */ | ||
189 | public double getSpeed() { | ||
190 | return speed; | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * <!-- begin-user-doc --> | ||
195 | * <!-- end-user-doc --> | ||
196 | * @generated | ||
197 | */ | ||
198 | public void setSpeed(double newSpeed) { | ||
199 | double oldSpeed = speed; | ||
200 | speed = newSpeed; | ||
201 | if (eNotificationRequired()) | ||
202 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TRAIN__SPEED, oldSpeed, speed)); | ||
203 | } | ||
204 | |||
205 | /** | ||
206 | * <!-- begin-user-doc --> | ||
207 | * <!-- end-user-doc --> | ||
208 | * @generated | ||
209 | */ | ||
210 | @Override | ||
211 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
212 | switch (featureID) { | ||
213 | case Modes3Package.TRAIN__LOCATION: | ||
214 | if (location != null) | ||
215 | msgs = ((InternalEObject)location).eInverseRemove(this, Modes3Package.SEGMENT__OCCUPIED_BY, Segment.class, msgs); | ||
216 | return basicSetLocation((Segment)otherEnd, msgs); | ||
217 | } | ||
218 | return super.eInverseAdd(otherEnd, featureID, msgs); | ||
219 | } | ||
220 | |||
221 | /** | ||
222 | * <!-- begin-user-doc --> | ||
223 | * <!-- end-user-doc --> | ||
224 | * @generated | ||
225 | */ | ||
226 | @Override | ||
227 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | ||
228 | switch (featureID) { | ||
229 | case Modes3Package.TRAIN__LOCATION: | ||
230 | return basicSetLocation(null, msgs); | ||
231 | } | ||
232 | return super.eInverseRemove(otherEnd, featureID, msgs); | ||
233 | } | ||
234 | |||
235 | /** | ||
236 | * <!-- begin-user-doc --> | ||
237 | * <!-- end-user-doc --> | ||
238 | * @generated | ||
239 | */ | ||
240 | @Override | ||
241 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
242 | switch (featureID) { | ||
243 | case Modes3Package.TRAIN__LOCATION: | ||
244 | if (resolve) return getLocation(); | ||
245 | return basicGetLocation(); | ||
246 | case Modes3Package.TRAIN__ID: | ||
247 | return getId(); | ||
248 | case Modes3Package.TRAIN__SPEED: | ||
249 | return getSpeed(); | ||
250 | } | ||
251 | return super.eGet(featureID, resolve, coreType); | ||
252 | } | ||
253 | |||
254 | /** | ||
255 | * <!-- begin-user-doc --> | ||
256 | * <!-- end-user-doc --> | ||
257 | * @generated | ||
258 | */ | ||
259 | @Override | ||
260 | public void eSet(int featureID, Object newValue) { | ||
261 | switch (featureID) { | ||
262 | case Modes3Package.TRAIN__LOCATION: | ||
263 | setLocation((Segment)newValue); | ||
264 | return; | ||
265 | case Modes3Package.TRAIN__ID: | ||
266 | setId((Integer)newValue); | ||
267 | return; | ||
268 | case Modes3Package.TRAIN__SPEED: | ||
269 | setSpeed((Double)newValue); | ||
270 | return; | ||
271 | } | ||
272 | super.eSet(featureID, newValue); | ||
273 | } | ||
274 | |||
275 | /** | ||
276 | * <!-- begin-user-doc --> | ||
277 | * <!-- end-user-doc --> | ||
278 | * @generated | ||
279 | */ | ||
280 | @Override | ||
281 | public void eUnset(int featureID) { | ||
282 | switch (featureID) { | ||
283 | case Modes3Package.TRAIN__LOCATION: | ||
284 | setLocation((Segment)null); | ||
285 | return; | ||
286 | case Modes3Package.TRAIN__ID: | ||
287 | setId(ID_EDEFAULT); | ||
288 | return; | ||
289 | case Modes3Package.TRAIN__SPEED: | ||
290 | setSpeed(SPEED_EDEFAULT); | ||
291 | return; | ||
292 | } | ||
293 | super.eUnset(featureID); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * <!-- begin-user-doc --> | ||
298 | * <!-- end-user-doc --> | ||
299 | * @generated | ||
300 | */ | ||
301 | @Override | ||
302 | public boolean eIsSet(int featureID) { | ||
303 | switch (featureID) { | ||
304 | case Modes3Package.TRAIN__LOCATION: | ||
305 | return location != null; | ||
306 | case Modes3Package.TRAIN__ID: | ||
307 | return id != ID_EDEFAULT; | ||
308 | case Modes3Package.TRAIN__SPEED: | ||
309 | return speed != SPEED_EDEFAULT; | ||
310 | } | ||
311 | return super.eIsSet(featureID); | ||
312 | } | ||
313 | |||
314 | /** | ||
315 | * <!-- begin-user-doc --> | ||
316 | * <!-- end-user-doc --> | ||
317 | * @generated | ||
318 | */ | ||
319 | @Override | ||
320 | public String toString() { | ||
321 | if (eIsProxy()) return super.toString(); | ||
322 | |||
323 | StringBuilder result = new StringBuilder(super.toString()); | ||
324 | result.append(" (id: "); | ||
325 | result.append(id); | ||
326 | result.append(", speed: "); | ||
327 | result.append(speed); | ||
328 | result.append(')'); | ||
329 | return result.toString(); | ||
330 | } | ||
331 | |||
332 | } //TrainImpl | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/TurnoutImpl.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/TurnoutImpl.java new file mode 100644 index 00000000..d20a104e --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/impl/TurnoutImpl.java | |||
@@ -0,0 +1,216 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.impl; | ||
4 | |||
5 | import modes3.Modes3Package; | ||
6 | import modes3.Segment; | ||
7 | import modes3.Turnout; | ||
8 | |||
9 | import org.eclipse.emf.common.notify.Notification; | ||
10 | |||
11 | import org.eclipse.emf.ecore.EClass; | ||
12 | import org.eclipse.emf.ecore.InternalEObject; | ||
13 | |||
14 | import org.eclipse.emf.ecore.impl.ENotificationImpl; | ||
15 | |||
16 | /** | ||
17 | * <!-- begin-user-doc --> | ||
18 | * An implementation of the model object '<em><b>Turnout</b></em>'. | ||
19 | * <!-- end-user-doc --> | ||
20 | * <p> | ||
21 | * The following features are implemented: | ||
22 | * </p> | ||
23 | * <ul> | ||
24 | * <li>{@link modes3.impl.TurnoutImpl#getStraight <em>Straight</em>}</li> | ||
25 | * <li>{@link modes3.impl.TurnoutImpl#getDivergent <em>Divergent</em>}</li> | ||
26 | * </ul> | ||
27 | * | ||
28 | * @generated | ||
29 | */ | ||
30 | public class TurnoutImpl extends SegmentImpl implements Turnout { | ||
31 | /** | ||
32 | * The cached value of the '{@link #getStraight() <em>Straight</em>}' reference. | ||
33 | * <!-- begin-user-doc --> | ||
34 | * <!-- end-user-doc --> | ||
35 | * @see #getStraight() | ||
36 | * @generated | ||
37 | * @ordered | ||
38 | */ | ||
39 | protected Segment straight; | ||
40 | |||
41 | /** | ||
42 | * The cached value of the '{@link #getDivergent() <em>Divergent</em>}' reference. | ||
43 | * <!-- begin-user-doc --> | ||
44 | * <!-- end-user-doc --> | ||
45 | * @see #getDivergent() | ||
46 | * @generated | ||
47 | * @ordered | ||
48 | */ | ||
49 | protected Segment divergent; | ||
50 | |||
51 | /** | ||
52 | * <!-- begin-user-doc --> | ||
53 | * <!-- end-user-doc --> | ||
54 | * @generated | ||
55 | */ | ||
56 | protected TurnoutImpl() { | ||
57 | super(); | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * <!-- begin-user-doc --> | ||
62 | * <!-- end-user-doc --> | ||
63 | * @generated | ||
64 | */ | ||
65 | @Override | ||
66 | protected EClass eStaticClass() { | ||
67 | return Modes3Package.Literals.TURNOUT; | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * <!-- begin-user-doc --> | ||
72 | * <!-- end-user-doc --> | ||
73 | * @generated | ||
74 | */ | ||
75 | public Segment getStraight() { | ||
76 | if (straight != null && straight.eIsProxy()) { | ||
77 | InternalEObject oldStraight = (InternalEObject)straight; | ||
78 | straight = (Segment)eResolveProxy(oldStraight); | ||
79 | if (straight != oldStraight) { | ||
80 | if (eNotificationRequired()) | ||
81 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, Modes3Package.TURNOUT__STRAIGHT, oldStraight, straight)); | ||
82 | } | ||
83 | } | ||
84 | return straight; | ||
85 | } | ||
86 | |||
87 | /** | ||
88 | * <!-- begin-user-doc --> | ||
89 | * <!-- end-user-doc --> | ||
90 | * @generated | ||
91 | */ | ||
92 | public Segment basicGetStraight() { | ||
93 | return straight; | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * <!-- begin-user-doc --> | ||
98 | * <!-- end-user-doc --> | ||
99 | * @generated | ||
100 | */ | ||
101 | public void setStraight(Segment newStraight) { | ||
102 | Segment oldStraight = straight; | ||
103 | straight = newStraight; | ||
104 | if (eNotificationRequired()) | ||
105 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TURNOUT__STRAIGHT, oldStraight, straight)); | ||
106 | } | ||
107 | |||
108 | /** | ||
109 | * <!-- begin-user-doc --> | ||
110 | * <!-- end-user-doc --> | ||
111 | * @generated | ||
112 | */ | ||
113 | public Segment getDivergent() { | ||
114 | if (divergent != null && divergent.eIsProxy()) { | ||
115 | InternalEObject oldDivergent = (InternalEObject)divergent; | ||
116 | divergent = (Segment)eResolveProxy(oldDivergent); | ||
117 | if (divergent != oldDivergent) { | ||
118 | if (eNotificationRequired()) | ||
119 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, Modes3Package.TURNOUT__DIVERGENT, oldDivergent, divergent)); | ||
120 | } | ||
121 | } | ||
122 | return divergent; | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * <!-- begin-user-doc --> | ||
127 | * <!-- end-user-doc --> | ||
128 | * @generated | ||
129 | */ | ||
130 | public Segment basicGetDivergent() { | ||
131 | return divergent; | ||
132 | } | ||
133 | |||
134 | /** | ||
135 | * <!-- begin-user-doc --> | ||
136 | * <!-- end-user-doc --> | ||
137 | * @generated | ||
138 | */ | ||
139 | public void setDivergent(Segment newDivergent) { | ||
140 | Segment oldDivergent = divergent; | ||
141 | divergent = newDivergent; | ||
142 | if (eNotificationRequired()) | ||
143 | eNotify(new ENotificationImpl(this, Notification.SET, Modes3Package.TURNOUT__DIVERGENT, oldDivergent, divergent)); | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * <!-- begin-user-doc --> | ||
148 | * <!-- end-user-doc --> | ||
149 | * @generated | ||
150 | */ | ||
151 | @Override | ||
152 | public Object eGet(int featureID, boolean resolve, boolean coreType) { | ||
153 | switch (featureID) { | ||
154 | case Modes3Package.TURNOUT__STRAIGHT: | ||
155 | if (resolve) return getStraight(); | ||
156 | return basicGetStraight(); | ||
157 | case Modes3Package.TURNOUT__DIVERGENT: | ||
158 | if (resolve) return getDivergent(); | ||
159 | return basicGetDivergent(); | ||
160 | } | ||
161 | return super.eGet(featureID, resolve, coreType); | ||
162 | } | ||
163 | |||
164 | /** | ||
165 | * <!-- begin-user-doc --> | ||
166 | * <!-- end-user-doc --> | ||
167 | * @generated | ||
168 | */ | ||
169 | @Override | ||
170 | public void eSet(int featureID, Object newValue) { | ||
171 | switch (featureID) { | ||
172 | case Modes3Package.TURNOUT__STRAIGHT: | ||
173 | setStraight((Segment)newValue); | ||
174 | return; | ||
175 | case Modes3Package.TURNOUT__DIVERGENT: | ||
176 | setDivergent((Segment)newValue); | ||
177 | return; | ||
178 | } | ||
179 | super.eSet(featureID, newValue); | ||
180 | } | ||
181 | |||
182 | /** | ||
183 | * <!-- begin-user-doc --> | ||
184 | * <!-- end-user-doc --> | ||
185 | * @generated | ||
186 | */ | ||
187 | @Override | ||
188 | public void eUnset(int featureID) { | ||
189 | switch (featureID) { | ||
190 | case Modes3Package.TURNOUT__STRAIGHT: | ||
191 | setStraight((Segment)null); | ||
192 | return; | ||
193 | case Modes3Package.TURNOUT__DIVERGENT: | ||
194 | setDivergent((Segment)null); | ||
195 | return; | ||
196 | } | ||
197 | super.eUnset(featureID); | ||
198 | } | ||
199 | |||
200 | /** | ||
201 | * <!-- begin-user-doc --> | ||
202 | * <!-- end-user-doc --> | ||
203 | * @generated | ||
204 | */ | ||
205 | @Override | ||
206 | public boolean eIsSet(int featureID) { | ||
207 | switch (featureID) { | ||
208 | case Modes3Package.TURNOUT__STRAIGHT: | ||
209 | return straight != null; | ||
210 | case Modes3Package.TURNOUT__DIVERGENT: | ||
211 | return divergent != null; | ||
212 | } | ||
213 | return super.eIsSet(featureID); | ||
214 | } | ||
215 | |||
216 | } //TurnoutImpl | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3AdapterFactory.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3AdapterFactory.java new file mode 100644 index 00000000..9c5c8d2d --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3AdapterFactory.java | |||
@@ -0,0 +1,192 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.util; | ||
4 | |||
5 | import modes3.*; | ||
6 | |||
7 | import org.eclipse.emf.common.notify.Adapter; | ||
8 | import org.eclipse.emf.common.notify.Notifier; | ||
9 | |||
10 | import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; | ||
11 | |||
12 | import org.eclipse.emf.ecore.EObject; | ||
13 | |||
14 | /** | ||
15 | * <!-- begin-user-doc --> | ||
16 | * The <b>Adapter Factory</b> for the model. | ||
17 | * It provides an adapter <code>createXXX</code> method for each class of the model. | ||
18 | * <!-- end-user-doc --> | ||
19 | * @see modes3.Modes3Package | ||
20 | * @generated | ||
21 | */ | ||
22 | public class Modes3AdapterFactory extends AdapterFactoryImpl { | ||
23 | /** | ||
24 | * The cached model package. | ||
25 | * <!-- begin-user-doc --> | ||
26 | * <!-- end-user-doc --> | ||
27 | * @generated | ||
28 | */ | ||
29 | protected static Modes3Package modelPackage; | ||
30 | |||
31 | /** | ||
32 | * Creates an instance of the adapter factory. | ||
33 | * <!-- begin-user-doc --> | ||
34 | * <!-- end-user-doc --> | ||
35 | * @generated | ||
36 | */ | ||
37 | public Modes3AdapterFactory() { | ||
38 | if (modelPackage == null) { | ||
39 | modelPackage = Modes3Package.eINSTANCE; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | * Returns whether this factory is applicable for the type of the object. | ||
45 | * <!-- begin-user-doc --> | ||
46 | * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. | ||
47 | * <!-- end-user-doc --> | ||
48 | * @return whether this factory is applicable for the type of the object. | ||
49 | * @generated | ||
50 | */ | ||
51 | @Override | ||
52 | public boolean isFactoryForType(Object object) { | ||
53 | if (object == modelPackage) { | ||
54 | return true; | ||
55 | } | ||
56 | if (object instanceof EObject) { | ||
57 | return ((EObject)object).eClass().getEPackage() == modelPackage; | ||
58 | } | ||
59 | return false; | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * The switch that delegates to the <code>createXXX</code> methods. | ||
64 | * <!-- begin-user-doc --> | ||
65 | * <!-- end-user-doc --> | ||
66 | * @generated | ||
67 | */ | ||
68 | protected Modes3Switch<Adapter> modelSwitch = | ||
69 | new Modes3Switch<Adapter>() { | ||
70 | @Override | ||
71 | public Adapter caseSegment(Segment object) { | ||
72 | return createSegmentAdapter(); | ||
73 | } | ||
74 | @Override | ||
75 | public Adapter caseModes3ModelRoot(Modes3ModelRoot object) { | ||
76 | return createModes3ModelRootAdapter(); | ||
77 | } | ||
78 | @Override | ||
79 | public Adapter caseTurnout(Turnout object) { | ||
80 | return createTurnoutAdapter(); | ||
81 | } | ||
82 | @Override | ||
83 | public Adapter caseTrain(Train object) { | ||
84 | return createTrainAdapter(); | ||
85 | } | ||
86 | @Override | ||
87 | public Adapter caseSimpleSegment(SimpleSegment object) { | ||
88 | return createSimpleSegmentAdapter(); | ||
89 | } | ||
90 | @Override | ||
91 | public Adapter defaultCase(EObject object) { | ||
92 | return createEObjectAdapter(); | ||
93 | } | ||
94 | }; | ||
95 | |||
96 | /** | ||
97 | * Creates an adapter for the <code>target</code>. | ||
98 | * <!-- begin-user-doc --> | ||
99 | * <!-- end-user-doc --> | ||
100 | * @param target the object to adapt. | ||
101 | * @return the adapter for the <code>target</code>. | ||
102 | * @generated | ||
103 | */ | ||
104 | @Override | ||
105 | public Adapter createAdapter(Notifier target) { | ||
106 | return modelSwitch.doSwitch((EObject)target); | ||
107 | } | ||
108 | |||
109 | |||
110 | /** | ||
111 | * Creates a new adapter for an object of class '{@link modes3.Segment <em>Segment</em>}'. | ||
112 | * <!-- begin-user-doc --> | ||
113 | * This default implementation returns null so that we can easily ignore cases; | ||
114 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
115 | * <!-- end-user-doc --> | ||
116 | * @return the new adapter. | ||
117 | * @see modes3.Segment | ||
118 | * @generated | ||
119 | */ | ||
120 | public Adapter createSegmentAdapter() { | ||
121 | return null; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * Creates a new adapter for an object of class '{@link modes3.Modes3ModelRoot <em>Model Root</em>}'. | ||
126 | * <!-- begin-user-doc --> | ||
127 | * This default implementation returns null so that we can easily ignore cases; | ||
128 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
129 | * <!-- end-user-doc --> | ||
130 | * @return the new adapter. | ||
131 | * @see modes3.Modes3ModelRoot | ||
132 | * @generated | ||
133 | */ | ||
134 | public Adapter createModes3ModelRootAdapter() { | ||
135 | return null; | ||
136 | } | ||
137 | |||
138 | /** | ||
139 | * Creates a new adapter for an object of class '{@link modes3.Turnout <em>Turnout</em>}'. | ||
140 | * <!-- begin-user-doc --> | ||
141 | * This default implementation returns null so that we can easily ignore cases; | ||
142 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
143 | * <!-- end-user-doc --> | ||
144 | * @return the new adapter. | ||
145 | * @see modes3.Turnout | ||
146 | * @generated | ||
147 | */ | ||
148 | public Adapter createTurnoutAdapter() { | ||
149 | return null; | ||
150 | } | ||
151 | |||
152 | /** | ||
153 | * Creates a new adapter for an object of class '{@link modes3.Train <em>Train</em>}'. | ||
154 | * <!-- begin-user-doc --> | ||
155 | * This default implementation returns null so that we can easily ignore cases; | ||
156 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
157 | * <!-- end-user-doc --> | ||
158 | * @return the new adapter. | ||
159 | * @see modes3.Train | ||
160 | * @generated | ||
161 | */ | ||
162 | public Adapter createTrainAdapter() { | ||
163 | return null; | ||
164 | } | ||
165 | |||
166 | /** | ||
167 | * Creates a new adapter for an object of class '{@link modes3.SimpleSegment <em>Simple Segment</em>}'. | ||
168 | * <!-- begin-user-doc --> | ||
169 | * This default implementation returns null so that we can easily ignore cases; | ||
170 | * it's useful to ignore a case when inheritance will catch all the cases anyway. | ||
171 | * <!-- end-user-doc --> | ||
172 | * @return the new adapter. | ||
173 | * @see modes3.SimpleSegment | ||
174 | * @generated | ||
175 | */ | ||
176 | public Adapter createSimpleSegmentAdapter() { | ||
177 | return null; | ||
178 | } | ||
179 | |||
180 | /** | ||
181 | * Creates a new adapter for the default case. | ||
182 | * <!-- begin-user-doc --> | ||
183 | * This default implementation returns null. | ||
184 | * <!-- end-user-doc --> | ||
185 | * @return the new adapter. | ||
186 | * @generated | ||
187 | */ | ||
188 | public Adapter createEObjectAdapter() { | ||
189 | return null; | ||
190 | } | ||
191 | |||
192 | } //Modes3AdapterFactory | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3Switch.java b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3Switch.java new file mode 100644 index 00000000..0c28861a --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/ecore-gen/modes3/util/Modes3Switch.java | |||
@@ -0,0 +1,196 @@ | |||
1 | /** | ||
2 | */ | ||
3 | package modes3.util; | ||
4 | |||
5 | import modes3.*; | ||
6 | |||
7 | import org.eclipse.emf.ecore.EObject; | ||
8 | import org.eclipse.emf.ecore.EPackage; | ||
9 | |||
10 | import org.eclipse.emf.ecore.util.Switch; | ||
11 | |||
12 | /** | ||
13 | * <!-- begin-user-doc --> | ||
14 | * The <b>Switch</b> for the model's inheritance hierarchy. | ||
15 | * It supports the call {@link #doSwitch(EObject) doSwitch(object)} | ||
16 | * to invoke the <code>caseXXX</code> method for each class of the model, | ||
17 | * starting with the actual class of the object | ||
18 | * and proceeding up the inheritance hierarchy | ||
19 | * until a non-null result is returned, | ||
20 | * which is the result of the switch. | ||
21 | * <!-- end-user-doc --> | ||
22 | * @see modes3.Modes3Package | ||
23 | * @generated | ||
24 | */ | ||
25 | public class Modes3Switch<T> extends Switch<T> { | ||
26 | /** | ||
27 | * The cached model package | ||
28 | * <!-- begin-user-doc --> | ||
29 | * <!-- end-user-doc --> | ||
30 | * @generated | ||
31 | */ | ||
32 | protected static Modes3Package modelPackage; | ||
33 | |||
34 | /** | ||
35 | * Creates an instance of the switch. | ||
36 | * <!-- begin-user-doc --> | ||
37 | * <!-- end-user-doc --> | ||
38 | * @generated | ||
39 | */ | ||
40 | public Modes3Switch() { | ||
41 | if (modelPackage == null) { | ||
42 | modelPackage = Modes3Package.eINSTANCE; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | /** | ||
47 | * Checks whether this is a switch for the given package. | ||
48 | * <!-- begin-user-doc --> | ||
49 | * <!-- end-user-doc --> | ||
50 | * @param ePackage the package in question. | ||
51 | * @return whether this is a switch for the given package. | ||
52 | * @generated | ||
53 | */ | ||
54 | @Override | ||
55 | protected boolean isSwitchFor(EPackage ePackage) { | ||
56 | return ePackage == modelPackage; | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. | ||
61 | * <!-- begin-user-doc --> | ||
62 | * <!-- end-user-doc --> | ||
63 | * @return the first non-null result returned by a <code>caseXXX</code> call. | ||
64 | * @generated | ||
65 | */ | ||
66 | @Override | ||
67 | protected T doSwitch(int classifierID, EObject theEObject) { | ||
68 | switch (classifierID) { | ||
69 | case Modes3Package.SEGMENT: { | ||
70 | Segment segment = (Segment)theEObject; | ||
71 | T result = caseSegment(segment); | ||
72 | if (result == null) result = defaultCase(theEObject); | ||
73 | return result; | ||
74 | } | ||
75 | case Modes3Package.MODES3_MODEL_ROOT: { | ||
76 | Modes3ModelRoot modes3ModelRoot = (Modes3ModelRoot)theEObject; | ||
77 | T result = caseModes3ModelRoot(modes3ModelRoot); | ||
78 | if (result == null) result = defaultCase(theEObject); | ||
79 | return result; | ||
80 | } | ||
81 | case Modes3Package.TURNOUT: { | ||
82 | Turnout turnout = (Turnout)theEObject; | ||
83 | T result = caseTurnout(turnout); | ||
84 | if (result == null) result = caseSegment(turnout); | ||
85 | if (result == null) result = defaultCase(theEObject); | ||
86 | return result; | ||
87 | } | ||
88 | case Modes3Package.TRAIN: { | ||
89 | Train train = (Train)theEObject; | ||
90 | T result = caseTrain(train); | ||
91 | if (result == null) result = defaultCase(theEObject); | ||
92 | return result; | ||
93 | } | ||
94 | case Modes3Package.SIMPLE_SEGMENT: { | ||
95 | SimpleSegment simpleSegment = (SimpleSegment)theEObject; | ||
96 | T result = caseSimpleSegment(simpleSegment); | ||
97 | if (result == null) result = caseSegment(simpleSegment); | ||
98 | if (result == null) result = defaultCase(theEObject); | ||
99 | return result; | ||
100 | } | ||
101 | default: return defaultCase(theEObject); | ||
102 | } | ||
103 | } | ||
104 | |||
105 | /** | ||
106 | * Returns the result of interpreting the object as an instance of '<em>Segment</em>'. | ||
107 | * <!-- begin-user-doc --> | ||
108 | * This implementation returns null; | ||
109 | * returning a non-null result will terminate the switch. | ||
110 | * <!-- end-user-doc --> | ||
111 | * @param object the target of the switch. | ||
112 | * @return the result of interpreting the object as an instance of '<em>Segment</em>'. | ||
113 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
114 | * @generated | ||
115 | */ | ||
116 | public T caseSegment(Segment object) { | ||
117 | return null; | ||
118 | } | ||
119 | |||
120 | /** | ||
121 | * Returns the result of interpreting the object as an instance of '<em>Model Root</em>'. | ||
122 | * <!-- begin-user-doc --> | ||
123 | * This implementation returns null; | ||
124 | * returning a non-null result will terminate the switch. | ||
125 | * <!-- end-user-doc --> | ||
126 | * @param object the target of the switch. | ||
127 | * @return the result of interpreting the object as an instance of '<em>Model Root</em>'. | ||
128 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
129 | * @generated | ||
130 | */ | ||
131 | public T caseModes3ModelRoot(Modes3ModelRoot object) { | ||
132 | return null; | ||
133 | } | ||
134 | |||
135 | /** | ||
136 | * Returns the result of interpreting the object as an instance of '<em>Turnout</em>'. | ||
137 | * <!-- begin-user-doc --> | ||
138 | * This implementation returns null; | ||
139 | * returning a non-null result will terminate the switch. | ||
140 | * <!-- end-user-doc --> | ||
141 | * @param object the target of the switch. | ||
142 | * @return the result of interpreting the object as an instance of '<em>Turnout</em>'. | ||
143 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
144 | * @generated | ||
145 | */ | ||
146 | public T caseTurnout(Turnout object) { | ||
147 | return null; | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * Returns the result of interpreting the object as an instance of '<em>Train</em>'. | ||
152 | * <!-- begin-user-doc --> | ||
153 | * This implementation returns null; | ||
154 | * returning a non-null result will terminate the switch. | ||
155 | * <!-- end-user-doc --> | ||
156 | * @param object the target of the switch. | ||
157 | * @return the result of interpreting the object as an instance of '<em>Train</em>'. | ||
158 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
159 | * @generated | ||
160 | */ | ||
161 | public T caseTrain(Train object) { | ||
162 | return null; | ||
163 | } | ||
164 | |||
165 | /** | ||
166 | * Returns the result of interpreting the object as an instance of '<em>Simple Segment</em>'. | ||
167 | * <!-- begin-user-doc --> | ||
168 | * This implementation returns null; | ||
169 | * returning a non-null result will terminate the switch. | ||
170 | * <!-- end-user-doc --> | ||
171 | * @param object the target of the switch. | ||
172 | * @return the result of interpreting the object as an instance of '<em>Simple Segment</em>'. | ||
173 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | ||
174 | * @generated | ||
175 | */ | ||
176 | public T caseSimpleSegment(SimpleSegment object) { | ||
177 | return null; | ||
178 | } | ||
179 | |||
180 | /** | ||
181 | * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. | ||
182 | * <!-- begin-user-doc --> | ||
183 | * This implementation returns null; | ||
184 | * returning a non-null result will terminate the switch, but this is the last case anyway. | ||
185 | * <!-- end-user-doc --> | ||
186 | * @param object the target of the switch. | ||
187 | * @return the result of interpreting the object as an instance of '<em>EObject</em>'. | ||
188 | * @see #doSwitch(org.eclipse.emf.ecore.EObject) | ||
189 | * @generated | ||
190 | */ | ||
191 | @Override | ||
192 | public T defaultCase(EObject object) { | ||
193 | return null; | ||
194 | } | ||
195 | |||
196 | } //Modes3Switch | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.ecore b/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.ecore new file mode 100644 index 00000000..f7cb28be --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.ecore | |||
@@ -0,0 +1,33 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="modes3" nsURI="http://www.ece.mcgill.ca/wcet/modes3" nsPrefix="modes3"> | ||
4 | <eClassifiers xsi:type="ecore:EClass" name="Segment"> | ||
5 | <eStructuralFeatures xsi:type="ecore:EReference" name="connectedTo" upperBound="2" | ||
6 | eType="#//Segment"/> | ||
7 | <eStructuralFeatures xsi:type="ecore:EReference" name="occupiedBy" eType="#//Train" | ||
8 | eOpposite="#//Train/location"/> | ||
9 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
10 | </eClassifiers> | ||
11 | <eClassifiers xsi:type="ecore:EClass" name="Modes3ModelRoot"> | ||
12 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
13 | <eStructuralFeatures xsi:type="ecore:EReference" name="trains" upperBound="-1" | ||
14 | eType="#//Train" containment="true"/> | ||
15 | <eStructuralFeatures xsi:type="ecore:EReference" name="segments" upperBound="-1" | ||
16 | eType="#//SimpleSegment" containment="true"/> | ||
17 | <eStructuralFeatures xsi:type="ecore:EReference" name="turnouts" upperBound="-1" | ||
18 | eType="#//Turnout" containment="true"/> | ||
19 | </eClassifiers> | ||
20 | <eClassifiers xsi:type="ecore:EClass" name="Turnout" eSuperTypes="#//Segment"> | ||
21 | <eStructuralFeatures xsi:type="ecore:EReference" name="straight" lowerBound="1" | ||
22 | eType="#//Segment"/> | ||
23 | <eStructuralFeatures xsi:type="ecore:EReference" name="divergent" lowerBound="1" | ||
24 | eType="#//Segment"/> | ||
25 | </eClassifiers> | ||
26 | <eClassifiers xsi:type="ecore:EClass" name="Train"> | ||
27 | <eStructuralFeatures xsi:type="ecore:EReference" name="location" lowerBound="1" | ||
28 | eType="#//Segment" eOpposite="#//Segment/occupiedBy"/> | ||
29 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
30 | <eStructuralFeatures xsi:type="ecore:EAttribute" name="speed" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDouble"/> | ||
31 | </eClassifiers> | ||
32 | <eClassifiers xsi:type="ecore:EClass" name="SimpleSegment" eSuperTypes="#//Segment"/> | ||
33 | </ecore:EPackage> | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.genmodel b/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.genmodel new file mode 100644 index 00000000..1cd4ac41 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/model/modes3.genmodel | |||
@@ -0,0 +1,31 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" | ||
3 | xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/ca.mcgill.rtgmrt.example.modes3/ecore-gen" modelPluginID="ca.mcgill.rtgmrt.example.modes3" | ||
4 | modelName="Modes3" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" | ||
5 | importerID="org.eclipse.emf.importer.ecore" complianceLevel="5.0" copyrightFields="false" | ||
6 | operationReflection="true" importOrganizing="true"> | ||
7 | <foreignModel>modes3.ecore</foreignModel> | ||
8 | <genPackages prefix="Modes3" disposableProviderFactory="true" ecorePackage="modes3.ecore#/"> | ||
9 | <genClasses ecoreClass="modes3.ecore#//Segment"> | ||
10 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference modes3.ecore#//Segment/connectedTo"/> | ||
11 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference modes3.ecore#//Segment/occupiedBy"/> | ||
12 | <genFeatures createChild="false" ecoreFeature="ecore:EAttribute modes3.ecore#//Segment/id"/> | ||
13 | </genClasses> | ||
14 | <genClasses ecoreClass="modes3.ecore#//Modes3ModelRoot"> | ||
15 | <genFeatures createChild="false" ecoreFeature="ecore:EAttribute modes3.ecore#//Modes3ModelRoot/id"/> | ||
16 | <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference modes3.ecore#//Modes3ModelRoot/trains"/> | ||
17 | <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference modes3.ecore#//Modes3ModelRoot/segments"/> | ||
18 | <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference modes3.ecore#//Modes3ModelRoot/turnouts"/> | ||
19 | </genClasses> | ||
20 | <genClasses ecoreClass="modes3.ecore#//Turnout"> | ||
21 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference modes3.ecore#//Turnout/straight"/> | ||
22 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference modes3.ecore#//Turnout/divergent"/> | ||
23 | </genClasses> | ||
24 | <genClasses ecoreClass="modes3.ecore#//Train"> | ||
25 | <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference modes3.ecore#//Train/location"/> | ||
26 | <genFeatures createChild="false" ecoreFeature="ecore:EAttribute modes3.ecore#//Train/id"/> | ||
27 | <genFeatures createChild="false" ecoreFeature="ecore:EAttribute modes3.ecore#//Train/speed"/> | ||
28 | </genClasses> | ||
29 | <genClasses ecoreClass="modes3.ecore#//SimpleSegment"/> | ||
30 | </genPackages> | ||
31 | </genmodel:GenModel> | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/plugin.properties b/Domains/ca.mcgill.rtgmrt.example.modes3/plugin.properties new file mode 100644 index 00000000..4eba0dd8 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/plugin.properties | |||
@@ -0,0 +1,4 @@ | |||
1 | # | ||
2 | |||
3 | pluginName = ca.mcgill.rtgmrt.example.modes3 | ||
4 | providerName = www.example.org | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/plugin.xml b/Domains/ca.mcgill.rtgmrt.example.modes3/plugin.xml new file mode 100644 index 00000000..f7d32541 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/plugin.xml | |||
@@ -0,0 +1,44 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?><?eclipse version="3.0"?><!-- | ||
2 | --><plugin> | ||
3 | <extension point="org.eclipse.emf.ecore.generated_package"> | ||
4 | <!-- @generated modes3 --> | ||
5 | <package class="modes3.Modes3Package" genModel="model/modes3.genmodel" uri="http://www.ece.mcgill.ca/wcet/modes3"/> | ||
6 | </extension> | ||
7 | <extension id="modes3.queries.Modes3Queries" point="org.eclipse.viatra.query.runtime.queryspecification"> | ||
8 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:modes3.queries.Modes3Queries" id="modes3.queries.Modes3Queries"> | ||
9 | <query-specification fqn="modes3.queries.connectedTo"/> | ||
10 | <query-specification fqn="modes3.queries.connectedToNotSymmetric"/> | ||
11 | <query-specification fqn="modes3.queries.connectedToReflexive"/> | ||
12 | <query-specification fqn="modes3.queries.turnoutOutput"/> | ||
13 | <query-specification fqn="modes3.queries.outputReflexive"/> | ||
14 | <query-specification fqn="modes3.queries.turnoutOutputsAreSame"/> | ||
15 | <query-specification fqn="modes3.queries.output"/> | ||
16 | <query-specification fqn="modes3.queries.tooManyInputsOfSegment"/> | ||
17 | <query-specification fqn="modes3.queries.turnoutConnectedToBothOutputs"/> | ||
18 | <query-specification fqn="modes3.queries.adjacent"/> | ||
19 | <query-specification fqn="modes3.queries.tooManyInputsOfTurnout"/> | ||
20 | <query-specification fqn="modes3.queries.inputsOfTurnout"/> | ||
21 | <query-specification fqn="modes3.queries.tooFewInputsOfTurnout"/> | ||
22 | <query-specification fqn="modes3.queries.reachable"/> | ||
23 | <query-specification fqn="modes3.queries.unreachable"/> | ||
24 | <query-specification fqn="modes3.queries.closeTrains_step_2"/> | ||
25 | <query-specification fqn="modes3.queries.closeTrains_step_3"/> | ||
26 | <query-specification fqn="modes3.queries.closeTrains_step_4"/> | ||
27 | <query-specification fqn="modes3.queries.closeTrains_step_5"/> | ||
28 | <query-specification fqn="modes3.queries.closeTrains_step_6"/> | ||
29 | <query-specification fqn="modes3.queries.closeTrains_step_7"/> | ||
30 | <query-specification fqn="modes3.queries.trainLocations_step_2"/> | ||
31 | <query-specification fqn="modes3.queries.trainLocations_step_3"/> | ||
32 | <query-specification fqn="modes3.queries.misalignedTurnout_step_2"/> | ||
33 | <query-specification fqn="modes3.queries.misalignedTurnout_step_3"/> | ||
34 | <query-specification fqn="modes3.queries.misalignedTurnout_step_4"/> | ||
35 | <query-specification fqn="modes3.queries.misalignedTurnout_step_5"/> | ||
36 | <query-specification fqn="modes3.queries.connectedSegmentsDirected"/> | ||
37 | <query-specification fqn="modes3.queries.endOfSiding_step_2"/> | ||
38 | <query-specification fqn="modes3.queries.endOfSiding_step_3"/> | ||
39 | <query-specification fqn="modes3.queries.endOfSiding_step_4"/> | ||
40 | <query-specification fqn="modes3.queries.endOfSiding_step_5"/> | ||
41 | <query-specification fqn="modes3.queries.multipleConnectedTo"/> | ||
42 | </group> | ||
43 | </extension> | ||
44 | </plugin> | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql new file mode 100644 index 00000000..d22bdd8b --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | |||
@@ -0,0 +1,295 @@ | |||
1 | package modes3.queries | ||
2 | |||
3 | import "http://www.ece.mcgill.ca/wcet/modes3" | ||
4 | |||
5 | pattern connectedTo(S1 : Segment, S2 : Segment) { | ||
6 | Segment.connectedTo(S1, S2); | ||
7 | } | ||
8 | |||
9 | @Constraint(message = "connectedToNotSymmetric", severity = "error", key = { S1, S2 }) | ||
10 | pattern connectedToNotSymmetric(S1 : Segment, S2 : Segment) { | ||
11 | Segment.connectedTo(S1, S2); | ||
12 | neg find connectedTo(S2, S1); | ||
13 | } | ||
14 | |||
15 | @Constraint(message = "connectedToReflexive", severity = "error", key = { S }) | ||
16 | pattern connectedToReflexive(S : Segment) { | ||
17 | Segment.connectedTo(S, S); | ||
18 | } | ||
19 | |||
20 | pattern turnoutOutput(T : Turnout, S : Segment) { | ||
21 | Turnout.straight(T, S); | ||
22 | } or { | ||
23 | Turnout.divergent(T, S); | ||
24 | } | ||
25 | |||
26 | @Constraint(message = "outputReflexive", severity = "error", key = { T }) | ||
27 | pattern outputReflexive(T : Turnout) { | ||
28 | find turnoutOutput(T, T); | ||
29 | } | ||
30 | |||
31 | @Constraint(message = "turnoutOutputsAreSame", severity = "error", key = { T }) | ||
32 | pattern turnoutOutputsAreSame(T : Turnout) { | ||
33 | Turnout.straight(T, S); | ||
34 | Turnout.divergent(T, S); | ||
35 | } | ||
36 | |||
37 | pattern output(S1 : Segment, S2 : Segment) { | ||
38 | Segment.connectedTo(S1, S2); | ||
39 | } or { | ||
40 | find turnoutOutput(S1, S2); | ||
41 | } | ||
42 | |||
43 | @Constraint(message = "tooManyInputsOfSegment", severity = "error", key = { S }) | ||
44 | pattern tooManyInputsOfSegment(S : SimpleSegment) { | ||
45 | find output(I1, S); | ||
46 | find output(I2, S); | ||
47 | find output(I3, S); | ||
48 | I1 != I2; | ||
49 | I1 != I3; | ||
50 | I2 != I3; | ||
51 | } | ||
52 | |||
53 | @Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) | ||
54 | pattern turnoutConnectedToBothOutputs(T : Turnout) { | ||
55 | Turnout.straight(T, Straight); | ||
56 | Turnout.divergent(T, Divergent); | ||
57 | Segment.connectedTo(T, Straight); | ||
58 | Segment.connectedTo(T, Divergent); | ||
59 | } | ||
60 | |||
61 | pattern adjacent(S1 : Segment, S2 : Segment) { | ||
62 | find output(S1, S2); | ||
63 | } or { | ||
64 | find turnoutOutput(S2, S1); | ||
65 | } | ||
66 | |||
67 | @Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) | ||
68 | pattern tooManyInputsOfTurnout(T : Turnout) { | ||
69 | find adjacent(I1, T); | ||
70 | find adjacent(I2, T); | ||
71 | find adjacent(I3, T); | ||
72 | find adjacent(I4, T); | ||
73 | I1 != I2; | ||
74 | I1 != I3; | ||
75 | I1 != I4; | ||
76 | I2 != I3; | ||
77 | I2 != I4; | ||
78 | I3 != I4; | ||
79 | } | ||
80 | |||
81 | pattern inputsOfTurnout(T : Turnout) { | ||
82 | find adjacent(I1, T); | ||
83 | find adjacent(I2, T); | ||
84 | find adjacent(I3, T); | ||
85 | I1 != I2; | ||
86 | I1 != I3; | ||
87 | I2 != I3; | ||
88 | } | ||
89 | |||
90 | @Constraint(message = "tooFewInputsOfTurnout", severity = "error", key = { T }) | ||
91 | pattern tooFewInputsOfTurnout(T : Turnout) { | ||
92 | neg find inputsOfTurnout(T); | ||
93 | } | ||
94 | |||
95 | pattern reachable(S1 : Segment, S2 : Segment) { | ||
96 | S1 == S2; | ||
97 | } or { | ||
98 | find adjacent+(S1, S2); | ||
99 | } | ||
100 | |||
101 | @Constraint(message = "unreachable", severity = "error", key = { S1, S2 }) | ||
102 | pattern unreachable(S1 : Segment, S2 : Segment) { | ||
103 | neg find reachable(S1, S2); | ||
104 | } | ||
105 | |||
106 | // | ||
107 | // closeTrains | ||
108 | // | ||
109 | |||
110 | pattern closeTrains_step_2(in train : Train) { | ||
111 | // frame->t1 = model->trains[i0]; | ||
112 | // frame->start = frame->t1->location; | ||
113 | // if(frame->start != 0){ | ||
114 | // ... | ||
115 | // } | ||
116 | // + OUTER FOR LOOP COUNTER INCREMENT | ||
117 | Train(train); | ||
118 | } | ||
119 | |||
120 | pattern closeTrains_step_3(in train : Train, in start : Segment) { | ||
121 | // int loop_bound1 = frame->start->connected_to_count; | ||
122 | // for (int i1 = 0; i1 < loop_bound1; i1++) { LOOP COUNTER INCREMENT IS NOT INCLUDED HERE | ||
123 | // ... | ||
124 | // } | ||
125 | Train.location(train, start); | ||
126 | } | ||
127 | |||
128 | pattern closeTrains_step_4(in train : Train, in start : Segment, in middle : Segment) { | ||
129 | // frame->middle = frame->start->connected_to[i1]; | ||
130 | // int loop_bound2 = frame->middle->connected_to_count; | ||
131 | |||
132 | // for (int i2 = 0; i2 < loop_bound2; i2++) { LOOP COUNTER INCREMENT IS NOT INCLUDED HERE | ||
133 | // ... | ||
134 | // } | ||
135 | // + OUTER FOR LOOP COUNTER INCREMENT | ||
136 | Train.location(train, start); | ||
137 | Segment.connectedTo(start, middle); | ||
138 | } | ||
139 | |||
140 | pattern closeTrains_step_5(in train : Train, in start : Segment, in middle : Segment, in end : Segment) { | ||
141 | // frame->end = frame->middle->connected_to[i2]; | ||
142 | // if (frame->start != frame->end) { | ||
143 | // ... | ||
144 | // } | ||
145 | // + OUTER FOR LOOP COUNTER INCREMENT | ||
146 | Train.location(train, start); | ||
147 | Segment.connectedTo(start, middle); | ||
148 | Segment.connectedTo(middle, end); | ||
149 | } | ||
150 | |||
151 | pattern closeTrains_step_6(in train : Train, in start : Segment, in middle : Segment, in end : Segment) { | ||
152 | // frame->t2 = frame->end->train; | ||
153 | // if (frame->t2 != 0) { | ||
154 | // ... | ||
155 | // } | ||
156 | Train.location(train, start); | ||
157 | Segment.connectedTo(start, middle); | ||
158 | Segment.connectedTo(middle, end); | ||
159 | start != end; | ||
160 | } | ||
161 | |||
162 | pattern closeTrains_step_7(in train : Train, in start : Segment, in middle : Segment, in end : Segment, in otherTrain : Train) { | ||
163 | // results->matches[match_cntr].start = frame->start; | ||
164 | // results->matches[match_cntr++].end = frame->end; | ||
165 | Train.location(train, start); | ||
166 | Segment.connectedTo(start, middle); | ||
167 | Segment.connectedTo(middle, end); | ||
168 | start != end; | ||
169 | Segment.occupiedBy(end, otherTrain); | ||
170 | } | ||
171 | |||
172 | // | ||
173 | // trainLocations | ||
174 | // | ||
175 | |||
176 | pattern trainLocations_step_2(in train : Train) { | ||
177 | // frame->train = model->trains[i0]; | ||
178 | // frame->location = frame->train->location; | ||
179 | // if (frame->location != NULL) { | ||
180 | // ... | ||
181 | // } | ||
182 | |||
183 | Train(train); | ||
184 | } | ||
185 | |||
186 | pattern trainLocations_step_3(in train : Train, in location : Segment) { | ||
187 | // results->matches[match_cntr].location = frame->location; | ||
188 | // results->matches[match_cntr++].train = frame->train; | ||
189 | Train(train); | ||
190 | Train.location(train, location); | ||
191 | } | ||
192 | |||
193 | // | ||
194 | // misalignedTurnout | ||
195 | // | ||
196 | |||
197 | pattern misalignedTurnout_step_2(in turnout : Turnout) { | ||
198 | // frame->turnout = model->turnouts[i0]; | ||
199 | // frame->location = frame->turnout->straight; | ||
200 | // if (frame->location != NULL) { | ||
201 | // ... | ||
202 | // } | ||
203 | Turnout(turnout); | ||
204 | } | ||
205 | |||
206 | pattern misalignedTurnout_step_3(in turnout : Turnout, in location : Segment) { | ||
207 | // Segment *disconnected = ((Segment *)frame->turnout); | ||
208 | // if (disconnected->connected_to[0] != frame->location && | ||
209 | // disconnected->connected_to[1] != frame->location) { | ||
210 | // ... | ||
211 | // } | ||
212 | Turnout(turnout); | ||
213 | Turnout.straight(turnout, location); | ||
214 | } | ||
215 | |||
216 | pattern misalignedTurnout_step_4(in turnout : Turnout, in location : Segment) { | ||
217 | // frame->train = frame->location->train; | ||
218 | // if (frame->train != NULL) { | ||
219 | // ... | ||
220 | // } | ||
221 | Turnout(turnout); | ||
222 | Turnout.straight(turnout, location); | ||
223 | neg find connectedSegmentsDirected(turnout, location); | ||
224 | } | ||
225 | |||
226 | pattern misalignedTurnout_step_5(in turnout : Turnout, in location : Segment, in train : Train) { | ||
227 | // results->matches[match_cntr].start = frame->start; | ||
228 | // results->matches[match_cntr++].end = frame->end; | ||
229 | Turnout(turnout); | ||
230 | Turnout.straight(turnout, location); | ||
231 | neg find connectedSegmentsDirected(turnout, location); | ||
232 | Segment.occupiedBy(location, train); | ||
233 | } | ||
234 | |||
235 | pattern connectedSegmentsDirected(s1 : Segment, s2 : Segment) { | ||
236 | Segment.connectedTo(s1, s2); | ||
237 | } | ||
238 | |||
239 | // | ||
240 | // endOfSiding | ||
241 | // | ||
242 | |||
243 | pattern endOfSiding_step_2(in train : Train) { | ||
244 | // frame->train = model->trains[i0]; | ||
245 | // frame->location = frame->train->location; | ||
246 | // if (frame->location != NULL) { | ||
247 | // ... | ||
248 | // } | ||
249 | |||
250 | Train(train); | ||
251 | } | ||
252 | |||
253 | pattern endOfSiding_step_3(in train : Train, in location : Segment) { | ||
254 | // int loop_bound1 = frame->location->connected_to_count; | ||
255 | // for (int i1 = 0; i1 < loop_bound1; i1++) { | ||
256 | // ... | ||
257 | // } | ||
258 | Train(train); | ||
259 | Train.location(train, location); | ||
260 | } | ||
261 | |||
262 | pattern endOfSiding_step_4(in train : Train, in location : Segment, in end : Segment) { | ||
263 | // frame->end = frame->location->connected_to[i1]; | ||
264 | // if (frame->end != NULL && | ||
265 | // frame->end->connected_to[1] == frame->location && | ||
266 | // frame->end->connected_to[0] == NULL) { | ||
267 | // ... | ||
268 | // } | ||
269 | // if (frame->end != NULL && | ||
270 | // frame->end->connected_to[0] == frame->location && | ||
271 | // frame->end->connected_to[1] == NULL) { | ||
272 | // ... | ||
273 | // } | ||
274 | Train(train); | ||
275 | Train.location(train, location); | ||
276 | Segment.connectedTo(location, end); | ||
277 | } | ||
278 | |||
279 | pattern endOfSiding_step_5(in train : Train, in location : Segment, in end : Segment) { | ||
280 | // results->matches[match_cntr].location = frame->location; | ||
281 | // results->matches[match_cntr++].train = frame->train; | ||
282 | // ...OR... | ||
283 | // results->matches[match_cntr].location = frame->location; | ||
284 | // results->matches[match_cntr++].train = frame->train; | ||
285 | Train(train); | ||
286 | Train.location(train, location); | ||
287 | Segment.connectedTo(location, end); | ||
288 | neg find multipleConnectedTo(end); | ||
289 | } | ||
290 | |||
291 | pattern multipleConnectedTo(s : Segment) { | ||
292 | Segment.connectedTo(s, n1); | ||
293 | Segment.connectedTo(s, n2); | ||
294 | n1 != n2; | ||
295 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/CloseTrainsObjectiveHint.xtend b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/CloseTrainsObjectiveHint.xtend new file mode 100644 index 00000000..519a228a --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/CloseTrainsObjectiveHint.xtend | |||
@@ -0,0 +1,201 @@ | |||
1 | package modes3.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint | ||
10 | import java.util.Collection | ||
11 | import java.util.Map | ||
12 | import modes3.Modes3Package | ||
13 | import modes3.queries.CloseTrains_step_2 | ||
14 | import modes3.queries.CloseTrains_step_3 | ||
15 | import modes3.queries.CloseTrains_step_4 | ||
16 | import modes3.queries.CloseTrains_step_5 | ||
17 | import modes3.queries.CloseTrains_step_6 | ||
18 | import modes3.queries.CloseTrains_step_7 | ||
19 | |||
20 | class CloseTrainsObjectiveHint extends CostObjectiveHint { | ||
21 | val Type segmentType | ||
22 | val Type trainType | ||
23 | |||
24 | new(extension Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { | ||
25 | extension val Modes3Package = Modes3Package.eINSTANCE | ||
26 | segmentType = ecore2LogicTrace.TypeofEClass(segment) | ||
27 | trainType = ecore2LogicTrace.TypeofEClass(train) | ||
28 | } | ||
29 | |||
30 | override isExact() { | ||
31 | true | ||
32 | } | ||
33 | |||
34 | override createPolyhedronExtensionOperator(Map<String, CostElementMatchers> costElementMatchers) { | ||
35 | val step2 = costElementMatchers.get(CloseTrains_step_2.instance.fullyQualifiedName) | ||
36 | val step3 = costElementMatchers.get(CloseTrains_step_3.instance.fullyQualifiedName) | ||
37 | val step4 = costElementMatchers.get(CloseTrains_step_4.instance.fullyQualifiedName) | ||
38 | val step5 = costElementMatchers.get(CloseTrains_step_5.instance.fullyQualifiedName) | ||
39 | val step6 = costElementMatchers.get(CloseTrains_step_6.instance.fullyQualifiedName) | ||
40 | val step7 = costElementMatchers.get(CloseTrains_step_7.instance.fullyQualifiedName); | ||
41 | |||
42 | [ | ||
43 | val objectiveBuilder = createBuilder | ||
44 | |||
45 | for (m : step2.matches) { | ||
46 | val dimension = getDimension(m.match) | ||
47 | objectiveBuilder.add(step2.weight, dimension) | ||
48 | dimension.tightenLowerBound(0) | ||
49 | if (m.multi) { | ||
50 | createBuilder.add(1, dimension).add(-1, trainType).build.assertEqualsTo(0) | ||
51 | } else { | ||
52 | dimension.tightenUpperBound(1) | ||
53 | if (m.must) { | ||
54 | dimension.tightenLowerBound(1) | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | |||
59 | val step3Matches = step3.matches | ||
60 | for (m : step3Matches) { | ||
61 | val dimension = getDimension(m.match) | ||
62 | objectiveBuilder.add(step3.weight, dimension) | ||
63 | dimension.tightenLowerBound(0) | ||
64 | if (!m.multi) { | ||
65 | dimension.tightenUpperBound(1) | ||
66 | if (m.must) { | ||
67 | dimension.tightenLowerBound(1) | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | for (pair : step3Matches.groupBy[step2.projectMayMatch(match, 2)].entrySet) { | ||
72 | val multiplicityBuilder = createBuilder | ||
73 | for (m : pair.value) { | ||
74 | multiplicityBuilder.add(1, m.match) | ||
75 | } | ||
76 | multiplicityBuilder.add(-1, pair.key) | ||
77 | multiplicityBuilder.build.assertEqualsTo(0) | ||
78 | } | ||
79 | boundLimit(step3Matches, 2, trainType, 1) | ||
80 | boundLimit(step3Matches, 3, segmentType, 1) | ||
81 | |||
82 | val step4Matches = step4.matches | ||
83 | for (m : step4Matches) { | ||
84 | val dimension = getDimension(m.match) | ||
85 | objectiveBuilder.add(step4.weight, dimension) | ||
86 | dimension.tightenLowerBound(0) | ||
87 | if (!m.multi) { | ||
88 | dimension.tightenUpperBound(1) | ||
89 | if (m.must) { | ||
90 | dimension.tightenLowerBound(1) | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | for (pair : step4Matches.groupBy[step3.projectMayMatch(match, 2, 3)].entrySet) { | ||
95 | val multiplicityBuilder = createBuilder | ||
96 | for (m : pair.value) { | ||
97 | multiplicityBuilder.add(1, m.match) | ||
98 | } | ||
99 | multiplicityBuilder.add(-2, pair.key) | ||
100 | multiplicityBuilder.build.tightenUpperBound(0) | ||
101 | } | ||
102 | boundLimit(step4Matches, 2, trainType, 2) | ||
103 | boundLimit(step4Matches, 3, segmentType, 2) | ||
104 | boundLimit(step4Matches, 4, segmentType, 2) | ||
105 | |||
106 | val step5Matches = step5.matches | ||
107 | for (m : step5Matches) { | ||
108 | val dimension = getDimension(m.match) | ||
109 | objectiveBuilder.add(step5.weight, dimension) | ||
110 | dimension.tightenLowerBound(0) | ||
111 | if (!m.multi) { | ||
112 | dimension.tightenUpperBound(1) | ||
113 | if (m.must) { | ||
114 | dimension.tightenLowerBound(1) | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | for (pair : step5Matches.groupBy[step4.projectMayMatch(match, 2, 3, 4)].entrySet) { | ||
119 | val multiplicityBuilder = createBuilder | ||
120 | for (m : pair.value) { | ||
121 | multiplicityBuilder.add(1, m.match) | ||
122 | } | ||
123 | multiplicityBuilder.add(-2, pair.key) | ||
124 | multiplicityBuilder.build.tightenUpperBound(0) | ||
125 | } | ||
126 | boundLimit(step5Matches, 2, trainType, 4) | ||
127 | boundLimit(step5Matches, 3, segmentType, 4) | ||
128 | boundLimit(step5Matches, 4, segmentType, 4) | ||
129 | boundLimit(step5Matches, 5, segmentType, 4) | ||
130 | |||
131 | val step6Matches = step6.matches | ||
132 | for (m : step6Matches) { | ||
133 | val dimension = getDimension(m.match) | ||
134 | objectiveBuilder.add(step6.weight, dimension) | ||
135 | dimension.tightenLowerBound(0) | ||
136 | if (m.multi) { | ||
137 | if (m.match.get(3) == m.match.get(5)) { | ||
138 | createBuilder.add(2, m.match).add(-1, step5.projectMayMatch(m.match, 2, 3, 4, 5)).build. | ||
139 | assertEqualsTo(0) | ||
140 | } else { | ||
141 | createBuilder.add(1, m.match).add(-1, step5.projectMayMatch(m.match, 2, 3, 4, 5)).build. | ||
142 | assertEqualsTo(0) | ||
143 | } | ||
144 | } else { | ||
145 | dimension.tightenUpperBound(1) | ||
146 | if (m.must) { | ||
147 | dimension.tightenLowerBound(1) | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | boundLimit(step6Matches, 2, trainType, 2) | ||
152 | boundLimit(step6Matches, 3, segmentType, 2) | ||
153 | boundLimit(step6Matches, 4, segmentType, 2) | ||
154 | boundLimit(step6Matches, 5, segmentType, 2) | ||
155 | |||
156 | val step7Matches = step7.matches | ||
157 | for (m : step7Matches) { | ||
158 | val dimension = getDimension(m.match) | ||
159 | objectiveBuilder.add(step7.weight, dimension) | ||
160 | dimension.tightenLowerBound(0) | ||
161 | if (!m.multi) { | ||
162 | dimension.tightenUpperBound(1) | ||
163 | if (m.must) { | ||
164 | dimension.tightenLowerBound(1) | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | for (pair : step7Matches.groupBy[step6.projectMayMatch(match, 2, 3, 4, 5)].entrySet) { | ||
169 | val multiplicityBuilder = createBuilder | ||
170 | for (m : pair.value) { | ||
171 | multiplicityBuilder.add(1, m.match) | ||
172 | } | ||
173 | multiplicityBuilder.add(-1, pair.key) | ||
174 | multiplicityBuilder.build.tightenUpperBound(0) | ||
175 | } | ||
176 | boundLimit(step7Matches, 2, trainType, 2) | ||
177 | boundLimit(step7Matches, 3, segmentType, 2) | ||
178 | boundLimit(step7Matches, 4, segmentType, 2) | ||
179 | boundLimit(step7Matches, 5, segmentType, 2) | ||
180 | boundLimit(step7Matches, 6, trainType, 2) | ||
181 | |||
182 | objectiveBuilder.buildWithBounds | ||
183 | ] | ||
184 | } | ||
185 | |||
186 | private static def boundLimit(extension ExtendedLinearExpressionBuilderFactory factory, | ||
187 | Collection<CostElementMatch> matches, int index, Type type, int count) { | ||
188 | for (pair : matches.groupBy[match.get(index)].entrySet) { | ||
189 | val multiplicityBuilder = createBuilder | ||
190 | for (m : pair.value) { | ||
191 | multiplicityBuilder.add(1, m.match) | ||
192 | } | ||
193 | if (CostElementMatchers.isMulti(pair.key)) { | ||
194 | multiplicityBuilder.add(-count, type) | ||
195 | multiplicityBuilder.build.tightenUpperBound(0) | ||
196 | } else { | ||
197 | multiplicityBuilder.build.tightenUpperBound(count) | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/EndOfSidingObjectiveHint.xtend b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/EndOfSidingObjectiveHint.xtend new file mode 100644 index 00000000..f7e23a57 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/EndOfSidingObjectiveHint.xtend | |||
@@ -0,0 +1,139 @@ | |||
1 | package modes3.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint | ||
10 | import java.util.Collection | ||
11 | import java.util.Map | ||
12 | import modes3.Modes3Package | ||
13 | import modes3.queries.EndOfSiding_step_2 | ||
14 | import modes3.queries.EndOfSiding_step_3 | ||
15 | import modes3.queries.EndOfSiding_step_4 | ||
16 | import modes3.queries.EndOfSiding_step_5 | ||
17 | |||
18 | class EndOfSidingObjectiveHint extends CostObjectiveHint { | ||
19 | val Type segmentType | ||
20 | val Type trainType | ||
21 | |||
22 | new(extension Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { | ||
23 | extension val Modes3Package = Modes3Package.eINSTANCE | ||
24 | segmentType = ecore2LogicTrace.TypeofEClass(segment) | ||
25 | trainType = ecore2LogicTrace.TypeofEClass(train) | ||
26 | } | ||
27 | |||
28 | override isExact() { | ||
29 | true | ||
30 | // false | ||
31 | } | ||
32 | |||
33 | override createPolyhedronExtensionOperator(Map<String, CostElementMatchers> costElementMatchers) { | ||
34 | val step2 = costElementMatchers.get(EndOfSiding_step_2.instance.fullyQualifiedName) | ||
35 | val step3 = costElementMatchers.get(EndOfSiding_step_3.instance.fullyQualifiedName) | ||
36 | val step4 = costElementMatchers.get(EndOfSiding_step_4.instance.fullyQualifiedName) | ||
37 | val step5 = costElementMatchers.get(EndOfSiding_step_5.instance.fullyQualifiedName); | ||
38 | |||
39 | [ | ||
40 | val objectiveBuilder = createBuilder | ||
41 | |||
42 | for (m : step2.matches) { | ||
43 | val dimension = getDimension(m.match) | ||
44 | objectiveBuilder.add(step2.weight, dimension) | ||
45 | dimension.tightenLowerBound(0) | ||
46 | if (m.multi) { | ||
47 | createBuilder.add(1, dimension).add(-1, trainType).build.assertEqualsTo(0) | ||
48 | } else { | ||
49 | dimension.tightenUpperBound(1) | ||
50 | if (m.must) { | ||
51 | dimension.tightenLowerBound(1) | ||
52 | } | ||
53 | } | ||
54 | } | ||
55 | |||
56 | val step3Matches = step3.matches | ||
57 | for (m : step3Matches) { | ||
58 | val dimension = getDimension(m.match) | ||
59 | objectiveBuilder.add(step3.weight, dimension) | ||
60 | dimension.tightenLowerBound(0) | ||
61 | if (!m.multi) { | ||
62 | dimension.tightenUpperBound(1) | ||
63 | if (m.must) { | ||
64 | dimension.tightenLowerBound(1) | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | for (pair : step3Matches.groupBy[step2.projectMayMatch(match, 2)].entrySet) { | ||
69 | val multiplicityBuilder = createBuilder | ||
70 | for (m : pair.value) { | ||
71 | multiplicityBuilder.add(1, m.match) | ||
72 | } | ||
73 | multiplicityBuilder.add(-1, pair.key) | ||
74 | multiplicityBuilder.build.assertEqualsTo(0) | ||
75 | } | ||
76 | boundLimit(step3Matches, 2, trainType, 1) | ||
77 | boundLimit(step3Matches, 3, segmentType, 1) | ||
78 | |||
79 | val step4Matches = step4.matches | ||
80 | for (m : step4Matches) { | ||
81 | val dimension = getDimension(m.match) | ||
82 | objectiveBuilder.add(step4.weight, dimension) | ||
83 | dimension.tightenLowerBound(0) | ||
84 | if (!m.multi) { | ||
85 | dimension.tightenUpperBound(1) | ||
86 | if (m.must) { | ||
87 | dimension.tightenLowerBound(1) | ||
88 | } | ||
89 | } | ||
90 | } | ||
91 | for (pair : step4Matches.groupBy[step3.projectMayMatch(match, 2, 3)].entrySet) { | ||
92 | val multiplicityBuilder = createBuilder | ||
93 | for (m : pair.value) { | ||
94 | multiplicityBuilder.add(1, m.match) | ||
95 | } | ||
96 | multiplicityBuilder.add(-2, pair.key) | ||
97 | multiplicityBuilder.build.tightenUpperBound(0) | ||
98 | } | ||
99 | boundLimit(step4Matches, 2, trainType, 2) | ||
100 | boundLimit(step4Matches, 3, segmentType, 2) | ||
101 | boundLimit(step4Matches, 4, segmentType, 2) | ||
102 | |||
103 | val step5Matches = step5.matches | ||
104 | for (m : step5Matches) { | ||
105 | val dimension = getDimension(m.match) | ||
106 | objectiveBuilder.add(step5.weight, dimension) | ||
107 | dimension.tightenLowerBound(0) | ||
108 | if (!m.multi) { | ||
109 | dimension.tightenUpperBound(1) | ||
110 | if (m.must) { | ||
111 | dimension.tightenLowerBound(1) | ||
112 | } | ||
113 | } | ||
114 | createBuilder.add(1, m.match).add(-1, step4.projectMayMatch(m.match, 2, 3, 4)).build.tightenUpperBound(0) | ||
115 | } | ||
116 | boundLimit(step5Matches, 2, trainType, 1) | ||
117 | boundLimit(step5Matches, 3, segmentType, 2) | ||
118 | boundLimit(step5Matches, 4, segmentType, 1) | ||
119 | |||
120 | objectiveBuilder.buildWithBounds | ||
121 | ] | ||
122 | } | ||
123 | |||
124 | private static def boundLimit(extension ExtendedLinearExpressionBuilderFactory factory, | ||
125 | Collection<CostElementMatch> matches, int index, Type type, int count) { | ||
126 | for (pair : matches.groupBy[match.get(index)].entrySet) { | ||
127 | val multiplicityBuilder = createBuilder | ||
128 | for (m : pair.value) { | ||
129 | multiplicityBuilder.add(1, m.match) | ||
130 | } | ||
131 | if (CostElementMatchers.isMulti(pair.key)) { | ||
132 | multiplicityBuilder.add(-count, type) | ||
133 | multiplicityBuilder.build.tightenUpperBound(0) | ||
134 | } else { | ||
135 | multiplicityBuilder.build.tightenUpperBound(count) | ||
136 | } | ||
137 | } | ||
138 | } | ||
139 | } \ No newline at end of file | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/MisalignedTurnoutObjectiveHint.xtend b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/MisalignedTurnoutObjectiveHint.xtend new file mode 100644 index 00000000..cb014dea --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/MisalignedTurnoutObjectiveHint.xtend | |||
@@ -0,0 +1,140 @@ | |||
1 | package modes3.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint | ||
10 | import java.util.Collection | ||
11 | import java.util.Map | ||
12 | import modes3.Modes3Package | ||
13 | import modes3.queries.MisalignedTurnout_step_2 | ||
14 | import modes3.queries.MisalignedTurnout_step_3 | ||
15 | import modes3.queries.MisalignedTurnout_step_4 | ||
16 | import modes3.queries.MisalignedTurnout_step_5 | ||
17 | |||
18 | class MisalignedTurnoutObjectiveHint extends CostObjectiveHint { | ||
19 | val Type segmentType | ||
20 | val Type turnoutType | ||
21 | val Type trainType | ||
22 | |||
23 | new(extension Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { | ||
24 | extension val Modes3Package = Modes3Package.eINSTANCE | ||
25 | segmentType = ecore2LogicTrace.TypeofEClass(segment) | ||
26 | turnoutType = ecore2LogicTrace.TypeofEClass(turnout) | ||
27 | trainType = ecore2LogicTrace.TypeofEClass(train) | ||
28 | } | ||
29 | |||
30 | override isExact() { | ||
31 | true | ||
32 | // false | ||
33 | } | ||
34 | |||
35 | override createPolyhedronExtensionOperator(Map<String, CostElementMatchers> costElementMatchers) { | ||
36 | val step2 = costElementMatchers.get(MisalignedTurnout_step_2.instance.fullyQualifiedName) | ||
37 | val step3 = costElementMatchers.get(MisalignedTurnout_step_3.instance.fullyQualifiedName) | ||
38 | val step4 = costElementMatchers.get(MisalignedTurnout_step_4.instance.fullyQualifiedName) | ||
39 | val step5 = costElementMatchers.get(MisalignedTurnout_step_5.instance.fullyQualifiedName); | ||
40 | |||
41 | [ | ||
42 | val objectiveBuilder = createBuilder | ||
43 | |||
44 | for (m : step2.matches) { | ||
45 | val dimension = getDimension(m.match) | ||
46 | objectiveBuilder.add(step2.weight, dimension) | ||
47 | dimension.tightenLowerBound(0) | ||
48 | if (m.multi) { | ||
49 | createBuilder.add(1, dimension).add(-1, turnoutType).build.assertEqualsTo(0) | ||
50 | } else { | ||
51 | dimension.tightenUpperBound(1) | ||
52 | if (m.must) { | ||
53 | dimension.tightenLowerBound(1) | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | |||
58 | val step3Matches = step3.matches | ||
59 | for (m : step3Matches) { | ||
60 | val dimension = getDimension(m.match) | ||
61 | objectiveBuilder.add(step3.weight, dimension) | ||
62 | dimension.tightenLowerBound(0) | ||
63 | if (!m.multi) { | ||
64 | dimension.tightenUpperBound(1) | ||
65 | if (m.must) { | ||
66 | dimension.tightenLowerBound(1) | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | for (pair : step3Matches.groupBy[step2.projectMayMatch(match, 2)].entrySet) { | ||
71 | val multiplicityBuilder = createBuilder | ||
72 | for (m : pair.value) { | ||
73 | multiplicityBuilder.add(1, m.match) | ||
74 | } | ||
75 | multiplicityBuilder.add(-1, pair.key) | ||
76 | multiplicityBuilder.build.tightenUpperBound(0) | ||
77 | } | ||
78 | boundLimit(step3Matches, 2, turnoutType, 1) | ||
79 | boundLimit(step3Matches, 3, segmentType, 2) | ||
80 | |||
81 | val step4Matches = step4.matches | ||
82 | for (m : step4Matches) { | ||
83 | val dimension = getDimension(m.match) | ||
84 | objectiveBuilder.add(step4.weight, dimension) | ||
85 | dimension.tightenLowerBound(0) | ||
86 | if (!m.multi) { | ||
87 | dimension.tightenUpperBound(1) | ||
88 | if (m.must) { | ||
89 | dimension.tightenLowerBound(1) | ||
90 | } | ||
91 | } | ||
92 | createBuilder.add(1, m.match).add(-1, step3.projectMayMatch(m.match, 2, 3)).build.tightenUpperBound(0) | ||
93 | } | ||
94 | boundLimit(step4Matches, 2, turnoutType, 1) | ||
95 | boundLimit(step4Matches, 3, segmentType, 2) | ||
96 | |||
97 | val step5Matches = step5.matches | ||
98 | for (m : step5Matches) { | ||
99 | val dimension = getDimension(m.match) | ||
100 | objectiveBuilder.add(step5.weight, dimension) | ||
101 | dimension.tightenLowerBound(0) | ||
102 | if (!m.multi) { | ||
103 | dimension.tightenUpperBound(1) | ||
104 | if (m.must) { | ||
105 | dimension.tightenLowerBound(1) | ||
106 | } | ||
107 | } | ||
108 | } | ||
109 | for (pair : step5Matches.groupBy[step4.projectMayMatch(match, 2, 3)].entrySet) { | ||
110 | val multiplicityBuilder = createBuilder | ||
111 | for (m : pair.value) { | ||
112 | multiplicityBuilder.add(1, m.match) | ||
113 | } | ||
114 | multiplicityBuilder.add(-1, pair.key) | ||
115 | multiplicityBuilder.build.tightenUpperBound(0) | ||
116 | } | ||
117 | boundLimit(step5Matches, 2, turnoutType, 1) | ||
118 | boundLimit(step5Matches, 3, segmentType, 2) | ||
119 | boundLimit(step5Matches, 4, trainType, 2) | ||
120 | |||
121 | objectiveBuilder.buildWithBounds | ||
122 | ] | ||
123 | } | ||
124 | |||
125 | private static def boundLimit(extension ExtendedLinearExpressionBuilderFactory factory, | ||
126 | Collection<CostElementMatch> matches, int index, Type type, int count) { | ||
127 | for (pair : matches.groupBy[match.get(index)].entrySet) { | ||
128 | val multiplicityBuilder = createBuilder | ||
129 | for (m : pair.value) { | ||
130 | multiplicityBuilder.add(1, m.match) | ||
131 | } | ||
132 | if (CostElementMatchers.isMulti(pair.key)) { | ||
133 | multiplicityBuilder.add(-count, type) | ||
134 | multiplicityBuilder.build.tightenUpperBound(0) | ||
135 | } else { | ||
136 | multiplicityBuilder.build.tightenUpperBound(count) | ||
137 | } | ||
138 | } | ||
139 | } | ||
140 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3ModelGenerator.xtend b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3ModelGenerator.xtend new file mode 100644 index 00000000..288a7692 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3ModelGenerator.xtend | |||
@@ -0,0 +1,357 @@ | |||
1 | package modes3.run | ||
2 | |||
3 | import com.google.common.collect.ImmutableList | ||
4 | import com.google.common.collect.ImmutableSet | ||
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EReferenceMapper_RelationsOverTypes_Trace | ||
6 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration | ||
8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
9 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor | ||
10 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsFactory | ||
11 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsPackage | ||
12 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel | ||
13 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder | ||
14 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage | ||
15 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition | ||
16 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage | ||
17 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult | ||
18 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore | ||
19 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic | ||
20 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration | ||
21 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor | ||
22 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.Viatra2LogicAnnotationsPackage | ||
23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod | ||
24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorConstraints | ||
25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorSolver | ||
26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy | ||
27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic | ||
28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink | ||
29 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation | ||
30 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage | ||
31 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml | ||
32 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.CostObjectiveConfiguration | ||
33 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.CostObjectiveElementConfiguration | ||
34 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.StateCoderStrategy | ||
35 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner | ||
36 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration | ||
37 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.PartialModelAsLogicInterpretation | ||
38 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind | ||
39 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold | ||
40 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser | ||
41 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace | ||
42 | import java.util.List | ||
43 | import modes3.Modes3Factory | ||
44 | import modes3.Modes3Package | ||
45 | import modes3.queries.CloseTrains_step_2 | ||
46 | import modes3.queries.CloseTrains_step_3 | ||
47 | import modes3.queries.CloseTrains_step_4 | ||
48 | import modes3.queries.CloseTrains_step_5 | ||
49 | import modes3.queries.CloseTrains_step_6 | ||
50 | import modes3.queries.CloseTrains_step_7 | ||
51 | import modes3.queries.EndOfSiding_step_2 | ||
52 | import modes3.queries.EndOfSiding_step_3 | ||
53 | import modes3.queries.EndOfSiding_step_4 | ||
54 | import modes3.queries.EndOfSiding_step_5 | ||
55 | import modes3.queries.MisalignedTurnout_step_2 | ||
56 | import modes3.queries.MisalignedTurnout_step_3 | ||
57 | import modes3.queries.MisalignedTurnout_step_4 | ||
58 | import modes3.queries.MisalignedTurnout_step_5 | ||
59 | import modes3.queries.Modes3Queries | ||
60 | import modes3.queries.TrainLocations_step_2 | ||
61 | import modes3.queries.TrainLocations_step_3 | ||
62 | import org.eclipse.emf.ecore.EClass | ||
63 | import org.eclipse.emf.ecore.EObject | ||
64 | import org.eclipse.emf.ecore.resource.Resource | ||
65 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | ||
66 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup | ||
67 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions | ||
68 | import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchEMFBackendFactory | ||
69 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory | ||
70 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor | ||
71 | |||
72 | @FinalFieldsConstructor | ||
73 | class Modes3ModelGenerator { | ||
74 | val MonitoringQuery monitoringQuery | ||
75 | val int modelSize | ||
76 | |||
77 | val ecore2Logic = new Ecore2Logic | ||
78 | val instanceModel2Logic = new InstanceModel2Logic | ||
79 | val viatra2Logic = new Viatra2Logic(ecore2Logic) | ||
80 | val solver = new ViatraReasoner | ||
81 | extension val LogicProblemBuilder = new LogicProblemBuilder | ||
82 | |||
83 | def generate() { | ||
84 | val metamodel = createMetamodelDescriptor() | ||
85 | val metamodelLogic = ecore2Logic.transformMetamodel(metamodel, new Ecore2LogicConfiguration) | ||
86 | val segment = ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.segment) | ||
87 | val connectedTo = ecore2Logic.relationOfReference(metamodelLogic.trace, | ||
88 | Modes3Package.eINSTANCE.segment_ConnectedTo) | ||
89 | val connectedToIndicator = (metamodelLogic.trace. | ||
90 | referenceMapperTrace as EReferenceMapper_RelationsOverTypes_Trace).indicators.get( | ||
91 | Modes3Package.eINSTANCE.segment_ConnectedTo) | ||
92 | val inverseAssertion = Assertion( | ||
93 | '''oppositeReference «connectedTo.name» «connectedTo.name»''', | ||
94 | Forall[ | ||
95 | val src = addVar('''src''', segment) | ||
96 | val trg = addVar('''trg''', segment) | ||
97 | connectedToIndicator.call(src, trg) <=> connectedToIndicator.call(trg, src) | ||
98 | ] | ||
99 | ) | ||
100 | metamodelLogic.output.assertions += inverseAssertion | ||
101 | val inverseAnnotation = Ecore2logicannotationsFactory.eINSTANCE.createInverseRelationAssertion => [ | ||
102 | target = inverseAssertion | ||
103 | inverseA = connectedTo | ||
104 | inverseB = connectedTo | ||
105 | ] | ||
106 | metamodelLogic.output.annotations += inverseAnnotation | ||
107 | val initialModel = loadInitialModel() | ||
108 | val initialModelLogic = instanceModel2Logic.transform(metamodelLogic, initialModel) | ||
109 | val queries = loadQueries | ||
110 | val logic = viatra2Logic.transformQueries(queries, initialModelLogic, new Viatra2LogicConfiguration) | ||
111 | val config = new ViatraReasonerConfiguration => [ | ||
112 | runtimeLimit = 3600 | ||
113 | typeScopes => [ | ||
114 | minNewElements = modelSize | ||
115 | maxNewElements = modelSize | ||
116 | minNewElementsByType => [ | ||
117 | // put(ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.train), modelSize / 5) | ||
118 | // put(ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.turnout), modelSize / 5) | ||
119 | // put(ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.simpleSegment), 3 * modelSize / 5) | ||
120 | ] | ||
121 | maxNewElementsByType => [ | ||
122 | put(ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.train), modelSize / 5) | ||
123 | put(ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.turnout), modelSize / 5) | ||
124 | // put(ecore2Logic.TypeofEClass(metamodelLogic.trace, Modes3Package.eINSTANCE.simpleSegment), 3 * modelSize / 5) | ||
125 | ] | ||
126 | ] | ||
127 | solutionScope => [ | ||
128 | numberOfRequiredSolutions = 1 | ||
129 | ] | ||
130 | costObjectives += getObjective(ecore2Logic, metamodelLogic.trace) | ||
131 | scopeWeight = 6 | ||
132 | nameNewElements = false | ||
133 | typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis | ||
134 | stateCoderStrategy = StateCoderStrategy.PairwiseNeighbourhood | ||
135 | scopePropagatorStrategy = new ScopePropagatorStrategy.Polyhedral( | ||
136 | PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp) | ||
137 | hints += new Modes3TypeScopeHint(ecore2Logic, metamodelLogic.trace) | ||
138 | unitPropagationPatternGenerators += new Modes3UnitPropagationGenerator(ecore2Logic, metamodelLogic.trace) | ||
139 | debugConfiguration => [ | ||
140 | partialInterpretatioVisualiser = new GraphvizVisualiser | ||
141 | // partalInterpretationVisualisationFrequency = 50 | ||
142 | ] | ||
143 | documentationLevel = DocumentationLevel.NORMAL | ||
144 | ] | ||
145 | val workspace = new FileSystemWorkspace("output/", "") | ||
146 | workspace.writeModel(logic.output, "problem.logicproblem") | ||
147 | val solution = solver.solve(logic.output, config, workspace) | ||
148 | if (solution instanceof ModelResult) { | ||
149 | println("Saving generated solutions") | ||
150 | val logic2Ecore = new Logic2Ecore(ecore2Logic) | ||
151 | val interpretations = solver.getInterpretations(solution) | ||
152 | for (representationIndex : 0 ..< interpretations.size) { | ||
153 | val interpretation = interpretations.get(representationIndex) | ||
154 | val representationNumber = representationIndex + 1 | ||
155 | if (interpretation instanceof PartialModelAsLogicInterpretation) { | ||
156 | val representation = interpretation.partialInterpretation | ||
157 | workspace.writeModel(representation, '''solution«representationNumber».partialinterpretation''') | ||
158 | val partialInterpretation2GML = new PartialInterpretation2Gml | ||
159 | val gml = partialInterpretation2GML.transform(representation) | ||
160 | workspace.writeText('''solution«representationNumber».gml''', gml) | ||
161 | val model = logic2Ecore.transformInterpretation(interpretation, metamodelLogic.trace) | ||
162 | val iterator = model.eAllContents | ||
163 | var int id = 0 | ||
164 | while (iterator.hasNext) { | ||
165 | val obj = iterator.next | ||
166 | val idFeature = obj.eClass.EAllAttributes.findFirst[name == 'id'] | ||
167 | if (idFeature !== null) { | ||
168 | obj.eSet(idFeature, id) | ||
169 | id++ | ||
170 | } | ||
171 | } | ||
172 | workspace.writeModel(model, '''solution«representationNumber».modes3''') | ||
173 | if (representation.newElements.size < 160) { | ||
174 | val rootType = (representation.problem.types.findFirst [ | ||
175 | name == "Modes3ModelRoot class DefinedPart" | ||
176 | ] as TypeDefinition) | ||
177 | val rootIntepretation = representation.partialtypeinterpratation.filter( | ||
178 | PartialComplexTypeInterpretation).findFirst [ | ||
179 | interpretationOf.name == "Modes3ModelRoot class" | ||
180 | ] | ||
181 | rootIntepretation.elements.removeAll(rootType.elements) | ||
182 | representation.problem.elements.removeAll(rootType.elements) | ||
183 | for (relationInterpretation : representation.partialrelationinterpretation) { | ||
184 | relationInterpretation.relationlinks.removeIf [ link | | ||
185 | if (link instanceof BinaryElementRelationLink) { | ||
186 | rootType.elements.contains(link.param1) || | ||
187 | rootType.elements.contains(link.param2) | ||
188 | } else { | ||
189 | false | ||
190 | } | ||
191 | ] | ||
192 | } | ||
193 | rootType.elements.clear | ||
194 | val visualiser = new GraphvizVisualiser | ||
195 | val visualisation = visualiser.visualiseConcretization(representation) | ||
196 | visualisation.writeToFile(workspace, '''solution«representationNumber».png''') | ||
197 | } | ||
198 | } else { | ||
199 | workspace.writeText('''solution«representationNumber».txt''', interpretation.toString) | ||
200 | } | ||
201 | } | ||
202 | } else { | ||
203 | println("Failed to solve problem") | ||
204 | val partial = logic.output | ||
205 | workspace.writeModel(partial, "solution.partialinterpretation") | ||
206 | } | ||
207 | } | ||
208 | |||
209 | static def createMetamodelDescriptor() { | ||
210 | val eClasses = ImmutableList.copyOf(Modes3Package.eINSTANCE.EClassifiers.filter(EClass)) | ||
211 | new EcoreMetamodelDescriptor( | ||
212 | eClasses, | ||
213 | emptySet, | ||
214 | false, | ||
215 | emptyList, | ||
216 | emptyList, | ||
217 | ImmutableList.copyOf(eClasses.flatMap[EReferences]), | ||
218 | emptyList | ||
219 | ) | ||
220 | } | ||
221 | |||
222 | static def List<EObject> loadInitialModel() { | ||
223 | #[Modes3Factory.eINSTANCE.createModes3ModelRoot] | ||
224 | } | ||
225 | |||
226 | def loadQueries() { | ||
227 | val patternsBuilder = ImmutableList.builder | ||
228 | patternsBuilder.addAll(Modes3Queries.instance.specifications) | ||
229 | val patterns = patternsBuilder.build | ||
230 | val validationPatterns = ImmutableSet.copyOf(patterns.filter [ pattern | | ||
231 | pattern.allAnnotations.exists[name == "Constraint"] | ||
232 | ]) | ||
233 | new ViatraQuerySetDescriptor( | ||
234 | patterns, | ||
235 | validationPatterns, | ||
236 | emptyMap | ||
237 | ) | ||
238 | } | ||
239 | |||
240 | def getObjective(Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { | ||
241 | new CostObjectiveConfiguration => [ | ||
242 | switch (monitoringQuery) { | ||
243 | case closeTrains: { | ||
244 | elements += new CostObjectiveElementConfiguration => [ | ||
245 | patternQualifiedName = CloseTrains_step_2.instance.fullyQualifiedName | ||
246 | weight = 14 + 53 + 11 | ||
247 | ] | ||
248 | elements += new CostObjectiveElementConfiguration => [ | ||
249 | patternQualifiedName = CloseTrains_step_3.instance.fullyQualifiedName | ||
250 | weight = 21 + 14 | ||
251 | ] | ||
252 | elements += new CostObjectiveElementConfiguration => [ | ||
253 | patternQualifiedName = CloseTrains_step_4.instance.fullyQualifiedName | ||
254 | weight = 14 + 44 + 14 + 9 | ||
255 | ] | ||
256 | elements += new CostObjectiveElementConfiguration => [ | ||
257 | patternQualifiedName = CloseTrains_step_5.instance.fullyQualifiedName | ||
258 | weight = 14 + 41 + 11 | ||
259 | ] | ||
260 | elements += new CostObjectiveElementConfiguration => [ | ||
261 | patternQualifiedName = CloseTrains_step_6.instance.fullyQualifiedName | ||
262 | weight = 27 | ||
263 | ] | ||
264 | elements += new CostObjectiveElementConfiguration => [ | ||
265 | patternQualifiedName = CloseTrains_step_7.instance.fullyQualifiedName | ||
266 | weight = 48 | ||
267 | ] | ||
268 | hint = new CloseTrainsObjectiveHint(ecore2Logic, ecore2LogicTrace) | ||
269 | } | ||
270 | case trainLocations: { | ||
271 | elements += new CostObjectiveElementConfiguration => [ | ||
272 | patternQualifiedName = TrainLocations_step_2.instance.fullyQualifiedName | ||
273 | weight = 14 + 53 + 11 | ||
274 | ] | ||
275 | elements += new CostObjectiveElementConfiguration => [ | ||
276 | patternQualifiedName = TrainLocations_step_3.instance.fullyQualifiedName | ||
277 | weight = 48 | ||
278 | ] | ||
279 | hint = new TrainLocationsObjectiveHint(ecore2Logic, ecore2LogicTrace) | ||
280 | } | ||
281 | case misalignedTurnout: { | ||
282 | elements += new CostObjectiveElementConfiguration => [ | ||
283 | patternQualifiedName = MisalignedTurnout_step_2.instance.fullyQualifiedName | ||
284 | weight = 14 + 53 + 11 | ||
285 | ] | ||
286 | elements += new CostObjectiveElementConfiguration => [ | ||
287 | patternQualifiedName = MisalignedTurnout_step_3.instance.fullyQualifiedName | ||
288 | weight = 108 | ||
289 | ] | ||
290 | elements += new CostObjectiveElementConfiguration => [ | ||
291 | patternQualifiedName = MisalignedTurnout_step_4.instance.fullyQualifiedName | ||
292 | weight = 27 | ||
293 | ] | ||
294 | elements += new CostObjectiveElementConfiguration => [ | ||
295 | patternQualifiedName = MisalignedTurnout_step_5.instance.fullyQualifiedName | ||
296 | weight = 48 | ||
297 | ] | ||
298 | hint = new MisalignedTurnoutObjectiveHint(ecore2Logic, ecore2LogicTrace) | ||
299 | } | ||
300 | case endOfSiding: { | ||
301 | elements += new CostObjectiveElementConfiguration => [ | ||
302 | patternQualifiedName = EndOfSiding_step_2.instance.fullyQualifiedName | ||
303 | weight = 14 + 53 + 11 | ||
304 | ] | ||
305 | elements += new CostObjectiveElementConfiguration => [ | ||
306 | patternQualifiedName = EndOfSiding_step_3.instance.fullyQualifiedName | ||
307 | weight = 21 + 14 | ||
308 | ] | ||
309 | elements += new CostObjectiveElementConfiguration => [ | ||
310 | patternQualifiedName = EndOfSiding_step_4.instance.fullyQualifiedName | ||
311 | weight = 14 + 35 + 21 + 15 + 14 + 21 + 15 + 11 | ||
312 | ] | ||
313 | elements += new CostObjectiveElementConfiguration => [ | ||
314 | patternQualifiedName = EndOfSiding_step_5.instance.fullyQualifiedName | ||
315 | weight = 48 | ||
316 | ] | ||
317 | hint = new EndOfSidingObjectiveHint(ecore2Logic, ecore2LogicTrace) | ||
318 | } | ||
319 | default: | ||
320 | throw new IllegalArgumentException("Unknown monitoring query: " + monitoringQuery) | ||
321 | } | ||
322 | kind = ObjectiveKind.HIGHER_IS_BETTER | ||
323 | threshold = ObjectiveThreshold.NO_THRESHOLD | ||
324 | findExtremum = true | ||
325 | ] | ||
326 | } | ||
327 | |||
328 | def static init() { | ||
329 | EMFPatternLanguageStandaloneSetup.doSetup | ||
330 | ViatraQueryEngineOptions.setSystemDefaultBackends(ReteBackendFactory.INSTANCE, ReteBackendFactory.INSTANCE, | ||
331 | LocalSearchEMFBackendFactory.INSTANCE) | ||
332 | LogiclanguagePackage.eINSTANCE.class | ||
333 | LogicproblemPackage.eINSTANCE.class | ||
334 | PartialinterpretationPackage.eINSTANCE.class | ||
335 | Ecore2logicannotationsPackage.eINSTANCE.class | ||
336 | Viatra2LogicAnnotationsPackage.eINSTANCE.class | ||
337 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("*", new XMIResourceFactoryImpl) | ||
338 | } | ||
339 | |||
340 | def static void main(String[] args) { | ||
341 | if (args.length != 2) { | ||
342 | System.err.println("Usage: <query> <model size>") | ||
343 | } | ||
344 | val monitoringQuery = MonitoringQuery.valueOf(args.get(0)) | ||
345 | val modelSize = Integer.parseInt(args.get(1)) | ||
346 | init() | ||
347 | val generator = new Modes3ModelGenerator(monitoringQuery, modelSize) | ||
348 | generator.generate() | ||
349 | } | ||
350 | |||
351 | private static enum MonitoringQuery { | ||
352 | closeTrains, | ||
353 | trainLocations, | ||
354 | endOfSiding, | ||
355 | misalignedTurnout | ||
356 | } | ||
357 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3TypeScopeHint.xtend b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3TypeScopeHint.xtend new file mode 100644 index 00000000..94e5eb08 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3TypeScopeHint.xtend | |||
@@ -0,0 +1,79 @@ | |||
1 | package modes3.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator | ||
10 | import java.util.Map | ||
11 | import modes3.Modes3Package | ||
12 | import modes3.queries.Adjacent | ||
13 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | ||
14 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | ||
15 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | ||
16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
17 | |||
18 | class Modes3TypeScopeHint implements LinearTypeConstraintHint { | ||
19 | static val TURNOUT_NEIGHBOR_COUNT = "turnoutNeighborCount" | ||
20 | |||
21 | val Type segmentType | ||
22 | val Type turnoutType | ||
23 | |||
24 | new(extension Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { | ||
25 | extension val Modes3Package = Modes3Package.eINSTANCE | ||
26 | segmentType = ecore2LogicTrace.TypeofEClass(segment) | ||
27 | turnoutType = ecore2LogicTrace.TypeofEClass(turnout) | ||
28 | } | ||
29 | |||
30 | override getAdditionalPatterns(extension PatternGenerator patternGenerator, Map<String, PQuery> fqnToPQuery) { | ||
31 | ''' | ||
32 | pattern «TURNOUT_NEIGHBOR_COUNT»_helper(problem: LogicProblem, interpretation: PartialInterpretation, source: DefinedElement, target: DefinedElement) { | ||
33 | find interpretation(problem, interpretation); | ||
34 | find mustExist(problem, interpretation, source); | ||
35 | find mustExist(problem, interpretation, target); | ||
36 | «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "source")» | ||
37 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "target")» | ||
38 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["source", "target"], Modality.MUST, true, false)» | ||
39 | } | ||
40 | |||
41 | pattern «TURNOUT_NEIGHBOR_COUNT»(problem: LogicProblem, interpretation: PartialInterpretation, element: DefinedElement, N) { | ||
42 | find interpretation(problem, interpretation); | ||
43 | find mustExist(problem, interpretation, element); | ||
44 | «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "element")» | ||
45 | N == count find «TURNOUT_NEIGHBOR_COUNT»_helper(problem, interpretation, element, _); | ||
46 | } | ||
47 | ''' | ||
48 | } | ||
49 | |||
50 | override createConstraintUpdater(LinearTypeExpressionBuilderFactory builderFactory) { | ||
51 | val turnoutNeighborCountMatcher = builderFactory.createMatcher(TURNOUT_NEIGHBOR_COUNT) | ||
52 | val newNeighbors = builderFactory.createBuilder.add(1, segmentType).build | ||
53 | |||
54 | return [ partialInterpretation | | ||
55 | val requiredNeighbbors = turnoutNeighborCountMatcher.getRemainingCount(partialInterpretation, 3) | ||
56 | newNeighbors.tightenLowerBound(requiredNeighbbors) | ||
57 | ] | ||
58 | } | ||
59 | |||
60 | private static def <T extends IPatternMatch> getRemainingCount(ViatraQueryMatcher<T> matcher, | ||
61 | PartialInterpretation partialInterpretation, int capacity) { | ||
62 | val partialMatch = matcher.newEmptyMatch | ||
63 | partialMatch.set(0, partialInterpretation.problem) | ||
64 | partialMatch.set(1, partialInterpretation) | ||
65 | val iterator = matcher.streamAllMatches(partialMatch).iterator | ||
66 | var int max = 0 | ||
67 | while (iterator.hasNext) { | ||
68 | val match = iterator.next | ||
69 | val n = (match.get(3) as Integer).intValue | ||
70 | if (n < capacity) { | ||
71 | val required = capacity - n | ||
72 | if (max < required) { | ||
73 | max = required | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | max | ||
78 | } | ||
79 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3UnitPropagationGenerator.xtend b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3UnitPropagationGenerator.xtend new file mode 100644 index 00000000..953a21d4 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/Modes3UnitPropagationGenerator.xtend | |||
@@ -0,0 +1,417 @@ | |||
1 | package modes3.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.UnitPropagationPatternGenerator | ||
10 | import java.util.Map | ||
11 | import modes3.Modes3Package | ||
12 | import modes3.queries.Adjacent | ||
13 | import modes3.queries.Output | ||
14 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | ||
15 | import org.eclipse.xtend2.lib.StringConcatenationClient | ||
16 | |||
17 | class Modes3UnitPropagationGenerator implements UnitPropagationPatternGenerator { | ||
18 | static val MUST_NOT_CONNECTED_TO = "mustNotConnectedTo" | ||
19 | static val MUST_NOT_STRAIGHT = "mustNotStraight" | ||
20 | static val MUST_NOT_DIVERGENT = "mustNotDivergent" | ||
21 | static val MUST_CONNECTED_TO = "mustConnectedTo" | ||
22 | static val MUST_STRAIGHT = "mustStraight" | ||
23 | static val MUST_DIVERGENT = "mustDivergent" | ||
24 | |||
25 | val Type segmentType | ||
26 | val Type simpleSegmentType | ||
27 | val Type turnoutType | ||
28 | val Relation connectedToRelation | ||
29 | val Relation straightRelation | ||
30 | val Relation divergentRelation | ||
31 | |||
32 | new(extension Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { | ||
33 | extension val Modes3Package = Modes3Package.eINSTANCE | ||
34 | segmentType = ecore2LogicTrace.TypeofEClass(segment) | ||
35 | simpleSegmentType = ecore2LogicTrace.TypeofEClass(simpleSegment) | ||
36 | turnoutType = ecore2LogicTrace.TypeofEClass(turnout) | ||
37 | connectedToRelation = ecore2LogicTrace.relationOfReference(segment_ConnectedTo) | ||
38 | straightRelation = ecore2LogicTrace.relationOfReference(turnout_Straight) | ||
39 | divergentRelation = ecore2LogicTrace.relationOfReference(turnout_Divergent) | ||
40 | } | ||
41 | |||
42 | override getMustPatterns() { | ||
43 | #{ | ||
44 | connectedToRelation -> MUST_CONNECTED_TO, | ||
45 | straightRelation -> MUST_STRAIGHT, | ||
46 | divergentRelation -> MUST_DIVERGENT | ||
47 | } | ||
48 | } | ||
49 | |||
50 | override getMustNotPatterns() { | ||
51 | #{ | ||
52 | connectedToRelation -> MUST_NOT_CONNECTED_TO, | ||
53 | straightRelation -> MUST_NOT_STRAIGHT, | ||
54 | divergentRelation -> MUST_NOT_DIVERGENT | ||
55 | } | ||
56 | } | ||
57 | |||
58 | override getAdditionalPatterns(extension PatternGenerator generator, Map<String, PQuery> fqnToPQuery) { | ||
59 | val StringConcatenationClient parameters = ''' | ||
60 | problem: LogicProblem, interpretation: PartialInterpretation, | ||
61 | source: DefinedElement, target: DefinedElement | ||
62 | ''' | ||
63 | |||
64 | val StringConcatenationClient commonMustParameterConstraints = ''' | ||
65 | find interpretation(problem, interpretation); | ||
66 | find mustExist(problem, interpretation, source); | ||
67 | find mustExist(problem, interpretation, target); | ||
68 | ''' | ||
69 | |||
70 | val StringConcatenationClient commonMayParameterConstraints = ''' | ||
71 | find interpretation(problem, interpretation); | ||
72 | find mayExist(problem, interpretation, source); | ||
73 | find mayExist(problem, interpretation, target); | ||
74 | ''' | ||
75 | |||
76 | ''' | ||
77 | pattern mayInput(«parameters») { | ||
78 | «commonMayParameterConstraints» | ||
79 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
80 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["target", "source"], Modality.MAY, true, false)» | ||
81 | neg «referRelation(straightRelation, "target", "source", Modality.MUST, fqnToPQuery)» | ||
82 | neg «referRelation(straightRelation, "target", "source", Modality.MUST, fqnToPQuery)» | ||
83 | } | ||
84 | |||
85 | pattern multipleMayInput(problem: LogicProblem, interpretation: PartialInterpretation, | ||
86 | target: DefinedElement) { | ||
87 | find interpretation(problem, interpretation); | ||
88 | find mustExist(problem, interpretation, target); | ||
89 | find mayInput(problem, interpretaton, source1, target); | ||
90 | find mayInput(problem, interpretaton, source2, target); | ||
91 | neg find mustEquivalent(problem, interpretation, source1, source2); | ||
92 | } | ||
93 | |||
94 | pattern multipleMayStraight(problem: LogicProblem, interpretation: PartialInterpretation, | ||
95 | source: DefinedElement) { | ||
96 | find interpretation(problem, interpretation); | ||
97 | find mustExist(problem, interpretation, source); | ||
98 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
99 | «referRelation(straightRelation, "source", "target1", Modality.MAY, fqnToPQuery)» | ||
100 | «referRelation(straightRelation, "source", "target2", Modality.MAY, fqnToPQuery)» | ||
101 | neg find mustEquivalent(problem, interpretation, target1, target2); | ||
102 | } | ||
103 | |||
104 | pattern multipleMayDivergent(problem: LogicProblem, interpretation: PartialInterpretation, | ||
105 | source: DefinedElement) { | ||
106 | find interpretation(problem, interpretation); | ||
107 | find mustExist(problem, interpretation, source); | ||
108 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
109 | «referRelation(divergentRelation, "source", "target1", Modality.MAY, fqnToPQuery)» | ||
110 | «referRelation(divergentRelation, "source", "target2", Modality.MAY, fqnToPQuery)» | ||
111 | neg find mustEquivalent(problem, interpretation, target1, target2); | ||
112 | } | ||
113 | |||
114 | pattern «MUST_CONNECTED_TO»(«parameters») { | ||
115 | «commonMustParameterConstraints» | ||
116 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
117 | find mayInput(problem, interpretaton, source, target); | ||
118 | neg find multipleMayInput(problem, interpretaton, target); | ||
119 | «referRelation(connectedToRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
120 | neg «referRelation(connectedToRelation, "source", "target", Modality.MUST, fqnToPQuery)» | ||
121 | neg «referRelation(straightRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
122 | neg «referRelation(divergentRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
123 | } | ||
124 | |||
125 | pattern «MUST_STRAIGHT»(«parameters») { | ||
126 | «commonMustParameterConstraints» | ||
127 | neg «referRelation(straightRelation, "source", "_", Modality.MUST, fqnToPQuery)» | ||
128 | neg find multipleMayStraight(problem, interpretation, source); | ||
129 | «referRelation(straightRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
130 | neg «referRelation(straightRelation, "source", "target", Modality.MUST, fqnToPQuery)» | ||
131 | } or { | ||
132 | «commonMustParameterConstraints» | ||
133 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
134 | find mayInput(problem, interpretaton, source, target); | ||
135 | neg find multipleMayInput(problem, interpretaton, target); | ||
136 | neg «referRelation(connectedToRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
137 | «referRelation(straightRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
138 | neg «referRelation(straightRelation, "source", "target", Modality.MUST, fqnToPQuery)» | ||
139 | neg «referRelation(divergentRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
140 | } | ||
141 | |||
142 | pattern «MUST_DIVERGENT»(«parameters») { | ||
143 | «commonMustParameterConstraints» | ||
144 | neg «referRelation(divergentRelation, "source", "_", Modality.MUST, fqnToPQuery)» | ||
145 | neg find multipleMayDivergent(problem, interpretation, source); | ||
146 | «referRelation(divergentRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
147 | neg «referRelation(divergentRelation, "source", "target", Modality.MUST, fqnToPQuery)» | ||
148 | } or { | ||
149 | «commonMustParameterConstraints» | ||
150 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
151 | find mayInput(problem, interpretaton, source, target); | ||
152 | neg find multipleMayInput(problem, interpretaton, target); | ||
153 | neg «referRelation(connectedToRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
154 | neg «referRelation(straightRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
155 | «referRelation(divergentRelation, "source", "target", Modality.MAY, fqnToPQuery)» | ||
156 | neg «referRelation(divergentRelation, "source", "target", Modality.MUST, fqnToPQuery)» | ||
157 | } | ||
158 | |||
159 | pattern turnoutOutput_must_to_true_by_straight(«parameters», T : DefinedElement, S : DefinedElement) { | ||
160 | «commonMayParameterConstraints» | ||
161 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
162 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
163 | T == source; | ||
164 | S == target; | ||
165 | } | ||
166 | |||
167 | pattern turnoutOutput_must_to_true_by_divergent(«parameters», T : DefinedElement, S : DefinedElement) { | ||
168 | «commonMayParameterConstraints» | ||
169 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
170 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
171 | T == source; | ||
172 | S == target; | ||
173 | } | ||
174 | |||
175 | pattern output_must_to_true_by_connectedTo(«parameters», S1 : DefinedElement, S2 : DefinedElement) { | ||
176 | «commonMayParameterConstraints» | ||
177 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "source")» | ||
178 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
179 | S1 == source; | ||
180 | S2 == target; | ||
181 | } | ||
182 | |||
183 | pattern output_must_to_true_by_straight(«parameters», S1 : DefinedElement, S2 : DefinedElement) { | ||
184 | find turnoutOutput_must_to_true_by_straight(problem, interpretation, source, target, S1, S2); | ||
185 | } | ||
186 | |||
187 | pattern output_must_to_true_by_divergent(«parameters», S1 : DefinedElement, S2 : DefinedElement) { | ||
188 | find turnoutOutput_must_to_true_by_divergent(problem, interpretation, source, target, S1, S2); | ||
189 | } | ||
190 | |||
191 | pattern adjacent_must_to_true_by_connectedTo(«parameters», S1 : DefinedElement, S2 : DefinedElement) { | ||
192 | find output_must_to_true_by_connectedTo(problem, interpretation, source, target, S1, S2); | ||
193 | } | ||
194 | |||
195 | pattern adjacent_must_to_true_by_straight(«parameters», S1 : DefinedElement, S2 : DefinedElement) { | ||
196 | find output_must_to_true_by_straight(problem, interpretation, source, target, S1, S2); | ||
197 | } or { | ||
198 | find turnoutOutput_must_to_true_by_straight(problem, interpretation, source, target, S2, S1); | ||
199 | } | ||
200 | |||
201 | pattern adjacent_must_to_true_by_divergent(«parameters», S1 : DefinedElement, S2 : DefinedElement) { | ||
202 | find output_must_to_true_by_divergent(problem, interpretation, source, target, S1, S2); | ||
203 | } or { | ||
204 | find turnoutOutput_must_to_true_by_divergent(problem, interpretation, source, target, S2, S1); | ||
205 | } | ||
206 | |||
207 | pattern connectedToReflexive_must_to_true_by_connectedTo(«parameters», S : DefinedElement) { | ||
208 | find mustExist(problem, interpretation, source); | ||
209 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "source")» | ||
210 | S == source; | ||
211 | S == target; | ||
212 | } | ||
213 | |||
214 | pattern outputReflexive_must_to_true_by_straight(«parameters», T : DefinedElement) { | ||
215 | find turnoutOutput_must_to_true_by_straight(problem, interpretation, source, target, T, T); | ||
216 | } | ||
217 | |||
218 | pattern outputReflexive_must_to_true_by_divergent(«parameters», T : DefinedElement) { | ||
219 | find turnoutOutput_must_to_true_by_divergent(problem, interpretation, source, target, T, T); | ||
220 | } | ||
221 | |||
222 | pattern turnoutOutputsAreSame_must_to_true_by_straight(«parameters», T : DefinedElement) { | ||
223 | «commonMayParameterConstraints» | ||
224 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
225 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
226 | T == source; | ||
227 | S == target; | ||
228 | «referRelation(divergentRelation, "T", "S", Modality.MUST, fqnToPQuery)» | ||
229 | } | ||
230 | |||
231 | pattern turnoutOutputsAreSame_must_to_true_by_divergent(«parameters», T : DefinedElement) { | ||
232 | «commonMayParameterConstraints» | ||
233 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
234 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
235 | T == source; | ||
236 | S == target; | ||
237 | «referRelation(straightRelation, "T", "S", Modality.MUST, fqnToPQuery)» | ||
238 | } | ||
239 | |||
240 | pattern tooManyInputsOfSegment_must_to_true_by_connectedTo(«parameters», S : DefinedElement) { | ||
241 | find mustExist(problem, interpretation, S); | ||
242 | «typeIndexer.referInstanceOf(simpleSegmentType, Modality.MUST, "S")» | ||
243 | find output_must_to_true_by_connectedTo(problem, interpretation, source, target, I1, S); | ||
244 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["I2", "S"], Modality.MUST, true, false)» | ||
245 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["I3", "S"], Modality.MUST, true, false)» | ||
246 | I1 != I2; | ||
247 | I1 != I3; | ||
248 | I2 != I3; | ||
249 | } | ||
250 | |||
251 | pattern tooManyInputsOfSegment_must_to_true_by_straight(«parameters», S : DefinedElement) { | ||
252 | find mustExist(problem, interpretation, S); | ||
253 | «typeIndexer.referInstanceOf(simpleSegmentType, Modality.MUST, "S")» | ||
254 | find output_must_to_true_by_straight(problem, interpretation, source, target, I1, S); | ||
255 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["I2", "S"], Modality.MUST, true, false)» | ||
256 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["I3", "S"], Modality.MUST, true, false)» | ||
257 | I1 != I2; | ||
258 | I1 != I3; | ||
259 | I2 != I3; | ||
260 | } | ||
261 | |||
262 | pattern tooManyInputsOfSegment_must_to_true_by_divergent(«parameters», S : DefinedElement) { | ||
263 | find mustExist(problem, interpretation, S); | ||
264 | «typeIndexer.referInstanceOf(simpleSegmentType, Modality.MUST, "S")» | ||
265 | find output_must_to_true_by_divergent(problem, interpretation, source, target, I1, S); | ||
266 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["I2", "S"], Modality.MUST, true, false)» | ||
267 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Output.instance.fullyQualifiedName), #["I3", "S"], Modality.MUST, true, false)» | ||
268 | I1 != I2; | ||
269 | I1 != I3; | ||
270 | I2 != I3; | ||
271 | } | ||
272 | |||
273 | pattern turnoutConnectedToBothOutputs_must_to_true_by_connectedTo(«parameters», T : DefinedElement) { | ||
274 | «commonMayParameterConstraints» | ||
275 | find mustExist(problem, interpretation, Straight); | ||
276 | find mustExist(problem, interpretation, Divergent); | ||
277 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
278 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
279 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Straight")» | ||
280 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Divergent")» | ||
281 | «referRelation(straightRelation, "T", "Straight", Modality.MUST, fqnToPQuery)» | ||
282 | «referRelation(divergentRelation, "T", "Divergent", Modality.MUST, fqnToPQuery)» | ||
283 | T == source; | ||
284 | Straight == target; | ||
285 | «referRelation(connectedToRelation, "T", "Divergent", Modality.MUST, fqnToPQuery)» | ||
286 | } or { | ||
287 | «commonMayParameterConstraints» | ||
288 | find mustExist(problem, interpretation, Straight); | ||
289 | find mustExist(problem, interpretation, Divergent); | ||
290 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
291 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
292 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Straight")» | ||
293 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Divergent")» | ||
294 | «referRelation(straightRelation, "T", "Straight", Modality.MUST, fqnToPQuery)» | ||
295 | «referRelation(divergentRelation, "T", "Divergent", Modality.MUST, fqnToPQuery)» | ||
296 | «referRelation(connectedToRelation, "T", "Straight", Modality.MUST, fqnToPQuery)» | ||
297 | T == source; | ||
298 | Straight == target; | ||
299 | } | ||
300 | |||
301 | pattern turnoutConnectedToBothOutputs_must_to_true_by_straight(«parameters», T : DefinedElement) { | ||
302 | «commonMayParameterConstraints» | ||
303 | find mustExist(problem, interpretation, Straight); | ||
304 | find mustExist(problem, interpretation, Divergent); | ||
305 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
306 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
307 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Straight")» | ||
308 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Divergent")» | ||
309 | T == source; | ||
310 | Straight == target; | ||
311 | «referRelation(divergentRelation, "T", "Divergent", Modality.MUST, fqnToPQuery)» | ||
312 | «referRelation(connectedToRelation, "T", "Straight", Modality.MUST, fqnToPQuery)» | ||
313 | «referRelation(connectedToRelation, "T", "Divergent", Modality.MUST, fqnToPQuery)» | ||
314 | } | ||
315 | |||
316 | pattern turnoutConnectedToBothOutputs_must_to_true_by_divergent(«parameters», T : DefinedElement) { | ||
317 | «commonMayParameterConstraints» | ||
318 | find mustExist(problem, interpretation, Straight); | ||
319 | find mustExist(problem, interpretation, Divergent); | ||
320 | «typeIndexer.referInstanceOf(turnoutType, Modality.MAY, "source")» | ||
321 | «typeIndexer.referInstanceOf(segmentType, Modality.MAY, "target")» | ||
322 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Straight")» | ||
323 | «typeIndexer.referInstanceOf(segmentType, Modality.MUST, "Divergent")» | ||
324 | «referRelation(straightRelation, "T", "Straight", Modality.MUST, fqnToPQuery)» | ||
325 | T == source; | ||
326 | Divergent == target; | ||
327 | «referRelation(connectedToRelation, "T", "Straight", Modality.MUST, fqnToPQuery)» | ||
328 | «referRelation(connectedToRelation, "T", "Divergent", Modality.MUST, fqnToPQuery)» | ||
329 | } | ||
330 | |||
331 | pattern tooManyInputsOfTurnout_must_to_true_by_connectedTo(«parameters», T : DefinedElement) { | ||
332 | find mustExist(problem, interpretation, S); | ||
333 | «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "S")» | ||
334 | find adjacent_must_to_true_by_connectedTo(problem, interpretation, source, target, I1, S); | ||
335 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I2", "S"], Modality.MUST, true, false)» | ||
336 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I3", "S"], Modality.MUST, true, false)» | ||
337 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I4", "S"], Modality.MUST, true, false)» | ||
338 | I1 != I2; | ||
339 | I1 != I3; | ||
340 | I1 != I4; | ||
341 | I2 != I3; | ||
342 | I2 != I4; | ||
343 | I3 != I4; | ||
344 | } | ||
345 | |||
346 | pattern tooManyInputsOfTurnout_must_to_true_by_straight(«parameters», T : DefinedElement) { | ||
347 | find mustExist(problem, interpretation, S); | ||
348 | «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "S")» | ||
349 | find adjacent_must_to_true_by_straight(problem, interpretation, source, target, I1, S); | ||
350 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I2", "S"], Modality.MUST, true, false)» | ||
351 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I3", "S"], Modality.MUST, true, false)» | ||
352 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I4", "S"], Modality.MUST, true, false)» | ||
353 | I1 != I2; | ||
354 | I1 != I3; | ||
355 | I1 != I4; | ||
356 | I2 != I3; | ||
357 | I2 != I4; | ||
358 | I3 != I4; | ||
359 | } | ||
360 | |||
361 | pattern tooManyInputsOfTurnout_must_to_true_by_divergent(«parameters», T : DefinedElement) { | ||
362 | find mustExist(problem, interpretation, S); | ||
363 | «typeIndexer.referInstanceOf(turnoutType, Modality.MUST, "S")» | ||
364 | find adjacent_must_to_true_by_divergent(problem, interpretation, source, target, I1, S); | ||
365 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I2", "S"], Modality.MUST, true, false)» | ||
366 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I3", "S"], Modality.MUST, true, false)» | ||
367 | «relationDefinitionIndexer.referPattern(fqnToPQuery.get(Adjacent.instance.fullyQualifiedName), #["I4", "S"], Modality.MUST, true, false)» | ||
368 | I1 != I2; | ||
369 | I1 != I3; | ||
370 | I1 != I4; | ||
371 | I2 != I3; | ||
372 | I2 != I4; | ||
373 | I3 != I4; | ||
374 | } | ||
375 | |||
376 | pattern «MUST_NOT_CONNECTED_TO»_helper(«parameters») { | ||
377 | find connectedToReflexive_must_to_true_by_connectedTo(problem, interpretation, source, target, _); | ||
378 | } or { | ||
379 | find tooManyInputsOfSegment_must_to_true_by_connectedTo(problem, interpretation, source, target, _); | ||
380 | } or { | ||
381 | find turnoutConnectedToBothOutputs_must_to_true_by_connectedTo(problem, interpretation, source, target, _); | ||
382 | } or { | ||
383 | find tooManyInputsOfTurnout_must_to_true_by_connectedTo(problem, interpretation, source, target, _); | ||
384 | } | ||
385 | |||
386 | pattern «MUST_NOT_CONNECTED_TO»(«parameters») { | ||
387 | find «MUST_NOT_CONNECTED_TO»_helper(problem, interpretation, source, target); | ||
388 | } or { | ||
389 | find «MUST_NOT_CONNECTED_TO»_helper(problem, interpretation, target, source); | ||
390 | } | ||
391 | |||
392 | pattern «MUST_NOT_STRAIGHT»(«parameters») { | ||
393 | find outputReflexive_must_to_true_by_straight(problem, interpretation, source, target, _); | ||
394 | } or { | ||
395 | find turnoutOutputsAreSame_must_to_true_by_straight(problem, interpretation, source, target, _); | ||
396 | } or { | ||
397 | find tooManyInputsOfSegment_must_to_true_by_straight(problem, interpretation, source, target, _); | ||
398 | } or { | ||
399 | find turnoutConnectedToBothOutputs_must_to_true_by_straight(problem, interpretation, source, target, _); | ||
400 | } or { | ||
401 | find tooManyInputsOfTurnout_must_to_true_by_straight(problem, interpretation, source, target, _); | ||
402 | } | ||
403 | |||
404 | pattern «MUST_NOT_DIVERGENT»(«parameters») { | ||
405 | find outputReflexive_must_to_true_by_divergent(problem, interpretation, source, target, _); | ||
406 | } or { | ||
407 | find turnoutOutputsAreSame_must_to_true_by_divergent(problem, interpretation, source, target, _); | ||
408 | } or { | ||
409 | find tooManyInputsOfSegment_must_to_true_by_divergent(problem, interpretation, source, target, _); | ||
410 | } or { | ||
411 | find turnoutConnectedToBothOutputs_must_to_true_by_divergent(problem, interpretation, source, target, _); | ||
412 | } or { | ||
413 | find tooManyInputsOfTurnout_must_to_true_by_divergent(problem, interpretation, source, target, _); | ||
414 | } | ||
415 | ''' | ||
416 | } | ||
417 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/TrainLocationsObjectiveHint.xtend b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/TrainLocationsObjectiveHint.xtend new file mode 100644 index 00000000..cc2d7925 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/run/TrainLocationsObjectiveHint.xtend | |||
@@ -0,0 +1,85 @@ | |||
1 | package modes3.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint | ||
10 | import java.util.Collection | ||
11 | import java.util.Map | ||
12 | import modes3.Modes3Package | ||
13 | import modes3.queries.TrainLocations_step_2 | ||
14 | import modes3.queries.TrainLocations_step_3 | ||
15 | |||
16 | class TrainLocationsObjectiveHint extends CostObjectiveHint { | ||
17 | val Type segmentType | ||
18 | val Type trainType | ||
19 | |||
20 | new(extension Ecore2Logic ecore2Logic, Ecore2Logic_Trace ecore2LogicTrace) { | ||
21 | extension val Modes3Package = Modes3Package.eINSTANCE | ||
22 | segmentType = ecore2LogicTrace.TypeofEClass(segment) | ||
23 | trainType = ecore2LogicTrace.TypeofEClass(train) | ||
24 | } | ||
25 | |||
26 | override isExact() { | ||
27 | true | ||
28 | } | ||
29 | |||
30 | override createPolyhedronExtensionOperator(Map<String, CostElementMatchers> costElementMatchers) { | ||
31 | val step2 = costElementMatchers.get(TrainLocations_step_2.instance.fullyQualifiedName) | ||
32 | val step3 = costElementMatchers.get(TrainLocations_step_3.instance.fullyQualifiedName); | ||
33 | |||
34 | [ | ||
35 | val objectiveBuilder = createBuilder | ||
36 | |||
37 | for (m : step2.matches) { | ||
38 | val dimension = getDimension(m.match) | ||
39 | objectiveBuilder.add(step2.weight, dimension) | ||
40 | dimension.tightenLowerBound(0) | ||
41 | if (m.multi) { | ||
42 | createBuilder.add(1, dimension).add(-1, trainType).build.assertEqualsTo(0) | ||
43 | } else { | ||
44 | dimension.tightenUpperBound(1) | ||
45 | if (m.must) { | ||
46 | dimension.tightenLowerBound(1) | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | |||
51 | val step3Matches = step3.matches | ||
52 | for (m : step3Matches) { | ||
53 | val dimension = getDimension(m.match) | ||
54 | objectiveBuilder.add(step3.weight, dimension) | ||
55 | dimension.tightenLowerBound(0) | ||
56 | if (!m.multi) { | ||
57 | dimension.tightenUpperBound(1) | ||
58 | if (m.must) { | ||
59 | dimension.tightenLowerBound(1) | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | boundLimit(step3Matches, 2, trainType, 1) | ||
64 | boundLimit(step3Matches, 3, segmentType, 1) | ||
65 | |||
66 | objectiveBuilder.buildWithBounds | ||
67 | ] | ||
68 | } | ||
69 | |||
70 | private static def boundLimit(extension ExtendedLinearExpressionBuilderFactory factory, | ||
71 | Collection<CostElementMatch> matches, int index, Type type, int count) { | ||
72 | for (pair : matches.groupBy[match.get(index)].entrySet) { | ||
73 | val multiplicityBuilder = createBuilder | ||
74 | for (m : pair.value) { | ||
75 | multiplicityBuilder.add(1, m.match) | ||
76 | } | ||
77 | if (CostElementMatchers.isMulti(pair.key)) { | ||
78 | multiplicityBuilder.add(-count, type) | ||
79 | multiplicityBuilder.build.tightenUpperBound(0) | ||
80 | } else { | ||
81 | multiplicityBuilder.build.tightenUpperBound(count) | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | } \ No newline at end of file | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/.gitignore b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/.gitignore new file mode 100644 index 00000000..a84c2906 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/.gitignore | |||
@@ -0,0 +1,78 @@ | |||
1 | /.ConnectedToReflexive.java._trace | ||
2 | /.Modes3Queries.java._trace | ||
3 | /.StraightReflexive.java._trace | ||
4 | /.DivergentReflexive.java._trace | ||
5 | /.TurnoutOutputsAreSame.java._trace | ||
6 | /.Adjacent.java._trace | ||
7 | /.Output.java._trace | ||
8 | /.OutputReflexive.java._trace | ||
9 | /.TooManyAdjacentSegmentsOfSegment.java._trace | ||
10 | /.Turnout.java._trace | ||
11 | /.ConnectedTo.java._trace | ||
12 | /.TurnoutNotConnectedToOutput.java._trace | ||
13 | /.DisjointNetwork.java._trace | ||
14 | /.Reachable.java._trace | ||
15 | /.Unreachable.java._trace | ||
16 | /.TurnoutInSegments.java._trace | ||
17 | /.ConnectedToNotSymmetric.java._trace | ||
18 | /.TurnoutConnectedToBothOutputs.java._trace | ||
19 | /.TooManyAdjacentTurnouts.java._trace | ||
20 | /.NoAdjacentSegmentOfSegment.java._trace | ||
21 | /.TurnoutOutput.java._trace | ||
22 | /.NoInputOfSegment.java._trace | ||
23 | /.TooManyInputsOfSegment.java._trace | ||
24 | /.ExtraInputOfTurnout.java._trace | ||
25 | /.NoExtraInputOfTurnout.java._trace | ||
26 | /.TooManyExtraInputsOfTurnout.java._trace | ||
27 | /.TooManyInputsOfTurnout.java._trace | ||
28 | /.NonDivergentInputOfTurnout.java._trace | ||
29 | /.NonStraightInputOfTurnout.java._trace | ||
30 | /.TooManyNonDivergentInputsOfTurnout.java._trace | ||
31 | /.TooManyNonStraightInputsOfTurnout.java._trace | ||
32 | /.InputsOfTurnout.java._trace | ||
33 | /.TooFewInputsOfTurnout.java._trace | ||
34 | /.CloseTrains_step_2.java._trace | ||
35 | /.CloseTrains_step_3.java._trace | ||
36 | /.CloseTrains_step_4.java._trace | ||
37 | /.CloseTrains_step_5.java._trace | ||
38 | /.CloseTrains_step_6.java._trace | ||
39 | /.CloseTrains_step_7.java._trace | ||
40 | /.MisalignedTurnout_step_2.java._trace | ||
41 | /.MisalignedTurnout_step_3.java._trace | ||
42 | /.MisalignedTurnout_step_4.java._trace | ||
43 | /.MisalignedTurnout_step_5.java._trace | ||
44 | /.ConnectedSegmentsDirected.java._trace | ||
45 | /Adjacent.java | ||
46 | /CloseTrains_step_2.java | ||
47 | /CloseTrains_step_3.java | ||
48 | /CloseTrains_step_4.java | ||
49 | /CloseTrains_step_5.java | ||
50 | /CloseTrains_step_6.java | ||
51 | /CloseTrains_step_7.java | ||
52 | /ConnectedSegmentsDirected.java | ||
53 | /ConnectedTo.java | ||
54 | /ConnectedToNotSymmetric.java | ||
55 | /ConnectedToReflexive.java | ||
56 | /InputsOfTurnout.java | ||
57 | /MisalignedTurnout_step_2.java | ||
58 | /MisalignedTurnout_step_3.java | ||
59 | /MisalignedTurnout_step_4.java | ||
60 | /MisalignedTurnout_step_5.java | ||
61 | /Modes3Queries.java | ||
62 | /Output.java | ||
63 | /OutputReflexive.java | ||
64 | /Reachable.java | ||
65 | /TooFewInputsOfTurnout.java | ||
66 | /TooManyInputsOfSegment.java | ||
67 | /TooManyInputsOfTurnout.java | ||
68 | /TurnoutConnectedToBothOutputs.java | ||
69 | /TurnoutOutput.java | ||
70 | /TurnoutOutputsAreSame.java | ||
71 | /Unreachable.java | ||
72 | /.TrainLocations_step_2.java._trace | ||
73 | /.TrainLocations_step_3.java._trace | ||
74 | /.EndOfSiding_step_2.java._trace | ||
75 | /.EndOfSiding_step_3.java._trace | ||
76 | /.EndOfSiding_step_4.java._trace | ||
77 | /.EndOfSiding_step_5.java._trace | ||
78 | /.MultipleConnectedTo.java._trace | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Adjacent.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Adjacent.java new file mode 100644 index 00000000..e87f9c18 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Adjacent.java | |||
@@ -0,0 +1,719 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.queries.Output; | ||
18 | import modes3.queries.TurnoutOutput; | ||
19 | import org.apache.log4j.Logger; | ||
20 | import org.eclipse.emf.ecore.EClass; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern adjacent(S1 : Segment, S2 : Segment) { | ||
48 | * find output(S1, S2); | ||
49 | * } or { | ||
50 | * find turnoutOutput(S2, S1); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class Adjacent extends BaseGeneratedEMFQuerySpecification<Adjacent.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.adjacent pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Segment fS1; | ||
74 | |||
75 | private Segment fS2; | ||
76 | |||
77 | private static List<String> parameterNames = makeImmutableList("S1", "S2"); | ||
78 | |||
79 | private Match(final Segment pS1, final Segment pS2) { | ||
80 | this.fS1 = pS1; | ||
81 | this.fS2 = pS2; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | switch(parameterName) { | ||
87 | case "S1": return this.fS1; | ||
88 | case "S2": return this.fS2; | ||
89 | default: return null; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | @Override | ||
94 | public Object get(final int index) { | ||
95 | switch(index) { | ||
96 | case 0: return this.fS1; | ||
97 | case 1: return this.fS2; | ||
98 | default: return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public Segment getS1() { | ||
103 | return this.fS1; | ||
104 | } | ||
105 | |||
106 | public Segment getS2() { | ||
107 | return this.fS2; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public boolean set(final String parameterName, final Object newValue) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | if ("S1".equals(parameterName) ) { | ||
114 | this.fS1 = (Segment) newValue; | ||
115 | return true; | ||
116 | } | ||
117 | if ("S2".equals(parameterName) ) { | ||
118 | this.fS2 = (Segment) newValue; | ||
119 | return true; | ||
120 | } | ||
121 | return false; | ||
122 | } | ||
123 | |||
124 | public void setS1(final Segment pS1) { | ||
125 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
126 | this.fS1 = pS1; | ||
127 | } | ||
128 | |||
129 | public void setS2(final Segment pS2) { | ||
130 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
131 | this.fS2 = pS2; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public String patternName() { | ||
136 | return "modes3.queries.adjacent"; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public List<String> parameterNames() { | ||
141 | return Adjacent.Match.parameterNames; | ||
142 | } | ||
143 | |||
144 | @Override | ||
145 | public Object[] toArray() { | ||
146 | return new Object[]{fS1, fS2}; | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public Adjacent.Match toImmutable() { | ||
151 | return isMutable() ? newMatch(fS1, fS2) : this; | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public String prettyPrint() { | ||
156 | StringBuilder result = new StringBuilder(); | ||
157 | result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); | ||
158 | result.append("\"S2\"=" + prettyPrintValue(fS2)); | ||
159 | return result.toString(); | ||
160 | } | ||
161 | |||
162 | @Override | ||
163 | public int hashCode() { | ||
164 | return Objects.hash(fS1, fS2); | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public boolean equals(final Object obj) { | ||
169 | if (this == obj) | ||
170 | return true; | ||
171 | if (obj == null) { | ||
172 | return false; | ||
173 | } | ||
174 | if ((obj instanceof Adjacent.Match)) { | ||
175 | Adjacent.Match other = (Adjacent.Match) obj; | ||
176 | return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); | ||
177 | } else { | ||
178 | // this should be infrequent | ||
179 | if (!(obj instanceof IPatternMatch)) { | ||
180 | return false; | ||
181 | } | ||
182 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
183 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | @Override | ||
188 | public Adjacent specification() { | ||
189 | return Adjacent.instance(); | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * Returns an empty, mutable match. | ||
194 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
195 | * | ||
196 | * @return the empty match. | ||
197 | * | ||
198 | */ | ||
199 | public static Adjacent.Match newEmptyMatch() { | ||
200 | return new Mutable(null, null); | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * Returns a mutable (partial) match. | ||
205 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
206 | * | ||
207 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
208 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
209 | * @return the new, mutable (partial) match object. | ||
210 | * | ||
211 | */ | ||
212 | public static Adjacent.Match newMutableMatch(final Segment pS1, final Segment pS2) { | ||
213 | return new Mutable(pS1, pS2); | ||
214 | } | ||
215 | |||
216 | /** | ||
217 | * Returns a new (partial) match. | ||
218 | * This can be used e.g. to call the matcher with a partial match. | ||
219 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
220 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
221 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
222 | * @return the (partial) match object. | ||
223 | * | ||
224 | */ | ||
225 | public static Adjacent.Match newMatch(final Segment pS1, final Segment pS2) { | ||
226 | return new Immutable(pS1, pS2); | ||
227 | } | ||
228 | |||
229 | private static final class Mutable extends Adjacent.Match { | ||
230 | Mutable(final Segment pS1, final Segment pS2) { | ||
231 | super(pS1, pS2); | ||
232 | } | ||
233 | |||
234 | @Override | ||
235 | public boolean isMutable() { | ||
236 | return true; | ||
237 | } | ||
238 | } | ||
239 | |||
240 | private static final class Immutable extends Adjacent.Match { | ||
241 | Immutable(final Segment pS1, final Segment pS2) { | ||
242 | super(pS1, pS2); | ||
243 | } | ||
244 | |||
245 | @Override | ||
246 | public boolean isMutable() { | ||
247 | return false; | ||
248 | } | ||
249 | } | ||
250 | } | ||
251 | |||
252 | /** | ||
253 | * Generated pattern matcher API of the modes3.queries.adjacent pattern, | ||
254 | * providing pattern-specific query methods. | ||
255 | * | ||
256 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
257 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
258 | * | ||
259 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
260 | * | ||
261 | * <p>Original source: | ||
262 | * <code><pre> | ||
263 | * pattern adjacent(S1 : Segment, S2 : Segment) { | ||
264 | * find output(S1, S2); | ||
265 | * } or { | ||
266 | * find turnoutOutput(S2, S1); | ||
267 | * } | ||
268 | * </pre></code> | ||
269 | * | ||
270 | * @see Match | ||
271 | * @see Adjacent | ||
272 | * | ||
273 | */ | ||
274 | public static class Matcher extends BaseMatcher<Adjacent.Match> { | ||
275 | /** | ||
276 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
277 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
278 | * | ||
279 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
280 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
281 | * | ||
282 | */ | ||
283 | public static Adjacent.Matcher on(final ViatraQueryEngine engine) { | ||
284 | // check if matcher already exists | ||
285 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
286 | if (matcher == null) { | ||
287 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
288 | } | ||
289 | return matcher; | ||
290 | } | ||
291 | |||
292 | /** | ||
293 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
294 | * @return an initialized matcher | ||
295 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
296 | * | ||
297 | */ | ||
298 | public static Adjacent.Matcher create() { | ||
299 | return new Matcher(); | ||
300 | } | ||
301 | |||
302 | private static final int POSITION_S1 = 0; | ||
303 | |||
304 | private static final int POSITION_S2 = 1; | ||
305 | |||
306 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Adjacent.Matcher.class); | ||
307 | |||
308 | /** | ||
309 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
310 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
311 | * | ||
312 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
313 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
314 | * | ||
315 | */ | ||
316 | private Matcher() { | ||
317 | super(querySpecification()); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
322 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
323 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
324 | * @return matches represented as a Match object. | ||
325 | * | ||
326 | */ | ||
327 | public Collection<Adjacent.Match> getAllMatches(final Segment pS1, final Segment pS2) { | ||
328 | return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
333 | * </p> | ||
334 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
335 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
336 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
337 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
338 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
339 | * @return a stream of matches represented as a Match object. | ||
340 | * | ||
341 | */ | ||
342 | public Stream<Adjacent.Match> streamAllMatches(final Segment pS1, final Segment pS2) { | ||
343 | return rawStreamAllMatches(new Object[]{pS1, pS2}); | ||
344 | } | ||
345 | |||
346 | /** | ||
347 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
348 | * Neither determinism nor randomness of selection is guaranteed. | ||
349 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
350 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
351 | * @return a match represented as a Match object, or null if no match is found. | ||
352 | * | ||
353 | */ | ||
354 | public Optional<Adjacent.Match> getOneArbitraryMatch(final Segment pS1, final Segment pS2) { | ||
355 | return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
360 | * under any possible substitution of the unspecified parameters (if any). | ||
361 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
362 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
363 | * @return true if the input is a valid (partial) match of the pattern. | ||
364 | * | ||
365 | */ | ||
366 | public boolean hasMatch(final Segment pS1, final Segment pS2) { | ||
367 | return rawHasMatch(new Object[]{pS1, pS2}); | ||
368 | } | ||
369 | |||
370 | /** | ||
371 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
372 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
373 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
374 | * @return the number of pattern matches found. | ||
375 | * | ||
376 | */ | ||
377 | public int countMatches(final Segment pS1, final Segment pS2) { | ||
378 | return rawCountMatches(new Object[]{pS1, pS2}); | ||
379 | } | ||
380 | |||
381 | /** | ||
382 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
383 | * Neither determinism nor randomness of selection is guaranteed. | ||
384 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
385 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
386 | * @param processor the action that will process the selected match. | ||
387 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
388 | * | ||
389 | */ | ||
390 | public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer<? super Adjacent.Match> processor) { | ||
391 | return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Returns a new (partial) match. | ||
396 | * This can be used e.g. to call the matcher with a partial match. | ||
397 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
398 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
399 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
400 | * @return the (partial) match object. | ||
401 | * | ||
402 | */ | ||
403 | public Adjacent.Match newMatch(final Segment pS1, final Segment pS2) { | ||
404 | return Adjacent.Match.newMatch(pS1, pS2); | ||
405 | } | ||
406 | |||
407 | /** | ||
408 | * Retrieve the set of values that occur in matches for S1. | ||
409 | * @return the Set of all values or empty set if there are no matches | ||
410 | * | ||
411 | */ | ||
412 | protected Stream<Segment> rawStreamAllValuesOfS1(final Object[] parameters) { | ||
413 | return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); | ||
414 | } | ||
415 | |||
416 | /** | ||
417 | * Retrieve the set of values that occur in matches for S1. | ||
418 | * @return the Set of all values or empty set if there are no matches | ||
419 | * | ||
420 | */ | ||
421 | public Set<Segment> getAllValuesOfS1() { | ||
422 | return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); | ||
423 | } | ||
424 | |||
425 | /** | ||
426 | * Retrieve the set of values that occur in matches for S1. | ||
427 | * @return the Set of all values or empty set if there are no matches | ||
428 | * | ||
429 | */ | ||
430 | public Stream<Segment> streamAllValuesOfS1() { | ||
431 | return rawStreamAllValuesOfS1(emptyArray()); | ||
432 | } | ||
433 | |||
434 | /** | ||
435 | * Retrieve the set of values that occur in matches for S1. | ||
436 | * </p> | ||
437 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
438 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
439 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
440 | * | ||
441 | * @return the Stream of all values or empty set if there are no matches | ||
442 | * | ||
443 | */ | ||
444 | public Stream<Segment> streamAllValuesOfS1(final Adjacent.Match partialMatch) { | ||
445 | return rawStreamAllValuesOfS1(partialMatch.toArray()); | ||
446 | } | ||
447 | |||
448 | /** | ||
449 | * Retrieve the set of values that occur in matches for S1. | ||
450 | * </p> | ||
451 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
452 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
453 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
454 | * | ||
455 | * @return the Stream of all values or empty set if there are no matches | ||
456 | * | ||
457 | */ | ||
458 | public Stream<Segment> streamAllValuesOfS1(final Segment pS2) { | ||
459 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}); | ||
460 | } | ||
461 | |||
462 | /** | ||
463 | * Retrieve the set of values that occur in matches for S1. | ||
464 | * @return the Set of all values or empty set if there are no matches | ||
465 | * | ||
466 | */ | ||
467 | public Set<Segment> getAllValuesOfS1(final Adjacent.Match partialMatch) { | ||
468 | return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); | ||
469 | } | ||
470 | |||
471 | /** | ||
472 | * Retrieve the set of values that occur in matches for S1. | ||
473 | * @return the Set of all values or empty set if there are no matches | ||
474 | * | ||
475 | */ | ||
476 | public Set<Segment> getAllValuesOfS1(final Segment pS2) { | ||
477 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Retrieve the set of values that occur in matches for S2. | ||
482 | * @return the Set of all values or empty set if there are no matches | ||
483 | * | ||
484 | */ | ||
485 | protected Stream<Segment> rawStreamAllValuesOfS2(final Object[] parameters) { | ||
486 | return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); | ||
487 | } | ||
488 | |||
489 | /** | ||
490 | * Retrieve the set of values that occur in matches for S2. | ||
491 | * @return the Set of all values or empty set if there are no matches | ||
492 | * | ||
493 | */ | ||
494 | public Set<Segment> getAllValuesOfS2() { | ||
495 | return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); | ||
496 | } | ||
497 | |||
498 | /** | ||
499 | * Retrieve the set of values that occur in matches for S2. | ||
500 | * @return the Set of all values or empty set if there are no matches | ||
501 | * | ||
502 | */ | ||
503 | public Stream<Segment> streamAllValuesOfS2() { | ||
504 | return rawStreamAllValuesOfS2(emptyArray()); | ||
505 | } | ||
506 | |||
507 | /** | ||
508 | * Retrieve the set of values that occur in matches for S2. | ||
509 | * </p> | ||
510 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
511 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
512 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
513 | * | ||
514 | * @return the Stream of all values or empty set if there are no matches | ||
515 | * | ||
516 | */ | ||
517 | public Stream<Segment> streamAllValuesOfS2(final Adjacent.Match partialMatch) { | ||
518 | return rawStreamAllValuesOfS2(partialMatch.toArray()); | ||
519 | } | ||
520 | |||
521 | /** | ||
522 | * Retrieve the set of values that occur in matches for S2. | ||
523 | * </p> | ||
524 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
525 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
526 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
527 | * | ||
528 | * @return the Stream of all values or empty set if there are no matches | ||
529 | * | ||
530 | */ | ||
531 | public Stream<Segment> streamAllValuesOfS2(final Segment pS1) { | ||
532 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}); | ||
533 | } | ||
534 | |||
535 | /** | ||
536 | * Retrieve the set of values that occur in matches for S2. | ||
537 | * @return the Set of all values or empty set if there are no matches | ||
538 | * | ||
539 | */ | ||
540 | public Set<Segment> getAllValuesOfS2(final Adjacent.Match partialMatch) { | ||
541 | return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); | ||
542 | } | ||
543 | |||
544 | /** | ||
545 | * Retrieve the set of values that occur in matches for S2. | ||
546 | * @return the Set of all values or empty set if there are no matches | ||
547 | * | ||
548 | */ | ||
549 | public Set<Segment> getAllValuesOfS2(final Segment pS1) { | ||
550 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); | ||
551 | } | ||
552 | |||
553 | @Override | ||
554 | protected Adjacent.Match tupleToMatch(final Tuple t) { | ||
555 | try { | ||
556 | return Adjacent.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); | ||
557 | } catch(ClassCastException e) { | ||
558 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
559 | return null; | ||
560 | } | ||
561 | } | ||
562 | |||
563 | @Override | ||
564 | protected Adjacent.Match arrayToMatch(final Object[] match) { | ||
565 | try { | ||
566 | return Adjacent.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
567 | } catch(ClassCastException e) { | ||
568 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
569 | return null; | ||
570 | } | ||
571 | } | ||
572 | |||
573 | @Override | ||
574 | protected Adjacent.Match arrayToMatchMutable(final Object[] match) { | ||
575 | try { | ||
576 | return Adjacent.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
577 | } catch(ClassCastException e) { | ||
578 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
579 | return null; | ||
580 | } | ||
581 | } | ||
582 | |||
583 | /** | ||
584 | * @return the singleton instance of the query specification of this pattern | ||
585 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
586 | * | ||
587 | */ | ||
588 | public static IQuerySpecification<Adjacent.Matcher> querySpecification() { | ||
589 | return Adjacent.instance(); | ||
590 | } | ||
591 | } | ||
592 | |||
593 | private Adjacent() { | ||
594 | super(GeneratedPQuery.INSTANCE); | ||
595 | } | ||
596 | |||
597 | /** | ||
598 | * @return the singleton instance of the query specification | ||
599 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
600 | * | ||
601 | */ | ||
602 | public static Adjacent instance() { | ||
603 | try{ | ||
604 | return LazyHolder.INSTANCE; | ||
605 | } catch (ExceptionInInitializerError err) { | ||
606 | throw processInitializerError(err); | ||
607 | } | ||
608 | } | ||
609 | |||
610 | @Override | ||
611 | protected Adjacent.Matcher instantiate(final ViatraQueryEngine engine) { | ||
612 | return Adjacent.Matcher.on(engine); | ||
613 | } | ||
614 | |||
615 | @Override | ||
616 | public Adjacent.Matcher instantiate() { | ||
617 | return Adjacent.Matcher.create(); | ||
618 | } | ||
619 | |||
620 | @Override | ||
621 | public Adjacent.Match newEmptyMatch() { | ||
622 | return Adjacent.Match.newEmptyMatch(); | ||
623 | } | ||
624 | |||
625 | @Override | ||
626 | public Adjacent.Match newMatch(final Object... parameters) { | ||
627 | return Adjacent.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); | ||
628 | } | ||
629 | |||
630 | /** | ||
631 | * Inner class allowing the singleton instance of {@link Adjacent} to be created | ||
632 | * <b>not</b> at the class load time of the outer class, | ||
633 | * but rather at the first call to {@link Adjacent#instance()}. | ||
634 | * | ||
635 | * <p> This workaround is required e.g. to support recursion. | ||
636 | * | ||
637 | */ | ||
638 | private static class LazyHolder { | ||
639 | private static final Adjacent INSTANCE = new Adjacent(); | ||
640 | |||
641 | /** | ||
642 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
643 | * This initialization order is required to support indirect recursion. | ||
644 | * | ||
645 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
646 | * | ||
647 | */ | ||
648 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
649 | |||
650 | public static Object ensureInitialized() { | ||
651 | INSTANCE.ensureInitializedInternal(); | ||
652 | return null; | ||
653 | } | ||
654 | } | ||
655 | |||
656 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
657 | private static final Adjacent.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
658 | |||
659 | private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
660 | |||
661 | private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
662 | |||
663 | private final List<PParameter> parameters = Arrays.asList(parameter_S1, parameter_S2); | ||
664 | |||
665 | private GeneratedPQuery() { | ||
666 | super(PVisibility.PUBLIC); | ||
667 | } | ||
668 | |||
669 | @Override | ||
670 | public String getFullyQualifiedName() { | ||
671 | return "modes3.queries.adjacent"; | ||
672 | } | ||
673 | |||
674 | @Override | ||
675 | public List<String> getParameterNames() { | ||
676 | return Arrays.asList("S1","S2"); | ||
677 | } | ||
678 | |||
679 | @Override | ||
680 | public List<PParameter> getParameters() { | ||
681 | return parameters; | ||
682 | } | ||
683 | |||
684 | @Override | ||
685 | public Set<PBody> doGetContainedBodies() { | ||
686 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
687 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
688 | { | ||
689 | PBody body = new PBody(this); | ||
690 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
691 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
692 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
693 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
694 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
695 | new ExportedParameter(body, var_S1, parameter_S1), | ||
696 | new ExportedParameter(body, var_S2, parameter_S2) | ||
697 | )); | ||
698 | // find output(S1, S2) | ||
699 | new PositivePatternCall(body, Tuples.flatTupleOf(var_S1, var_S2), Output.instance().getInternalQueryRepresentation()); | ||
700 | bodies.add(body); | ||
701 | } | ||
702 | { | ||
703 | PBody body = new PBody(this); | ||
704 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
705 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
706 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
707 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
708 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
709 | new ExportedParameter(body, var_S1, parameter_S1), | ||
710 | new ExportedParameter(body, var_S2, parameter_S2) | ||
711 | )); | ||
712 | // find turnoutOutput(S2, S1) | ||
713 | new PositivePatternCall(body, Tuples.flatTupleOf(var_S2, var_S1), TurnoutOutput.instance().getInternalQueryRepresentation()); | ||
714 | bodies.add(body); | ||
715 | } | ||
716 | return bodies; | ||
717 | } | ||
718 | } | ||
719 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedTo.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedTo.java new file mode 100644 index 00000000..a0f14958 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedTo.java | |||
@@ -0,0 +1,704 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
39 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
40 | |||
41 | /** | ||
42 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
43 | * | ||
44 | * <p>Original source: | ||
45 | * <code><pre> | ||
46 | * pattern connectedTo(S1 : Segment, S2 : Segment) { | ||
47 | * Segment.connectedTo(S1, S2); | ||
48 | * } | ||
49 | * </pre></code> | ||
50 | * | ||
51 | * @see Matcher | ||
52 | * @see Match | ||
53 | * | ||
54 | */ | ||
55 | @SuppressWarnings("all") | ||
56 | public final class ConnectedTo extends BaseGeneratedEMFQuerySpecification<ConnectedTo.Matcher> { | ||
57 | /** | ||
58 | * Pattern-specific match representation of the modes3.queries.connectedTo pattern, | ||
59 | * to be used in conjunction with {@link Matcher}. | ||
60 | * | ||
61 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
62 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
63 | * usable to represent a match of the pattern in the result of a query, | ||
64 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
65 | * | ||
66 | * @see Matcher | ||
67 | * | ||
68 | */ | ||
69 | public static abstract class Match extends BasePatternMatch { | ||
70 | private Segment fS1; | ||
71 | |||
72 | private Segment fS2; | ||
73 | |||
74 | private static List<String> parameterNames = makeImmutableList("S1", "S2"); | ||
75 | |||
76 | private Match(final Segment pS1, final Segment pS2) { | ||
77 | this.fS1 = pS1; | ||
78 | this.fS2 = pS2; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "S1": return this.fS1; | ||
85 | case "S2": return this.fS2; | ||
86 | default: return null; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | @Override | ||
91 | public Object get(final int index) { | ||
92 | switch(index) { | ||
93 | case 0: return this.fS1; | ||
94 | case 1: return this.fS2; | ||
95 | default: return null; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | public Segment getS1() { | ||
100 | return this.fS1; | ||
101 | } | ||
102 | |||
103 | public Segment getS2() { | ||
104 | return this.fS2; | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public boolean set(final String parameterName, final Object newValue) { | ||
109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
110 | if ("S1".equals(parameterName) ) { | ||
111 | this.fS1 = (Segment) newValue; | ||
112 | return true; | ||
113 | } | ||
114 | if ("S2".equals(parameterName) ) { | ||
115 | this.fS2 = (Segment) newValue; | ||
116 | return true; | ||
117 | } | ||
118 | return false; | ||
119 | } | ||
120 | |||
121 | public void setS1(final Segment pS1) { | ||
122 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
123 | this.fS1 = pS1; | ||
124 | } | ||
125 | |||
126 | public void setS2(final Segment pS2) { | ||
127 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
128 | this.fS2 = pS2; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public String patternName() { | ||
133 | return "modes3.queries.connectedTo"; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public List<String> parameterNames() { | ||
138 | return ConnectedTo.Match.parameterNames; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public Object[] toArray() { | ||
143 | return new Object[]{fS1, fS2}; | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public ConnectedTo.Match toImmutable() { | ||
148 | return isMutable() ? newMatch(fS1, fS2) : this; | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public String prettyPrint() { | ||
153 | StringBuilder result = new StringBuilder(); | ||
154 | result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); | ||
155 | result.append("\"S2\"=" + prettyPrintValue(fS2)); | ||
156 | return result.toString(); | ||
157 | } | ||
158 | |||
159 | @Override | ||
160 | public int hashCode() { | ||
161 | return Objects.hash(fS1, fS2); | ||
162 | } | ||
163 | |||
164 | @Override | ||
165 | public boolean equals(final Object obj) { | ||
166 | if (this == obj) | ||
167 | return true; | ||
168 | if (obj == null) { | ||
169 | return false; | ||
170 | } | ||
171 | if ((obj instanceof ConnectedTo.Match)) { | ||
172 | ConnectedTo.Match other = (ConnectedTo.Match) obj; | ||
173 | return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); | ||
174 | } else { | ||
175 | // this should be infrequent | ||
176 | if (!(obj instanceof IPatternMatch)) { | ||
177 | return false; | ||
178 | } | ||
179 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
180 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | @Override | ||
185 | public ConnectedTo specification() { | ||
186 | return ConnectedTo.instance(); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * Returns an empty, mutable match. | ||
191 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
192 | * | ||
193 | * @return the empty match. | ||
194 | * | ||
195 | */ | ||
196 | public static ConnectedTo.Match newEmptyMatch() { | ||
197 | return new Mutable(null, null); | ||
198 | } | ||
199 | |||
200 | /** | ||
201 | * Returns a mutable (partial) match. | ||
202 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
203 | * | ||
204 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
205 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
206 | * @return the new, mutable (partial) match object. | ||
207 | * | ||
208 | */ | ||
209 | public static ConnectedTo.Match newMutableMatch(final Segment pS1, final Segment pS2) { | ||
210 | return new Mutable(pS1, pS2); | ||
211 | } | ||
212 | |||
213 | /** | ||
214 | * Returns a new (partial) match. | ||
215 | * This can be used e.g. to call the matcher with a partial match. | ||
216 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
217 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
218 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
219 | * @return the (partial) match object. | ||
220 | * | ||
221 | */ | ||
222 | public static ConnectedTo.Match newMatch(final Segment pS1, final Segment pS2) { | ||
223 | return new Immutable(pS1, pS2); | ||
224 | } | ||
225 | |||
226 | private static final class Mutable extends ConnectedTo.Match { | ||
227 | Mutable(final Segment pS1, final Segment pS2) { | ||
228 | super(pS1, pS2); | ||
229 | } | ||
230 | |||
231 | @Override | ||
232 | public boolean isMutable() { | ||
233 | return true; | ||
234 | } | ||
235 | } | ||
236 | |||
237 | private static final class Immutable extends ConnectedTo.Match { | ||
238 | Immutable(final Segment pS1, final Segment pS2) { | ||
239 | super(pS1, pS2); | ||
240 | } | ||
241 | |||
242 | @Override | ||
243 | public boolean isMutable() { | ||
244 | return false; | ||
245 | } | ||
246 | } | ||
247 | } | ||
248 | |||
249 | /** | ||
250 | * Generated pattern matcher API of the modes3.queries.connectedTo pattern, | ||
251 | * providing pattern-specific query methods. | ||
252 | * | ||
253 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
254 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
255 | * | ||
256 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
257 | * | ||
258 | * <p>Original source: | ||
259 | * <code><pre> | ||
260 | * pattern connectedTo(S1 : Segment, S2 : Segment) { | ||
261 | * Segment.connectedTo(S1, S2); | ||
262 | * } | ||
263 | * </pre></code> | ||
264 | * | ||
265 | * @see Match | ||
266 | * @see ConnectedTo | ||
267 | * | ||
268 | */ | ||
269 | public static class Matcher extends BaseMatcher<ConnectedTo.Match> { | ||
270 | /** | ||
271 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
272 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
273 | * | ||
274 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
275 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
276 | * | ||
277 | */ | ||
278 | public static ConnectedTo.Matcher on(final ViatraQueryEngine engine) { | ||
279 | // check if matcher already exists | ||
280 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
281 | if (matcher == null) { | ||
282 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
283 | } | ||
284 | return matcher; | ||
285 | } | ||
286 | |||
287 | /** | ||
288 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
289 | * @return an initialized matcher | ||
290 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
291 | * | ||
292 | */ | ||
293 | public static ConnectedTo.Matcher create() { | ||
294 | return new Matcher(); | ||
295 | } | ||
296 | |||
297 | private static final int POSITION_S1 = 0; | ||
298 | |||
299 | private static final int POSITION_S2 = 1; | ||
300 | |||
301 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ConnectedTo.Matcher.class); | ||
302 | |||
303 | /** | ||
304 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
305 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
306 | * | ||
307 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
308 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
309 | * | ||
310 | */ | ||
311 | private Matcher() { | ||
312 | super(querySpecification()); | ||
313 | } | ||
314 | |||
315 | /** | ||
316 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
317 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
318 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
319 | * @return matches represented as a Match object. | ||
320 | * | ||
321 | */ | ||
322 | public Collection<ConnectedTo.Match> getAllMatches(final Segment pS1, final Segment pS2) { | ||
323 | return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
328 | * </p> | ||
329 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
330 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
331 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
332 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
333 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
334 | * @return a stream of matches represented as a Match object. | ||
335 | * | ||
336 | */ | ||
337 | public Stream<ConnectedTo.Match> streamAllMatches(final Segment pS1, final Segment pS2) { | ||
338 | return rawStreamAllMatches(new Object[]{pS1, pS2}); | ||
339 | } | ||
340 | |||
341 | /** | ||
342 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
343 | * Neither determinism nor randomness of selection is guaranteed. | ||
344 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
345 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
346 | * @return a match represented as a Match object, or null if no match is found. | ||
347 | * | ||
348 | */ | ||
349 | public Optional<ConnectedTo.Match> getOneArbitraryMatch(final Segment pS1, final Segment pS2) { | ||
350 | return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
355 | * under any possible substitution of the unspecified parameters (if any). | ||
356 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
357 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
358 | * @return true if the input is a valid (partial) match of the pattern. | ||
359 | * | ||
360 | */ | ||
361 | public boolean hasMatch(final Segment pS1, final Segment pS2) { | ||
362 | return rawHasMatch(new Object[]{pS1, pS2}); | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
367 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
368 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
369 | * @return the number of pattern matches found. | ||
370 | * | ||
371 | */ | ||
372 | public int countMatches(final Segment pS1, final Segment pS2) { | ||
373 | return rawCountMatches(new Object[]{pS1, pS2}); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
378 | * Neither determinism nor randomness of selection is guaranteed. | ||
379 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
380 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
381 | * @param processor the action that will process the selected match. | ||
382 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
383 | * | ||
384 | */ | ||
385 | public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer<? super ConnectedTo.Match> processor) { | ||
386 | return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); | ||
387 | } | ||
388 | |||
389 | /** | ||
390 | * Returns a new (partial) match. | ||
391 | * This can be used e.g. to call the matcher with a partial match. | ||
392 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
393 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
394 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
395 | * @return the (partial) match object. | ||
396 | * | ||
397 | */ | ||
398 | public ConnectedTo.Match newMatch(final Segment pS1, final Segment pS2) { | ||
399 | return ConnectedTo.Match.newMatch(pS1, pS2); | ||
400 | } | ||
401 | |||
402 | /** | ||
403 | * Retrieve the set of values that occur in matches for S1. | ||
404 | * @return the Set of all values or empty set if there are no matches | ||
405 | * | ||
406 | */ | ||
407 | protected Stream<Segment> rawStreamAllValuesOfS1(final Object[] parameters) { | ||
408 | return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); | ||
409 | } | ||
410 | |||
411 | /** | ||
412 | * Retrieve the set of values that occur in matches for S1. | ||
413 | * @return the Set of all values or empty set if there are no matches | ||
414 | * | ||
415 | */ | ||
416 | public Set<Segment> getAllValuesOfS1() { | ||
417 | return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); | ||
418 | } | ||
419 | |||
420 | /** | ||
421 | * Retrieve the set of values that occur in matches for S1. | ||
422 | * @return the Set of all values or empty set if there are no matches | ||
423 | * | ||
424 | */ | ||
425 | public Stream<Segment> streamAllValuesOfS1() { | ||
426 | return rawStreamAllValuesOfS1(emptyArray()); | ||
427 | } | ||
428 | |||
429 | /** | ||
430 | * Retrieve the set of values that occur in matches for S1. | ||
431 | * </p> | ||
432 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
433 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
434 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
435 | * | ||
436 | * @return the Stream of all values or empty set if there are no matches | ||
437 | * | ||
438 | */ | ||
439 | public Stream<Segment> streamAllValuesOfS1(final ConnectedTo.Match partialMatch) { | ||
440 | return rawStreamAllValuesOfS1(partialMatch.toArray()); | ||
441 | } | ||
442 | |||
443 | /** | ||
444 | * Retrieve the set of values that occur in matches for S1. | ||
445 | * </p> | ||
446 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
447 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
448 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
449 | * | ||
450 | * @return the Stream of all values or empty set if there are no matches | ||
451 | * | ||
452 | */ | ||
453 | public Stream<Segment> streamAllValuesOfS1(final Segment pS2) { | ||
454 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}); | ||
455 | } | ||
456 | |||
457 | /** | ||
458 | * Retrieve the set of values that occur in matches for S1. | ||
459 | * @return the Set of all values or empty set if there are no matches | ||
460 | * | ||
461 | */ | ||
462 | public Set<Segment> getAllValuesOfS1(final ConnectedTo.Match partialMatch) { | ||
463 | return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); | ||
464 | } | ||
465 | |||
466 | /** | ||
467 | * Retrieve the set of values that occur in matches for S1. | ||
468 | * @return the Set of all values or empty set if there are no matches | ||
469 | * | ||
470 | */ | ||
471 | public Set<Segment> getAllValuesOfS1(final Segment pS2) { | ||
472 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); | ||
473 | } | ||
474 | |||
475 | /** | ||
476 | * Retrieve the set of values that occur in matches for S2. | ||
477 | * @return the Set of all values or empty set if there are no matches | ||
478 | * | ||
479 | */ | ||
480 | protected Stream<Segment> rawStreamAllValuesOfS2(final Object[] parameters) { | ||
481 | return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); | ||
482 | } | ||
483 | |||
484 | /** | ||
485 | * Retrieve the set of values that occur in matches for S2. | ||
486 | * @return the Set of all values or empty set if there are no matches | ||
487 | * | ||
488 | */ | ||
489 | public Set<Segment> getAllValuesOfS2() { | ||
490 | return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); | ||
491 | } | ||
492 | |||
493 | /** | ||
494 | * Retrieve the set of values that occur in matches for S2. | ||
495 | * @return the Set of all values or empty set if there are no matches | ||
496 | * | ||
497 | */ | ||
498 | public Stream<Segment> streamAllValuesOfS2() { | ||
499 | return rawStreamAllValuesOfS2(emptyArray()); | ||
500 | } | ||
501 | |||
502 | /** | ||
503 | * Retrieve the set of values that occur in matches for S2. | ||
504 | * </p> | ||
505 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
506 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
507 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
508 | * | ||
509 | * @return the Stream of all values or empty set if there are no matches | ||
510 | * | ||
511 | */ | ||
512 | public Stream<Segment> streamAllValuesOfS2(final ConnectedTo.Match partialMatch) { | ||
513 | return rawStreamAllValuesOfS2(partialMatch.toArray()); | ||
514 | } | ||
515 | |||
516 | /** | ||
517 | * Retrieve the set of values that occur in matches for S2. | ||
518 | * </p> | ||
519 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
520 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
521 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
522 | * | ||
523 | * @return the Stream of all values or empty set if there are no matches | ||
524 | * | ||
525 | */ | ||
526 | public Stream<Segment> streamAllValuesOfS2(final Segment pS1) { | ||
527 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}); | ||
528 | } | ||
529 | |||
530 | /** | ||
531 | * Retrieve the set of values that occur in matches for S2. | ||
532 | * @return the Set of all values or empty set if there are no matches | ||
533 | * | ||
534 | */ | ||
535 | public Set<Segment> getAllValuesOfS2(final ConnectedTo.Match partialMatch) { | ||
536 | return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); | ||
537 | } | ||
538 | |||
539 | /** | ||
540 | * Retrieve the set of values that occur in matches for S2. | ||
541 | * @return the Set of all values or empty set if there are no matches | ||
542 | * | ||
543 | */ | ||
544 | public Set<Segment> getAllValuesOfS2(final Segment pS1) { | ||
545 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); | ||
546 | } | ||
547 | |||
548 | @Override | ||
549 | protected ConnectedTo.Match tupleToMatch(final Tuple t) { | ||
550 | try { | ||
551 | return ConnectedTo.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); | ||
552 | } catch(ClassCastException e) { | ||
553 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
554 | return null; | ||
555 | } | ||
556 | } | ||
557 | |||
558 | @Override | ||
559 | protected ConnectedTo.Match arrayToMatch(final Object[] match) { | ||
560 | try { | ||
561 | return ConnectedTo.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
562 | } catch(ClassCastException e) { | ||
563 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
564 | return null; | ||
565 | } | ||
566 | } | ||
567 | |||
568 | @Override | ||
569 | protected ConnectedTo.Match arrayToMatchMutable(final Object[] match) { | ||
570 | try { | ||
571 | return ConnectedTo.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
572 | } catch(ClassCastException e) { | ||
573 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
574 | return null; | ||
575 | } | ||
576 | } | ||
577 | |||
578 | /** | ||
579 | * @return the singleton instance of the query specification of this pattern | ||
580 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
581 | * | ||
582 | */ | ||
583 | public static IQuerySpecification<ConnectedTo.Matcher> querySpecification() { | ||
584 | return ConnectedTo.instance(); | ||
585 | } | ||
586 | } | ||
587 | |||
588 | private ConnectedTo() { | ||
589 | super(GeneratedPQuery.INSTANCE); | ||
590 | } | ||
591 | |||
592 | /** | ||
593 | * @return the singleton instance of the query specification | ||
594 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
595 | * | ||
596 | */ | ||
597 | public static ConnectedTo instance() { | ||
598 | try{ | ||
599 | return LazyHolder.INSTANCE; | ||
600 | } catch (ExceptionInInitializerError err) { | ||
601 | throw processInitializerError(err); | ||
602 | } | ||
603 | } | ||
604 | |||
605 | @Override | ||
606 | protected ConnectedTo.Matcher instantiate(final ViatraQueryEngine engine) { | ||
607 | return ConnectedTo.Matcher.on(engine); | ||
608 | } | ||
609 | |||
610 | @Override | ||
611 | public ConnectedTo.Matcher instantiate() { | ||
612 | return ConnectedTo.Matcher.create(); | ||
613 | } | ||
614 | |||
615 | @Override | ||
616 | public ConnectedTo.Match newEmptyMatch() { | ||
617 | return ConnectedTo.Match.newEmptyMatch(); | ||
618 | } | ||
619 | |||
620 | @Override | ||
621 | public ConnectedTo.Match newMatch(final Object... parameters) { | ||
622 | return ConnectedTo.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); | ||
623 | } | ||
624 | |||
625 | /** | ||
626 | * Inner class allowing the singleton instance of {@link ConnectedTo} to be created | ||
627 | * <b>not</b> at the class load time of the outer class, | ||
628 | * but rather at the first call to {@link ConnectedTo#instance()}. | ||
629 | * | ||
630 | * <p> This workaround is required e.g. to support recursion. | ||
631 | * | ||
632 | */ | ||
633 | private static class LazyHolder { | ||
634 | private static final ConnectedTo INSTANCE = new ConnectedTo(); | ||
635 | |||
636 | /** | ||
637 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
638 | * This initialization order is required to support indirect recursion. | ||
639 | * | ||
640 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
641 | * | ||
642 | */ | ||
643 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
644 | |||
645 | public static Object ensureInitialized() { | ||
646 | INSTANCE.ensureInitializedInternal(); | ||
647 | return null; | ||
648 | } | ||
649 | } | ||
650 | |||
651 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
652 | private static final ConnectedTo.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
653 | |||
654 | private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
655 | |||
656 | private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
657 | |||
658 | private final List<PParameter> parameters = Arrays.asList(parameter_S1, parameter_S2); | ||
659 | |||
660 | private GeneratedPQuery() { | ||
661 | super(PVisibility.PUBLIC); | ||
662 | } | ||
663 | |||
664 | @Override | ||
665 | public String getFullyQualifiedName() { | ||
666 | return "modes3.queries.connectedTo"; | ||
667 | } | ||
668 | |||
669 | @Override | ||
670 | public List<String> getParameterNames() { | ||
671 | return Arrays.asList("S1","S2"); | ||
672 | } | ||
673 | |||
674 | @Override | ||
675 | public List<PParameter> getParameters() { | ||
676 | return parameters; | ||
677 | } | ||
678 | |||
679 | @Override | ||
680 | public Set<PBody> doGetContainedBodies() { | ||
681 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
682 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
683 | { | ||
684 | PBody body = new PBody(this); | ||
685 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
686 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
687 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
688 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
689 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
690 | new ExportedParameter(body, var_S1, parameter_S1), | ||
691 | new ExportedParameter(body, var_S2, parameter_S2) | ||
692 | )); | ||
693 | // Segment.connectedTo(S1, S2) | ||
694 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
695 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
696 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
697 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
698 | new Equality(body, var__virtual_0_, var_S2); | ||
699 | bodies.add(body); | ||
700 | } | ||
701 | return bodies; | ||
702 | } | ||
703 | } | ||
704 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedToNotSymmetric.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedToNotSymmetric.java new file mode 100644 index 00000000..91b74c7e --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedToNotSymmetric.java | |||
@@ -0,0 +1,724 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.queries.ConnectedTo; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
43 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
44 | |||
45 | /** | ||
46 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
47 | * | ||
48 | * <p>Original source: | ||
49 | * <code><pre> | ||
50 | * {@literal @}Constraint(message = "connectedToNotSymmetric", severity = "error", key = { S1, S2 }) | ||
51 | * pattern connectedToNotSymmetric(S1 : Segment, S2 : Segment) { | ||
52 | * Segment.connectedTo(S1, S2); | ||
53 | * neg find connectedTo(S2, S1); | ||
54 | * } | ||
55 | * </pre></code> | ||
56 | * | ||
57 | * @see Matcher | ||
58 | * @see Match | ||
59 | * | ||
60 | */ | ||
61 | @SuppressWarnings("all") | ||
62 | public final class ConnectedToNotSymmetric extends BaseGeneratedEMFQuerySpecification<ConnectedToNotSymmetric.Matcher> { | ||
63 | /** | ||
64 | * Pattern-specific match representation of the modes3.queries.connectedToNotSymmetric pattern, | ||
65 | * to be used in conjunction with {@link Matcher}. | ||
66 | * | ||
67 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
68 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
69 | * usable to represent a match of the pattern in the result of a query, | ||
70 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
71 | * | ||
72 | * @see Matcher | ||
73 | * | ||
74 | */ | ||
75 | public static abstract class Match extends BasePatternMatch { | ||
76 | private Segment fS1; | ||
77 | |||
78 | private Segment fS2; | ||
79 | |||
80 | private static List<String> parameterNames = makeImmutableList("S1", "S2"); | ||
81 | |||
82 | private Match(final Segment pS1, final Segment pS2) { | ||
83 | this.fS1 = pS1; | ||
84 | this.fS2 = pS2; | ||
85 | } | ||
86 | |||
87 | @Override | ||
88 | public Object get(final String parameterName) { | ||
89 | switch(parameterName) { | ||
90 | case "S1": return this.fS1; | ||
91 | case "S2": return this.fS2; | ||
92 | default: return null; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | @Override | ||
97 | public Object get(final int index) { | ||
98 | switch(index) { | ||
99 | case 0: return this.fS1; | ||
100 | case 1: return this.fS2; | ||
101 | default: return null; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | public Segment getS1() { | ||
106 | return this.fS1; | ||
107 | } | ||
108 | |||
109 | public Segment getS2() { | ||
110 | return this.fS2; | ||
111 | } | ||
112 | |||
113 | @Override | ||
114 | public boolean set(final String parameterName, final Object newValue) { | ||
115 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
116 | if ("S1".equals(parameterName) ) { | ||
117 | this.fS1 = (Segment) newValue; | ||
118 | return true; | ||
119 | } | ||
120 | if ("S2".equals(parameterName) ) { | ||
121 | this.fS2 = (Segment) newValue; | ||
122 | return true; | ||
123 | } | ||
124 | return false; | ||
125 | } | ||
126 | |||
127 | public void setS1(final Segment pS1) { | ||
128 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
129 | this.fS1 = pS1; | ||
130 | } | ||
131 | |||
132 | public void setS2(final Segment pS2) { | ||
133 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
134 | this.fS2 = pS2; | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public String patternName() { | ||
139 | return "modes3.queries.connectedToNotSymmetric"; | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public List<String> parameterNames() { | ||
144 | return ConnectedToNotSymmetric.Match.parameterNames; | ||
145 | } | ||
146 | |||
147 | @Override | ||
148 | public Object[] toArray() { | ||
149 | return new Object[]{fS1, fS2}; | ||
150 | } | ||
151 | |||
152 | @Override | ||
153 | public ConnectedToNotSymmetric.Match toImmutable() { | ||
154 | return isMutable() ? newMatch(fS1, fS2) : this; | ||
155 | } | ||
156 | |||
157 | @Override | ||
158 | public String prettyPrint() { | ||
159 | StringBuilder result = new StringBuilder(); | ||
160 | result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); | ||
161 | result.append("\"S2\"=" + prettyPrintValue(fS2)); | ||
162 | return result.toString(); | ||
163 | } | ||
164 | |||
165 | @Override | ||
166 | public int hashCode() { | ||
167 | return Objects.hash(fS1, fS2); | ||
168 | } | ||
169 | |||
170 | @Override | ||
171 | public boolean equals(final Object obj) { | ||
172 | if (this == obj) | ||
173 | return true; | ||
174 | if (obj == null) { | ||
175 | return false; | ||
176 | } | ||
177 | if ((obj instanceof ConnectedToNotSymmetric.Match)) { | ||
178 | ConnectedToNotSymmetric.Match other = (ConnectedToNotSymmetric.Match) obj; | ||
179 | return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); | ||
180 | } else { | ||
181 | // this should be infrequent | ||
182 | if (!(obj instanceof IPatternMatch)) { | ||
183 | return false; | ||
184 | } | ||
185 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
186 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
187 | } | ||
188 | } | ||
189 | |||
190 | @Override | ||
191 | public ConnectedToNotSymmetric specification() { | ||
192 | return ConnectedToNotSymmetric.instance(); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * Returns an empty, mutable match. | ||
197 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
198 | * | ||
199 | * @return the empty match. | ||
200 | * | ||
201 | */ | ||
202 | public static ConnectedToNotSymmetric.Match newEmptyMatch() { | ||
203 | return new Mutable(null, null); | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * Returns a mutable (partial) match. | ||
208 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
209 | * | ||
210 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
211 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
212 | * @return the new, mutable (partial) match object. | ||
213 | * | ||
214 | */ | ||
215 | public static ConnectedToNotSymmetric.Match newMutableMatch(final Segment pS1, final Segment pS2) { | ||
216 | return new Mutable(pS1, pS2); | ||
217 | } | ||
218 | |||
219 | /** | ||
220 | * Returns a new (partial) match. | ||
221 | * This can be used e.g. to call the matcher with a partial match. | ||
222 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
223 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
224 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
225 | * @return the (partial) match object. | ||
226 | * | ||
227 | */ | ||
228 | public static ConnectedToNotSymmetric.Match newMatch(final Segment pS1, final Segment pS2) { | ||
229 | return new Immutable(pS1, pS2); | ||
230 | } | ||
231 | |||
232 | private static final class Mutable extends ConnectedToNotSymmetric.Match { | ||
233 | Mutable(final Segment pS1, final Segment pS2) { | ||
234 | super(pS1, pS2); | ||
235 | } | ||
236 | |||
237 | @Override | ||
238 | public boolean isMutable() { | ||
239 | return true; | ||
240 | } | ||
241 | } | ||
242 | |||
243 | private static final class Immutable extends ConnectedToNotSymmetric.Match { | ||
244 | Immutable(final Segment pS1, final Segment pS2) { | ||
245 | super(pS1, pS2); | ||
246 | } | ||
247 | |||
248 | @Override | ||
249 | public boolean isMutable() { | ||
250 | return false; | ||
251 | } | ||
252 | } | ||
253 | } | ||
254 | |||
255 | /** | ||
256 | * Generated pattern matcher API of the modes3.queries.connectedToNotSymmetric pattern, | ||
257 | * providing pattern-specific query methods. | ||
258 | * | ||
259 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
260 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
261 | * | ||
262 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
263 | * | ||
264 | * <p>Original source: | ||
265 | * <code><pre> | ||
266 | * {@literal @}Constraint(message = "connectedToNotSymmetric", severity = "error", key = { S1, S2 }) | ||
267 | * pattern connectedToNotSymmetric(S1 : Segment, S2 : Segment) { | ||
268 | * Segment.connectedTo(S1, S2); | ||
269 | * neg find connectedTo(S2, S1); | ||
270 | * } | ||
271 | * </pre></code> | ||
272 | * | ||
273 | * @see Match | ||
274 | * @see ConnectedToNotSymmetric | ||
275 | * | ||
276 | */ | ||
277 | public static class Matcher extends BaseMatcher<ConnectedToNotSymmetric.Match> { | ||
278 | /** | ||
279 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
280 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
281 | * | ||
282 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
283 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
284 | * | ||
285 | */ | ||
286 | public static ConnectedToNotSymmetric.Matcher on(final ViatraQueryEngine engine) { | ||
287 | // check if matcher already exists | ||
288 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
289 | if (matcher == null) { | ||
290 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
291 | } | ||
292 | return matcher; | ||
293 | } | ||
294 | |||
295 | /** | ||
296 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
297 | * @return an initialized matcher | ||
298 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
299 | * | ||
300 | */ | ||
301 | public static ConnectedToNotSymmetric.Matcher create() { | ||
302 | return new Matcher(); | ||
303 | } | ||
304 | |||
305 | private static final int POSITION_S1 = 0; | ||
306 | |||
307 | private static final int POSITION_S2 = 1; | ||
308 | |||
309 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ConnectedToNotSymmetric.Matcher.class); | ||
310 | |||
311 | /** | ||
312 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
313 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
314 | * | ||
315 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
316 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
317 | * | ||
318 | */ | ||
319 | private Matcher() { | ||
320 | super(querySpecification()); | ||
321 | } | ||
322 | |||
323 | /** | ||
324 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
325 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
326 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
327 | * @return matches represented as a Match object. | ||
328 | * | ||
329 | */ | ||
330 | public Collection<ConnectedToNotSymmetric.Match> getAllMatches(final Segment pS1, final Segment pS2) { | ||
331 | return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); | ||
332 | } | ||
333 | |||
334 | /** | ||
335 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
336 | * </p> | ||
337 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
338 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
339 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
340 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
341 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
342 | * @return a stream of matches represented as a Match object. | ||
343 | * | ||
344 | */ | ||
345 | public Stream<ConnectedToNotSymmetric.Match> streamAllMatches(final Segment pS1, final Segment pS2) { | ||
346 | return rawStreamAllMatches(new Object[]{pS1, pS2}); | ||
347 | } | ||
348 | |||
349 | /** | ||
350 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
351 | * Neither determinism nor randomness of selection is guaranteed. | ||
352 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
353 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
354 | * @return a match represented as a Match object, or null if no match is found. | ||
355 | * | ||
356 | */ | ||
357 | public Optional<ConnectedToNotSymmetric.Match> getOneArbitraryMatch(final Segment pS1, final Segment pS2) { | ||
358 | return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); | ||
359 | } | ||
360 | |||
361 | /** | ||
362 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
363 | * under any possible substitution of the unspecified parameters (if any). | ||
364 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
365 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
366 | * @return true if the input is a valid (partial) match of the pattern. | ||
367 | * | ||
368 | */ | ||
369 | public boolean hasMatch(final Segment pS1, final Segment pS2) { | ||
370 | return rawHasMatch(new Object[]{pS1, pS2}); | ||
371 | } | ||
372 | |||
373 | /** | ||
374 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
375 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
376 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
377 | * @return the number of pattern matches found. | ||
378 | * | ||
379 | */ | ||
380 | public int countMatches(final Segment pS1, final Segment pS2) { | ||
381 | return rawCountMatches(new Object[]{pS1, pS2}); | ||
382 | } | ||
383 | |||
384 | /** | ||
385 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
386 | * Neither determinism nor randomness of selection is guaranteed. | ||
387 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
388 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
389 | * @param processor the action that will process the selected match. | ||
390 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
391 | * | ||
392 | */ | ||
393 | public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer<? super ConnectedToNotSymmetric.Match> processor) { | ||
394 | return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); | ||
395 | } | ||
396 | |||
397 | /** | ||
398 | * Returns a new (partial) match. | ||
399 | * This can be used e.g. to call the matcher with a partial match. | ||
400 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
401 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
402 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
403 | * @return the (partial) match object. | ||
404 | * | ||
405 | */ | ||
406 | public ConnectedToNotSymmetric.Match newMatch(final Segment pS1, final Segment pS2) { | ||
407 | return ConnectedToNotSymmetric.Match.newMatch(pS1, pS2); | ||
408 | } | ||
409 | |||
410 | /** | ||
411 | * Retrieve the set of values that occur in matches for S1. | ||
412 | * @return the Set of all values or empty set if there are no matches | ||
413 | * | ||
414 | */ | ||
415 | protected Stream<Segment> rawStreamAllValuesOfS1(final Object[] parameters) { | ||
416 | return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); | ||
417 | } | ||
418 | |||
419 | /** | ||
420 | * Retrieve the set of values that occur in matches for S1. | ||
421 | * @return the Set of all values or empty set if there are no matches | ||
422 | * | ||
423 | */ | ||
424 | public Set<Segment> getAllValuesOfS1() { | ||
425 | return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); | ||
426 | } | ||
427 | |||
428 | /** | ||
429 | * Retrieve the set of values that occur in matches for S1. | ||
430 | * @return the Set of all values or empty set if there are no matches | ||
431 | * | ||
432 | */ | ||
433 | public Stream<Segment> streamAllValuesOfS1() { | ||
434 | return rawStreamAllValuesOfS1(emptyArray()); | ||
435 | } | ||
436 | |||
437 | /** | ||
438 | * Retrieve the set of values that occur in matches for S1. | ||
439 | * </p> | ||
440 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
441 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
442 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
443 | * | ||
444 | * @return the Stream of all values or empty set if there are no matches | ||
445 | * | ||
446 | */ | ||
447 | public Stream<Segment> streamAllValuesOfS1(final ConnectedToNotSymmetric.Match partialMatch) { | ||
448 | return rawStreamAllValuesOfS1(partialMatch.toArray()); | ||
449 | } | ||
450 | |||
451 | /** | ||
452 | * Retrieve the set of values that occur in matches for S1. | ||
453 | * </p> | ||
454 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
455 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
456 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
457 | * | ||
458 | * @return the Stream of all values or empty set if there are no matches | ||
459 | * | ||
460 | */ | ||
461 | public Stream<Segment> streamAllValuesOfS1(final Segment pS2) { | ||
462 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}); | ||
463 | } | ||
464 | |||
465 | /** | ||
466 | * Retrieve the set of values that occur in matches for S1. | ||
467 | * @return the Set of all values or empty set if there are no matches | ||
468 | * | ||
469 | */ | ||
470 | public Set<Segment> getAllValuesOfS1(final ConnectedToNotSymmetric.Match partialMatch) { | ||
471 | return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); | ||
472 | } | ||
473 | |||
474 | /** | ||
475 | * Retrieve the set of values that occur in matches for S1. | ||
476 | * @return the Set of all values or empty set if there are no matches | ||
477 | * | ||
478 | */ | ||
479 | public Set<Segment> getAllValuesOfS1(final Segment pS2) { | ||
480 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); | ||
481 | } | ||
482 | |||
483 | /** | ||
484 | * Retrieve the set of values that occur in matches for S2. | ||
485 | * @return the Set of all values or empty set if there are no matches | ||
486 | * | ||
487 | */ | ||
488 | protected Stream<Segment> rawStreamAllValuesOfS2(final Object[] parameters) { | ||
489 | return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); | ||
490 | } | ||
491 | |||
492 | /** | ||
493 | * Retrieve the set of values that occur in matches for S2. | ||
494 | * @return the Set of all values or empty set if there are no matches | ||
495 | * | ||
496 | */ | ||
497 | public Set<Segment> getAllValuesOfS2() { | ||
498 | return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); | ||
499 | } | ||
500 | |||
501 | /** | ||
502 | * Retrieve the set of values that occur in matches for S2. | ||
503 | * @return the Set of all values or empty set if there are no matches | ||
504 | * | ||
505 | */ | ||
506 | public Stream<Segment> streamAllValuesOfS2() { | ||
507 | return rawStreamAllValuesOfS2(emptyArray()); | ||
508 | } | ||
509 | |||
510 | /** | ||
511 | * Retrieve the set of values that occur in matches for S2. | ||
512 | * </p> | ||
513 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
514 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
515 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
516 | * | ||
517 | * @return the Stream of all values or empty set if there are no matches | ||
518 | * | ||
519 | */ | ||
520 | public Stream<Segment> streamAllValuesOfS2(final ConnectedToNotSymmetric.Match partialMatch) { | ||
521 | return rawStreamAllValuesOfS2(partialMatch.toArray()); | ||
522 | } | ||
523 | |||
524 | /** | ||
525 | * Retrieve the set of values that occur in matches for S2. | ||
526 | * </p> | ||
527 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
528 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
529 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
530 | * | ||
531 | * @return the Stream of all values or empty set if there are no matches | ||
532 | * | ||
533 | */ | ||
534 | public Stream<Segment> streamAllValuesOfS2(final Segment pS1) { | ||
535 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}); | ||
536 | } | ||
537 | |||
538 | /** | ||
539 | * Retrieve the set of values that occur in matches for S2. | ||
540 | * @return the Set of all values or empty set if there are no matches | ||
541 | * | ||
542 | */ | ||
543 | public Set<Segment> getAllValuesOfS2(final ConnectedToNotSymmetric.Match partialMatch) { | ||
544 | return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); | ||
545 | } | ||
546 | |||
547 | /** | ||
548 | * Retrieve the set of values that occur in matches for S2. | ||
549 | * @return the Set of all values or empty set if there are no matches | ||
550 | * | ||
551 | */ | ||
552 | public Set<Segment> getAllValuesOfS2(final Segment pS1) { | ||
553 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); | ||
554 | } | ||
555 | |||
556 | @Override | ||
557 | protected ConnectedToNotSymmetric.Match tupleToMatch(final Tuple t) { | ||
558 | try { | ||
559 | return ConnectedToNotSymmetric.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); | ||
560 | } catch(ClassCastException e) { | ||
561 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
562 | return null; | ||
563 | } | ||
564 | } | ||
565 | |||
566 | @Override | ||
567 | protected ConnectedToNotSymmetric.Match arrayToMatch(final Object[] match) { | ||
568 | try { | ||
569 | return ConnectedToNotSymmetric.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
570 | } catch(ClassCastException e) { | ||
571 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
572 | return null; | ||
573 | } | ||
574 | } | ||
575 | |||
576 | @Override | ||
577 | protected ConnectedToNotSymmetric.Match arrayToMatchMutable(final Object[] match) { | ||
578 | try { | ||
579 | return ConnectedToNotSymmetric.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
580 | } catch(ClassCastException e) { | ||
581 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
582 | return null; | ||
583 | } | ||
584 | } | ||
585 | |||
586 | /** | ||
587 | * @return the singleton instance of the query specification of this pattern | ||
588 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
589 | * | ||
590 | */ | ||
591 | public static IQuerySpecification<ConnectedToNotSymmetric.Matcher> querySpecification() { | ||
592 | return ConnectedToNotSymmetric.instance(); | ||
593 | } | ||
594 | } | ||
595 | |||
596 | private ConnectedToNotSymmetric() { | ||
597 | super(GeneratedPQuery.INSTANCE); | ||
598 | } | ||
599 | |||
600 | /** | ||
601 | * @return the singleton instance of the query specification | ||
602 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
603 | * | ||
604 | */ | ||
605 | public static ConnectedToNotSymmetric instance() { | ||
606 | try{ | ||
607 | return LazyHolder.INSTANCE; | ||
608 | } catch (ExceptionInInitializerError err) { | ||
609 | throw processInitializerError(err); | ||
610 | } | ||
611 | } | ||
612 | |||
613 | @Override | ||
614 | protected ConnectedToNotSymmetric.Matcher instantiate(final ViatraQueryEngine engine) { | ||
615 | return ConnectedToNotSymmetric.Matcher.on(engine); | ||
616 | } | ||
617 | |||
618 | @Override | ||
619 | public ConnectedToNotSymmetric.Matcher instantiate() { | ||
620 | return ConnectedToNotSymmetric.Matcher.create(); | ||
621 | } | ||
622 | |||
623 | @Override | ||
624 | public ConnectedToNotSymmetric.Match newEmptyMatch() { | ||
625 | return ConnectedToNotSymmetric.Match.newEmptyMatch(); | ||
626 | } | ||
627 | |||
628 | @Override | ||
629 | public ConnectedToNotSymmetric.Match newMatch(final Object... parameters) { | ||
630 | return ConnectedToNotSymmetric.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); | ||
631 | } | ||
632 | |||
633 | /** | ||
634 | * Inner class allowing the singleton instance of {@link ConnectedToNotSymmetric} to be created | ||
635 | * <b>not</b> at the class load time of the outer class, | ||
636 | * but rather at the first call to {@link ConnectedToNotSymmetric#instance()}. | ||
637 | * | ||
638 | * <p> This workaround is required e.g. to support recursion. | ||
639 | * | ||
640 | */ | ||
641 | private static class LazyHolder { | ||
642 | private static final ConnectedToNotSymmetric INSTANCE = new ConnectedToNotSymmetric(); | ||
643 | |||
644 | /** | ||
645 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
646 | * This initialization order is required to support indirect recursion. | ||
647 | * | ||
648 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
649 | * | ||
650 | */ | ||
651 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
652 | |||
653 | public static Object ensureInitialized() { | ||
654 | INSTANCE.ensureInitializedInternal(); | ||
655 | return null; | ||
656 | } | ||
657 | } | ||
658 | |||
659 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
660 | private static final ConnectedToNotSymmetric.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
661 | |||
662 | private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
663 | |||
664 | private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
665 | |||
666 | private final List<PParameter> parameters = Arrays.asList(parameter_S1, parameter_S2); | ||
667 | |||
668 | private GeneratedPQuery() { | ||
669 | super(PVisibility.PUBLIC); | ||
670 | } | ||
671 | |||
672 | @Override | ||
673 | public String getFullyQualifiedName() { | ||
674 | return "modes3.queries.connectedToNotSymmetric"; | ||
675 | } | ||
676 | |||
677 | @Override | ||
678 | public List<String> getParameterNames() { | ||
679 | return Arrays.asList("S1","S2"); | ||
680 | } | ||
681 | |||
682 | @Override | ||
683 | public List<PParameter> getParameters() { | ||
684 | return parameters; | ||
685 | } | ||
686 | |||
687 | @Override | ||
688 | public Set<PBody> doGetContainedBodies() { | ||
689 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
690 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
691 | { | ||
692 | PBody body = new PBody(this); | ||
693 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
694 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
695 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
696 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
697 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
698 | new ExportedParameter(body, var_S1, parameter_S1), | ||
699 | new ExportedParameter(body, var_S2, parameter_S2) | ||
700 | )); | ||
701 | // Segment.connectedTo(S1, S2) | ||
702 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
703 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
704 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
705 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
706 | new Equality(body, var__virtual_0_, var_S2); | ||
707 | // neg find connectedTo(S2, S1) | ||
708 | new NegativePatternCall(body, Tuples.flatTupleOf(var_S2, var_S1), ConnectedTo.instance().getInternalQueryRepresentation()); | ||
709 | bodies.add(body); | ||
710 | } | ||
711 | { | ||
712 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
713 | annotation.addAttribute("message", "connectedToNotSymmetric"); | ||
714 | annotation.addAttribute("severity", "error"); | ||
715 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
716 | new ParameterReference("S1"), | ||
717 | new ParameterReference("S2") | ||
718 | })); | ||
719 | addAnnotation(annotation); | ||
720 | } | ||
721 | return bodies; | ||
722 | } | ||
723 | } | ||
724 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedToReflexive.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedToReflexive.java new file mode 100644 index 00000000..948fec73 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/ConnectedToReflexive.java | |||
@@ -0,0 +1,563 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * {@literal @}Constraint(message = "connectedToReflexive", severity = "error", key = { S }) | ||
49 | * pattern connectedToReflexive(S : Segment) { | ||
50 | * Segment.connectedTo(S, S); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class ConnectedToReflexive extends BaseGeneratedEMFQuerySpecification<ConnectedToReflexive.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.connectedToReflexive pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Segment fS; | ||
74 | |||
75 | private static List<String> parameterNames = makeImmutableList("S"); | ||
76 | |||
77 | private Match(final Segment pS) { | ||
78 | this.fS = pS; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "S": return this.fS; | ||
85 | default: return null; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final int index) { | ||
91 | switch(index) { | ||
92 | case 0: return this.fS; | ||
93 | default: return null; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | public Segment getS() { | ||
98 | return this.fS; | ||
99 | } | ||
100 | |||
101 | @Override | ||
102 | public boolean set(final String parameterName, final Object newValue) { | ||
103 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
104 | if ("S".equals(parameterName) ) { | ||
105 | this.fS = (Segment) newValue; | ||
106 | return true; | ||
107 | } | ||
108 | return false; | ||
109 | } | ||
110 | |||
111 | public void setS(final Segment pS) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | this.fS = pS; | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public String patternName() { | ||
118 | return "modes3.queries.connectedToReflexive"; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public List<String> parameterNames() { | ||
123 | return ConnectedToReflexive.Match.parameterNames; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public Object[] toArray() { | ||
128 | return new Object[]{fS}; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public ConnectedToReflexive.Match toImmutable() { | ||
133 | return isMutable() ? newMatch(fS) : this; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public String prettyPrint() { | ||
138 | StringBuilder result = new StringBuilder(); | ||
139 | result.append("\"S\"=" + prettyPrintValue(fS)); | ||
140 | return result.toString(); | ||
141 | } | ||
142 | |||
143 | @Override | ||
144 | public int hashCode() { | ||
145 | return Objects.hash(fS); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public boolean equals(final Object obj) { | ||
150 | if (this == obj) | ||
151 | return true; | ||
152 | if (obj == null) { | ||
153 | return false; | ||
154 | } | ||
155 | if ((obj instanceof ConnectedToReflexive.Match)) { | ||
156 | ConnectedToReflexive.Match other = (ConnectedToReflexive.Match) obj; | ||
157 | return Objects.equals(fS, other.fS); | ||
158 | } else { | ||
159 | // this should be infrequent | ||
160 | if (!(obj instanceof IPatternMatch)) { | ||
161 | return false; | ||
162 | } | ||
163 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
164 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public ConnectedToReflexive specification() { | ||
170 | return ConnectedToReflexive.instance(); | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * Returns an empty, mutable match. | ||
175 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
176 | * | ||
177 | * @return the empty match. | ||
178 | * | ||
179 | */ | ||
180 | public static ConnectedToReflexive.Match newEmptyMatch() { | ||
181 | return new Mutable(null); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Returns a mutable (partial) match. | ||
186 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
187 | * | ||
188 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
189 | * @return the new, mutable (partial) match object. | ||
190 | * | ||
191 | */ | ||
192 | public static ConnectedToReflexive.Match newMutableMatch(final Segment pS) { | ||
193 | return new Mutable(pS); | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * Returns a new (partial) match. | ||
198 | * This can be used e.g. to call the matcher with a partial match. | ||
199 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
200 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
201 | * @return the (partial) match object. | ||
202 | * | ||
203 | */ | ||
204 | public static ConnectedToReflexive.Match newMatch(final Segment pS) { | ||
205 | return new Immutable(pS); | ||
206 | } | ||
207 | |||
208 | private static final class Mutable extends ConnectedToReflexive.Match { | ||
209 | Mutable(final Segment pS) { | ||
210 | super(pS); | ||
211 | } | ||
212 | |||
213 | @Override | ||
214 | public boolean isMutable() { | ||
215 | return true; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | private static final class Immutable extends ConnectedToReflexive.Match { | ||
220 | Immutable(final Segment pS) { | ||
221 | super(pS); | ||
222 | } | ||
223 | |||
224 | @Override | ||
225 | public boolean isMutable() { | ||
226 | return false; | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * Generated pattern matcher API of the modes3.queries.connectedToReflexive pattern, | ||
233 | * providing pattern-specific query methods. | ||
234 | * | ||
235 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
236 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
237 | * | ||
238 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
239 | * | ||
240 | * <p>Original source: | ||
241 | * <code><pre> | ||
242 | * {@literal @}Constraint(message = "connectedToReflexive", severity = "error", key = { S }) | ||
243 | * pattern connectedToReflexive(S : Segment) { | ||
244 | * Segment.connectedTo(S, S); | ||
245 | * } | ||
246 | * </pre></code> | ||
247 | * | ||
248 | * @see Match | ||
249 | * @see ConnectedToReflexive | ||
250 | * | ||
251 | */ | ||
252 | public static class Matcher extends BaseMatcher<ConnectedToReflexive.Match> { | ||
253 | /** | ||
254 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
255 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
256 | * | ||
257 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
258 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
259 | * | ||
260 | */ | ||
261 | public static ConnectedToReflexive.Matcher on(final ViatraQueryEngine engine) { | ||
262 | // check if matcher already exists | ||
263 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
264 | if (matcher == null) { | ||
265 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
266 | } | ||
267 | return matcher; | ||
268 | } | ||
269 | |||
270 | /** | ||
271 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
272 | * @return an initialized matcher | ||
273 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
274 | * | ||
275 | */ | ||
276 | public static ConnectedToReflexive.Matcher create() { | ||
277 | return new Matcher(); | ||
278 | } | ||
279 | |||
280 | private static final int POSITION_S = 0; | ||
281 | |||
282 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ConnectedToReflexive.Matcher.class); | ||
283 | |||
284 | /** | ||
285 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
286 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
287 | * | ||
288 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
289 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
290 | * | ||
291 | */ | ||
292 | private Matcher() { | ||
293 | super(querySpecification()); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
298 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
299 | * @return matches represented as a Match object. | ||
300 | * | ||
301 | */ | ||
302 | public Collection<ConnectedToReflexive.Match> getAllMatches(final Segment pS) { | ||
303 | return rawStreamAllMatches(new Object[]{pS}).collect(Collectors.toSet()); | ||
304 | } | ||
305 | |||
306 | /** | ||
307 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
308 | * </p> | ||
309 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
310 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
311 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
312 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
313 | * @return a stream of matches represented as a Match object. | ||
314 | * | ||
315 | */ | ||
316 | public Stream<ConnectedToReflexive.Match> streamAllMatches(final Segment pS) { | ||
317 | return rawStreamAllMatches(new Object[]{pS}); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
322 | * Neither determinism nor randomness of selection is guaranteed. | ||
323 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
324 | * @return a match represented as a Match object, or null if no match is found. | ||
325 | * | ||
326 | */ | ||
327 | public Optional<ConnectedToReflexive.Match> getOneArbitraryMatch(final Segment pS) { | ||
328 | return rawGetOneArbitraryMatch(new Object[]{pS}); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
333 | * under any possible substitution of the unspecified parameters (if any). | ||
334 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
335 | * @return true if the input is a valid (partial) match of the pattern. | ||
336 | * | ||
337 | */ | ||
338 | public boolean hasMatch(final Segment pS) { | ||
339 | return rawHasMatch(new Object[]{pS}); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
344 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
345 | * @return the number of pattern matches found. | ||
346 | * | ||
347 | */ | ||
348 | public int countMatches(final Segment pS) { | ||
349 | return rawCountMatches(new Object[]{pS}); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
354 | * Neither determinism nor randomness of selection is guaranteed. | ||
355 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
356 | * @param processor the action that will process the selected match. | ||
357 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
358 | * | ||
359 | */ | ||
360 | public boolean forOneArbitraryMatch(final Segment pS, final Consumer<? super ConnectedToReflexive.Match> processor) { | ||
361 | return rawForOneArbitraryMatch(new Object[]{pS}, processor); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Returns a new (partial) match. | ||
366 | * This can be used e.g. to call the matcher with a partial match. | ||
367 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
368 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
369 | * @return the (partial) match object. | ||
370 | * | ||
371 | */ | ||
372 | public ConnectedToReflexive.Match newMatch(final Segment pS) { | ||
373 | return ConnectedToReflexive.Match.newMatch(pS); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Retrieve the set of values that occur in matches for S. | ||
378 | * @return the Set of all values or empty set if there are no matches | ||
379 | * | ||
380 | */ | ||
381 | protected Stream<Segment> rawStreamAllValuesOfS(final Object[] parameters) { | ||
382 | return rawStreamAllValues(POSITION_S, parameters).map(Segment.class::cast); | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * Retrieve the set of values that occur in matches for S. | ||
387 | * @return the Set of all values or empty set if there are no matches | ||
388 | * | ||
389 | */ | ||
390 | public Set<Segment> getAllValuesOfS() { | ||
391 | return rawStreamAllValuesOfS(emptyArray()).collect(Collectors.toSet()); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Retrieve the set of values that occur in matches for S. | ||
396 | * @return the Set of all values or empty set if there are no matches | ||
397 | * | ||
398 | */ | ||
399 | public Stream<Segment> streamAllValuesOfS() { | ||
400 | return rawStreamAllValuesOfS(emptyArray()); | ||
401 | } | ||
402 | |||
403 | @Override | ||
404 | protected ConnectedToReflexive.Match tupleToMatch(final Tuple t) { | ||
405 | try { | ||
406 | return ConnectedToReflexive.Match.newMatch((Segment) t.get(POSITION_S)); | ||
407 | } catch(ClassCastException e) { | ||
408 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
409 | return null; | ||
410 | } | ||
411 | } | ||
412 | |||
413 | @Override | ||
414 | protected ConnectedToReflexive.Match arrayToMatch(final Object[] match) { | ||
415 | try { | ||
416 | return ConnectedToReflexive.Match.newMatch((Segment) match[POSITION_S]); | ||
417 | } catch(ClassCastException e) { | ||
418 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
419 | return null; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | @Override | ||
424 | protected ConnectedToReflexive.Match arrayToMatchMutable(final Object[] match) { | ||
425 | try { | ||
426 | return ConnectedToReflexive.Match.newMutableMatch((Segment) match[POSITION_S]); | ||
427 | } catch(ClassCastException e) { | ||
428 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
429 | return null; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * @return the singleton instance of the query specification of this pattern | ||
435 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
436 | * | ||
437 | */ | ||
438 | public static IQuerySpecification<ConnectedToReflexive.Matcher> querySpecification() { | ||
439 | return ConnectedToReflexive.instance(); | ||
440 | } | ||
441 | } | ||
442 | |||
443 | private ConnectedToReflexive() { | ||
444 | super(GeneratedPQuery.INSTANCE); | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @return the singleton instance of the query specification | ||
449 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
450 | * | ||
451 | */ | ||
452 | public static ConnectedToReflexive instance() { | ||
453 | try{ | ||
454 | return LazyHolder.INSTANCE; | ||
455 | } catch (ExceptionInInitializerError err) { | ||
456 | throw processInitializerError(err); | ||
457 | } | ||
458 | } | ||
459 | |||
460 | @Override | ||
461 | protected ConnectedToReflexive.Matcher instantiate(final ViatraQueryEngine engine) { | ||
462 | return ConnectedToReflexive.Matcher.on(engine); | ||
463 | } | ||
464 | |||
465 | @Override | ||
466 | public ConnectedToReflexive.Matcher instantiate() { | ||
467 | return ConnectedToReflexive.Matcher.create(); | ||
468 | } | ||
469 | |||
470 | @Override | ||
471 | public ConnectedToReflexive.Match newEmptyMatch() { | ||
472 | return ConnectedToReflexive.Match.newEmptyMatch(); | ||
473 | } | ||
474 | |||
475 | @Override | ||
476 | public ConnectedToReflexive.Match newMatch(final Object... parameters) { | ||
477 | return ConnectedToReflexive.Match.newMatch((modes3.Segment) parameters[0]); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Inner class allowing the singleton instance of {@link ConnectedToReflexive} to be created | ||
482 | * <b>not</b> at the class load time of the outer class, | ||
483 | * but rather at the first call to {@link ConnectedToReflexive#instance()}. | ||
484 | * | ||
485 | * <p> This workaround is required e.g. to support recursion. | ||
486 | * | ||
487 | */ | ||
488 | private static class LazyHolder { | ||
489 | private static final ConnectedToReflexive INSTANCE = new ConnectedToReflexive(); | ||
490 | |||
491 | /** | ||
492 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
493 | * This initialization order is required to support indirect recursion. | ||
494 | * | ||
495 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
496 | * | ||
497 | */ | ||
498 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
499 | |||
500 | public static Object ensureInitialized() { | ||
501 | INSTANCE.ensureInitializedInternal(); | ||
502 | return null; | ||
503 | } | ||
504 | } | ||
505 | |||
506 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
507 | private static final ConnectedToReflexive.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
508 | |||
509 | private final PParameter parameter_S = new PParameter("S", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
510 | |||
511 | private final List<PParameter> parameters = Arrays.asList(parameter_S); | ||
512 | |||
513 | private GeneratedPQuery() { | ||
514 | super(PVisibility.PUBLIC); | ||
515 | } | ||
516 | |||
517 | @Override | ||
518 | public String getFullyQualifiedName() { | ||
519 | return "modes3.queries.connectedToReflexive"; | ||
520 | } | ||
521 | |||
522 | @Override | ||
523 | public List<String> getParameterNames() { | ||
524 | return Arrays.asList("S"); | ||
525 | } | ||
526 | |||
527 | @Override | ||
528 | public List<PParameter> getParameters() { | ||
529 | return parameters; | ||
530 | } | ||
531 | |||
532 | @Override | ||
533 | public Set<PBody> doGetContainedBodies() { | ||
534 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
535 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
536 | { | ||
537 | PBody body = new PBody(this); | ||
538 | PVariable var_S = body.getOrCreateVariableByName("S"); | ||
539 | new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
540 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
541 | new ExportedParameter(body, var_S, parameter_S) | ||
542 | )); | ||
543 | // Segment.connectedTo(S, S) | ||
544 | new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
545 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
546 | new TypeConstraint(body, Tuples.flatTupleOf(var_S, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
547 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
548 | new Equality(body, var__virtual_0_, var_S); | ||
549 | bodies.add(body); | ||
550 | } | ||
551 | { | ||
552 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
553 | annotation.addAttribute("message", "connectedToReflexive"); | ||
554 | annotation.addAttribute("severity", "error"); | ||
555 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
556 | new ParameterReference("S") | ||
557 | })); | ||
558 | addAnnotation(annotation); | ||
559 | } | ||
560 | return bodies; | ||
561 | } | ||
562 | } | ||
563 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_2.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_2.java new file mode 100644 index 00000000..a8f68dca --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_2.java | |||
@@ -0,0 +1,564 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Train; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
37 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
38 | |||
39 | /** | ||
40 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
41 | * | ||
42 | * <p>Original source: | ||
43 | * <code><pre> | ||
44 | * // | ||
45 | * // endOfSiding | ||
46 | * // | ||
47 | * | ||
48 | * pattern endOfSiding_step_2(in train : Train) { | ||
49 | * // frame-{@literal >}train = model-{@literal >}trains[i0]; | ||
50 | * // frame-{@literal >}location = frame-{@literal >}train-{@literal >}location; | ||
51 | * // if (frame-{@literal >}location != NULL) { | ||
52 | * // ... | ||
53 | * // } | ||
54 | * | ||
55 | * Train(train); | ||
56 | * } | ||
57 | * </pre></code> | ||
58 | * | ||
59 | * @see Matcher | ||
60 | * @see Match | ||
61 | * | ||
62 | */ | ||
63 | @SuppressWarnings("all") | ||
64 | public final class EndOfSiding_step_2 extends BaseGeneratedEMFQuerySpecification<EndOfSiding_step_2.Matcher> { | ||
65 | /** | ||
66 | * Pattern-specific match representation of the modes3.queries.endOfSiding_step_2 pattern, | ||
67 | * to be used in conjunction with {@link Matcher}. | ||
68 | * | ||
69 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
70 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
71 | * usable to represent a match of the pattern in the result of a query, | ||
72 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
73 | * | ||
74 | * @see Matcher | ||
75 | * | ||
76 | */ | ||
77 | public static abstract class Match extends BasePatternMatch { | ||
78 | private Train fTrain; | ||
79 | |||
80 | private static List<String> parameterNames = makeImmutableList("train"); | ||
81 | |||
82 | private Match(final Train pTrain) { | ||
83 | this.fTrain = pTrain; | ||
84 | } | ||
85 | |||
86 | @Override | ||
87 | public Object get(final String parameterName) { | ||
88 | switch(parameterName) { | ||
89 | case "train": return this.fTrain; | ||
90 | default: return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | @Override | ||
95 | public Object get(final int index) { | ||
96 | switch(index) { | ||
97 | case 0: return this.fTrain; | ||
98 | default: return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public Train getTrain() { | ||
103 | return this.fTrain; | ||
104 | } | ||
105 | |||
106 | @Override | ||
107 | public boolean set(final String parameterName, final Object newValue) { | ||
108 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
109 | if ("train".equals(parameterName) ) { | ||
110 | this.fTrain = (Train) newValue; | ||
111 | return true; | ||
112 | } | ||
113 | return false; | ||
114 | } | ||
115 | |||
116 | public void setTrain(final Train pTrain) { | ||
117 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
118 | this.fTrain = pTrain; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public String patternName() { | ||
123 | return "modes3.queries.endOfSiding_step_2"; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public List<String> parameterNames() { | ||
128 | return EndOfSiding_step_2.Match.parameterNames; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public Object[] toArray() { | ||
133 | return new Object[]{fTrain}; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public EndOfSiding_step_2.Match toImmutable() { | ||
138 | return isMutable() ? newMatch(fTrain) : this; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public String prettyPrint() { | ||
143 | StringBuilder result = new StringBuilder(); | ||
144 | result.append("\"train\"=" + prettyPrintValue(fTrain)); | ||
145 | return result.toString(); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public int hashCode() { | ||
150 | return Objects.hash(fTrain); | ||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public boolean equals(final Object obj) { | ||
155 | if (this == obj) | ||
156 | return true; | ||
157 | if (obj == null) { | ||
158 | return false; | ||
159 | } | ||
160 | if ((obj instanceof EndOfSiding_step_2.Match)) { | ||
161 | EndOfSiding_step_2.Match other = (EndOfSiding_step_2.Match) obj; | ||
162 | return Objects.equals(fTrain, other.fTrain); | ||
163 | } else { | ||
164 | // this should be infrequent | ||
165 | if (!(obj instanceof IPatternMatch)) { | ||
166 | return false; | ||
167 | } | ||
168 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
169 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | @Override | ||
174 | public EndOfSiding_step_2 specification() { | ||
175 | return EndOfSiding_step_2.instance(); | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * Returns an empty, mutable match. | ||
180 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
181 | * | ||
182 | * @return the empty match. | ||
183 | * | ||
184 | */ | ||
185 | public static EndOfSiding_step_2.Match newEmptyMatch() { | ||
186 | return new Mutable(null); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * Returns a mutable (partial) match. | ||
191 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
192 | * | ||
193 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
194 | * @return the new, mutable (partial) match object. | ||
195 | * | ||
196 | */ | ||
197 | public static EndOfSiding_step_2.Match newMutableMatch(final Train pTrain) { | ||
198 | return new Mutable(pTrain); | ||
199 | } | ||
200 | |||
201 | /** | ||
202 | * Returns a new (partial) match. | ||
203 | * This can be used e.g. to call the matcher with a partial match. | ||
204 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
205 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
206 | * @return the (partial) match object. | ||
207 | * | ||
208 | */ | ||
209 | public static EndOfSiding_step_2.Match newMatch(final Train pTrain) { | ||
210 | return new Immutable(pTrain); | ||
211 | } | ||
212 | |||
213 | private static final class Mutable extends EndOfSiding_step_2.Match { | ||
214 | Mutable(final Train pTrain) { | ||
215 | super(pTrain); | ||
216 | } | ||
217 | |||
218 | @Override | ||
219 | public boolean isMutable() { | ||
220 | return true; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | private static final class Immutable extends EndOfSiding_step_2.Match { | ||
225 | Immutable(final Train pTrain) { | ||
226 | super(pTrain); | ||
227 | } | ||
228 | |||
229 | @Override | ||
230 | public boolean isMutable() { | ||
231 | return false; | ||
232 | } | ||
233 | } | ||
234 | } | ||
235 | |||
236 | /** | ||
237 | * Generated pattern matcher API of the modes3.queries.endOfSiding_step_2 pattern, | ||
238 | * providing pattern-specific query methods. | ||
239 | * | ||
240 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
241 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
242 | * | ||
243 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
244 | * | ||
245 | * <p>Original source: | ||
246 | * <code><pre> | ||
247 | * // | ||
248 | * // endOfSiding | ||
249 | * // | ||
250 | * | ||
251 | * pattern endOfSiding_step_2(in train : Train) { | ||
252 | * // frame-{@literal >}train = model-{@literal >}trains[i0]; | ||
253 | * // frame-{@literal >}location = frame-{@literal >}train-{@literal >}location; | ||
254 | * // if (frame-{@literal >}location != NULL) { | ||
255 | * // ... | ||
256 | * // } | ||
257 | * | ||
258 | * Train(train); | ||
259 | * } | ||
260 | * </pre></code> | ||
261 | * | ||
262 | * @see Match | ||
263 | * @see EndOfSiding_step_2 | ||
264 | * | ||
265 | */ | ||
266 | public static class Matcher extends BaseMatcher<EndOfSiding_step_2.Match> { | ||
267 | /** | ||
268 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
269 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
270 | * | ||
271 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
272 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
273 | * | ||
274 | */ | ||
275 | public static EndOfSiding_step_2.Matcher on(final ViatraQueryEngine engine) { | ||
276 | // check if matcher already exists | ||
277 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
278 | if (matcher == null) { | ||
279 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
280 | } | ||
281 | return matcher; | ||
282 | } | ||
283 | |||
284 | /** | ||
285 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
286 | * @return an initialized matcher | ||
287 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
288 | * | ||
289 | */ | ||
290 | public static EndOfSiding_step_2.Matcher create() { | ||
291 | return new Matcher(); | ||
292 | } | ||
293 | |||
294 | private static final int POSITION_TRAIN = 0; | ||
295 | |||
296 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EndOfSiding_step_2.Matcher.class); | ||
297 | |||
298 | /** | ||
299 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
300 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
301 | * | ||
302 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
303 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
304 | * | ||
305 | */ | ||
306 | private Matcher() { | ||
307 | super(querySpecification()); | ||
308 | } | ||
309 | |||
310 | /** | ||
311 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
312 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
313 | * @return matches represented as a Match object. | ||
314 | * | ||
315 | */ | ||
316 | public Collection<EndOfSiding_step_2.Match> getAllMatches(final Train pTrain) { | ||
317 | return rawStreamAllMatches(new Object[]{pTrain}).collect(Collectors.toSet()); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
322 | * </p> | ||
323 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
324 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
325 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
326 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
327 | * @return a stream of matches represented as a Match object. | ||
328 | * | ||
329 | */ | ||
330 | public Stream<EndOfSiding_step_2.Match> streamAllMatches(final Train pTrain) { | ||
331 | return rawStreamAllMatches(new Object[]{pTrain}); | ||
332 | } | ||
333 | |||
334 | /** | ||
335 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
336 | * Neither determinism nor randomness of selection is guaranteed. | ||
337 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
338 | * @return a match represented as a Match object, or null if no match is found. | ||
339 | * | ||
340 | */ | ||
341 | public Optional<EndOfSiding_step_2.Match> getOneArbitraryMatch(final Train pTrain) { | ||
342 | return rawGetOneArbitraryMatch(new Object[]{pTrain}); | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
347 | * under any possible substitution of the unspecified parameters (if any). | ||
348 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
349 | * @return true if the input is a valid (partial) match of the pattern. | ||
350 | * | ||
351 | */ | ||
352 | public boolean hasMatch(final Train pTrain) { | ||
353 | return rawHasMatch(new Object[]{pTrain}); | ||
354 | } | ||
355 | |||
356 | /** | ||
357 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
358 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
359 | * @return the number of pattern matches found. | ||
360 | * | ||
361 | */ | ||
362 | public int countMatches(final Train pTrain) { | ||
363 | return rawCountMatches(new Object[]{pTrain}); | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
368 | * Neither determinism nor randomness of selection is guaranteed. | ||
369 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
370 | * @param processor the action that will process the selected match. | ||
371 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
372 | * | ||
373 | */ | ||
374 | public boolean forOneArbitraryMatch(final Train pTrain, final Consumer<? super EndOfSiding_step_2.Match> processor) { | ||
375 | return rawForOneArbitraryMatch(new Object[]{pTrain}, processor); | ||
376 | } | ||
377 | |||
378 | /** | ||
379 | * Returns a new (partial) match. | ||
380 | * This can be used e.g. to call the matcher with a partial match. | ||
381 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
382 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
383 | * @return the (partial) match object. | ||
384 | * | ||
385 | */ | ||
386 | public EndOfSiding_step_2.Match newMatch(final Train pTrain) { | ||
387 | return EndOfSiding_step_2.Match.newMatch(pTrain); | ||
388 | } | ||
389 | |||
390 | /** | ||
391 | * Retrieve the set of values that occur in matches for train. | ||
392 | * @return the Set of all values or empty set if there are no matches | ||
393 | * | ||
394 | */ | ||
395 | protected Stream<Train> rawStreamAllValuesOftrain(final Object[] parameters) { | ||
396 | return rawStreamAllValues(POSITION_TRAIN, parameters).map(Train.class::cast); | ||
397 | } | ||
398 | |||
399 | /** | ||
400 | * Retrieve the set of values that occur in matches for train. | ||
401 | * @return the Set of all values or empty set if there are no matches | ||
402 | * | ||
403 | */ | ||
404 | public Set<Train> getAllValuesOftrain() { | ||
405 | return rawStreamAllValuesOftrain(emptyArray()).collect(Collectors.toSet()); | ||
406 | } | ||
407 | |||
408 | /** | ||
409 | * Retrieve the set of values that occur in matches for train. | ||
410 | * @return the Set of all values or empty set if there are no matches | ||
411 | * | ||
412 | */ | ||
413 | public Stream<Train> streamAllValuesOftrain() { | ||
414 | return rawStreamAllValuesOftrain(emptyArray()); | ||
415 | } | ||
416 | |||
417 | @Override | ||
418 | protected EndOfSiding_step_2.Match tupleToMatch(final Tuple t) { | ||
419 | try { | ||
420 | return EndOfSiding_step_2.Match.newMatch((Train) t.get(POSITION_TRAIN)); | ||
421 | } catch(ClassCastException e) { | ||
422 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
423 | return null; | ||
424 | } | ||
425 | } | ||
426 | |||
427 | @Override | ||
428 | protected EndOfSiding_step_2.Match arrayToMatch(final Object[] match) { | ||
429 | try { | ||
430 | return EndOfSiding_step_2.Match.newMatch((Train) match[POSITION_TRAIN]); | ||
431 | } catch(ClassCastException e) { | ||
432 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
433 | return null; | ||
434 | } | ||
435 | } | ||
436 | |||
437 | @Override | ||
438 | protected EndOfSiding_step_2.Match arrayToMatchMutable(final Object[] match) { | ||
439 | try { | ||
440 | return EndOfSiding_step_2.Match.newMutableMatch((Train) match[POSITION_TRAIN]); | ||
441 | } catch(ClassCastException e) { | ||
442 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
443 | return null; | ||
444 | } | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @return the singleton instance of the query specification of this pattern | ||
449 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
450 | * | ||
451 | */ | ||
452 | public static IQuerySpecification<EndOfSiding_step_2.Matcher> querySpecification() { | ||
453 | return EndOfSiding_step_2.instance(); | ||
454 | } | ||
455 | } | ||
456 | |||
457 | private EndOfSiding_step_2() { | ||
458 | super(GeneratedPQuery.INSTANCE); | ||
459 | } | ||
460 | |||
461 | /** | ||
462 | * @return the singleton instance of the query specification | ||
463 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
464 | * | ||
465 | */ | ||
466 | public static EndOfSiding_step_2 instance() { | ||
467 | try{ | ||
468 | return LazyHolder.INSTANCE; | ||
469 | } catch (ExceptionInInitializerError err) { | ||
470 | throw processInitializerError(err); | ||
471 | } | ||
472 | } | ||
473 | |||
474 | @Override | ||
475 | protected EndOfSiding_step_2.Matcher instantiate(final ViatraQueryEngine engine) { | ||
476 | return EndOfSiding_step_2.Matcher.on(engine); | ||
477 | } | ||
478 | |||
479 | @Override | ||
480 | public EndOfSiding_step_2.Matcher instantiate() { | ||
481 | return EndOfSiding_step_2.Matcher.create(); | ||
482 | } | ||
483 | |||
484 | @Override | ||
485 | public EndOfSiding_step_2.Match newEmptyMatch() { | ||
486 | return EndOfSiding_step_2.Match.newEmptyMatch(); | ||
487 | } | ||
488 | |||
489 | @Override | ||
490 | public EndOfSiding_step_2.Match newMatch(final Object... parameters) { | ||
491 | return EndOfSiding_step_2.Match.newMatch((modes3.Train) parameters[0]); | ||
492 | } | ||
493 | |||
494 | /** | ||
495 | * Inner class allowing the singleton instance of {@link EndOfSiding_step_2} to be created | ||
496 | * <b>not</b> at the class load time of the outer class, | ||
497 | * but rather at the first call to {@link EndOfSiding_step_2#instance()}. | ||
498 | * | ||
499 | * <p> This workaround is required e.g. to support recursion. | ||
500 | * | ||
501 | */ | ||
502 | private static class LazyHolder { | ||
503 | private static final EndOfSiding_step_2 INSTANCE = new EndOfSiding_step_2(); | ||
504 | |||
505 | /** | ||
506 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
507 | * This initialization order is required to support indirect recursion. | ||
508 | * | ||
509 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
510 | * | ||
511 | */ | ||
512 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
513 | |||
514 | public static Object ensureInitialized() { | ||
515 | INSTANCE.ensureInitializedInternal(); | ||
516 | return null; | ||
517 | } | ||
518 | } | ||
519 | |||
520 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
521 | private static final EndOfSiding_step_2.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
522 | |||
523 | private final PParameter parameter_train = new PParameter("train", "modes3.Train", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Train")), PParameterDirection.INOUT); | ||
524 | |||
525 | private final List<PParameter> parameters = Arrays.asList(parameter_train); | ||
526 | |||
527 | private GeneratedPQuery() { | ||
528 | super(PVisibility.PUBLIC); | ||
529 | } | ||
530 | |||
531 | @Override | ||
532 | public String getFullyQualifiedName() { | ||
533 | return "modes3.queries.endOfSiding_step_2"; | ||
534 | } | ||
535 | |||
536 | @Override | ||
537 | public List<String> getParameterNames() { | ||
538 | return Arrays.asList("train"); | ||
539 | } | ||
540 | |||
541 | @Override | ||
542 | public List<PParameter> getParameters() { | ||
543 | return parameters; | ||
544 | } | ||
545 | |||
546 | @Override | ||
547 | public Set<PBody> doGetContainedBodies() { | ||
548 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
549 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
550 | { | ||
551 | PBody body = new PBody(this); | ||
552 | PVariable var_train = body.getOrCreateVariableByName("train"); | ||
553 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
554 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
555 | new ExportedParameter(body, var_train, parameter_train) | ||
556 | )); | ||
557 | // // frame->train = model->trains[i0];// frame->location = frame->train->location;// if (frame->location != NULL) {// ...// } Train(train) | ||
558 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
559 | bodies.add(body); | ||
560 | } | ||
561 | return bodies; | ||
562 | } | ||
563 | } | ||
564 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_3.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_3.java new file mode 100644 index 00000000..16b28a9f --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_3.java | |||
@@ -0,0 +1,717 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.Train; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern endOfSiding_step_3(in train : Train, in location : Segment) { | ||
48 | * // int loop_bound1 = frame-{@literal >}location-{@literal >}connected_to_count; | ||
49 | * // for (int i1 = 0; i1 {@literal <} loop_bound1; i1++) { | ||
50 | * // ... | ||
51 | * // } | ||
52 | * Train(train); | ||
53 | * Train.location(train, location); | ||
54 | * } | ||
55 | * </pre></code> | ||
56 | * | ||
57 | * @see Matcher | ||
58 | * @see Match | ||
59 | * | ||
60 | */ | ||
61 | @SuppressWarnings("all") | ||
62 | public final class EndOfSiding_step_3 extends BaseGeneratedEMFQuerySpecification<EndOfSiding_step_3.Matcher> { | ||
63 | /** | ||
64 | * Pattern-specific match representation of the modes3.queries.endOfSiding_step_3 pattern, | ||
65 | * to be used in conjunction with {@link Matcher}. | ||
66 | * | ||
67 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
68 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
69 | * usable to represent a match of the pattern in the result of a query, | ||
70 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
71 | * | ||
72 | * @see Matcher | ||
73 | * | ||
74 | */ | ||
75 | public static abstract class Match extends BasePatternMatch { | ||
76 | private Train fTrain; | ||
77 | |||
78 | private Segment fLocation; | ||
79 | |||
80 | private static List<String> parameterNames = makeImmutableList("train", "location"); | ||
81 | |||
82 | private Match(final Train pTrain, final Segment pLocation) { | ||
83 | this.fTrain = pTrain; | ||
84 | this.fLocation = pLocation; | ||
85 | } | ||
86 | |||
87 | @Override | ||
88 | public Object get(final String parameterName) { | ||
89 | switch(parameterName) { | ||
90 | case "train": return this.fTrain; | ||
91 | case "location": return this.fLocation; | ||
92 | default: return null; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | @Override | ||
97 | public Object get(final int index) { | ||
98 | switch(index) { | ||
99 | case 0: return this.fTrain; | ||
100 | case 1: return this.fLocation; | ||
101 | default: return null; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | public Train getTrain() { | ||
106 | return this.fTrain; | ||
107 | } | ||
108 | |||
109 | public Segment getLocation() { | ||
110 | return this.fLocation; | ||
111 | } | ||
112 | |||
113 | @Override | ||
114 | public boolean set(final String parameterName, final Object newValue) { | ||
115 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
116 | if ("train".equals(parameterName) ) { | ||
117 | this.fTrain = (Train) newValue; | ||
118 | return true; | ||
119 | } | ||
120 | if ("location".equals(parameterName) ) { | ||
121 | this.fLocation = (Segment) newValue; | ||
122 | return true; | ||
123 | } | ||
124 | return false; | ||
125 | } | ||
126 | |||
127 | public void setTrain(final Train pTrain) { | ||
128 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
129 | this.fTrain = pTrain; | ||
130 | } | ||
131 | |||
132 | public void setLocation(final Segment pLocation) { | ||
133 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
134 | this.fLocation = pLocation; | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public String patternName() { | ||
139 | return "modes3.queries.endOfSiding_step_3"; | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public List<String> parameterNames() { | ||
144 | return EndOfSiding_step_3.Match.parameterNames; | ||
145 | } | ||
146 | |||
147 | @Override | ||
148 | public Object[] toArray() { | ||
149 | return new Object[]{fTrain, fLocation}; | ||
150 | } | ||
151 | |||
152 | @Override | ||
153 | public EndOfSiding_step_3.Match toImmutable() { | ||
154 | return isMutable() ? newMatch(fTrain, fLocation) : this; | ||
155 | } | ||
156 | |||
157 | @Override | ||
158 | public String prettyPrint() { | ||
159 | StringBuilder result = new StringBuilder(); | ||
160 | result.append("\"train\"=" + prettyPrintValue(fTrain) + ", "); | ||
161 | result.append("\"location\"=" + prettyPrintValue(fLocation)); | ||
162 | return result.toString(); | ||
163 | } | ||
164 | |||
165 | @Override | ||
166 | public int hashCode() { | ||
167 | return Objects.hash(fTrain, fLocation); | ||
168 | } | ||
169 | |||
170 | @Override | ||
171 | public boolean equals(final Object obj) { | ||
172 | if (this == obj) | ||
173 | return true; | ||
174 | if (obj == null) { | ||
175 | return false; | ||
176 | } | ||
177 | if ((obj instanceof EndOfSiding_step_3.Match)) { | ||
178 | EndOfSiding_step_3.Match other = (EndOfSiding_step_3.Match) obj; | ||
179 | return Objects.equals(fTrain, other.fTrain) && Objects.equals(fLocation, other.fLocation); | ||
180 | } else { | ||
181 | // this should be infrequent | ||
182 | if (!(obj instanceof IPatternMatch)) { | ||
183 | return false; | ||
184 | } | ||
185 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
186 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
187 | } | ||
188 | } | ||
189 | |||
190 | @Override | ||
191 | public EndOfSiding_step_3 specification() { | ||
192 | return EndOfSiding_step_3.instance(); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * Returns an empty, mutable match. | ||
197 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
198 | * | ||
199 | * @return the empty match. | ||
200 | * | ||
201 | */ | ||
202 | public static EndOfSiding_step_3.Match newEmptyMatch() { | ||
203 | return new Mutable(null, null); | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * Returns a mutable (partial) match. | ||
208 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
209 | * | ||
210 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
211 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
212 | * @return the new, mutable (partial) match object. | ||
213 | * | ||
214 | */ | ||
215 | public static EndOfSiding_step_3.Match newMutableMatch(final Train pTrain, final Segment pLocation) { | ||
216 | return new Mutable(pTrain, pLocation); | ||
217 | } | ||
218 | |||
219 | /** | ||
220 | * Returns a new (partial) match. | ||
221 | * This can be used e.g. to call the matcher with a partial match. | ||
222 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
223 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
224 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
225 | * @return the (partial) match object. | ||
226 | * | ||
227 | */ | ||
228 | public static EndOfSiding_step_3.Match newMatch(final Train pTrain, final Segment pLocation) { | ||
229 | return new Immutable(pTrain, pLocation); | ||
230 | } | ||
231 | |||
232 | private static final class Mutable extends EndOfSiding_step_3.Match { | ||
233 | Mutable(final Train pTrain, final Segment pLocation) { | ||
234 | super(pTrain, pLocation); | ||
235 | } | ||
236 | |||
237 | @Override | ||
238 | public boolean isMutable() { | ||
239 | return true; | ||
240 | } | ||
241 | } | ||
242 | |||
243 | private static final class Immutable extends EndOfSiding_step_3.Match { | ||
244 | Immutable(final Train pTrain, final Segment pLocation) { | ||
245 | super(pTrain, pLocation); | ||
246 | } | ||
247 | |||
248 | @Override | ||
249 | public boolean isMutable() { | ||
250 | return false; | ||
251 | } | ||
252 | } | ||
253 | } | ||
254 | |||
255 | /** | ||
256 | * Generated pattern matcher API of the modes3.queries.endOfSiding_step_3 pattern, | ||
257 | * providing pattern-specific query methods. | ||
258 | * | ||
259 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
260 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
261 | * | ||
262 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
263 | * | ||
264 | * <p>Original source: | ||
265 | * <code><pre> | ||
266 | * pattern endOfSiding_step_3(in train : Train, in location : Segment) { | ||
267 | * // int loop_bound1 = frame-{@literal >}location-{@literal >}connected_to_count; | ||
268 | * // for (int i1 = 0; i1 {@literal <} loop_bound1; i1++) { | ||
269 | * // ... | ||
270 | * // } | ||
271 | * Train(train); | ||
272 | * Train.location(train, location); | ||
273 | * } | ||
274 | * </pre></code> | ||
275 | * | ||
276 | * @see Match | ||
277 | * @see EndOfSiding_step_3 | ||
278 | * | ||
279 | */ | ||
280 | public static class Matcher extends BaseMatcher<EndOfSiding_step_3.Match> { | ||
281 | /** | ||
282 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
283 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
284 | * | ||
285 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
286 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
287 | * | ||
288 | */ | ||
289 | public static EndOfSiding_step_3.Matcher on(final ViatraQueryEngine engine) { | ||
290 | // check if matcher already exists | ||
291 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
292 | if (matcher == null) { | ||
293 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
294 | } | ||
295 | return matcher; | ||
296 | } | ||
297 | |||
298 | /** | ||
299 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
300 | * @return an initialized matcher | ||
301 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
302 | * | ||
303 | */ | ||
304 | public static EndOfSiding_step_3.Matcher create() { | ||
305 | return new Matcher(); | ||
306 | } | ||
307 | |||
308 | private static final int POSITION_TRAIN = 0; | ||
309 | |||
310 | private static final int POSITION_LOCATION = 1; | ||
311 | |||
312 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EndOfSiding_step_3.Matcher.class); | ||
313 | |||
314 | /** | ||
315 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
316 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
317 | * | ||
318 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
319 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
320 | * | ||
321 | */ | ||
322 | private Matcher() { | ||
323 | super(querySpecification()); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
328 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
329 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
330 | * @return matches represented as a Match object. | ||
331 | * | ||
332 | */ | ||
333 | public Collection<EndOfSiding_step_3.Match> getAllMatches(final Train pTrain, final Segment pLocation) { | ||
334 | return rawStreamAllMatches(new Object[]{pTrain, pLocation}).collect(Collectors.toSet()); | ||
335 | } | ||
336 | |||
337 | /** | ||
338 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
339 | * </p> | ||
340 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
341 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
342 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
343 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
344 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
345 | * @return a stream of matches represented as a Match object. | ||
346 | * | ||
347 | */ | ||
348 | public Stream<EndOfSiding_step_3.Match> streamAllMatches(final Train pTrain, final Segment pLocation) { | ||
349 | return rawStreamAllMatches(new Object[]{pTrain, pLocation}); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
354 | * Neither determinism nor randomness of selection is guaranteed. | ||
355 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
356 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
357 | * @return a match represented as a Match object, or null if no match is found. | ||
358 | * | ||
359 | */ | ||
360 | public Optional<EndOfSiding_step_3.Match> getOneArbitraryMatch(final Train pTrain, final Segment pLocation) { | ||
361 | return rawGetOneArbitraryMatch(new Object[]{pTrain, pLocation}); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
366 | * under any possible substitution of the unspecified parameters (if any). | ||
367 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
368 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
369 | * @return true if the input is a valid (partial) match of the pattern. | ||
370 | * | ||
371 | */ | ||
372 | public boolean hasMatch(final Train pTrain, final Segment pLocation) { | ||
373 | return rawHasMatch(new Object[]{pTrain, pLocation}); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
378 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
379 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
380 | * @return the number of pattern matches found. | ||
381 | * | ||
382 | */ | ||
383 | public int countMatches(final Train pTrain, final Segment pLocation) { | ||
384 | return rawCountMatches(new Object[]{pTrain, pLocation}); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
389 | * Neither determinism nor randomness of selection is guaranteed. | ||
390 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
391 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
392 | * @param processor the action that will process the selected match. | ||
393 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
394 | * | ||
395 | */ | ||
396 | public boolean forOneArbitraryMatch(final Train pTrain, final Segment pLocation, final Consumer<? super EndOfSiding_step_3.Match> processor) { | ||
397 | return rawForOneArbitraryMatch(new Object[]{pTrain, pLocation}, processor); | ||
398 | } | ||
399 | |||
400 | /** | ||
401 | * Returns a new (partial) match. | ||
402 | * This can be used e.g. to call the matcher with a partial match. | ||
403 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
404 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
405 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
406 | * @return the (partial) match object. | ||
407 | * | ||
408 | */ | ||
409 | public EndOfSiding_step_3.Match newMatch(final Train pTrain, final Segment pLocation) { | ||
410 | return EndOfSiding_step_3.Match.newMatch(pTrain, pLocation); | ||
411 | } | ||
412 | |||
413 | /** | ||
414 | * Retrieve the set of values that occur in matches for train. | ||
415 | * @return the Set of all values or empty set if there are no matches | ||
416 | * | ||
417 | */ | ||
418 | protected Stream<Train> rawStreamAllValuesOftrain(final Object[] parameters) { | ||
419 | return rawStreamAllValues(POSITION_TRAIN, parameters).map(Train.class::cast); | ||
420 | } | ||
421 | |||
422 | /** | ||
423 | * Retrieve the set of values that occur in matches for train. | ||
424 | * @return the Set of all values or empty set if there are no matches | ||
425 | * | ||
426 | */ | ||
427 | public Set<Train> getAllValuesOftrain() { | ||
428 | return rawStreamAllValuesOftrain(emptyArray()).collect(Collectors.toSet()); | ||
429 | } | ||
430 | |||
431 | /** | ||
432 | * Retrieve the set of values that occur in matches for train. | ||
433 | * @return the Set of all values or empty set if there are no matches | ||
434 | * | ||
435 | */ | ||
436 | public Stream<Train> streamAllValuesOftrain() { | ||
437 | return rawStreamAllValuesOftrain(emptyArray()); | ||
438 | } | ||
439 | |||
440 | /** | ||
441 | * Retrieve the set of values that occur in matches for train. | ||
442 | * </p> | ||
443 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
444 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
445 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
446 | * | ||
447 | * @return the Stream of all values or empty set if there are no matches | ||
448 | * | ||
449 | */ | ||
450 | public Stream<Train> streamAllValuesOftrain(final EndOfSiding_step_3.Match partialMatch) { | ||
451 | return rawStreamAllValuesOftrain(partialMatch.toArray()); | ||
452 | } | ||
453 | |||
454 | /** | ||
455 | * Retrieve the set of values that occur in matches for train. | ||
456 | * </p> | ||
457 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
458 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
459 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
460 | * | ||
461 | * @return the Stream of all values or empty set if there are no matches | ||
462 | * | ||
463 | */ | ||
464 | public Stream<Train> streamAllValuesOftrain(final Segment pLocation) { | ||
465 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation}); | ||
466 | } | ||
467 | |||
468 | /** | ||
469 | * Retrieve the set of values that occur in matches for train. | ||
470 | * @return the Set of all values or empty set if there are no matches | ||
471 | * | ||
472 | */ | ||
473 | public Set<Train> getAllValuesOftrain(final EndOfSiding_step_3.Match partialMatch) { | ||
474 | return rawStreamAllValuesOftrain(partialMatch.toArray()).collect(Collectors.toSet()); | ||
475 | } | ||
476 | |||
477 | /** | ||
478 | * Retrieve the set of values that occur in matches for train. | ||
479 | * @return the Set of all values or empty set if there are no matches | ||
480 | * | ||
481 | */ | ||
482 | public Set<Train> getAllValuesOftrain(final Segment pLocation) { | ||
483 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation}).collect(Collectors.toSet()); | ||
484 | } | ||
485 | |||
486 | /** | ||
487 | * Retrieve the set of values that occur in matches for location. | ||
488 | * @return the Set of all values or empty set if there are no matches | ||
489 | * | ||
490 | */ | ||
491 | protected Stream<Segment> rawStreamAllValuesOflocation(final Object[] parameters) { | ||
492 | return rawStreamAllValues(POSITION_LOCATION, parameters).map(Segment.class::cast); | ||
493 | } | ||
494 | |||
495 | /** | ||
496 | * Retrieve the set of values that occur in matches for location. | ||
497 | * @return the Set of all values or empty set if there are no matches | ||
498 | * | ||
499 | */ | ||
500 | public Set<Segment> getAllValuesOflocation() { | ||
501 | return rawStreamAllValuesOflocation(emptyArray()).collect(Collectors.toSet()); | ||
502 | } | ||
503 | |||
504 | /** | ||
505 | * Retrieve the set of values that occur in matches for location. | ||
506 | * @return the Set of all values or empty set if there are no matches | ||
507 | * | ||
508 | */ | ||
509 | public Stream<Segment> streamAllValuesOflocation() { | ||
510 | return rawStreamAllValuesOflocation(emptyArray()); | ||
511 | } | ||
512 | |||
513 | /** | ||
514 | * Retrieve the set of values that occur in matches for location. | ||
515 | * </p> | ||
516 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
517 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
518 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
519 | * | ||
520 | * @return the Stream of all values or empty set if there are no matches | ||
521 | * | ||
522 | */ | ||
523 | public Stream<Segment> streamAllValuesOflocation(final EndOfSiding_step_3.Match partialMatch) { | ||
524 | return rawStreamAllValuesOflocation(partialMatch.toArray()); | ||
525 | } | ||
526 | |||
527 | /** | ||
528 | * Retrieve the set of values that occur in matches for location. | ||
529 | * </p> | ||
530 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
531 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
532 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
533 | * | ||
534 | * @return the Stream of all values or empty set if there are no matches | ||
535 | * | ||
536 | */ | ||
537 | public Stream<Segment> streamAllValuesOflocation(final Train pTrain) { | ||
538 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null}); | ||
539 | } | ||
540 | |||
541 | /** | ||
542 | * Retrieve the set of values that occur in matches for location. | ||
543 | * @return the Set of all values or empty set if there are no matches | ||
544 | * | ||
545 | */ | ||
546 | public Set<Segment> getAllValuesOflocation(final EndOfSiding_step_3.Match partialMatch) { | ||
547 | return rawStreamAllValuesOflocation(partialMatch.toArray()).collect(Collectors.toSet()); | ||
548 | } | ||
549 | |||
550 | /** | ||
551 | * Retrieve the set of values that occur in matches for location. | ||
552 | * @return the Set of all values or empty set if there are no matches | ||
553 | * | ||
554 | */ | ||
555 | public Set<Segment> getAllValuesOflocation(final Train pTrain) { | ||
556 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null}).collect(Collectors.toSet()); | ||
557 | } | ||
558 | |||
559 | @Override | ||
560 | protected EndOfSiding_step_3.Match tupleToMatch(final Tuple t) { | ||
561 | try { | ||
562 | return EndOfSiding_step_3.Match.newMatch((Train) t.get(POSITION_TRAIN), (Segment) t.get(POSITION_LOCATION)); | ||
563 | } catch(ClassCastException e) { | ||
564 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
565 | return null; | ||
566 | } | ||
567 | } | ||
568 | |||
569 | @Override | ||
570 | protected EndOfSiding_step_3.Match arrayToMatch(final Object[] match) { | ||
571 | try { | ||
572 | return EndOfSiding_step_3.Match.newMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION]); | ||
573 | } catch(ClassCastException e) { | ||
574 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
575 | return null; | ||
576 | } | ||
577 | } | ||
578 | |||
579 | @Override | ||
580 | protected EndOfSiding_step_3.Match arrayToMatchMutable(final Object[] match) { | ||
581 | try { | ||
582 | return EndOfSiding_step_3.Match.newMutableMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION]); | ||
583 | } catch(ClassCastException e) { | ||
584 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
585 | return null; | ||
586 | } | ||
587 | } | ||
588 | |||
589 | /** | ||
590 | * @return the singleton instance of the query specification of this pattern | ||
591 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
592 | * | ||
593 | */ | ||
594 | public static IQuerySpecification<EndOfSiding_step_3.Matcher> querySpecification() { | ||
595 | return EndOfSiding_step_3.instance(); | ||
596 | } | ||
597 | } | ||
598 | |||
599 | private EndOfSiding_step_3() { | ||
600 | super(GeneratedPQuery.INSTANCE); | ||
601 | } | ||
602 | |||
603 | /** | ||
604 | * @return the singleton instance of the query specification | ||
605 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
606 | * | ||
607 | */ | ||
608 | public static EndOfSiding_step_3 instance() { | ||
609 | try{ | ||
610 | return LazyHolder.INSTANCE; | ||
611 | } catch (ExceptionInInitializerError err) { | ||
612 | throw processInitializerError(err); | ||
613 | } | ||
614 | } | ||
615 | |||
616 | @Override | ||
617 | protected EndOfSiding_step_3.Matcher instantiate(final ViatraQueryEngine engine) { | ||
618 | return EndOfSiding_step_3.Matcher.on(engine); | ||
619 | } | ||
620 | |||
621 | @Override | ||
622 | public EndOfSiding_step_3.Matcher instantiate() { | ||
623 | return EndOfSiding_step_3.Matcher.create(); | ||
624 | } | ||
625 | |||
626 | @Override | ||
627 | public EndOfSiding_step_3.Match newEmptyMatch() { | ||
628 | return EndOfSiding_step_3.Match.newEmptyMatch(); | ||
629 | } | ||
630 | |||
631 | @Override | ||
632 | public EndOfSiding_step_3.Match newMatch(final Object... parameters) { | ||
633 | return EndOfSiding_step_3.Match.newMatch((modes3.Train) parameters[0], (modes3.Segment) parameters[1]); | ||
634 | } | ||
635 | |||
636 | /** | ||
637 | * Inner class allowing the singleton instance of {@link EndOfSiding_step_3} to be created | ||
638 | * <b>not</b> at the class load time of the outer class, | ||
639 | * but rather at the first call to {@link EndOfSiding_step_3#instance()}. | ||
640 | * | ||
641 | * <p> This workaround is required e.g. to support recursion. | ||
642 | * | ||
643 | */ | ||
644 | private static class LazyHolder { | ||
645 | private static final EndOfSiding_step_3 INSTANCE = new EndOfSiding_step_3(); | ||
646 | |||
647 | /** | ||
648 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
649 | * This initialization order is required to support indirect recursion. | ||
650 | * | ||
651 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
652 | * | ||
653 | */ | ||
654 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
655 | |||
656 | public static Object ensureInitialized() { | ||
657 | INSTANCE.ensureInitializedInternal(); | ||
658 | return null; | ||
659 | } | ||
660 | } | ||
661 | |||
662 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
663 | private static final EndOfSiding_step_3.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
664 | |||
665 | private final PParameter parameter_train = new PParameter("train", "modes3.Train", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Train")), PParameterDirection.INOUT); | ||
666 | |||
667 | private final PParameter parameter_location = new PParameter("location", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
668 | |||
669 | private final List<PParameter> parameters = Arrays.asList(parameter_train, parameter_location); | ||
670 | |||
671 | private GeneratedPQuery() { | ||
672 | super(PVisibility.PUBLIC); | ||
673 | } | ||
674 | |||
675 | @Override | ||
676 | public String getFullyQualifiedName() { | ||
677 | return "modes3.queries.endOfSiding_step_3"; | ||
678 | } | ||
679 | |||
680 | @Override | ||
681 | public List<String> getParameterNames() { | ||
682 | return Arrays.asList("train","location"); | ||
683 | } | ||
684 | |||
685 | @Override | ||
686 | public List<PParameter> getParameters() { | ||
687 | return parameters; | ||
688 | } | ||
689 | |||
690 | @Override | ||
691 | public Set<PBody> doGetContainedBodies() { | ||
692 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
693 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
694 | { | ||
695 | PBody body = new PBody(this); | ||
696 | PVariable var_train = body.getOrCreateVariableByName("train"); | ||
697 | PVariable var_location = body.getOrCreateVariableByName("location"); | ||
698 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
699 | new TypeConstraint(body, Tuples.flatTupleOf(var_location), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
700 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
701 | new ExportedParameter(body, var_train, parameter_train), | ||
702 | new ExportedParameter(body, var_location, parameter_location) | ||
703 | )); | ||
704 | // // int loop_bound1 = frame->location->connected_to_count;// for (int i1 = 0; i1 < loop_bound1; i1++) {// ...// } Train(train) | ||
705 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
706 | // Train.location(train, location) | ||
707 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
708 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
709 | new TypeConstraint(body, Tuples.flatTupleOf(var_train, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train", "location"))); | ||
710 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
711 | new Equality(body, var__virtual_0_, var_location); | ||
712 | bodies.add(body); | ||
713 | } | ||
714 | return bodies; | ||
715 | } | ||
716 | } | ||
717 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_4.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_4.java new file mode 100644 index 00000000..73df8514 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_4.java | |||
@@ -0,0 +1,847 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.Train; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern endOfSiding_step_4(in train : Train, in location : Segment, in end : Segment) { | ||
48 | * // frame-{@literal >}end = frame-{@literal >}location-{@literal >}connected_to[i1]; | ||
49 | * // if (frame-{@literal >}end != NULL && | ||
50 | * // frame-{@literal >}end-{@literal >}connected_to[1] == frame-{@literal >}location && | ||
51 | * // frame-{@literal >}end-{@literal >}connected_to[0] == NULL) { | ||
52 | * // ... | ||
53 | * // } | ||
54 | * // if (frame-{@literal >}end != NULL && | ||
55 | * // frame-{@literal >}end-{@literal >}connected_to[0] == frame-{@literal >}location && | ||
56 | * // frame-{@literal >}end-{@literal >}connected_to[1] == NULL) { | ||
57 | * // ... | ||
58 | * // } | ||
59 | * Train(train); | ||
60 | * Train.location(train, location); | ||
61 | * Segment.connectedTo(location, end); | ||
62 | * } | ||
63 | * </pre></code> | ||
64 | * | ||
65 | * @see Matcher | ||
66 | * @see Match | ||
67 | * | ||
68 | */ | ||
69 | @SuppressWarnings("all") | ||
70 | public final class EndOfSiding_step_4 extends BaseGeneratedEMFQuerySpecification<EndOfSiding_step_4.Matcher> { | ||
71 | /** | ||
72 | * Pattern-specific match representation of the modes3.queries.endOfSiding_step_4 pattern, | ||
73 | * to be used in conjunction with {@link Matcher}. | ||
74 | * | ||
75 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
76 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
77 | * usable to represent a match of the pattern in the result of a query, | ||
78 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
79 | * | ||
80 | * @see Matcher | ||
81 | * | ||
82 | */ | ||
83 | public static abstract class Match extends BasePatternMatch { | ||
84 | private Train fTrain; | ||
85 | |||
86 | private Segment fLocation; | ||
87 | |||
88 | private Segment fEnd; | ||
89 | |||
90 | private static List<String> parameterNames = makeImmutableList("train", "location", "end"); | ||
91 | |||
92 | private Match(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
93 | this.fTrain = pTrain; | ||
94 | this.fLocation = pLocation; | ||
95 | this.fEnd = pEnd; | ||
96 | } | ||
97 | |||
98 | @Override | ||
99 | public Object get(final String parameterName) { | ||
100 | switch(parameterName) { | ||
101 | case "train": return this.fTrain; | ||
102 | case "location": return this.fLocation; | ||
103 | case "end": return this.fEnd; | ||
104 | default: return null; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | @Override | ||
109 | public Object get(final int index) { | ||
110 | switch(index) { | ||
111 | case 0: return this.fTrain; | ||
112 | case 1: return this.fLocation; | ||
113 | case 2: return this.fEnd; | ||
114 | default: return null; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | public Train getTrain() { | ||
119 | return this.fTrain; | ||
120 | } | ||
121 | |||
122 | public Segment getLocation() { | ||
123 | return this.fLocation; | ||
124 | } | ||
125 | |||
126 | public Segment getEnd() { | ||
127 | return this.fEnd; | ||
128 | } | ||
129 | |||
130 | @Override | ||
131 | public boolean set(final String parameterName, final Object newValue) { | ||
132 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
133 | if ("train".equals(parameterName) ) { | ||
134 | this.fTrain = (Train) newValue; | ||
135 | return true; | ||
136 | } | ||
137 | if ("location".equals(parameterName) ) { | ||
138 | this.fLocation = (Segment) newValue; | ||
139 | return true; | ||
140 | } | ||
141 | if ("end".equals(parameterName) ) { | ||
142 | this.fEnd = (Segment) newValue; | ||
143 | return true; | ||
144 | } | ||
145 | return false; | ||
146 | } | ||
147 | |||
148 | public void setTrain(final Train pTrain) { | ||
149 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
150 | this.fTrain = pTrain; | ||
151 | } | ||
152 | |||
153 | public void setLocation(final Segment pLocation) { | ||
154 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
155 | this.fLocation = pLocation; | ||
156 | } | ||
157 | |||
158 | public void setEnd(final Segment pEnd) { | ||
159 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
160 | this.fEnd = pEnd; | ||
161 | } | ||
162 | |||
163 | @Override | ||
164 | public String patternName() { | ||
165 | return "modes3.queries.endOfSiding_step_4"; | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public List<String> parameterNames() { | ||
170 | return EndOfSiding_step_4.Match.parameterNames; | ||
171 | } | ||
172 | |||
173 | @Override | ||
174 | public Object[] toArray() { | ||
175 | return new Object[]{fTrain, fLocation, fEnd}; | ||
176 | } | ||
177 | |||
178 | @Override | ||
179 | public EndOfSiding_step_4.Match toImmutable() { | ||
180 | return isMutable() ? newMatch(fTrain, fLocation, fEnd) : this; | ||
181 | } | ||
182 | |||
183 | @Override | ||
184 | public String prettyPrint() { | ||
185 | StringBuilder result = new StringBuilder(); | ||
186 | result.append("\"train\"=" + prettyPrintValue(fTrain) + ", "); | ||
187 | result.append("\"location\"=" + prettyPrintValue(fLocation) + ", "); | ||
188 | result.append("\"end\"=" + prettyPrintValue(fEnd)); | ||
189 | return result.toString(); | ||
190 | } | ||
191 | |||
192 | @Override | ||
193 | public int hashCode() { | ||
194 | return Objects.hash(fTrain, fLocation, fEnd); | ||
195 | } | ||
196 | |||
197 | @Override | ||
198 | public boolean equals(final Object obj) { | ||
199 | if (this == obj) | ||
200 | return true; | ||
201 | if (obj == null) { | ||
202 | return false; | ||
203 | } | ||
204 | if ((obj instanceof EndOfSiding_step_4.Match)) { | ||
205 | EndOfSiding_step_4.Match other = (EndOfSiding_step_4.Match) obj; | ||
206 | return Objects.equals(fTrain, other.fTrain) && Objects.equals(fLocation, other.fLocation) && Objects.equals(fEnd, other.fEnd); | ||
207 | } else { | ||
208 | // this should be infrequent | ||
209 | if (!(obj instanceof IPatternMatch)) { | ||
210 | return false; | ||
211 | } | ||
212 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
213 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | @Override | ||
218 | public EndOfSiding_step_4 specification() { | ||
219 | return EndOfSiding_step_4.instance(); | ||
220 | } | ||
221 | |||
222 | /** | ||
223 | * Returns an empty, mutable match. | ||
224 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
225 | * | ||
226 | * @return the empty match. | ||
227 | * | ||
228 | */ | ||
229 | public static EndOfSiding_step_4.Match newEmptyMatch() { | ||
230 | return new Mutable(null, null, null); | ||
231 | } | ||
232 | |||
233 | /** | ||
234 | * Returns a mutable (partial) match. | ||
235 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
236 | * | ||
237 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
238 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
239 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
240 | * @return the new, mutable (partial) match object. | ||
241 | * | ||
242 | */ | ||
243 | public static EndOfSiding_step_4.Match newMutableMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
244 | return new Mutable(pTrain, pLocation, pEnd); | ||
245 | } | ||
246 | |||
247 | /** | ||
248 | * Returns a new (partial) match. | ||
249 | * This can be used e.g. to call the matcher with a partial match. | ||
250 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
251 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
252 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
253 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
254 | * @return the (partial) match object. | ||
255 | * | ||
256 | */ | ||
257 | public static EndOfSiding_step_4.Match newMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
258 | return new Immutable(pTrain, pLocation, pEnd); | ||
259 | } | ||
260 | |||
261 | private static final class Mutable extends EndOfSiding_step_4.Match { | ||
262 | Mutable(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
263 | super(pTrain, pLocation, pEnd); | ||
264 | } | ||
265 | |||
266 | @Override | ||
267 | public boolean isMutable() { | ||
268 | return true; | ||
269 | } | ||
270 | } | ||
271 | |||
272 | private static final class Immutable extends EndOfSiding_step_4.Match { | ||
273 | Immutable(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
274 | super(pTrain, pLocation, pEnd); | ||
275 | } | ||
276 | |||
277 | @Override | ||
278 | public boolean isMutable() { | ||
279 | return false; | ||
280 | } | ||
281 | } | ||
282 | } | ||
283 | |||
284 | /** | ||
285 | * Generated pattern matcher API of the modes3.queries.endOfSiding_step_4 pattern, | ||
286 | * providing pattern-specific query methods. | ||
287 | * | ||
288 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
289 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
290 | * | ||
291 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
292 | * | ||
293 | * <p>Original source: | ||
294 | * <code><pre> | ||
295 | * pattern endOfSiding_step_4(in train : Train, in location : Segment, in end : Segment) { | ||
296 | * // frame-{@literal >}end = frame-{@literal >}location-{@literal >}connected_to[i1]; | ||
297 | * // if (frame-{@literal >}end != NULL && | ||
298 | * // frame-{@literal >}end-{@literal >}connected_to[1] == frame-{@literal >}location && | ||
299 | * // frame-{@literal >}end-{@literal >}connected_to[0] == NULL) { | ||
300 | * // ... | ||
301 | * // } | ||
302 | * // if (frame-{@literal >}end != NULL && | ||
303 | * // frame-{@literal >}end-{@literal >}connected_to[0] == frame-{@literal >}location && | ||
304 | * // frame-{@literal >}end-{@literal >}connected_to[1] == NULL) { | ||
305 | * // ... | ||
306 | * // } | ||
307 | * Train(train); | ||
308 | * Train.location(train, location); | ||
309 | * Segment.connectedTo(location, end); | ||
310 | * } | ||
311 | * </pre></code> | ||
312 | * | ||
313 | * @see Match | ||
314 | * @see EndOfSiding_step_4 | ||
315 | * | ||
316 | */ | ||
317 | public static class Matcher extends BaseMatcher<EndOfSiding_step_4.Match> { | ||
318 | /** | ||
319 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
320 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
321 | * | ||
322 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
323 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
324 | * | ||
325 | */ | ||
326 | public static EndOfSiding_step_4.Matcher on(final ViatraQueryEngine engine) { | ||
327 | // check if matcher already exists | ||
328 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
329 | if (matcher == null) { | ||
330 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
331 | } | ||
332 | return matcher; | ||
333 | } | ||
334 | |||
335 | /** | ||
336 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
337 | * @return an initialized matcher | ||
338 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
339 | * | ||
340 | */ | ||
341 | public static EndOfSiding_step_4.Matcher create() { | ||
342 | return new Matcher(); | ||
343 | } | ||
344 | |||
345 | private static final int POSITION_TRAIN = 0; | ||
346 | |||
347 | private static final int POSITION_LOCATION = 1; | ||
348 | |||
349 | private static final int POSITION_END = 2; | ||
350 | |||
351 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EndOfSiding_step_4.Matcher.class); | ||
352 | |||
353 | /** | ||
354 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
355 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
356 | * | ||
357 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
358 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
359 | * | ||
360 | */ | ||
361 | private Matcher() { | ||
362 | super(querySpecification()); | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
367 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
368 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
369 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
370 | * @return matches represented as a Match object. | ||
371 | * | ||
372 | */ | ||
373 | public Collection<EndOfSiding_step_4.Match> getAllMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
374 | return rawStreamAllMatches(new Object[]{pTrain, pLocation, pEnd}).collect(Collectors.toSet()); | ||
375 | } | ||
376 | |||
377 | /** | ||
378 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
379 | * </p> | ||
380 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
381 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
382 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
383 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
384 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
385 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
386 | * @return a stream of matches represented as a Match object. | ||
387 | * | ||
388 | */ | ||
389 | public Stream<EndOfSiding_step_4.Match> streamAllMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
390 | return rawStreamAllMatches(new Object[]{pTrain, pLocation, pEnd}); | ||
391 | } | ||
392 | |||
393 | /** | ||
394 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
395 | * Neither determinism nor randomness of selection is guaranteed. | ||
396 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
397 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
398 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
399 | * @return a match represented as a Match object, or null if no match is found. | ||
400 | * | ||
401 | */ | ||
402 | public Optional<EndOfSiding_step_4.Match> getOneArbitraryMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
403 | return rawGetOneArbitraryMatch(new Object[]{pTrain, pLocation, pEnd}); | ||
404 | } | ||
405 | |||
406 | /** | ||
407 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
408 | * under any possible substitution of the unspecified parameters (if any). | ||
409 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
410 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
411 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
412 | * @return true if the input is a valid (partial) match of the pattern. | ||
413 | * | ||
414 | */ | ||
415 | public boolean hasMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
416 | return rawHasMatch(new Object[]{pTrain, pLocation, pEnd}); | ||
417 | } | ||
418 | |||
419 | /** | ||
420 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
421 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
422 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
423 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
424 | * @return the number of pattern matches found. | ||
425 | * | ||
426 | */ | ||
427 | public int countMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
428 | return rawCountMatches(new Object[]{pTrain, pLocation, pEnd}); | ||
429 | } | ||
430 | |||
431 | /** | ||
432 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
433 | * Neither determinism nor randomness of selection is guaranteed. | ||
434 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
435 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
436 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
437 | * @param processor the action that will process the selected match. | ||
438 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
439 | * | ||
440 | */ | ||
441 | public boolean forOneArbitraryMatch(final Train pTrain, final Segment pLocation, final Segment pEnd, final Consumer<? super EndOfSiding_step_4.Match> processor) { | ||
442 | return rawForOneArbitraryMatch(new Object[]{pTrain, pLocation, pEnd}, processor); | ||
443 | } | ||
444 | |||
445 | /** | ||
446 | * Returns a new (partial) match. | ||
447 | * This can be used e.g. to call the matcher with a partial match. | ||
448 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
449 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
450 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
451 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
452 | * @return the (partial) match object. | ||
453 | * | ||
454 | */ | ||
455 | public EndOfSiding_step_4.Match newMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
456 | return EndOfSiding_step_4.Match.newMatch(pTrain, pLocation, pEnd); | ||
457 | } | ||
458 | |||
459 | /** | ||
460 | * Retrieve the set of values that occur in matches for train. | ||
461 | * @return the Set of all values or empty set if there are no matches | ||
462 | * | ||
463 | */ | ||
464 | protected Stream<Train> rawStreamAllValuesOftrain(final Object[] parameters) { | ||
465 | return rawStreamAllValues(POSITION_TRAIN, parameters).map(Train.class::cast); | ||
466 | } | ||
467 | |||
468 | /** | ||
469 | * Retrieve the set of values that occur in matches for train. | ||
470 | * @return the Set of all values or empty set if there are no matches | ||
471 | * | ||
472 | */ | ||
473 | public Set<Train> getAllValuesOftrain() { | ||
474 | return rawStreamAllValuesOftrain(emptyArray()).collect(Collectors.toSet()); | ||
475 | } | ||
476 | |||
477 | /** | ||
478 | * Retrieve the set of values that occur in matches for train. | ||
479 | * @return the Set of all values or empty set if there are no matches | ||
480 | * | ||
481 | */ | ||
482 | public Stream<Train> streamAllValuesOftrain() { | ||
483 | return rawStreamAllValuesOftrain(emptyArray()); | ||
484 | } | ||
485 | |||
486 | /** | ||
487 | * Retrieve the set of values that occur in matches for train. | ||
488 | * </p> | ||
489 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
490 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
491 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
492 | * | ||
493 | * @return the Stream of all values or empty set if there are no matches | ||
494 | * | ||
495 | */ | ||
496 | public Stream<Train> streamAllValuesOftrain(final EndOfSiding_step_4.Match partialMatch) { | ||
497 | return rawStreamAllValuesOftrain(partialMatch.toArray()); | ||
498 | } | ||
499 | |||
500 | /** | ||
501 | * Retrieve the set of values that occur in matches for train. | ||
502 | * </p> | ||
503 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
504 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
505 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
506 | * | ||
507 | * @return the Stream of all values or empty set if there are no matches | ||
508 | * | ||
509 | */ | ||
510 | public Stream<Train> streamAllValuesOftrain(final Segment pLocation, final Segment pEnd) { | ||
511 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation, pEnd}); | ||
512 | } | ||
513 | |||
514 | /** | ||
515 | * Retrieve the set of values that occur in matches for train. | ||
516 | * @return the Set of all values or empty set if there are no matches | ||
517 | * | ||
518 | */ | ||
519 | public Set<Train> getAllValuesOftrain(final EndOfSiding_step_4.Match partialMatch) { | ||
520 | return rawStreamAllValuesOftrain(partialMatch.toArray()).collect(Collectors.toSet()); | ||
521 | } | ||
522 | |||
523 | /** | ||
524 | * Retrieve the set of values that occur in matches for train. | ||
525 | * @return the Set of all values or empty set if there are no matches | ||
526 | * | ||
527 | */ | ||
528 | public Set<Train> getAllValuesOftrain(final Segment pLocation, final Segment pEnd) { | ||
529 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation, pEnd}).collect(Collectors.toSet()); | ||
530 | } | ||
531 | |||
532 | /** | ||
533 | * Retrieve the set of values that occur in matches for location. | ||
534 | * @return the Set of all values or empty set if there are no matches | ||
535 | * | ||
536 | */ | ||
537 | protected Stream<Segment> rawStreamAllValuesOflocation(final Object[] parameters) { | ||
538 | return rawStreamAllValues(POSITION_LOCATION, parameters).map(Segment.class::cast); | ||
539 | } | ||
540 | |||
541 | /** | ||
542 | * Retrieve the set of values that occur in matches for location. | ||
543 | * @return the Set of all values or empty set if there are no matches | ||
544 | * | ||
545 | */ | ||
546 | public Set<Segment> getAllValuesOflocation() { | ||
547 | return rawStreamAllValuesOflocation(emptyArray()).collect(Collectors.toSet()); | ||
548 | } | ||
549 | |||
550 | /** | ||
551 | * Retrieve the set of values that occur in matches for location. | ||
552 | * @return the Set of all values or empty set if there are no matches | ||
553 | * | ||
554 | */ | ||
555 | public Stream<Segment> streamAllValuesOflocation() { | ||
556 | return rawStreamAllValuesOflocation(emptyArray()); | ||
557 | } | ||
558 | |||
559 | /** | ||
560 | * Retrieve the set of values that occur in matches for location. | ||
561 | * </p> | ||
562 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
563 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
564 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
565 | * | ||
566 | * @return the Stream of all values or empty set if there are no matches | ||
567 | * | ||
568 | */ | ||
569 | public Stream<Segment> streamAllValuesOflocation(final EndOfSiding_step_4.Match partialMatch) { | ||
570 | return rawStreamAllValuesOflocation(partialMatch.toArray()); | ||
571 | } | ||
572 | |||
573 | /** | ||
574 | * Retrieve the set of values that occur in matches for location. | ||
575 | * </p> | ||
576 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
577 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
578 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
579 | * | ||
580 | * @return the Stream of all values or empty set if there are no matches | ||
581 | * | ||
582 | */ | ||
583 | public Stream<Segment> streamAllValuesOflocation(final Train pTrain, final Segment pEnd) { | ||
584 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null, pEnd}); | ||
585 | } | ||
586 | |||
587 | /** | ||
588 | * Retrieve the set of values that occur in matches for location. | ||
589 | * @return the Set of all values or empty set if there are no matches | ||
590 | * | ||
591 | */ | ||
592 | public Set<Segment> getAllValuesOflocation(final EndOfSiding_step_4.Match partialMatch) { | ||
593 | return rawStreamAllValuesOflocation(partialMatch.toArray()).collect(Collectors.toSet()); | ||
594 | } | ||
595 | |||
596 | /** | ||
597 | * Retrieve the set of values that occur in matches for location. | ||
598 | * @return the Set of all values or empty set if there are no matches | ||
599 | * | ||
600 | */ | ||
601 | public Set<Segment> getAllValuesOflocation(final Train pTrain, final Segment pEnd) { | ||
602 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null, pEnd}).collect(Collectors.toSet()); | ||
603 | } | ||
604 | |||
605 | /** | ||
606 | * Retrieve the set of values that occur in matches for end. | ||
607 | * @return the Set of all values or empty set if there are no matches | ||
608 | * | ||
609 | */ | ||
610 | protected Stream<Segment> rawStreamAllValuesOfend(final Object[] parameters) { | ||
611 | return rawStreamAllValues(POSITION_END, parameters).map(Segment.class::cast); | ||
612 | } | ||
613 | |||
614 | /** | ||
615 | * Retrieve the set of values that occur in matches for end. | ||
616 | * @return the Set of all values or empty set if there are no matches | ||
617 | * | ||
618 | */ | ||
619 | public Set<Segment> getAllValuesOfend() { | ||
620 | return rawStreamAllValuesOfend(emptyArray()).collect(Collectors.toSet()); | ||
621 | } | ||
622 | |||
623 | /** | ||
624 | * Retrieve the set of values that occur in matches for end. | ||
625 | * @return the Set of all values or empty set if there are no matches | ||
626 | * | ||
627 | */ | ||
628 | public Stream<Segment> streamAllValuesOfend() { | ||
629 | return rawStreamAllValuesOfend(emptyArray()); | ||
630 | } | ||
631 | |||
632 | /** | ||
633 | * Retrieve the set of values that occur in matches for end. | ||
634 | * </p> | ||
635 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
636 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
637 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
638 | * | ||
639 | * @return the Stream of all values or empty set if there are no matches | ||
640 | * | ||
641 | */ | ||
642 | public Stream<Segment> streamAllValuesOfend(final EndOfSiding_step_4.Match partialMatch) { | ||
643 | return rawStreamAllValuesOfend(partialMatch.toArray()); | ||
644 | } | ||
645 | |||
646 | /** | ||
647 | * Retrieve the set of values that occur in matches for end. | ||
648 | * </p> | ||
649 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
650 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
651 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
652 | * | ||
653 | * @return the Stream of all values or empty set if there are no matches | ||
654 | * | ||
655 | */ | ||
656 | public Stream<Segment> streamAllValuesOfend(final Train pTrain, final Segment pLocation) { | ||
657 | return rawStreamAllValuesOfend(new Object[]{pTrain, pLocation, null}); | ||
658 | } | ||
659 | |||
660 | /** | ||
661 | * Retrieve the set of values that occur in matches for end. | ||
662 | * @return the Set of all values or empty set if there are no matches | ||
663 | * | ||
664 | */ | ||
665 | public Set<Segment> getAllValuesOfend(final EndOfSiding_step_4.Match partialMatch) { | ||
666 | return rawStreamAllValuesOfend(partialMatch.toArray()).collect(Collectors.toSet()); | ||
667 | } | ||
668 | |||
669 | /** | ||
670 | * Retrieve the set of values that occur in matches for end. | ||
671 | * @return the Set of all values or empty set if there are no matches | ||
672 | * | ||
673 | */ | ||
674 | public Set<Segment> getAllValuesOfend(final Train pTrain, final Segment pLocation) { | ||
675 | return rawStreamAllValuesOfend(new Object[]{pTrain, pLocation, null}).collect(Collectors.toSet()); | ||
676 | } | ||
677 | |||
678 | @Override | ||
679 | protected EndOfSiding_step_4.Match tupleToMatch(final Tuple t) { | ||
680 | try { | ||
681 | return EndOfSiding_step_4.Match.newMatch((Train) t.get(POSITION_TRAIN), (Segment) t.get(POSITION_LOCATION), (Segment) t.get(POSITION_END)); | ||
682 | } catch(ClassCastException e) { | ||
683 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
684 | return null; | ||
685 | } | ||
686 | } | ||
687 | |||
688 | @Override | ||
689 | protected EndOfSiding_step_4.Match arrayToMatch(final Object[] match) { | ||
690 | try { | ||
691 | return EndOfSiding_step_4.Match.newMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION], (Segment) match[POSITION_END]); | ||
692 | } catch(ClassCastException e) { | ||
693 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
694 | return null; | ||
695 | } | ||
696 | } | ||
697 | |||
698 | @Override | ||
699 | protected EndOfSiding_step_4.Match arrayToMatchMutable(final Object[] match) { | ||
700 | try { | ||
701 | return EndOfSiding_step_4.Match.newMutableMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION], (Segment) match[POSITION_END]); | ||
702 | } catch(ClassCastException e) { | ||
703 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
704 | return null; | ||
705 | } | ||
706 | } | ||
707 | |||
708 | /** | ||
709 | * @return the singleton instance of the query specification of this pattern | ||
710 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
711 | * | ||
712 | */ | ||
713 | public static IQuerySpecification<EndOfSiding_step_4.Matcher> querySpecification() { | ||
714 | return EndOfSiding_step_4.instance(); | ||
715 | } | ||
716 | } | ||
717 | |||
718 | private EndOfSiding_step_4() { | ||
719 | super(GeneratedPQuery.INSTANCE); | ||
720 | } | ||
721 | |||
722 | /** | ||
723 | * @return the singleton instance of the query specification | ||
724 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
725 | * | ||
726 | */ | ||
727 | public static EndOfSiding_step_4 instance() { | ||
728 | try{ | ||
729 | return LazyHolder.INSTANCE; | ||
730 | } catch (ExceptionInInitializerError err) { | ||
731 | throw processInitializerError(err); | ||
732 | } | ||
733 | } | ||
734 | |||
735 | @Override | ||
736 | protected EndOfSiding_step_4.Matcher instantiate(final ViatraQueryEngine engine) { | ||
737 | return EndOfSiding_step_4.Matcher.on(engine); | ||
738 | } | ||
739 | |||
740 | @Override | ||
741 | public EndOfSiding_step_4.Matcher instantiate() { | ||
742 | return EndOfSiding_step_4.Matcher.create(); | ||
743 | } | ||
744 | |||
745 | @Override | ||
746 | public EndOfSiding_step_4.Match newEmptyMatch() { | ||
747 | return EndOfSiding_step_4.Match.newEmptyMatch(); | ||
748 | } | ||
749 | |||
750 | @Override | ||
751 | public EndOfSiding_step_4.Match newMatch(final Object... parameters) { | ||
752 | return EndOfSiding_step_4.Match.newMatch((modes3.Train) parameters[0], (modes3.Segment) parameters[1], (modes3.Segment) parameters[2]); | ||
753 | } | ||
754 | |||
755 | /** | ||
756 | * Inner class allowing the singleton instance of {@link EndOfSiding_step_4} to be created | ||
757 | * <b>not</b> at the class load time of the outer class, | ||
758 | * but rather at the first call to {@link EndOfSiding_step_4#instance()}. | ||
759 | * | ||
760 | * <p> This workaround is required e.g. to support recursion. | ||
761 | * | ||
762 | */ | ||
763 | private static class LazyHolder { | ||
764 | private static final EndOfSiding_step_4 INSTANCE = new EndOfSiding_step_4(); | ||
765 | |||
766 | /** | ||
767 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
768 | * This initialization order is required to support indirect recursion. | ||
769 | * | ||
770 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
771 | * | ||
772 | */ | ||
773 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
774 | |||
775 | public static Object ensureInitialized() { | ||
776 | INSTANCE.ensureInitializedInternal(); | ||
777 | return null; | ||
778 | } | ||
779 | } | ||
780 | |||
781 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
782 | private static final EndOfSiding_step_4.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
783 | |||
784 | private final PParameter parameter_train = new PParameter("train", "modes3.Train", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Train")), PParameterDirection.INOUT); | ||
785 | |||
786 | private final PParameter parameter_location = new PParameter("location", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
787 | |||
788 | private final PParameter parameter_end = new PParameter("end", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
789 | |||
790 | private final List<PParameter> parameters = Arrays.asList(parameter_train, parameter_location, parameter_end); | ||
791 | |||
792 | private GeneratedPQuery() { | ||
793 | super(PVisibility.PUBLIC); | ||
794 | } | ||
795 | |||
796 | @Override | ||
797 | public String getFullyQualifiedName() { | ||
798 | return "modes3.queries.endOfSiding_step_4"; | ||
799 | } | ||
800 | |||
801 | @Override | ||
802 | public List<String> getParameterNames() { | ||
803 | return Arrays.asList("train","location","end"); | ||
804 | } | ||
805 | |||
806 | @Override | ||
807 | public List<PParameter> getParameters() { | ||
808 | return parameters; | ||
809 | } | ||
810 | |||
811 | @Override | ||
812 | public Set<PBody> doGetContainedBodies() { | ||
813 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
814 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
815 | { | ||
816 | PBody body = new PBody(this); | ||
817 | PVariable var_train = body.getOrCreateVariableByName("train"); | ||
818 | PVariable var_location = body.getOrCreateVariableByName("location"); | ||
819 | PVariable var_end = body.getOrCreateVariableByName("end"); | ||
820 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
821 | new TypeConstraint(body, Tuples.flatTupleOf(var_location), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
822 | new TypeConstraint(body, Tuples.flatTupleOf(var_end), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
823 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
824 | new ExportedParameter(body, var_train, parameter_train), | ||
825 | new ExportedParameter(body, var_location, parameter_location), | ||
826 | new ExportedParameter(body, var_end, parameter_end) | ||
827 | )); | ||
828 | // // frame->end = frame->location->connected_to[i1];// if (frame->end != NULL &&// frame->end->connected_to[1] == frame->location &&// frame->end->connected_to[0] == NULL) {// ...// } // if (frame->end != NULL &&// frame->end->connected_to[0] == frame->location &&// frame->end->connected_to[1] == NULL) {// ...// } Train(train) | ||
829 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
830 | // Train.location(train, location) | ||
831 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
832 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
833 | new TypeConstraint(body, Tuples.flatTupleOf(var_train, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train", "location"))); | ||
834 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
835 | new Equality(body, var__virtual_0_, var_location); | ||
836 | // Segment.connectedTo(location, end) | ||
837 | new TypeConstraint(body, Tuples.flatTupleOf(var_location), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
838 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
839 | new TypeConstraint(body, Tuples.flatTupleOf(var_location, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
840 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
841 | new Equality(body, var__virtual_1_, var_end); | ||
842 | bodies.add(body); | ||
843 | } | ||
844 | return bodies; | ||
845 | } | ||
846 | } | ||
847 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_5.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_5.java new file mode 100644 index 00000000..48a2697d --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/EndOfSiding_step_5.java | |||
@@ -0,0 +1,841 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.Train; | ||
18 | import modes3.queries.MultipleConnectedTo; | ||
19 | import org.apache.log4j.Logger; | ||
20 | import org.eclipse.emf.ecore.EClass; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
42 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
43 | |||
44 | /** | ||
45 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
46 | * | ||
47 | * <p>Original source: | ||
48 | * <code><pre> | ||
49 | * pattern endOfSiding_step_5(in train : Train, in location : Segment, in end : Segment) { | ||
50 | * // results-{@literal >}matches[match_cntr].location = frame-{@literal >}location; | ||
51 | * // results-{@literal >}matches[match_cntr++].train = frame-{@literal >}train; | ||
52 | * // ...OR... | ||
53 | * // results-{@literal >}matches[match_cntr].location = frame-{@literal >}location; | ||
54 | * // results-{@literal >}matches[match_cntr++].train = frame-{@literal >}train; | ||
55 | * Train(train); | ||
56 | * Train.location(train, location); | ||
57 | * Segment.connectedTo(location, end); | ||
58 | * neg find multipleConnectedTo(end); | ||
59 | * } | ||
60 | * </pre></code> | ||
61 | * | ||
62 | * @see Matcher | ||
63 | * @see Match | ||
64 | * | ||
65 | */ | ||
66 | @SuppressWarnings("all") | ||
67 | public final class EndOfSiding_step_5 extends BaseGeneratedEMFQuerySpecification<EndOfSiding_step_5.Matcher> { | ||
68 | /** | ||
69 | * Pattern-specific match representation of the modes3.queries.endOfSiding_step_5 pattern, | ||
70 | * to be used in conjunction with {@link Matcher}. | ||
71 | * | ||
72 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
73 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
74 | * usable to represent a match of the pattern in the result of a query, | ||
75 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
76 | * | ||
77 | * @see Matcher | ||
78 | * | ||
79 | */ | ||
80 | public static abstract class Match extends BasePatternMatch { | ||
81 | private Train fTrain; | ||
82 | |||
83 | private Segment fLocation; | ||
84 | |||
85 | private Segment fEnd; | ||
86 | |||
87 | private static List<String> parameterNames = makeImmutableList("train", "location", "end"); | ||
88 | |||
89 | private Match(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
90 | this.fTrain = pTrain; | ||
91 | this.fLocation = pLocation; | ||
92 | this.fEnd = pEnd; | ||
93 | } | ||
94 | |||
95 | @Override | ||
96 | public Object get(final String parameterName) { | ||
97 | switch(parameterName) { | ||
98 | case "train": return this.fTrain; | ||
99 | case "location": return this.fLocation; | ||
100 | case "end": return this.fEnd; | ||
101 | default: return null; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | public Object get(final int index) { | ||
107 | switch(index) { | ||
108 | case 0: return this.fTrain; | ||
109 | case 1: return this.fLocation; | ||
110 | case 2: return this.fEnd; | ||
111 | default: return null; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | public Train getTrain() { | ||
116 | return this.fTrain; | ||
117 | } | ||
118 | |||
119 | public Segment getLocation() { | ||
120 | return this.fLocation; | ||
121 | } | ||
122 | |||
123 | public Segment getEnd() { | ||
124 | return this.fEnd; | ||
125 | } | ||
126 | |||
127 | @Override | ||
128 | public boolean set(final String parameterName, final Object newValue) { | ||
129 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
130 | if ("train".equals(parameterName) ) { | ||
131 | this.fTrain = (Train) newValue; | ||
132 | return true; | ||
133 | } | ||
134 | if ("location".equals(parameterName) ) { | ||
135 | this.fLocation = (Segment) newValue; | ||
136 | return true; | ||
137 | } | ||
138 | if ("end".equals(parameterName) ) { | ||
139 | this.fEnd = (Segment) newValue; | ||
140 | return true; | ||
141 | } | ||
142 | return false; | ||
143 | } | ||
144 | |||
145 | public void setTrain(final Train pTrain) { | ||
146 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
147 | this.fTrain = pTrain; | ||
148 | } | ||
149 | |||
150 | public void setLocation(final Segment pLocation) { | ||
151 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
152 | this.fLocation = pLocation; | ||
153 | } | ||
154 | |||
155 | public void setEnd(final Segment pEnd) { | ||
156 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
157 | this.fEnd = pEnd; | ||
158 | } | ||
159 | |||
160 | @Override | ||
161 | public String patternName() { | ||
162 | return "modes3.queries.endOfSiding_step_5"; | ||
163 | } | ||
164 | |||
165 | @Override | ||
166 | public List<String> parameterNames() { | ||
167 | return EndOfSiding_step_5.Match.parameterNames; | ||
168 | } | ||
169 | |||
170 | @Override | ||
171 | public Object[] toArray() { | ||
172 | return new Object[]{fTrain, fLocation, fEnd}; | ||
173 | } | ||
174 | |||
175 | @Override | ||
176 | public EndOfSiding_step_5.Match toImmutable() { | ||
177 | return isMutable() ? newMatch(fTrain, fLocation, fEnd) : this; | ||
178 | } | ||
179 | |||
180 | @Override | ||
181 | public String prettyPrint() { | ||
182 | StringBuilder result = new StringBuilder(); | ||
183 | result.append("\"train\"=" + prettyPrintValue(fTrain) + ", "); | ||
184 | result.append("\"location\"=" + prettyPrintValue(fLocation) + ", "); | ||
185 | result.append("\"end\"=" + prettyPrintValue(fEnd)); | ||
186 | return result.toString(); | ||
187 | } | ||
188 | |||
189 | @Override | ||
190 | public int hashCode() { | ||
191 | return Objects.hash(fTrain, fLocation, fEnd); | ||
192 | } | ||
193 | |||
194 | @Override | ||
195 | public boolean equals(final Object obj) { | ||
196 | if (this == obj) | ||
197 | return true; | ||
198 | if (obj == null) { | ||
199 | return false; | ||
200 | } | ||
201 | if ((obj instanceof EndOfSiding_step_5.Match)) { | ||
202 | EndOfSiding_step_5.Match other = (EndOfSiding_step_5.Match) obj; | ||
203 | return Objects.equals(fTrain, other.fTrain) && Objects.equals(fLocation, other.fLocation) && Objects.equals(fEnd, other.fEnd); | ||
204 | } else { | ||
205 | // this should be infrequent | ||
206 | if (!(obj instanceof IPatternMatch)) { | ||
207 | return false; | ||
208 | } | ||
209 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
210 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
211 | } | ||
212 | } | ||
213 | |||
214 | @Override | ||
215 | public EndOfSiding_step_5 specification() { | ||
216 | return EndOfSiding_step_5.instance(); | ||
217 | } | ||
218 | |||
219 | /** | ||
220 | * Returns an empty, mutable match. | ||
221 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
222 | * | ||
223 | * @return the empty match. | ||
224 | * | ||
225 | */ | ||
226 | public static EndOfSiding_step_5.Match newEmptyMatch() { | ||
227 | return new Mutable(null, null, null); | ||
228 | } | ||
229 | |||
230 | /** | ||
231 | * Returns a mutable (partial) match. | ||
232 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
233 | * | ||
234 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
235 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
236 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
237 | * @return the new, mutable (partial) match object. | ||
238 | * | ||
239 | */ | ||
240 | public static EndOfSiding_step_5.Match newMutableMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
241 | return new Mutable(pTrain, pLocation, pEnd); | ||
242 | } | ||
243 | |||
244 | /** | ||
245 | * Returns a new (partial) match. | ||
246 | * This can be used e.g. to call the matcher with a partial match. | ||
247 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
248 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
249 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
250 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
251 | * @return the (partial) match object. | ||
252 | * | ||
253 | */ | ||
254 | public static EndOfSiding_step_5.Match newMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
255 | return new Immutable(pTrain, pLocation, pEnd); | ||
256 | } | ||
257 | |||
258 | private static final class Mutable extends EndOfSiding_step_5.Match { | ||
259 | Mutable(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
260 | super(pTrain, pLocation, pEnd); | ||
261 | } | ||
262 | |||
263 | @Override | ||
264 | public boolean isMutable() { | ||
265 | return true; | ||
266 | } | ||
267 | } | ||
268 | |||
269 | private static final class Immutable extends EndOfSiding_step_5.Match { | ||
270 | Immutable(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
271 | super(pTrain, pLocation, pEnd); | ||
272 | } | ||
273 | |||
274 | @Override | ||
275 | public boolean isMutable() { | ||
276 | return false; | ||
277 | } | ||
278 | } | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * Generated pattern matcher API of the modes3.queries.endOfSiding_step_5 pattern, | ||
283 | * providing pattern-specific query methods. | ||
284 | * | ||
285 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
286 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
287 | * | ||
288 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
289 | * | ||
290 | * <p>Original source: | ||
291 | * <code><pre> | ||
292 | * pattern endOfSiding_step_5(in train : Train, in location : Segment, in end : Segment) { | ||
293 | * // results-{@literal >}matches[match_cntr].location = frame-{@literal >}location; | ||
294 | * // results-{@literal >}matches[match_cntr++].train = frame-{@literal >}train; | ||
295 | * // ...OR... | ||
296 | * // results-{@literal >}matches[match_cntr].location = frame-{@literal >}location; | ||
297 | * // results-{@literal >}matches[match_cntr++].train = frame-{@literal >}train; | ||
298 | * Train(train); | ||
299 | * Train.location(train, location); | ||
300 | * Segment.connectedTo(location, end); | ||
301 | * neg find multipleConnectedTo(end); | ||
302 | * } | ||
303 | * </pre></code> | ||
304 | * | ||
305 | * @see Match | ||
306 | * @see EndOfSiding_step_5 | ||
307 | * | ||
308 | */ | ||
309 | public static class Matcher extends BaseMatcher<EndOfSiding_step_5.Match> { | ||
310 | /** | ||
311 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
312 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
313 | * | ||
314 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
315 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
316 | * | ||
317 | */ | ||
318 | public static EndOfSiding_step_5.Matcher on(final ViatraQueryEngine engine) { | ||
319 | // check if matcher already exists | ||
320 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
321 | if (matcher == null) { | ||
322 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
323 | } | ||
324 | return matcher; | ||
325 | } | ||
326 | |||
327 | /** | ||
328 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
329 | * @return an initialized matcher | ||
330 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
331 | * | ||
332 | */ | ||
333 | public static EndOfSiding_step_5.Matcher create() { | ||
334 | return new Matcher(); | ||
335 | } | ||
336 | |||
337 | private static final int POSITION_TRAIN = 0; | ||
338 | |||
339 | private static final int POSITION_LOCATION = 1; | ||
340 | |||
341 | private static final int POSITION_END = 2; | ||
342 | |||
343 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EndOfSiding_step_5.Matcher.class); | ||
344 | |||
345 | /** | ||
346 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
347 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
348 | * | ||
349 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
350 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
351 | * | ||
352 | */ | ||
353 | private Matcher() { | ||
354 | super(querySpecification()); | ||
355 | } | ||
356 | |||
357 | /** | ||
358 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
359 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
360 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
361 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
362 | * @return matches represented as a Match object. | ||
363 | * | ||
364 | */ | ||
365 | public Collection<EndOfSiding_step_5.Match> getAllMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
366 | return rawStreamAllMatches(new Object[]{pTrain, pLocation, pEnd}).collect(Collectors.toSet()); | ||
367 | } | ||
368 | |||
369 | /** | ||
370 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
371 | * </p> | ||
372 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
373 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
374 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
375 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
376 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
377 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
378 | * @return a stream of matches represented as a Match object. | ||
379 | * | ||
380 | */ | ||
381 | public Stream<EndOfSiding_step_5.Match> streamAllMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
382 | return rawStreamAllMatches(new Object[]{pTrain, pLocation, pEnd}); | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
387 | * Neither determinism nor randomness of selection is guaranteed. | ||
388 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
389 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
390 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
391 | * @return a match represented as a Match object, or null if no match is found. | ||
392 | * | ||
393 | */ | ||
394 | public Optional<EndOfSiding_step_5.Match> getOneArbitraryMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
395 | return rawGetOneArbitraryMatch(new Object[]{pTrain, pLocation, pEnd}); | ||
396 | } | ||
397 | |||
398 | /** | ||
399 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
400 | * under any possible substitution of the unspecified parameters (if any). | ||
401 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
402 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
403 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
404 | * @return true if the input is a valid (partial) match of the pattern. | ||
405 | * | ||
406 | */ | ||
407 | public boolean hasMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
408 | return rawHasMatch(new Object[]{pTrain, pLocation, pEnd}); | ||
409 | } | ||
410 | |||
411 | /** | ||
412 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
413 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
414 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
415 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
416 | * @return the number of pattern matches found. | ||
417 | * | ||
418 | */ | ||
419 | public int countMatches(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
420 | return rawCountMatches(new Object[]{pTrain, pLocation, pEnd}); | ||
421 | } | ||
422 | |||
423 | /** | ||
424 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
425 | * Neither determinism nor randomness of selection is guaranteed. | ||
426 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
427 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
428 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
429 | * @param processor the action that will process the selected match. | ||
430 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
431 | * | ||
432 | */ | ||
433 | public boolean forOneArbitraryMatch(final Train pTrain, final Segment pLocation, final Segment pEnd, final Consumer<? super EndOfSiding_step_5.Match> processor) { | ||
434 | return rawForOneArbitraryMatch(new Object[]{pTrain, pLocation, pEnd}, processor); | ||
435 | } | ||
436 | |||
437 | /** | ||
438 | * Returns a new (partial) match. | ||
439 | * This can be used e.g. to call the matcher with a partial match. | ||
440 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
441 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
442 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
443 | * @param pEnd the fixed value of pattern parameter end, or null if not bound. | ||
444 | * @return the (partial) match object. | ||
445 | * | ||
446 | */ | ||
447 | public EndOfSiding_step_5.Match newMatch(final Train pTrain, final Segment pLocation, final Segment pEnd) { | ||
448 | return EndOfSiding_step_5.Match.newMatch(pTrain, pLocation, pEnd); | ||
449 | } | ||
450 | |||
451 | /** | ||
452 | * Retrieve the set of values that occur in matches for train. | ||
453 | * @return the Set of all values or empty set if there are no matches | ||
454 | * | ||
455 | */ | ||
456 | protected Stream<Train> rawStreamAllValuesOftrain(final Object[] parameters) { | ||
457 | return rawStreamAllValues(POSITION_TRAIN, parameters).map(Train.class::cast); | ||
458 | } | ||
459 | |||
460 | /** | ||
461 | * Retrieve the set of values that occur in matches for train. | ||
462 | * @return the Set of all values or empty set if there are no matches | ||
463 | * | ||
464 | */ | ||
465 | public Set<Train> getAllValuesOftrain() { | ||
466 | return rawStreamAllValuesOftrain(emptyArray()).collect(Collectors.toSet()); | ||
467 | } | ||
468 | |||
469 | /** | ||
470 | * Retrieve the set of values that occur in matches for train. | ||
471 | * @return the Set of all values or empty set if there are no matches | ||
472 | * | ||
473 | */ | ||
474 | public Stream<Train> streamAllValuesOftrain() { | ||
475 | return rawStreamAllValuesOftrain(emptyArray()); | ||
476 | } | ||
477 | |||
478 | /** | ||
479 | * Retrieve the set of values that occur in matches for train. | ||
480 | * </p> | ||
481 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
482 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
483 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
484 | * | ||
485 | * @return the Stream of all values or empty set if there are no matches | ||
486 | * | ||
487 | */ | ||
488 | public Stream<Train> streamAllValuesOftrain(final EndOfSiding_step_5.Match partialMatch) { | ||
489 | return rawStreamAllValuesOftrain(partialMatch.toArray()); | ||
490 | } | ||
491 | |||
492 | /** | ||
493 | * Retrieve the set of values that occur in matches for train. | ||
494 | * </p> | ||
495 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
496 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
497 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
498 | * | ||
499 | * @return the Stream of all values or empty set if there are no matches | ||
500 | * | ||
501 | */ | ||
502 | public Stream<Train> streamAllValuesOftrain(final Segment pLocation, final Segment pEnd) { | ||
503 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation, pEnd}); | ||
504 | } | ||
505 | |||
506 | /** | ||
507 | * Retrieve the set of values that occur in matches for train. | ||
508 | * @return the Set of all values or empty set if there are no matches | ||
509 | * | ||
510 | */ | ||
511 | public Set<Train> getAllValuesOftrain(final EndOfSiding_step_5.Match partialMatch) { | ||
512 | return rawStreamAllValuesOftrain(partialMatch.toArray()).collect(Collectors.toSet()); | ||
513 | } | ||
514 | |||
515 | /** | ||
516 | * Retrieve the set of values that occur in matches for train. | ||
517 | * @return the Set of all values or empty set if there are no matches | ||
518 | * | ||
519 | */ | ||
520 | public Set<Train> getAllValuesOftrain(final Segment pLocation, final Segment pEnd) { | ||
521 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation, pEnd}).collect(Collectors.toSet()); | ||
522 | } | ||
523 | |||
524 | /** | ||
525 | * Retrieve the set of values that occur in matches for location. | ||
526 | * @return the Set of all values or empty set if there are no matches | ||
527 | * | ||
528 | */ | ||
529 | protected Stream<Segment> rawStreamAllValuesOflocation(final Object[] parameters) { | ||
530 | return rawStreamAllValues(POSITION_LOCATION, parameters).map(Segment.class::cast); | ||
531 | } | ||
532 | |||
533 | /** | ||
534 | * Retrieve the set of values that occur in matches for location. | ||
535 | * @return the Set of all values or empty set if there are no matches | ||
536 | * | ||
537 | */ | ||
538 | public Set<Segment> getAllValuesOflocation() { | ||
539 | return rawStreamAllValuesOflocation(emptyArray()).collect(Collectors.toSet()); | ||
540 | } | ||
541 | |||
542 | /** | ||
543 | * Retrieve the set of values that occur in matches for location. | ||
544 | * @return the Set of all values or empty set if there are no matches | ||
545 | * | ||
546 | */ | ||
547 | public Stream<Segment> streamAllValuesOflocation() { | ||
548 | return rawStreamAllValuesOflocation(emptyArray()); | ||
549 | } | ||
550 | |||
551 | /** | ||
552 | * Retrieve the set of values that occur in matches for location. | ||
553 | * </p> | ||
554 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
555 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
556 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
557 | * | ||
558 | * @return the Stream of all values or empty set if there are no matches | ||
559 | * | ||
560 | */ | ||
561 | public Stream<Segment> streamAllValuesOflocation(final EndOfSiding_step_5.Match partialMatch) { | ||
562 | return rawStreamAllValuesOflocation(partialMatch.toArray()); | ||
563 | } | ||
564 | |||
565 | /** | ||
566 | * Retrieve the set of values that occur in matches for location. | ||
567 | * </p> | ||
568 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
569 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
570 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
571 | * | ||
572 | * @return the Stream of all values or empty set if there are no matches | ||
573 | * | ||
574 | */ | ||
575 | public Stream<Segment> streamAllValuesOflocation(final Train pTrain, final Segment pEnd) { | ||
576 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null, pEnd}); | ||
577 | } | ||
578 | |||
579 | /** | ||
580 | * Retrieve the set of values that occur in matches for location. | ||
581 | * @return the Set of all values or empty set if there are no matches | ||
582 | * | ||
583 | */ | ||
584 | public Set<Segment> getAllValuesOflocation(final EndOfSiding_step_5.Match partialMatch) { | ||
585 | return rawStreamAllValuesOflocation(partialMatch.toArray()).collect(Collectors.toSet()); | ||
586 | } | ||
587 | |||
588 | /** | ||
589 | * Retrieve the set of values that occur in matches for location. | ||
590 | * @return the Set of all values or empty set if there are no matches | ||
591 | * | ||
592 | */ | ||
593 | public Set<Segment> getAllValuesOflocation(final Train pTrain, final Segment pEnd) { | ||
594 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null, pEnd}).collect(Collectors.toSet()); | ||
595 | } | ||
596 | |||
597 | /** | ||
598 | * Retrieve the set of values that occur in matches for end. | ||
599 | * @return the Set of all values or empty set if there are no matches | ||
600 | * | ||
601 | */ | ||
602 | protected Stream<Segment> rawStreamAllValuesOfend(final Object[] parameters) { | ||
603 | return rawStreamAllValues(POSITION_END, parameters).map(Segment.class::cast); | ||
604 | } | ||
605 | |||
606 | /** | ||
607 | * Retrieve the set of values that occur in matches for end. | ||
608 | * @return the Set of all values or empty set if there are no matches | ||
609 | * | ||
610 | */ | ||
611 | public Set<Segment> getAllValuesOfend() { | ||
612 | return rawStreamAllValuesOfend(emptyArray()).collect(Collectors.toSet()); | ||
613 | } | ||
614 | |||
615 | /** | ||
616 | * Retrieve the set of values that occur in matches for end. | ||
617 | * @return the Set of all values or empty set if there are no matches | ||
618 | * | ||
619 | */ | ||
620 | public Stream<Segment> streamAllValuesOfend() { | ||
621 | return rawStreamAllValuesOfend(emptyArray()); | ||
622 | } | ||
623 | |||
624 | /** | ||
625 | * Retrieve the set of values that occur in matches for end. | ||
626 | * </p> | ||
627 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
628 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
629 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
630 | * | ||
631 | * @return the Stream of all values or empty set if there are no matches | ||
632 | * | ||
633 | */ | ||
634 | public Stream<Segment> streamAllValuesOfend(final EndOfSiding_step_5.Match partialMatch) { | ||
635 | return rawStreamAllValuesOfend(partialMatch.toArray()); | ||
636 | } | ||
637 | |||
638 | /** | ||
639 | * Retrieve the set of values that occur in matches for end. | ||
640 | * </p> | ||
641 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
642 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
643 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
644 | * | ||
645 | * @return the Stream of all values or empty set if there are no matches | ||
646 | * | ||
647 | */ | ||
648 | public Stream<Segment> streamAllValuesOfend(final Train pTrain, final Segment pLocation) { | ||
649 | return rawStreamAllValuesOfend(new Object[]{pTrain, pLocation, null}); | ||
650 | } | ||
651 | |||
652 | /** | ||
653 | * Retrieve the set of values that occur in matches for end. | ||
654 | * @return the Set of all values or empty set if there are no matches | ||
655 | * | ||
656 | */ | ||
657 | public Set<Segment> getAllValuesOfend(final EndOfSiding_step_5.Match partialMatch) { | ||
658 | return rawStreamAllValuesOfend(partialMatch.toArray()).collect(Collectors.toSet()); | ||
659 | } | ||
660 | |||
661 | /** | ||
662 | * Retrieve the set of values that occur in matches for end. | ||
663 | * @return the Set of all values or empty set if there are no matches | ||
664 | * | ||
665 | */ | ||
666 | public Set<Segment> getAllValuesOfend(final Train pTrain, final Segment pLocation) { | ||
667 | return rawStreamAllValuesOfend(new Object[]{pTrain, pLocation, null}).collect(Collectors.toSet()); | ||
668 | } | ||
669 | |||
670 | @Override | ||
671 | protected EndOfSiding_step_5.Match tupleToMatch(final Tuple t) { | ||
672 | try { | ||
673 | return EndOfSiding_step_5.Match.newMatch((Train) t.get(POSITION_TRAIN), (Segment) t.get(POSITION_LOCATION), (Segment) t.get(POSITION_END)); | ||
674 | } catch(ClassCastException e) { | ||
675 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
676 | return null; | ||
677 | } | ||
678 | } | ||
679 | |||
680 | @Override | ||
681 | protected EndOfSiding_step_5.Match arrayToMatch(final Object[] match) { | ||
682 | try { | ||
683 | return EndOfSiding_step_5.Match.newMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION], (Segment) match[POSITION_END]); | ||
684 | } catch(ClassCastException e) { | ||
685 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
686 | return null; | ||
687 | } | ||
688 | } | ||
689 | |||
690 | @Override | ||
691 | protected EndOfSiding_step_5.Match arrayToMatchMutable(final Object[] match) { | ||
692 | try { | ||
693 | return EndOfSiding_step_5.Match.newMutableMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION], (Segment) match[POSITION_END]); | ||
694 | } catch(ClassCastException e) { | ||
695 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
696 | return null; | ||
697 | } | ||
698 | } | ||
699 | |||
700 | /** | ||
701 | * @return the singleton instance of the query specification of this pattern | ||
702 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
703 | * | ||
704 | */ | ||
705 | public static IQuerySpecification<EndOfSiding_step_5.Matcher> querySpecification() { | ||
706 | return EndOfSiding_step_5.instance(); | ||
707 | } | ||
708 | } | ||
709 | |||
710 | private EndOfSiding_step_5() { | ||
711 | super(GeneratedPQuery.INSTANCE); | ||
712 | } | ||
713 | |||
714 | /** | ||
715 | * @return the singleton instance of the query specification | ||
716 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
717 | * | ||
718 | */ | ||
719 | public static EndOfSiding_step_5 instance() { | ||
720 | try{ | ||
721 | return LazyHolder.INSTANCE; | ||
722 | } catch (ExceptionInInitializerError err) { | ||
723 | throw processInitializerError(err); | ||
724 | } | ||
725 | } | ||
726 | |||
727 | @Override | ||
728 | protected EndOfSiding_step_5.Matcher instantiate(final ViatraQueryEngine engine) { | ||
729 | return EndOfSiding_step_5.Matcher.on(engine); | ||
730 | } | ||
731 | |||
732 | @Override | ||
733 | public EndOfSiding_step_5.Matcher instantiate() { | ||
734 | return EndOfSiding_step_5.Matcher.create(); | ||
735 | } | ||
736 | |||
737 | @Override | ||
738 | public EndOfSiding_step_5.Match newEmptyMatch() { | ||
739 | return EndOfSiding_step_5.Match.newEmptyMatch(); | ||
740 | } | ||
741 | |||
742 | @Override | ||
743 | public EndOfSiding_step_5.Match newMatch(final Object... parameters) { | ||
744 | return EndOfSiding_step_5.Match.newMatch((modes3.Train) parameters[0], (modes3.Segment) parameters[1], (modes3.Segment) parameters[2]); | ||
745 | } | ||
746 | |||
747 | /** | ||
748 | * Inner class allowing the singleton instance of {@link EndOfSiding_step_5} to be created | ||
749 | * <b>not</b> at the class load time of the outer class, | ||
750 | * but rather at the first call to {@link EndOfSiding_step_5#instance()}. | ||
751 | * | ||
752 | * <p> This workaround is required e.g. to support recursion. | ||
753 | * | ||
754 | */ | ||
755 | private static class LazyHolder { | ||
756 | private static final EndOfSiding_step_5 INSTANCE = new EndOfSiding_step_5(); | ||
757 | |||
758 | /** | ||
759 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
760 | * This initialization order is required to support indirect recursion. | ||
761 | * | ||
762 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
763 | * | ||
764 | */ | ||
765 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
766 | |||
767 | public static Object ensureInitialized() { | ||
768 | INSTANCE.ensureInitializedInternal(); | ||
769 | return null; | ||
770 | } | ||
771 | } | ||
772 | |||
773 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
774 | private static final EndOfSiding_step_5.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
775 | |||
776 | private final PParameter parameter_train = new PParameter("train", "modes3.Train", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Train")), PParameterDirection.INOUT); | ||
777 | |||
778 | private final PParameter parameter_location = new PParameter("location", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
779 | |||
780 | private final PParameter parameter_end = new PParameter("end", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
781 | |||
782 | private final List<PParameter> parameters = Arrays.asList(parameter_train, parameter_location, parameter_end); | ||
783 | |||
784 | private GeneratedPQuery() { | ||
785 | super(PVisibility.PUBLIC); | ||
786 | } | ||
787 | |||
788 | @Override | ||
789 | public String getFullyQualifiedName() { | ||
790 | return "modes3.queries.endOfSiding_step_5"; | ||
791 | } | ||
792 | |||
793 | @Override | ||
794 | public List<String> getParameterNames() { | ||
795 | return Arrays.asList("train","location","end"); | ||
796 | } | ||
797 | |||
798 | @Override | ||
799 | public List<PParameter> getParameters() { | ||
800 | return parameters; | ||
801 | } | ||
802 | |||
803 | @Override | ||
804 | public Set<PBody> doGetContainedBodies() { | ||
805 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
806 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
807 | { | ||
808 | PBody body = new PBody(this); | ||
809 | PVariable var_train = body.getOrCreateVariableByName("train"); | ||
810 | PVariable var_location = body.getOrCreateVariableByName("location"); | ||
811 | PVariable var_end = body.getOrCreateVariableByName("end"); | ||
812 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
813 | new TypeConstraint(body, Tuples.flatTupleOf(var_location), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
814 | new TypeConstraint(body, Tuples.flatTupleOf(var_end), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
815 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
816 | new ExportedParameter(body, var_train, parameter_train), | ||
817 | new ExportedParameter(body, var_location, parameter_location), | ||
818 | new ExportedParameter(body, var_end, parameter_end) | ||
819 | )); | ||
820 | // // results->matches[match_cntr].location = frame->location;// results->matches[match_cntr++].train = frame->train;// ...OR...// results->matches[match_cntr].location = frame->location;// results->matches[match_cntr++].train = frame->train; Train(train) | ||
821 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
822 | // Train.location(train, location) | ||
823 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
824 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
825 | new TypeConstraint(body, Tuples.flatTupleOf(var_train, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train", "location"))); | ||
826 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
827 | new Equality(body, var__virtual_0_, var_location); | ||
828 | // Segment.connectedTo(location, end) | ||
829 | new TypeConstraint(body, Tuples.flatTupleOf(var_location), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
830 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
831 | new TypeConstraint(body, Tuples.flatTupleOf(var_location, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
832 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
833 | new Equality(body, var__virtual_1_, var_end); | ||
834 | // neg find multipleConnectedTo(end) | ||
835 | new NegativePatternCall(body, Tuples.flatTupleOf(var_end), MultipleConnectedTo.instance().getInternalQueryRepresentation()); | ||
836 | bodies.add(body); | ||
837 | } | ||
838 | return bodies; | ||
839 | } | ||
840 | } | ||
841 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/InputsOfTurnout.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/InputsOfTurnout.java new file mode 100644 index 00000000..2f2eea11 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/InputsOfTurnout.java | |||
@@ -0,0 +1,570 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Turnout; | ||
17 | import modes3.queries.Adjacent; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern inputsOfTurnout(T : Turnout) { | ||
48 | * find adjacent(I1, T); | ||
49 | * find adjacent(I2, T); | ||
50 | * find adjacent(I3, T); | ||
51 | * I1 != I2; | ||
52 | * I1 != I3; | ||
53 | * I2 != I3; | ||
54 | * } | ||
55 | * </pre></code> | ||
56 | * | ||
57 | * @see Matcher | ||
58 | * @see Match | ||
59 | * | ||
60 | */ | ||
61 | @SuppressWarnings("all") | ||
62 | public final class InputsOfTurnout extends BaseGeneratedEMFQuerySpecification<InputsOfTurnout.Matcher> { | ||
63 | /** | ||
64 | * Pattern-specific match representation of the modes3.queries.inputsOfTurnout pattern, | ||
65 | * to be used in conjunction with {@link Matcher}. | ||
66 | * | ||
67 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
68 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
69 | * usable to represent a match of the pattern in the result of a query, | ||
70 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
71 | * | ||
72 | * @see Matcher | ||
73 | * | ||
74 | */ | ||
75 | public static abstract class Match extends BasePatternMatch { | ||
76 | private Turnout fT; | ||
77 | |||
78 | private static List<String> parameterNames = makeImmutableList("T"); | ||
79 | |||
80 | private Match(final Turnout pT) { | ||
81 | this.fT = pT; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | switch(parameterName) { | ||
87 | case "T": return this.fT; | ||
88 | default: return null; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | @Override | ||
93 | public Object get(final int index) { | ||
94 | switch(index) { | ||
95 | case 0: return this.fT; | ||
96 | default: return null; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | public Turnout getT() { | ||
101 | return this.fT; | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public boolean set(final String parameterName, final Object newValue) { | ||
106 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
107 | if ("T".equals(parameterName) ) { | ||
108 | this.fT = (Turnout) newValue; | ||
109 | return true; | ||
110 | } | ||
111 | return false; | ||
112 | } | ||
113 | |||
114 | public void setT(final Turnout pT) { | ||
115 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
116 | this.fT = pT; | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public String patternName() { | ||
121 | return "modes3.queries.inputsOfTurnout"; | ||
122 | } | ||
123 | |||
124 | @Override | ||
125 | public List<String> parameterNames() { | ||
126 | return InputsOfTurnout.Match.parameterNames; | ||
127 | } | ||
128 | |||
129 | @Override | ||
130 | public Object[] toArray() { | ||
131 | return new Object[]{fT}; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public InputsOfTurnout.Match toImmutable() { | ||
136 | return isMutable() ? newMatch(fT) : this; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public String prettyPrint() { | ||
141 | StringBuilder result = new StringBuilder(); | ||
142 | result.append("\"T\"=" + prettyPrintValue(fT)); | ||
143 | return result.toString(); | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public int hashCode() { | ||
148 | return Objects.hash(fT); | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public boolean equals(final Object obj) { | ||
153 | if (this == obj) | ||
154 | return true; | ||
155 | if (obj == null) { | ||
156 | return false; | ||
157 | } | ||
158 | if ((obj instanceof InputsOfTurnout.Match)) { | ||
159 | InputsOfTurnout.Match other = (InputsOfTurnout.Match) obj; | ||
160 | return Objects.equals(fT, other.fT); | ||
161 | } else { | ||
162 | // this should be infrequent | ||
163 | if (!(obj instanceof IPatternMatch)) { | ||
164 | return false; | ||
165 | } | ||
166 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
167 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
168 | } | ||
169 | } | ||
170 | |||
171 | @Override | ||
172 | public InputsOfTurnout specification() { | ||
173 | return InputsOfTurnout.instance(); | ||
174 | } | ||
175 | |||
176 | /** | ||
177 | * Returns an empty, mutable match. | ||
178 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
179 | * | ||
180 | * @return the empty match. | ||
181 | * | ||
182 | */ | ||
183 | public static InputsOfTurnout.Match newEmptyMatch() { | ||
184 | return new Mutable(null); | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * Returns a mutable (partial) match. | ||
189 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
190 | * | ||
191 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
192 | * @return the new, mutable (partial) match object. | ||
193 | * | ||
194 | */ | ||
195 | public static InputsOfTurnout.Match newMutableMatch(final Turnout pT) { | ||
196 | return new Mutable(pT); | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * Returns a new (partial) match. | ||
201 | * This can be used e.g. to call the matcher with a partial match. | ||
202 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
203 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
204 | * @return the (partial) match object. | ||
205 | * | ||
206 | */ | ||
207 | public static InputsOfTurnout.Match newMatch(final Turnout pT) { | ||
208 | return new Immutable(pT); | ||
209 | } | ||
210 | |||
211 | private static final class Mutable extends InputsOfTurnout.Match { | ||
212 | Mutable(final Turnout pT) { | ||
213 | super(pT); | ||
214 | } | ||
215 | |||
216 | @Override | ||
217 | public boolean isMutable() { | ||
218 | return true; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | private static final class Immutable extends InputsOfTurnout.Match { | ||
223 | Immutable(final Turnout pT) { | ||
224 | super(pT); | ||
225 | } | ||
226 | |||
227 | @Override | ||
228 | public boolean isMutable() { | ||
229 | return false; | ||
230 | } | ||
231 | } | ||
232 | } | ||
233 | |||
234 | /** | ||
235 | * Generated pattern matcher API of the modes3.queries.inputsOfTurnout pattern, | ||
236 | * providing pattern-specific query methods. | ||
237 | * | ||
238 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
239 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
240 | * | ||
241 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
242 | * | ||
243 | * <p>Original source: | ||
244 | * <code><pre> | ||
245 | * pattern inputsOfTurnout(T : Turnout) { | ||
246 | * find adjacent(I1, T); | ||
247 | * find adjacent(I2, T); | ||
248 | * find adjacent(I3, T); | ||
249 | * I1 != I2; | ||
250 | * I1 != I3; | ||
251 | * I2 != I3; | ||
252 | * } | ||
253 | * </pre></code> | ||
254 | * | ||
255 | * @see Match | ||
256 | * @see InputsOfTurnout | ||
257 | * | ||
258 | */ | ||
259 | public static class Matcher extends BaseMatcher<InputsOfTurnout.Match> { | ||
260 | /** | ||
261 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
262 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
263 | * | ||
264 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
265 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
266 | * | ||
267 | */ | ||
268 | public static InputsOfTurnout.Matcher on(final ViatraQueryEngine engine) { | ||
269 | // check if matcher already exists | ||
270 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
271 | if (matcher == null) { | ||
272 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
273 | } | ||
274 | return matcher; | ||
275 | } | ||
276 | |||
277 | /** | ||
278 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
279 | * @return an initialized matcher | ||
280 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
281 | * | ||
282 | */ | ||
283 | public static InputsOfTurnout.Matcher create() { | ||
284 | return new Matcher(); | ||
285 | } | ||
286 | |||
287 | private static final int POSITION_T = 0; | ||
288 | |||
289 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(InputsOfTurnout.Matcher.class); | ||
290 | |||
291 | /** | ||
292 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
293 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
294 | * | ||
295 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
296 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
297 | * | ||
298 | */ | ||
299 | private Matcher() { | ||
300 | super(querySpecification()); | ||
301 | } | ||
302 | |||
303 | /** | ||
304 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
305 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
306 | * @return matches represented as a Match object. | ||
307 | * | ||
308 | */ | ||
309 | public Collection<InputsOfTurnout.Match> getAllMatches(final Turnout pT) { | ||
310 | return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); | ||
311 | } | ||
312 | |||
313 | /** | ||
314 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
315 | * </p> | ||
316 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
317 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
318 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
319 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
320 | * @return a stream of matches represented as a Match object. | ||
321 | * | ||
322 | */ | ||
323 | public Stream<InputsOfTurnout.Match> streamAllMatches(final Turnout pT) { | ||
324 | return rawStreamAllMatches(new Object[]{pT}); | ||
325 | } | ||
326 | |||
327 | /** | ||
328 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
329 | * Neither determinism nor randomness of selection is guaranteed. | ||
330 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
331 | * @return a match represented as a Match object, or null if no match is found. | ||
332 | * | ||
333 | */ | ||
334 | public Optional<InputsOfTurnout.Match> getOneArbitraryMatch(final Turnout pT) { | ||
335 | return rawGetOneArbitraryMatch(new Object[]{pT}); | ||
336 | } | ||
337 | |||
338 | /** | ||
339 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
340 | * under any possible substitution of the unspecified parameters (if any). | ||
341 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
342 | * @return true if the input is a valid (partial) match of the pattern. | ||
343 | * | ||
344 | */ | ||
345 | public boolean hasMatch(final Turnout pT) { | ||
346 | return rawHasMatch(new Object[]{pT}); | ||
347 | } | ||
348 | |||
349 | /** | ||
350 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
351 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
352 | * @return the number of pattern matches found. | ||
353 | * | ||
354 | */ | ||
355 | public int countMatches(final Turnout pT) { | ||
356 | return rawCountMatches(new Object[]{pT}); | ||
357 | } | ||
358 | |||
359 | /** | ||
360 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
361 | * Neither determinism nor randomness of selection is guaranteed. | ||
362 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
363 | * @param processor the action that will process the selected match. | ||
364 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
365 | * | ||
366 | */ | ||
367 | public boolean forOneArbitraryMatch(final Turnout pT, final Consumer<? super InputsOfTurnout.Match> processor) { | ||
368 | return rawForOneArbitraryMatch(new Object[]{pT}, processor); | ||
369 | } | ||
370 | |||
371 | /** | ||
372 | * Returns a new (partial) match. | ||
373 | * This can be used e.g. to call the matcher with a partial match. | ||
374 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
375 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
376 | * @return the (partial) match object. | ||
377 | * | ||
378 | */ | ||
379 | public InputsOfTurnout.Match newMatch(final Turnout pT) { | ||
380 | return InputsOfTurnout.Match.newMatch(pT); | ||
381 | } | ||
382 | |||
383 | /** | ||
384 | * Retrieve the set of values that occur in matches for T. | ||
385 | * @return the Set of all values or empty set if there are no matches | ||
386 | * | ||
387 | */ | ||
388 | protected Stream<Turnout> rawStreamAllValuesOfT(final Object[] parameters) { | ||
389 | return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); | ||
390 | } | ||
391 | |||
392 | /** | ||
393 | * Retrieve the set of values that occur in matches for T. | ||
394 | * @return the Set of all values or empty set if there are no matches | ||
395 | * | ||
396 | */ | ||
397 | public Set<Turnout> getAllValuesOfT() { | ||
398 | return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); | ||
399 | } | ||
400 | |||
401 | /** | ||
402 | * Retrieve the set of values that occur in matches for T. | ||
403 | * @return the Set of all values or empty set if there are no matches | ||
404 | * | ||
405 | */ | ||
406 | public Stream<Turnout> streamAllValuesOfT() { | ||
407 | return rawStreamAllValuesOfT(emptyArray()); | ||
408 | } | ||
409 | |||
410 | @Override | ||
411 | protected InputsOfTurnout.Match tupleToMatch(final Tuple t) { | ||
412 | try { | ||
413 | return InputsOfTurnout.Match.newMatch((Turnout) t.get(POSITION_T)); | ||
414 | } catch(ClassCastException e) { | ||
415 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
416 | return null; | ||
417 | } | ||
418 | } | ||
419 | |||
420 | @Override | ||
421 | protected InputsOfTurnout.Match arrayToMatch(final Object[] match) { | ||
422 | try { | ||
423 | return InputsOfTurnout.Match.newMatch((Turnout) match[POSITION_T]); | ||
424 | } catch(ClassCastException e) { | ||
425 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
426 | return null; | ||
427 | } | ||
428 | } | ||
429 | |||
430 | @Override | ||
431 | protected InputsOfTurnout.Match arrayToMatchMutable(final Object[] match) { | ||
432 | try { | ||
433 | return InputsOfTurnout.Match.newMutableMatch((Turnout) match[POSITION_T]); | ||
434 | } catch(ClassCastException e) { | ||
435 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
436 | return null; | ||
437 | } | ||
438 | } | ||
439 | |||
440 | /** | ||
441 | * @return the singleton instance of the query specification of this pattern | ||
442 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
443 | * | ||
444 | */ | ||
445 | public static IQuerySpecification<InputsOfTurnout.Matcher> querySpecification() { | ||
446 | return InputsOfTurnout.instance(); | ||
447 | } | ||
448 | } | ||
449 | |||
450 | private InputsOfTurnout() { | ||
451 | super(GeneratedPQuery.INSTANCE); | ||
452 | } | ||
453 | |||
454 | /** | ||
455 | * @return the singleton instance of the query specification | ||
456 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
457 | * | ||
458 | */ | ||
459 | public static InputsOfTurnout instance() { | ||
460 | try{ | ||
461 | return LazyHolder.INSTANCE; | ||
462 | } catch (ExceptionInInitializerError err) { | ||
463 | throw processInitializerError(err); | ||
464 | } | ||
465 | } | ||
466 | |||
467 | @Override | ||
468 | protected InputsOfTurnout.Matcher instantiate(final ViatraQueryEngine engine) { | ||
469 | return InputsOfTurnout.Matcher.on(engine); | ||
470 | } | ||
471 | |||
472 | @Override | ||
473 | public InputsOfTurnout.Matcher instantiate() { | ||
474 | return InputsOfTurnout.Matcher.create(); | ||
475 | } | ||
476 | |||
477 | @Override | ||
478 | public InputsOfTurnout.Match newEmptyMatch() { | ||
479 | return InputsOfTurnout.Match.newEmptyMatch(); | ||
480 | } | ||
481 | |||
482 | @Override | ||
483 | public InputsOfTurnout.Match newMatch(final Object... parameters) { | ||
484 | return InputsOfTurnout.Match.newMatch((modes3.Turnout) parameters[0]); | ||
485 | } | ||
486 | |||
487 | /** | ||
488 | * Inner class allowing the singleton instance of {@link InputsOfTurnout} to be created | ||
489 | * <b>not</b> at the class load time of the outer class, | ||
490 | * but rather at the first call to {@link InputsOfTurnout#instance()}. | ||
491 | * | ||
492 | * <p> This workaround is required e.g. to support recursion. | ||
493 | * | ||
494 | */ | ||
495 | private static class LazyHolder { | ||
496 | private static final InputsOfTurnout INSTANCE = new InputsOfTurnout(); | ||
497 | |||
498 | /** | ||
499 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
500 | * This initialization order is required to support indirect recursion. | ||
501 | * | ||
502 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
503 | * | ||
504 | */ | ||
505 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
506 | |||
507 | public static Object ensureInitialized() { | ||
508 | INSTANCE.ensureInitializedInternal(); | ||
509 | return null; | ||
510 | } | ||
511 | } | ||
512 | |||
513 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
514 | private static final InputsOfTurnout.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
515 | |||
516 | private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); | ||
517 | |||
518 | private final List<PParameter> parameters = Arrays.asList(parameter_T); | ||
519 | |||
520 | private GeneratedPQuery() { | ||
521 | super(PVisibility.PUBLIC); | ||
522 | } | ||
523 | |||
524 | @Override | ||
525 | public String getFullyQualifiedName() { | ||
526 | return "modes3.queries.inputsOfTurnout"; | ||
527 | } | ||
528 | |||
529 | @Override | ||
530 | public List<String> getParameterNames() { | ||
531 | return Arrays.asList("T"); | ||
532 | } | ||
533 | |||
534 | @Override | ||
535 | public List<PParameter> getParameters() { | ||
536 | return parameters; | ||
537 | } | ||
538 | |||
539 | @Override | ||
540 | public Set<PBody> doGetContainedBodies() { | ||
541 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
542 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
543 | { | ||
544 | PBody body = new PBody(this); | ||
545 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
546 | PVariable var_I1 = body.getOrCreateVariableByName("I1"); | ||
547 | PVariable var_I2 = body.getOrCreateVariableByName("I2"); | ||
548 | PVariable var_I3 = body.getOrCreateVariableByName("I3"); | ||
549 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
550 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
551 | new ExportedParameter(body, var_T, parameter_T) | ||
552 | )); | ||
553 | // find adjacent(I1, T) | ||
554 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I1, var_T), Adjacent.instance().getInternalQueryRepresentation()); | ||
555 | // find adjacent(I2, T) | ||
556 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I2, var_T), Adjacent.instance().getInternalQueryRepresentation()); | ||
557 | // find adjacent(I3, T) | ||
558 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I3, var_T), Adjacent.instance().getInternalQueryRepresentation()); | ||
559 | // I1 != I2 | ||
560 | new Inequality(body, var_I1, var_I2); | ||
561 | // I1 != I3 | ||
562 | new Inequality(body, var_I1, var_I3); | ||
563 | // I2 != I3 | ||
564 | new Inequality(body, var_I2, var_I3); | ||
565 | bodies.add(body); | ||
566 | } | ||
567 | return bodies; | ||
568 | } | ||
569 | } | ||
570 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Modes3Queries.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Modes3Queries.java new file mode 100644 index 00000000..d1238d61 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Modes3Queries.java | |||
@@ -0,0 +1,405 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import modes3.queries.Adjacent; | ||
7 | import modes3.queries.CloseTrains_step_2; | ||
8 | import modes3.queries.CloseTrains_step_3; | ||
9 | import modes3.queries.CloseTrains_step_4; | ||
10 | import modes3.queries.CloseTrains_step_5; | ||
11 | import modes3.queries.CloseTrains_step_6; | ||
12 | import modes3.queries.CloseTrains_step_7; | ||
13 | import modes3.queries.ConnectedSegmentsDirected; | ||
14 | import modes3.queries.ConnectedTo; | ||
15 | import modes3.queries.ConnectedToNotSymmetric; | ||
16 | import modes3.queries.ConnectedToReflexive; | ||
17 | import modes3.queries.EndOfSiding_step_2; | ||
18 | import modes3.queries.EndOfSiding_step_3; | ||
19 | import modes3.queries.EndOfSiding_step_4; | ||
20 | import modes3.queries.EndOfSiding_step_5; | ||
21 | import modes3.queries.InputsOfTurnout; | ||
22 | import modes3.queries.MisalignedTurnout_step_2; | ||
23 | import modes3.queries.MisalignedTurnout_step_3; | ||
24 | import modes3.queries.MisalignedTurnout_step_4; | ||
25 | import modes3.queries.MisalignedTurnout_step_5; | ||
26 | import modes3.queries.MultipleConnectedTo; | ||
27 | import modes3.queries.Output; | ||
28 | import modes3.queries.OutputReflexive; | ||
29 | import modes3.queries.Reachable; | ||
30 | import modes3.queries.TooFewInputsOfTurnout; | ||
31 | import modes3.queries.TooManyInputsOfSegment; | ||
32 | import modes3.queries.TooManyInputsOfTurnout; | ||
33 | import modes3.queries.TrainLocations_step_2; | ||
34 | import modes3.queries.TrainLocations_step_3; | ||
35 | import modes3.queries.TurnoutConnectedToBothOutputs; | ||
36 | import modes3.queries.TurnoutOutput; | ||
37 | import modes3.queries.TurnoutOutputsAreSame; | ||
38 | import modes3.queries.Unreachable; | ||
39 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
40 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; | ||
41 | |||
42 | /** | ||
43 | * A pattern group formed of all public patterns defined in Modes3Queries.vql. | ||
44 | * | ||
45 | * <p>Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare | ||
46 | * a VIATRA Query engine for matching all patterns originally defined in file Modes3Queries.vql, | ||
47 | * in order to achieve better performance than one-by-one on-demand matcher initialization. | ||
48 | * | ||
49 | * <p> From package modes3.queries, the group contains the definition of the following patterns: <ul> | ||
50 | * <li>connectedTo</li> | ||
51 | * <li>connectedToNotSymmetric</li> | ||
52 | * <li>connectedToReflexive</li> | ||
53 | * <li>turnoutOutput</li> | ||
54 | * <li>outputReflexive</li> | ||
55 | * <li>turnoutOutputsAreSame</li> | ||
56 | * <li>output</li> | ||
57 | * <li>tooManyInputsOfSegment</li> | ||
58 | * <li>turnoutConnectedToBothOutputs</li> | ||
59 | * <li>adjacent</li> | ||
60 | * <li>tooManyInputsOfTurnout</li> | ||
61 | * <li>inputsOfTurnout</li> | ||
62 | * <li>tooFewInputsOfTurnout</li> | ||
63 | * <li>reachable</li> | ||
64 | * <li>unreachable</li> | ||
65 | * <li>closeTrains_step_2</li> | ||
66 | * <li>closeTrains_step_3</li> | ||
67 | * <li>closeTrains_step_4</li> | ||
68 | * <li>closeTrains_step_5</li> | ||
69 | * <li>closeTrains_step_6</li> | ||
70 | * <li>closeTrains_step_7</li> | ||
71 | * <li>trainLocations_step_2</li> | ||
72 | * <li>trainLocations_step_3</li> | ||
73 | * <li>misalignedTurnout_step_2</li> | ||
74 | * <li>misalignedTurnout_step_3</li> | ||
75 | * <li>misalignedTurnout_step_4</li> | ||
76 | * <li>misalignedTurnout_step_5</li> | ||
77 | * <li>connectedSegmentsDirected</li> | ||
78 | * <li>endOfSiding_step_2</li> | ||
79 | * <li>endOfSiding_step_3</li> | ||
80 | * <li>endOfSiding_step_4</li> | ||
81 | * <li>endOfSiding_step_5</li> | ||
82 | * <li>multipleConnectedTo</li> | ||
83 | * </ul> | ||
84 | * | ||
85 | * @see IQueryGroup | ||
86 | * | ||
87 | */ | ||
88 | @SuppressWarnings("all") | ||
89 | public final class Modes3Queries extends BaseGeneratedPatternGroup { | ||
90 | /** | ||
91 | * Access the pattern group. | ||
92 | * | ||
93 | * @return the singleton instance of the group | ||
94 | * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications | ||
95 | * | ||
96 | */ | ||
97 | public static Modes3Queries instance() { | ||
98 | if (INSTANCE == null) { | ||
99 | INSTANCE = new Modes3Queries(); | ||
100 | } | ||
101 | return INSTANCE; | ||
102 | } | ||
103 | |||
104 | private static Modes3Queries INSTANCE; | ||
105 | |||
106 | private Modes3Queries() { | ||
107 | querySpecifications.add(ConnectedTo.instance()); | ||
108 | querySpecifications.add(ConnectedToNotSymmetric.instance()); | ||
109 | querySpecifications.add(ConnectedToReflexive.instance()); | ||
110 | querySpecifications.add(TurnoutOutput.instance()); | ||
111 | querySpecifications.add(OutputReflexive.instance()); | ||
112 | querySpecifications.add(TurnoutOutputsAreSame.instance()); | ||
113 | querySpecifications.add(Output.instance()); | ||
114 | querySpecifications.add(TooManyInputsOfSegment.instance()); | ||
115 | querySpecifications.add(TurnoutConnectedToBothOutputs.instance()); | ||
116 | querySpecifications.add(Adjacent.instance()); | ||
117 | querySpecifications.add(TooManyInputsOfTurnout.instance()); | ||
118 | querySpecifications.add(InputsOfTurnout.instance()); | ||
119 | querySpecifications.add(TooFewInputsOfTurnout.instance()); | ||
120 | querySpecifications.add(Reachable.instance()); | ||
121 | querySpecifications.add(Unreachable.instance()); | ||
122 | querySpecifications.add(CloseTrains_step_2.instance()); | ||
123 | querySpecifications.add(CloseTrains_step_3.instance()); | ||
124 | querySpecifications.add(CloseTrains_step_4.instance()); | ||
125 | querySpecifications.add(CloseTrains_step_5.instance()); | ||
126 | querySpecifications.add(CloseTrains_step_6.instance()); | ||
127 | querySpecifications.add(CloseTrains_step_7.instance()); | ||
128 | querySpecifications.add(TrainLocations_step_2.instance()); | ||
129 | querySpecifications.add(TrainLocations_step_3.instance()); | ||
130 | querySpecifications.add(MisalignedTurnout_step_2.instance()); | ||
131 | querySpecifications.add(MisalignedTurnout_step_3.instance()); | ||
132 | querySpecifications.add(MisalignedTurnout_step_4.instance()); | ||
133 | querySpecifications.add(MisalignedTurnout_step_5.instance()); | ||
134 | querySpecifications.add(ConnectedSegmentsDirected.instance()); | ||
135 | querySpecifications.add(EndOfSiding_step_2.instance()); | ||
136 | querySpecifications.add(EndOfSiding_step_3.instance()); | ||
137 | querySpecifications.add(EndOfSiding_step_4.instance()); | ||
138 | querySpecifications.add(EndOfSiding_step_5.instance()); | ||
139 | querySpecifications.add(MultipleConnectedTo.instance()); | ||
140 | } | ||
141 | |||
142 | public ConnectedTo getConnectedTo() { | ||
143 | return ConnectedTo.instance(); | ||
144 | } | ||
145 | |||
146 | public ConnectedTo.Matcher getConnectedTo(final ViatraQueryEngine engine) { | ||
147 | return ConnectedTo.Matcher.on(engine); | ||
148 | } | ||
149 | |||
150 | public ConnectedToNotSymmetric getConnectedToNotSymmetric() { | ||
151 | return ConnectedToNotSymmetric.instance(); | ||
152 | } | ||
153 | |||
154 | public ConnectedToNotSymmetric.Matcher getConnectedToNotSymmetric(final ViatraQueryEngine engine) { | ||
155 | return ConnectedToNotSymmetric.Matcher.on(engine); | ||
156 | } | ||
157 | |||
158 | public ConnectedToReflexive getConnectedToReflexive() { | ||
159 | return ConnectedToReflexive.instance(); | ||
160 | } | ||
161 | |||
162 | public ConnectedToReflexive.Matcher getConnectedToReflexive(final ViatraQueryEngine engine) { | ||
163 | return ConnectedToReflexive.Matcher.on(engine); | ||
164 | } | ||
165 | |||
166 | public TurnoutOutput getTurnoutOutput() { | ||
167 | return TurnoutOutput.instance(); | ||
168 | } | ||
169 | |||
170 | public TurnoutOutput.Matcher getTurnoutOutput(final ViatraQueryEngine engine) { | ||
171 | return TurnoutOutput.Matcher.on(engine); | ||
172 | } | ||
173 | |||
174 | public OutputReflexive getOutputReflexive() { | ||
175 | return OutputReflexive.instance(); | ||
176 | } | ||
177 | |||
178 | public OutputReflexive.Matcher getOutputReflexive(final ViatraQueryEngine engine) { | ||
179 | return OutputReflexive.Matcher.on(engine); | ||
180 | } | ||
181 | |||
182 | public TurnoutOutputsAreSame getTurnoutOutputsAreSame() { | ||
183 | return TurnoutOutputsAreSame.instance(); | ||
184 | } | ||
185 | |||
186 | public TurnoutOutputsAreSame.Matcher getTurnoutOutputsAreSame(final ViatraQueryEngine engine) { | ||
187 | return TurnoutOutputsAreSame.Matcher.on(engine); | ||
188 | } | ||
189 | |||
190 | public Output getOutput() { | ||
191 | return Output.instance(); | ||
192 | } | ||
193 | |||
194 | public Output.Matcher getOutput(final ViatraQueryEngine engine) { | ||
195 | return Output.Matcher.on(engine); | ||
196 | } | ||
197 | |||
198 | public TooManyInputsOfSegment getTooManyInputsOfSegment() { | ||
199 | return TooManyInputsOfSegment.instance(); | ||
200 | } | ||
201 | |||
202 | public TooManyInputsOfSegment.Matcher getTooManyInputsOfSegment(final ViatraQueryEngine engine) { | ||
203 | return TooManyInputsOfSegment.Matcher.on(engine); | ||
204 | } | ||
205 | |||
206 | public TurnoutConnectedToBothOutputs getTurnoutConnectedToBothOutputs() { | ||
207 | return TurnoutConnectedToBothOutputs.instance(); | ||
208 | } | ||
209 | |||
210 | public TurnoutConnectedToBothOutputs.Matcher getTurnoutConnectedToBothOutputs(final ViatraQueryEngine engine) { | ||
211 | return TurnoutConnectedToBothOutputs.Matcher.on(engine); | ||
212 | } | ||
213 | |||
214 | public Adjacent getAdjacent() { | ||
215 | return Adjacent.instance(); | ||
216 | } | ||
217 | |||
218 | public Adjacent.Matcher getAdjacent(final ViatraQueryEngine engine) { | ||
219 | return Adjacent.Matcher.on(engine); | ||
220 | } | ||
221 | |||
222 | public TooManyInputsOfTurnout getTooManyInputsOfTurnout() { | ||
223 | return TooManyInputsOfTurnout.instance(); | ||
224 | } | ||
225 | |||
226 | public TooManyInputsOfTurnout.Matcher getTooManyInputsOfTurnout(final ViatraQueryEngine engine) { | ||
227 | return TooManyInputsOfTurnout.Matcher.on(engine); | ||
228 | } | ||
229 | |||
230 | public InputsOfTurnout getInputsOfTurnout() { | ||
231 | return InputsOfTurnout.instance(); | ||
232 | } | ||
233 | |||
234 | public InputsOfTurnout.Matcher getInputsOfTurnout(final ViatraQueryEngine engine) { | ||
235 | return InputsOfTurnout.Matcher.on(engine); | ||
236 | } | ||
237 | |||
238 | public TooFewInputsOfTurnout getTooFewInputsOfTurnout() { | ||
239 | return TooFewInputsOfTurnout.instance(); | ||
240 | } | ||
241 | |||
242 | public TooFewInputsOfTurnout.Matcher getTooFewInputsOfTurnout(final ViatraQueryEngine engine) { | ||
243 | return TooFewInputsOfTurnout.Matcher.on(engine); | ||
244 | } | ||
245 | |||
246 | public Reachable getReachable() { | ||
247 | return Reachable.instance(); | ||
248 | } | ||
249 | |||
250 | public Reachable.Matcher getReachable(final ViatraQueryEngine engine) { | ||
251 | return Reachable.Matcher.on(engine); | ||
252 | } | ||
253 | |||
254 | public Unreachable getUnreachable() { | ||
255 | return Unreachable.instance(); | ||
256 | } | ||
257 | |||
258 | public Unreachable.Matcher getUnreachable(final ViatraQueryEngine engine) { | ||
259 | return Unreachable.Matcher.on(engine); | ||
260 | } | ||
261 | |||
262 | public CloseTrains_step_2 getCloseTrains_step_2() { | ||
263 | return CloseTrains_step_2.instance(); | ||
264 | } | ||
265 | |||
266 | public CloseTrains_step_2.Matcher getCloseTrains_step_2(final ViatraQueryEngine engine) { | ||
267 | return CloseTrains_step_2.Matcher.on(engine); | ||
268 | } | ||
269 | |||
270 | public CloseTrains_step_3 getCloseTrains_step_3() { | ||
271 | return CloseTrains_step_3.instance(); | ||
272 | } | ||
273 | |||
274 | public CloseTrains_step_3.Matcher getCloseTrains_step_3(final ViatraQueryEngine engine) { | ||
275 | return CloseTrains_step_3.Matcher.on(engine); | ||
276 | } | ||
277 | |||
278 | public CloseTrains_step_4 getCloseTrains_step_4() { | ||
279 | return CloseTrains_step_4.instance(); | ||
280 | } | ||
281 | |||
282 | public CloseTrains_step_4.Matcher getCloseTrains_step_4(final ViatraQueryEngine engine) { | ||
283 | return CloseTrains_step_4.Matcher.on(engine); | ||
284 | } | ||
285 | |||
286 | public CloseTrains_step_5 getCloseTrains_step_5() { | ||
287 | return CloseTrains_step_5.instance(); | ||
288 | } | ||
289 | |||
290 | public CloseTrains_step_5.Matcher getCloseTrains_step_5(final ViatraQueryEngine engine) { | ||
291 | return CloseTrains_step_5.Matcher.on(engine); | ||
292 | } | ||
293 | |||
294 | public CloseTrains_step_6 getCloseTrains_step_6() { | ||
295 | return CloseTrains_step_6.instance(); | ||
296 | } | ||
297 | |||
298 | public CloseTrains_step_6.Matcher getCloseTrains_step_6(final ViatraQueryEngine engine) { | ||
299 | return CloseTrains_step_6.Matcher.on(engine); | ||
300 | } | ||
301 | |||
302 | public CloseTrains_step_7 getCloseTrains_step_7() { | ||
303 | return CloseTrains_step_7.instance(); | ||
304 | } | ||
305 | |||
306 | public CloseTrains_step_7.Matcher getCloseTrains_step_7(final ViatraQueryEngine engine) { | ||
307 | return CloseTrains_step_7.Matcher.on(engine); | ||
308 | } | ||
309 | |||
310 | public TrainLocations_step_2 getTrainLocations_step_2() { | ||
311 | return TrainLocations_step_2.instance(); | ||
312 | } | ||
313 | |||
314 | public TrainLocations_step_2.Matcher getTrainLocations_step_2(final ViatraQueryEngine engine) { | ||
315 | return TrainLocations_step_2.Matcher.on(engine); | ||
316 | } | ||
317 | |||
318 | public TrainLocations_step_3 getTrainLocations_step_3() { | ||
319 | return TrainLocations_step_3.instance(); | ||
320 | } | ||
321 | |||
322 | public TrainLocations_step_3.Matcher getTrainLocations_step_3(final ViatraQueryEngine engine) { | ||
323 | return TrainLocations_step_3.Matcher.on(engine); | ||
324 | } | ||
325 | |||
326 | public MisalignedTurnout_step_2 getMisalignedTurnout_step_2() { | ||
327 | return MisalignedTurnout_step_2.instance(); | ||
328 | } | ||
329 | |||
330 | public MisalignedTurnout_step_2.Matcher getMisalignedTurnout_step_2(final ViatraQueryEngine engine) { | ||
331 | return MisalignedTurnout_step_2.Matcher.on(engine); | ||
332 | } | ||
333 | |||
334 | public MisalignedTurnout_step_3 getMisalignedTurnout_step_3() { | ||
335 | return MisalignedTurnout_step_3.instance(); | ||
336 | } | ||
337 | |||
338 | public MisalignedTurnout_step_3.Matcher getMisalignedTurnout_step_3(final ViatraQueryEngine engine) { | ||
339 | return MisalignedTurnout_step_3.Matcher.on(engine); | ||
340 | } | ||
341 | |||
342 | public MisalignedTurnout_step_4 getMisalignedTurnout_step_4() { | ||
343 | return MisalignedTurnout_step_4.instance(); | ||
344 | } | ||
345 | |||
346 | public MisalignedTurnout_step_4.Matcher getMisalignedTurnout_step_4(final ViatraQueryEngine engine) { | ||
347 | return MisalignedTurnout_step_4.Matcher.on(engine); | ||
348 | } | ||
349 | |||
350 | public MisalignedTurnout_step_5 getMisalignedTurnout_step_5() { | ||
351 | return MisalignedTurnout_step_5.instance(); | ||
352 | } | ||
353 | |||
354 | public MisalignedTurnout_step_5.Matcher getMisalignedTurnout_step_5(final ViatraQueryEngine engine) { | ||
355 | return MisalignedTurnout_step_5.Matcher.on(engine); | ||
356 | } | ||
357 | |||
358 | public ConnectedSegmentsDirected getConnectedSegmentsDirected() { | ||
359 | return ConnectedSegmentsDirected.instance(); | ||
360 | } | ||
361 | |||
362 | public ConnectedSegmentsDirected.Matcher getConnectedSegmentsDirected(final ViatraQueryEngine engine) { | ||
363 | return ConnectedSegmentsDirected.Matcher.on(engine); | ||
364 | } | ||
365 | |||
366 | public EndOfSiding_step_2 getEndOfSiding_step_2() { | ||
367 | return EndOfSiding_step_2.instance(); | ||
368 | } | ||
369 | |||
370 | public EndOfSiding_step_2.Matcher getEndOfSiding_step_2(final ViatraQueryEngine engine) { | ||
371 | return EndOfSiding_step_2.Matcher.on(engine); | ||
372 | } | ||
373 | |||
374 | public EndOfSiding_step_3 getEndOfSiding_step_3() { | ||
375 | return EndOfSiding_step_3.instance(); | ||
376 | } | ||
377 | |||
378 | public EndOfSiding_step_3.Matcher getEndOfSiding_step_3(final ViatraQueryEngine engine) { | ||
379 | return EndOfSiding_step_3.Matcher.on(engine); | ||
380 | } | ||
381 | |||
382 | public EndOfSiding_step_4 getEndOfSiding_step_4() { | ||
383 | return EndOfSiding_step_4.instance(); | ||
384 | } | ||
385 | |||
386 | public EndOfSiding_step_4.Matcher getEndOfSiding_step_4(final ViatraQueryEngine engine) { | ||
387 | return EndOfSiding_step_4.Matcher.on(engine); | ||
388 | } | ||
389 | |||
390 | public EndOfSiding_step_5 getEndOfSiding_step_5() { | ||
391 | return EndOfSiding_step_5.instance(); | ||
392 | } | ||
393 | |||
394 | public EndOfSiding_step_5.Matcher getEndOfSiding_step_5(final ViatraQueryEngine engine) { | ||
395 | return EndOfSiding_step_5.Matcher.on(engine); | ||
396 | } | ||
397 | |||
398 | public MultipleConnectedTo getMultipleConnectedTo() { | ||
399 | return MultipleConnectedTo.instance(); | ||
400 | } | ||
401 | |||
402 | public MultipleConnectedTo.Matcher getMultipleConnectedTo(final ViatraQueryEngine engine) { | ||
403 | return MultipleConnectedTo.Matcher.on(engine); | ||
404 | } | ||
405 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/MultipleConnectedTo.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/MultipleConnectedTo.java new file mode 100644 index 00000000..277006c9 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/MultipleConnectedTo.java | |||
@@ -0,0 +1,565 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern multipleConnectedTo(s : Segment) { | ||
48 | * Segment.connectedTo(s, n1); | ||
49 | * Segment.connectedTo(s, n2); | ||
50 | * n1 != n2; | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class MultipleConnectedTo extends BaseGeneratedEMFQuerySpecification<MultipleConnectedTo.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.multipleConnectedTo pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Segment fS; | ||
74 | |||
75 | private static List<String> parameterNames = makeImmutableList("s"); | ||
76 | |||
77 | private Match(final Segment pS) { | ||
78 | this.fS = pS; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "s": return this.fS; | ||
85 | default: return null; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final int index) { | ||
91 | switch(index) { | ||
92 | case 0: return this.fS; | ||
93 | default: return null; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | public Segment getS() { | ||
98 | return this.fS; | ||
99 | } | ||
100 | |||
101 | @Override | ||
102 | public boolean set(final String parameterName, final Object newValue) { | ||
103 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
104 | if ("s".equals(parameterName) ) { | ||
105 | this.fS = (Segment) newValue; | ||
106 | return true; | ||
107 | } | ||
108 | return false; | ||
109 | } | ||
110 | |||
111 | public void setS(final Segment pS) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | this.fS = pS; | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public String patternName() { | ||
118 | return "modes3.queries.multipleConnectedTo"; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public List<String> parameterNames() { | ||
123 | return MultipleConnectedTo.Match.parameterNames; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public Object[] toArray() { | ||
128 | return new Object[]{fS}; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public MultipleConnectedTo.Match toImmutable() { | ||
133 | return isMutable() ? newMatch(fS) : this; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public String prettyPrint() { | ||
138 | StringBuilder result = new StringBuilder(); | ||
139 | result.append("\"s\"=" + prettyPrintValue(fS)); | ||
140 | return result.toString(); | ||
141 | } | ||
142 | |||
143 | @Override | ||
144 | public int hashCode() { | ||
145 | return Objects.hash(fS); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public boolean equals(final Object obj) { | ||
150 | if (this == obj) | ||
151 | return true; | ||
152 | if (obj == null) { | ||
153 | return false; | ||
154 | } | ||
155 | if ((obj instanceof MultipleConnectedTo.Match)) { | ||
156 | MultipleConnectedTo.Match other = (MultipleConnectedTo.Match) obj; | ||
157 | return Objects.equals(fS, other.fS); | ||
158 | } else { | ||
159 | // this should be infrequent | ||
160 | if (!(obj instanceof IPatternMatch)) { | ||
161 | return false; | ||
162 | } | ||
163 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
164 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public MultipleConnectedTo specification() { | ||
170 | return MultipleConnectedTo.instance(); | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * Returns an empty, mutable match. | ||
175 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
176 | * | ||
177 | * @return the empty match. | ||
178 | * | ||
179 | */ | ||
180 | public static MultipleConnectedTo.Match newEmptyMatch() { | ||
181 | return new Mutable(null); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Returns a mutable (partial) match. | ||
186 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
187 | * | ||
188 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
189 | * @return the new, mutable (partial) match object. | ||
190 | * | ||
191 | */ | ||
192 | public static MultipleConnectedTo.Match newMutableMatch(final Segment pS) { | ||
193 | return new Mutable(pS); | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * Returns a new (partial) match. | ||
198 | * This can be used e.g. to call the matcher with a partial match. | ||
199 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
200 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
201 | * @return the (partial) match object. | ||
202 | * | ||
203 | */ | ||
204 | public static MultipleConnectedTo.Match newMatch(final Segment pS) { | ||
205 | return new Immutable(pS); | ||
206 | } | ||
207 | |||
208 | private static final class Mutable extends MultipleConnectedTo.Match { | ||
209 | Mutable(final Segment pS) { | ||
210 | super(pS); | ||
211 | } | ||
212 | |||
213 | @Override | ||
214 | public boolean isMutable() { | ||
215 | return true; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | private static final class Immutable extends MultipleConnectedTo.Match { | ||
220 | Immutable(final Segment pS) { | ||
221 | super(pS); | ||
222 | } | ||
223 | |||
224 | @Override | ||
225 | public boolean isMutable() { | ||
226 | return false; | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * Generated pattern matcher API of the modes3.queries.multipleConnectedTo pattern, | ||
233 | * providing pattern-specific query methods. | ||
234 | * | ||
235 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
236 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
237 | * | ||
238 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
239 | * | ||
240 | * <p>Original source: | ||
241 | * <code><pre> | ||
242 | * pattern multipleConnectedTo(s : Segment) { | ||
243 | * Segment.connectedTo(s, n1); | ||
244 | * Segment.connectedTo(s, n2); | ||
245 | * n1 != n2; | ||
246 | * } | ||
247 | * </pre></code> | ||
248 | * | ||
249 | * @see Match | ||
250 | * @see MultipleConnectedTo | ||
251 | * | ||
252 | */ | ||
253 | public static class Matcher extends BaseMatcher<MultipleConnectedTo.Match> { | ||
254 | /** | ||
255 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
256 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
257 | * | ||
258 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
259 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
260 | * | ||
261 | */ | ||
262 | public static MultipleConnectedTo.Matcher on(final ViatraQueryEngine engine) { | ||
263 | // check if matcher already exists | ||
264 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
265 | if (matcher == null) { | ||
266 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
267 | } | ||
268 | return matcher; | ||
269 | } | ||
270 | |||
271 | /** | ||
272 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
273 | * @return an initialized matcher | ||
274 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
275 | * | ||
276 | */ | ||
277 | public static MultipleConnectedTo.Matcher create() { | ||
278 | return new Matcher(); | ||
279 | } | ||
280 | |||
281 | private static final int POSITION_S = 0; | ||
282 | |||
283 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(MultipleConnectedTo.Matcher.class); | ||
284 | |||
285 | /** | ||
286 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
287 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
288 | * | ||
289 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
290 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
291 | * | ||
292 | */ | ||
293 | private Matcher() { | ||
294 | super(querySpecification()); | ||
295 | } | ||
296 | |||
297 | /** | ||
298 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
299 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
300 | * @return matches represented as a Match object. | ||
301 | * | ||
302 | */ | ||
303 | public Collection<MultipleConnectedTo.Match> getAllMatches(final Segment pS) { | ||
304 | return rawStreamAllMatches(new Object[]{pS}).collect(Collectors.toSet()); | ||
305 | } | ||
306 | |||
307 | /** | ||
308 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
309 | * </p> | ||
310 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
311 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
312 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
313 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
314 | * @return a stream of matches represented as a Match object. | ||
315 | * | ||
316 | */ | ||
317 | public Stream<MultipleConnectedTo.Match> streamAllMatches(final Segment pS) { | ||
318 | return rawStreamAllMatches(new Object[]{pS}); | ||
319 | } | ||
320 | |||
321 | /** | ||
322 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
323 | * Neither determinism nor randomness of selection is guaranteed. | ||
324 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
325 | * @return a match represented as a Match object, or null if no match is found. | ||
326 | * | ||
327 | */ | ||
328 | public Optional<MultipleConnectedTo.Match> getOneArbitraryMatch(final Segment pS) { | ||
329 | return rawGetOneArbitraryMatch(new Object[]{pS}); | ||
330 | } | ||
331 | |||
332 | /** | ||
333 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
334 | * under any possible substitution of the unspecified parameters (if any). | ||
335 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
336 | * @return true if the input is a valid (partial) match of the pattern. | ||
337 | * | ||
338 | */ | ||
339 | public boolean hasMatch(final Segment pS) { | ||
340 | return rawHasMatch(new Object[]{pS}); | ||
341 | } | ||
342 | |||
343 | /** | ||
344 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
345 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
346 | * @return the number of pattern matches found. | ||
347 | * | ||
348 | */ | ||
349 | public int countMatches(final Segment pS) { | ||
350 | return rawCountMatches(new Object[]{pS}); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
355 | * Neither determinism nor randomness of selection is guaranteed. | ||
356 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
357 | * @param processor the action that will process the selected match. | ||
358 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
359 | * | ||
360 | */ | ||
361 | public boolean forOneArbitraryMatch(final Segment pS, final Consumer<? super MultipleConnectedTo.Match> processor) { | ||
362 | return rawForOneArbitraryMatch(new Object[]{pS}, processor); | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * Returns a new (partial) match. | ||
367 | * This can be used e.g. to call the matcher with a partial match. | ||
368 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
369 | * @param pS the fixed value of pattern parameter s, or null if not bound. | ||
370 | * @return the (partial) match object. | ||
371 | * | ||
372 | */ | ||
373 | public MultipleConnectedTo.Match newMatch(final Segment pS) { | ||
374 | return MultipleConnectedTo.Match.newMatch(pS); | ||
375 | } | ||
376 | |||
377 | /** | ||
378 | * Retrieve the set of values that occur in matches for s. | ||
379 | * @return the Set of all values or empty set if there are no matches | ||
380 | * | ||
381 | */ | ||
382 | protected Stream<Segment> rawStreamAllValuesOfs(final Object[] parameters) { | ||
383 | return rawStreamAllValues(POSITION_S, parameters).map(Segment.class::cast); | ||
384 | } | ||
385 | |||
386 | /** | ||
387 | * Retrieve the set of values that occur in matches for s. | ||
388 | * @return the Set of all values or empty set if there are no matches | ||
389 | * | ||
390 | */ | ||
391 | public Set<Segment> getAllValuesOfs() { | ||
392 | return rawStreamAllValuesOfs(emptyArray()).collect(Collectors.toSet()); | ||
393 | } | ||
394 | |||
395 | /** | ||
396 | * Retrieve the set of values that occur in matches for s. | ||
397 | * @return the Set of all values or empty set if there are no matches | ||
398 | * | ||
399 | */ | ||
400 | public Stream<Segment> streamAllValuesOfs() { | ||
401 | return rawStreamAllValuesOfs(emptyArray()); | ||
402 | } | ||
403 | |||
404 | @Override | ||
405 | protected MultipleConnectedTo.Match tupleToMatch(final Tuple t) { | ||
406 | try { | ||
407 | return MultipleConnectedTo.Match.newMatch((Segment) t.get(POSITION_S)); | ||
408 | } catch(ClassCastException e) { | ||
409 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
410 | return null; | ||
411 | } | ||
412 | } | ||
413 | |||
414 | @Override | ||
415 | protected MultipleConnectedTo.Match arrayToMatch(final Object[] match) { | ||
416 | try { | ||
417 | return MultipleConnectedTo.Match.newMatch((Segment) match[POSITION_S]); | ||
418 | } catch(ClassCastException e) { | ||
419 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
420 | return null; | ||
421 | } | ||
422 | } | ||
423 | |||
424 | @Override | ||
425 | protected MultipleConnectedTo.Match arrayToMatchMutable(final Object[] match) { | ||
426 | try { | ||
427 | return MultipleConnectedTo.Match.newMutableMatch((Segment) match[POSITION_S]); | ||
428 | } catch(ClassCastException e) { | ||
429 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
430 | return null; | ||
431 | } | ||
432 | } | ||
433 | |||
434 | /** | ||
435 | * @return the singleton instance of the query specification of this pattern | ||
436 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
437 | * | ||
438 | */ | ||
439 | public static IQuerySpecification<MultipleConnectedTo.Matcher> querySpecification() { | ||
440 | return MultipleConnectedTo.instance(); | ||
441 | } | ||
442 | } | ||
443 | |||
444 | private MultipleConnectedTo() { | ||
445 | super(GeneratedPQuery.INSTANCE); | ||
446 | } | ||
447 | |||
448 | /** | ||
449 | * @return the singleton instance of the query specification | ||
450 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
451 | * | ||
452 | */ | ||
453 | public static MultipleConnectedTo instance() { | ||
454 | try{ | ||
455 | return LazyHolder.INSTANCE; | ||
456 | } catch (ExceptionInInitializerError err) { | ||
457 | throw processInitializerError(err); | ||
458 | } | ||
459 | } | ||
460 | |||
461 | @Override | ||
462 | protected MultipleConnectedTo.Matcher instantiate(final ViatraQueryEngine engine) { | ||
463 | return MultipleConnectedTo.Matcher.on(engine); | ||
464 | } | ||
465 | |||
466 | @Override | ||
467 | public MultipleConnectedTo.Matcher instantiate() { | ||
468 | return MultipleConnectedTo.Matcher.create(); | ||
469 | } | ||
470 | |||
471 | @Override | ||
472 | public MultipleConnectedTo.Match newEmptyMatch() { | ||
473 | return MultipleConnectedTo.Match.newEmptyMatch(); | ||
474 | } | ||
475 | |||
476 | @Override | ||
477 | public MultipleConnectedTo.Match newMatch(final Object... parameters) { | ||
478 | return MultipleConnectedTo.Match.newMatch((modes3.Segment) parameters[0]); | ||
479 | } | ||
480 | |||
481 | /** | ||
482 | * Inner class allowing the singleton instance of {@link MultipleConnectedTo} to be created | ||
483 | * <b>not</b> at the class load time of the outer class, | ||
484 | * but rather at the first call to {@link MultipleConnectedTo#instance()}. | ||
485 | * | ||
486 | * <p> This workaround is required e.g. to support recursion. | ||
487 | * | ||
488 | */ | ||
489 | private static class LazyHolder { | ||
490 | private static final MultipleConnectedTo INSTANCE = new MultipleConnectedTo(); | ||
491 | |||
492 | /** | ||
493 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
494 | * This initialization order is required to support indirect recursion. | ||
495 | * | ||
496 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
497 | * | ||
498 | */ | ||
499 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
500 | |||
501 | public static Object ensureInitialized() { | ||
502 | INSTANCE.ensureInitializedInternal(); | ||
503 | return null; | ||
504 | } | ||
505 | } | ||
506 | |||
507 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
508 | private static final MultipleConnectedTo.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
509 | |||
510 | private final PParameter parameter_s = new PParameter("s", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
511 | |||
512 | private final List<PParameter> parameters = Arrays.asList(parameter_s); | ||
513 | |||
514 | private GeneratedPQuery() { | ||
515 | super(PVisibility.PUBLIC); | ||
516 | } | ||
517 | |||
518 | @Override | ||
519 | public String getFullyQualifiedName() { | ||
520 | return "modes3.queries.multipleConnectedTo"; | ||
521 | } | ||
522 | |||
523 | @Override | ||
524 | public List<String> getParameterNames() { | ||
525 | return Arrays.asList("s"); | ||
526 | } | ||
527 | |||
528 | @Override | ||
529 | public List<PParameter> getParameters() { | ||
530 | return parameters; | ||
531 | } | ||
532 | |||
533 | @Override | ||
534 | public Set<PBody> doGetContainedBodies() { | ||
535 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
536 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
537 | { | ||
538 | PBody body = new PBody(this); | ||
539 | PVariable var_s = body.getOrCreateVariableByName("s"); | ||
540 | PVariable var_n1 = body.getOrCreateVariableByName("n1"); | ||
541 | PVariable var_n2 = body.getOrCreateVariableByName("n2"); | ||
542 | new TypeConstraint(body, Tuples.flatTupleOf(var_s), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
543 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
544 | new ExportedParameter(body, var_s, parameter_s) | ||
545 | )); | ||
546 | // Segment.connectedTo(s, n1) | ||
547 | new TypeConstraint(body, Tuples.flatTupleOf(var_s), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
548 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
549 | new TypeConstraint(body, Tuples.flatTupleOf(var_s, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
550 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
551 | new Equality(body, var__virtual_0_, var_n1); | ||
552 | // Segment.connectedTo(s, n2) | ||
553 | new TypeConstraint(body, Tuples.flatTupleOf(var_s), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
554 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
555 | new TypeConstraint(body, Tuples.flatTupleOf(var_s, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
556 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
557 | new Equality(body, var__virtual_1_, var_n2); | ||
558 | // n1 != n2 | ||
559 | new Inequality(body, var_n1, var_n2); | ||
560 | bodies.add(body); | ||
561 | } | ||
562 | return bodies; | ||
563 | } | ||
564 | } | ||
565 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Output.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Output.java new file mode 100644 index 00000000..615b33af --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Output.java | |||
@@ -0,0 +1,724 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.queries.TurnoutOutput; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * pattern output(S1 : Segment, S2 : Segment) { | ||
49 | * Segment.connectedTo(S1, S2); | ||
50 | * } or { | ||
51 | * find turnoutOutput(S1, S2); | ||
52 | * } | ||
53 | * </pre></code> | ||
54 | * | ||
55 | * @see Matcher | ||
56 | * @see Match | ||
57 | * | ||
58 | */ | ||
59 | @SuppressWarnings("all") | ||
60 | public final class Output extends BaseGeneratedEMFQuerySpecification<Output.Matcher> { | ||
61 | /** | ||
62 | * Pattern-specific match representation of the modes3.queries.output pattern, | ||
63 | * to be used in conjunction with {@link Matcher}. | ||
64 | * | ||
65 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
66 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
67 | * usable to represent a match of the pattern in the result of a query, | ||
68 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
69 | * | ||
70 | * @see Matcher | ||
71 | * | ||
72 | */ | ||
73 | public static abstract class Match extends BasePatternMatch { | ||
74 | private Segment fS1; | ||
75 | |||
76 | private Segment fS2; | ||
77 | |||
78 | private static List<String> parameterNames = makeImmutableList("S1", "S2"); | ||
79 | |||
80 | private Match(final Segment pS1, final Segment pS2) { | ||
81 | this.fS1 = pS1; | ||
82 | this.fS2 = pS2; | ||
83 | } | ||
84 | |||
85 | @Override | ||
86 | public Object get(final String parameterName) { | ||
87 | switch(parameterName) { | ||
88 | case "S1": return this.fS1; | ||
89 | case "S2": return this.fS2; | ||
90 | default: return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | @Override | ||
95 | public Object get(final int index) { | ||
96 | switch(index) { | ||
97 | case 0: return this.fS1; | ||
98 | case 1: return this.fS2; | ||
99 | default: return null; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | public Segment getS1() { | ||
104 | return this.fS1; | ||
105 | } | ||
106 | |||
107 | public Segment getS2() { | ||
108 | return this.fS2; | ||
109 | } | ||
110 | |||
111 | @Override | ||
112 | public boolean set(final String parameterName, final Object newValue) { | ||
113 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
114 | if ("S1".equals(parameterName) ) { | ||
115 | this.fS1 = (Segment) newValue; | ||
116 | return true; | ||
117 | } | ||
118 | if ("S2".equals(parameterName) ) { | ||
119 | this.fS2 = (Segment) newValue; | ||
120 | return true; | ||
121 | } | ||
122 | return false; | ||
123 | } | ||
124 | |||
125 | public void setS1(final Segment pS1) { | ||
126 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
127 | this.fS1 = pS1; | ||
128 | } | ||
129 | |||
130 | public void setS2(final Segment pS2) { | ||
131 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
132 | this.fS2 = pS2; | ||
133 | } | ||
134 | |||
135 | @Override | ||
136 | public String patternName() { | ||
137 | return "modes3.queries.output"; | ||
138 | } | ||
139 | |||
140 | @Override | ||
141 | public List<String> parameterNames() { | ||
142 | return Output.Match.parameterNames; | ||
143 | } | ||
144 | |||
145 | @Override | ||
146 | public Object[] toArray() { | ||
147 | return new Object[]{fS1, fS2}; | ||
148 | } | ||
149 | |||
150 | @Override | ||
151 | public Output.Match toImmutable() { | ||
152 | return isMutable() ? newMatch(fS1, fS2) : this; | ||
153 | } | ||
154 | |||
155 | @Override | ||
156 | public String prettyPrint() { | ||
157 | StringBuilder result = new StringBuilder(); | ||
158 | result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); | ||
159 | result.append("\"S2\"=" + prettyPrintValue(fS2)); | ||
160 | return result.toString(); | ||
161 | } | ||
162 | |||
163 | @Override | ||
164 | public int hashCode() { | ||
165 | return Objects.hash(fS1, fS2); | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public boolean equals(final Object obj) { | ||
170 | if (this == obj) | ||
171 | return true; | ||
172 | if (obj == null) { | ||
173 | return false; | ||
174 | } | ||
175 | if ((obj instanceof Output.Match)) { | ||
176 | Output.Match other = (Output.Match) obj; | ||
177 | return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); | ||
178 | } else { | ||
179 | // this should be infrequent | ||
180 | if (!(obj instanceof IPatternMatch)) { | ||
181 | return false; | ||
182 | } | ||
183 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
184 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
185 | } | ||
186 | } | ||
187 | |||
188 | @Override | ||
189 | public Output specification() { | ||
190 | return Output.instance(); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * Returns an empty, mutable match. | ||
195 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
196 | * | ||
197 | * @return the empty match. | ||
198 | * | ||
199 | */ | ||
200 | public static Output.Match newEmptyMatch() { | ||
201 | return new Mutable(null, null); | ||
202 | } | ||
203 | |||
204 | /** | ||
205 | * Returns a mutable (partial) match. | ||
206 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
207 | * | ||
208 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
209 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
210 | * @return the new, mutable (partial) match object. | ||
211 | * | ||
212 | */ | ||
213 | public static Output.Match newMutableMatch(final Segment pS1, final Segment pS2) { | ||
214 | return new Mutable(pS1, pS2); | ||
215 | } | ||
216 | |||
217 | /** | ||
218 | * Returns a new (partial) match. | ||
219 | * This can be used e.g. to call the matcher with a partial match. | ||
220 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
221 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
222 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
223 | * @return the (partial) match object. | ||
224 | * | ||
225 | */ | ||
226 | public static Output.Match newMatch(final Segment pS1, final Segment pS2) { | ||
227 | return new Immutable(pS1, pS2); | ||
228 | } | ||
229 | |||
230 | private static final class Mutable extends Output.Match { | ||
231 | Mutable(final Segment pS1, final Segment pS2) { | ||
232 | super(pS1, pS2); | ||
233 | } | ||
234 | |||
235 | @Override | ||
236 | public boolean isMutable() { | ||
237 | return true; | ||
238 | } | ||
239 | } | ||
240 | |||
241 | private static final class Immutable extends Output.Match { | ||
242 | Immutable(final Segment pS1, final Segment pS2) { | ||
243 | super(pS1, pS2); | ||
244 | } | ||
245 | |||
246 | @Override | ||
247 | public boolean isMutable() { | ||
248 | return false; | ||
249 | } | ||
250 | } | ||
251 | } | ||
252 | |||
253 | /** | ||
254 | * Generated pattern matcher API of the modes3.queries.output pattern, | ||
255 | * providing pattern-specific query methods. | ||
256 | * | ||
257 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
258 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
259 | * | ||
260 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
261 | * | ||
262 | * <p>Original source: | ||
263 | * <code><pre> | ||
264 | * pattern output(S1 : Segment, S2 : Segment) { | ||
265 | * Segment.connectedTo(S1, S2); | ||
266 | * } or { | ||
267 | * find turnoutOutput(S1, S2); | ||
268 | * } | ||
269 | * </pre></code> | ||
270 | * | ||
271 | * @see Match | ||
272 | * @see Output | ||
273 | * | ||
274 | */ | ||
275 | public static class Matcher extends BaseMatcher<Output.Match> { | ||
276 | /** | ||
277 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
278 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
279 | * | ||
280 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
281 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
282 | * | ||
283 | */ | ||
284 | public static Output.Matcher on(final ViatraQueryEngine engine) { | ||
285 | // check if matcher already exists | ||
286 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
287 | if (matcher == null) { | ||
288 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
289 | } | ||
290 | return matcher; | ||
291 | } | ||
292 | |||
293 | /** | ||
294 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
295 | * @return an initialized matcher | ||
296 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
297 | * | ||
298 | */ | ||
299 | public static Output.Matcher create() { | ||
300 | return new Matcher(); | ||
301 | } | ||
302 | |||
303 | private static final int POSITION_S1 = 0; | ||
304 | |||
305 | private static final int POSITION_S2 = 1; | ||
306 | |||
307 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Output.Matcher.class); | ||
308 | |||
309 | /** | ||
310 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
311 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
312 | * | ||
313 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
314 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
315 | * | ||
316 | */ | ||
317 | private Matcher() { | ||
318 | super(querySpecification()); | ||
319 | } | ||
320 | |||
321 | /** | ||
322 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
323 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
324 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
325 | * @return matches represented as a Match object. | ||
326 | * | ||
327 | */ | ||
328 | public Collection<Output.Match> getAllMatches(final Segment pS1, final Segment pS2) { | ||
329 | return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); | ||
330 | } | ||
331 | |||
332 | /** | ||
333 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
334 | * </p> | ||
335 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
336 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
337 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
338 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
339 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
340 | * @return a stream of matches represented as a Match object. | ||
341 | * | ||
342 | */ | ||
343 | public Stream<Output.Match> streamAllMatches(final Segment pS1, final Segment pS2) { | ||
344 | return rawStreamAllMatches(new Object[]{pS1, pS2}); | ||
345 | } | ||
346 | |||
347 | /** | ||
348 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
349 | * Neither determinism nor randomness of selection is guaranteed. | ||
350 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
351 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
352 | * @return a match represented as a Match object, or null if no match is found. | ||
353 | * | ||
354 | */ | ||
355 | public Optional<Output.Match> getOneArbitraryMatch(final Segment pS1, final Segment pS2) { | ||
356 | return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); | ||
357 | } | ||
358 | |||
359 | /** | ||
360 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
361 | * under any possible substitution of the unspecified parameters (if any). | ||
362 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
363 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
364 | * @return true if the input is a valid (partial) match of the pattern. | ||
365 | * | ||
366 | */ | ||
367 | public boolean hasMatch(final Segment pS1, final Segment pS2) { | ||
368 | return rawHasMatch(new Object[]{pS1, pS2}); | ||
369 | } | ||
370 | |||
371 | /** | ||
372 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
373 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
374 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
375 | * @return the number of pattern matches found. | ||
376 | * | ||
377 | */ | ||
378 | public int countMatches(final Segment pS1, final Segment pS2) { | ||
379 | return rawCountMatches(new Object[]{pS1, pS2}); | ||
380 | } | ||
381 | |||
382 | /** | ||
383 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
384 | * Neither determinism nor randomness of selection is guaranteed. | ||
385 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
386 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
387 | * @param processor the action that will process the selected match. | ||
388 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
389 | * | ||
390 | */ | ||
391 | public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer<? super Output.Match> processor) { | ||
392 | return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); | ||
393 | } | ||
394 | |||
395 | /** | ||
396 | * Returns a new (partial) match. | ||
397 | * This can be used e.g. to call the matcher with a partial match. | ||
398 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
399 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
400 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
401 | * @return the (partial) match object. | ||
402 | * | ||
403 | */ | ||
404 | public Output.Match newMatch(final Segment pS1, final Segment pS2) { | ||
405 | return Output.Match.newMatch(pS1, pS2); | ||
406 | } | ||
407 | |||
408 | /** | ||
409 | * Retrieve the set of values that occur in matches for S1. | ||
410 | * @return the Set of all values or empty set if there are no matches | ||
411 | * | ||
412 | */ | ||
413 | protected Stream<Segment> rawStreamAllValuesOfS1(final Object[] parameters) { | ||
414 | return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); | ||
415 | } | ||
416 | |||
417 | /** | ||
418 | * Retrieve the set of values that occur in matches for S1. | ||
419 | * @return the Set of all values or empty set if there are no matches | ||
420 | * | ||
421 | */ | ||
422 | public Set<Segment> getAllValuesOfS1() { | ||
423 | return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); | ||
424 | } | ||
425 | |||
426 | /** | ||
427 | * Retrieve the set of values that occur in matches for S1. | ||
428 | * @return the Set of all values or empty set if there are no matches | ||
429 | * | ||
430 | */ | ||
431 | public Stream<Segment> streamAllValuesOfS1() { | ||
432 | return rawStreamAllValuesOfS1(emptyArray()); | ||
433 | } | ||
434 | |||
435 | /** | ||
436 | * Retrieve the set of values that occur in matches for S1. | ||
437 | * </p> | ||
438 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
439 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
440 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
441 | * | ||
442 | * @return the Stream of all values or empty set if there are no matches | ||
443 | * | ||
444 | */ | ||
445 | public Stream<Segment> streamAllValuesOfS1(final Output.Match partialMatch) { | ||
446 | return rawStreamAllValuesOfS1(partialMatch.toArray()); | ||
447 | } | ||
448 | |||
449 | /** | ||
450 | * Retrieve the set of values that occur in matches for S1. | ||
451 | * </p> | ||
452 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
453 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
454 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
455 | * | ||
456 | * @return the Stream of all values or empty set if there are no matches | ||
457 | * | ||
458 | */ | ||
459 | public Stream<Segment> streamAllValuesOfS1(final Segment pS2) { | ||
460 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}); | ||
461 | } | ||
462 | |||
463 | /** | ||
464 | * Retrieve the set of values that occur in matches for S1. | ||
465 | * @return the Set of all values or empty set if there are no matches | ||
466 | * | ||
467 | */ | ||
468 | public Set<Segment> getAllValuesOfS1(final Output.Match partialMatch) { | ||
469 | return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); | ||
470 | } | ||
471 | |||
472 | /** | ||
473 | * Retrieve the set of values that occur in matches for S1. | ||
474 | * @return the Set of all values or empty set if there are no matches | ||
475 | * | ||
476 | */ | ||
477 | public Set<Segment> getAllValuesOfS1(final Segment pS2) { | ||
478 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); | ||
479 | } | ||
480 | |||
481 | /** | ||
482 | * Retrieve the set of values that occur in matches for S2. | ||
483 | * @return the Set of all values or empty set if there are no matches | ||
484 | * | ||
485 | */ | ||
486 | protected Stream<Segment> rawStreamAllValuesOfS2(final Object[] parameters) { | ||
487 | return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); | ||
488 | } | ||
489 | |||
490 | /** | ||
491 | * Retrieve the set of values that occur in matches for S2. | ||
492 | * @return the Set of all values or empty set if there are no matches | ||
493 | * | ||
494 | */ | ||
495 | public Set<Segment> getAllValuesOfS2() { | ||
496 | return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); | ||
497 | } | ||
498 | |||
499 | /** | ||
500 | * Retrieve the set of values that occur in matches for S2. | ||
501 | * @return the Set of all values or empty set if there are no matches | ||
502 | * | ||
503 | */ | ||
504 | public Stream<Segment> streamAllValuesOfS2() { | ||
505 | return rawStreamAllValuesOfS2(emptyArray()); | ||
506 | } | ||
507 | |||
508 | /** | ||
509 | * Retrieve the set of values that occur in matches for S2. | ||
510 | * </p> | ||
511 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
512 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
513 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
514 | * | ||
515 | * @return the Stream of all values or empty set if there are no matches | ||
516 | * | ||
517 | */ | ||
518 | public Stream<Segment> streamAllValuesOfS2(final Output.Match partialMatch) { | ||
519 | return rawStreamAllValuesOfS2(partialMatch.toArray()); | ||
520 | } | ||
521 | |||
522 | /** | ||
523 | * Retrieve the set of values that occur in matches for S2. | ||
524 | * </p> | ||
525 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
526 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
527 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
528 | * | ||
529 | * @return the Stream of all values or empty set if there are no matches | ||
530 | * | ||
531 | */ | ||
532 | public Stream<Segment> streamAllValuesOfS2(final Segment pS1) { | ||
533 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}); | ||
534 | } | ||
535 | |||
536 | /** | ||
537 | * Retrieve the set of values that occur in matches for S2. | ||
538 | * @return the Set of all values or empty set if there are no matches | ||
539 | * | ||
540 | */ | ||
541 | public Set<Segment> getAllValuesOfS2(final Output.Match partialMatch) { | ||
542 | return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); | ||
543 | } | ||
544 | |||
545 | /** | ||
546 | * Retrieve the set of values that occur in matches for S2. | ||
547 | * @return the Set of all values or empty set if there are no matches | ||
548 | * | ||
549 | */ | ||
550 | public Set<Segment> getAllValuesOfS2(final Segment pS1) { | ||
551 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); | ||
552 | } | ||
553 | |||
554 | @Override | ||
555 | protected Output.Match tupleToMatch(final Tuple t) { | ||
556 | try { | ||
557 | return Output.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); | ||
558 | } catch(ClassCastException e) { | ||
559 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
560 | return null; | ||
561 | } | ||
562 | } | ||
563 | |||
564 | @Override | ||
565 | protected Output.Match arrayToMatch(final Object[] match) { | ||
566 | try { | ||
567 | return Output.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
568 | } catch(ClassCastException e) { | ||
569 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
570 | return null; | ||
571 | } | ||
572 | } | ||
573 | |||
574 | @Override | ||
575 | protected Output.Match arrayToMatchMutable(final Object[] match) { | ||
576 | try { | ||
577 | return Output.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
578 | } catch(ClassCastException e) { | ||
579 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
580 | return null; | ||
581 | } | ||
582 | } | ||
583 | |||
584 | /** | ||
585 | * @return the singleton instance of the query specification of this pattern | ||
586 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
587 | * | ||
588 | */ | ||
589 | public static IQuerySpecification<Output.Matcher> querySpecification() { | ||
590 | return Output.instance(); | ||
591 | } | ||
592 | } | ||
593 | |||
594 | private Output() { | ||
595 | super(GeneratedPQuery.INSTANCE); | ||
596 | } | ||
597 | |||
598 | /** | ||
599 | * @return the singleton instance of the query specification | ||
600 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
601 | * | ||
602 | */ | ||
603 | public static Output instance() { | ||
604 | try{ | ||
605 | return LazyHolder.INSTANCE; | ||
606 | } catch (ExceptionInInitializerError err) { | ||
607 | throw processInitializerError(err); | ||
608 | } | ||
609 | } | ||
610 | |||
611 | @Override | ||
612 | protected Output.Matcher instantiate(final ViatraQueryEngine engine) { | ||
613 | return Output.Matcher.on(engine); | ||
614 | } | ||
615 | |||
616 | @Override | ||
617 | public Output.Matcher instantiate() { | ||
618 | return Output.Matcher.create(); | ||
619 | } | ||
620 | |||
621 | @Override | ||
622 | public Output.Match newEmptyMatch() { | ||
623 | return Output.Match.newEmptyMatch(); | ||
624 | } | ||
625 | |||
626 | @Override | ||
627 | public Output.Match newMatch(final Object... parameters) { | ||
628 | return Output.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); | ||
629 | } | ||
630 | |||
631 | /** | ||
632 | * Inner class allowing the singleton instance of {@link Output} to be created | ||
633 | * <b>not</b> at the class load time of the outer class, | ||
634 | * but rather at the first call to {@link Output#instance()}. | ||
635 | * | ||
636 | * <p> This workaround is required e.g. to support recursion. | ||
637 | * | ||
638 | */ | ||
639 | private static class LazyHolder { | ||
640 | private static final Output INSTANCE = new Output(); | ||
641 | |||
642 | /** | ||
643 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
644 | * This initialization order is required to support indirect recursion. | ||
645 | * | ||
646 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
647 | * | ||
648 | */ | ||
649 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
650 | |||
651 | public static Object ensureInitialized() { | ||
652 | INSTANCE.ensureInitializedInternal(); | ||
653 | return null; | ||
654 | } | ||
655 | } | ||
656 | |||
657 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
658 | private static final Output.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
659 | |||
660 | private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
661 | |||
662 | private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
663 | |||
664 | private final List<PParameter> parameters = Arrays.asList(parameter_S1, parameter_S2); | ||
665 | |||
666 | private GeneratedPQuery() { | ||
667 | super(PVisibility.PUBLIC); | ||
668 | } | ||
669 | |||
670 | @Override | ||
671 | public String getFullyQualifiedName() { | ||
672 | return "modes3.queries.output"; | ||
673 | } | ||
674 | |||
675 | @Override | ||
676 | public List<String> getParameterNames() { | ||
677 | return Arrays.asList("S1","S2"); | ||
678 | } | ||
679 | |||
680 | @Override | ||
681 | public List<PParameter> getParameters() { | ||
682 | return parameters; | ||
683 | } | ||
684 | |||
685 | @Override | ||
686 | public Set<PBody> doGetContainedBodies() { | ||
687 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
688 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
689 | { | ||
690 | PBody body = new PBody(this); | ||
691 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
692 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
693 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
694 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
695 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
696 | new ExportedParameter(body, var_S1, parameter_S1), | ||
697 | new ExportedParameter(body, var_S2, parameter_S2) | ||
698 | )); | ||
699 | // Segment.connectedTo(S1, S2) | ||
700 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
701 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
702 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
703 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
704 | new Equality(body, var__virtual_0_, var_S2); | ||
705 | bodies.add(body); | ||
706 | } | ||
707 | { | ||
708 | PBody body = new PBody(this); | ||
709 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
710 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
711 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
712 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
713 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
714 | new ExportedParameter(body, var_S1, parameter_S1), | ||
715 | new ExportedParameter(body, var_S2, parameter_S2) | ||
716 | )); | ||
717 | // find turnoutOutput(S1, S2) | ||
718 | new PositivePatternCall(body, Tuples.flatTupleOf(var_S1, var_S2), TurnoutOutput.instance().getInternalQueryRepresentation()); | ||
719 | bodies.add(body); | ||
720 | } | ||
721 | return bodies; | ||
722 | } | ||
723 | } | ||
724 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/OutputReflexive.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/OutputReflexive.java new file mode 100644 index 00000000..3d90ede5 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/OutputReflexive.java | |||
@@ -0,0 +1,559 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Turnout; | ||
17 | import modes3.queries.TurnoutOutput; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * {@literal @}Constraint(message = "outputReflexive", severity = "error", key = { T }) | ||
49 | * pattern outputReflexive(T : Turnout) { | ||
50 | * find turnoutOutput(T, T); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class OutputReflexive extends BaseGeneratedEMFQuerySpecification<OutputReflexive.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.outputReflexive pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Turnout fT; | ||
74 | |||
75 | private static List<String> parameterNames = makeImmutableList("T"); | ||
76 | |||
77 | private Match(final Turnout pT) { | ||
78 | this.fT = pT; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "T": return this.fT; | ||
85 | default: return null; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final int index) { | ||
91 | switch(index) { | ||
92 | case 0: return this.fT; | ||
93 | default: return null; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | public Turnout getT() { | ||
98 | return this.fT; | ||
99 | } | ||
100 | |||
101 | @Override | ||
102 | public boolean set(final String parameterName, final Object newValue) { | ||
103 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
104 | if ("T".equals(parameterName) ) { | ||
105 | this.fT = (Turnout) newValue; | ||
106 | return true; | ||
107 | } | ||
108 | return false; | ||
109 | } | ||
110 | |||
111 | public void setT(final Turnout pT) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | this.fT = pT; | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public String patternName() { | ||
118 | return "modes3.queries.outputReflexive"; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public List<String> parameterNames() { | ||
123 | return OutputReflexive.Match.parameterNames; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public Object[] toArray() { | ||
128 | return new Object[]{fT}; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public OutputReflexive.Match toImmutable() { | ||
133 | return isMutable() ? newMatch(fT) : this; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public String prettyPrint() { | ||
138 | StringBuilder result = new StringBuilder(); | ||
139 | result.append("\"T\"=" + prettyPrintValue(fT)); | ||
140 | return result.toString(); | ||
141 | } | ||
142 | |||
143 | @Override | ||
144 | public int hashCode() { | ||
145 | return Objects.hash(fT); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public boolean equals(final Object obj) { | ||
150 | if (this == obj) | ||
151 | return true; | ||
152 | if (obj == null) { | ||
153 | return false; | ||
154 | } | ||
155 | if ((obj instanceof OutputReflexive.Match)) { | ||
156 | OutputReflexive.Match other = (OutputReflexive.Match) obj; | ||
157 | return Objects.equals(fT, other.fT); | ||
158 | } else { | ||
159 | // this should be infrequent | ||
160 | if (!(obj instanceof IPatternMatch)) { | ||
161 | return false; | ||
162 | } | ||
163 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
164 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public OutputReflexive specification() { | ||
170 | return OutputReflexive.instance(); | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * Returns an empty, mutable match. | ||
175 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
176 | * | ||
177 | * @return the empty match. | ||
178 | * | ||
179 | */ | ||
180 | public static OutputReflexive.Match newEmptyMatch() { | ||
181 | return new Mutable(null); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Returns a mutable (partial) match. | ||
186 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
187 | * | ||
188 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
189 | * @return the new, mutable (partial) match object. | ||
190 | * | ||
191 | */ | ||
192 | public static OutputReflexive.Match newMutableMatch(final Turnout pT) { | ||
193 | return new Mutable(pT); | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * Returns a new (partial) match. | ||
198 | * This can be used e.g. to call the matcher with a partial match. | ||
199 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
200 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
201 | * @return the (partial) match object. | ||
202 | * | ||
203 | */ | ||
204 | public static OutputReflexive.Match newMatch(final Turnout pT) { | ||
205 | return new Immutable(pT); | ||
206 | } | ||
207 | |||
208 | private static final class Mutable extends OutputReflexive.Match { | ||
209 | Mutable(final Turnout pT) { | ||
210 | super(pT); | ||
211 | } | ||
212 | |||
213 | @Override | ||
214 | public boolean isMutable() { | ||
215 | return true; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | private static final class Immutable extends OutputReflexive.Match { | ||
220 | Immutable(final Turnout pT) { | ||
221 | super(pT); | ||
222 | } | ||
223 | |||
224 | @Override | ||
225 | public boolean isMutable() { | ||
226 | return false; | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * Generated pattern matcher API of the modes3.queries.outputReflexive pattern, | ||
233 | * providing pattern-specific query methods. | ||
234 | * | ||
235 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
236 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
237 | * | ||
238 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
239 | * | ||
240 | * <p>Original source: | ||
241 | * <code><pre> | ||
242 | * {@literal @}Constraint(message = "outputReflexive", severity = "error", key = { T }) | ||
243 | * pattern outputReflexive(T : Turnout) { | ||
244 | * find turnoutOutput(T, T); | ||
245 | * } | ||
246 | * </pre></code> | ||
247 | * | ||
248 | * @see Match | ||
249 | * @see OutputReflexive | ||
250 | * | ||
251 | */ | ||
252 | public static class Matcher extends BaseMatcher<OutputReflexive.Match> { | ||
253 | /** | ||
254 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
255 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
256 | * | ||
257 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
258 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
259 | * | ||
260 | */ | ||
261 | public static OutputReflexive.Matcher on(final ViatraQueryEngine engine) { | ||
262 | // check if matcher already exists | ||
263 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
264 | if (matcher == null) { | ||
265 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
266 | } | ||
267 | return matcher; | ||
268 | } | ||
269 | |||
270 | /** | ||
271 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
272 | * @return an initialized matcher | ||
273 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
274 | * | ||
275 | */ | ||
276 | public static OutputReflexive.Matcher create() { | ||
277 | return new Matcher(); | ||
278 | } | ||
279 | |||
280 | private static final int POSITION_T = 0; | ||
281 | |||
282 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(OutputReflexive.Matcher.class); | ||
283 | |||
284 | /** | ||
285 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
286 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
287 | * | ||
288 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
289 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
290 | * | ||
291 | */ | ||
292 | private Matcher() { | ||
293 | super(querySpecification()); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
298 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
299 | * @return matches represented as a Match object. | ||
300 | * | ||
301 | */ | ||
302 | public Collection<OutputReflexive.Match> getAllMatches(final Turnout pT) { | ||
303 | return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); | ||
304 | } | ||
305 | |||
306 | /** | ||
307 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
308 | * </p> | ||
309 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
310 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
311 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
312 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
313 | * @return a stream of matches represented as a Match object. | ||
314 | * | ||
315 | */ | ||
316 | public Stream<OutputReflexive.Match> streamAllMatches(final Turnout pT) { | ||
317 | return rawStreamAllMatches(new Object[]{pT}); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
322 | * Neither determinism nor randomness of selection is guaranteed. | ||
323 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
324 | * @return a match represented as a Match object, or null if no match is found. | ||
325 | * | ||
326 | */ | ||
327 | public Optional<OutputReflexive.Match> getOneArbitraryMatch(final Turnout pT) { | ||
328 | return rawGetOneArbitraryMatch(new Object[]{pT}); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
333 | * under any possible substitution of the unspecified parameters (if any). | ||
334 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
335 | * @return true if the input is a valid (partial) match of the pattern. | ||
336 | * | ||
337 | */ | ||
338 | public boolean hasMatch(final Turnout pT) { | ||
339 | return rawHasMatch(new Object[]{pT}); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
344 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
345 | * @return the number of pattern matches found. | ||
346 | * | ||
347 | */ | ||
348 | public int countMatches(final Turnout pT) { | ||
349 | return rawCountMatches(new Object[]{pT}); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
354 | * Neither determinism nor randomness of selection is guaranteed. | ||
355 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
356 | * @param processor the action that will process the selected match. | ||
357 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
358 | * | ||
359 | */ | ||
360 | public boolean forOneArbitraryMatch(final Turnout pT, final Consumer<? super OutputReflexive.Match> processor) { | ||
361 | return rawForOneArbitraryMatch(new Object[]{pT}, processor); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Returns a new (partial) match. | ||
366 | * This can be used e.g. to call the matcher with a partial match. | ||
367 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
368 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
369 | * @return the (partial) match object. | ||
370 | * | ||
371 | */ | ||
372 | public OutputReflexive.Match newMatch(final Turnout pT) { | ||
373 | return OutputReflexive.Match.newMatch(pT); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Retrieve the set of values that occur in matches for T. | ||
378 | * @return the Set of all values or empty set if there are no matches | ||
379 | * | ||
380 | */ | ||
381 | protected Stream<Turnout> rawStreamAllValuesOfT(final Object[] parameters) { | ||
382 | return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * Retrieve the set of values that occur in matches for T. | ||
387 | * @return the Set of all values or empty set if there are no matches | ||
388 | * | ||
389 | */ | ||
390 | public Set<Turnout> getAllValuesOfT() { | ||
391 | return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Retrieve the set of values that occur in matches for T. | ||
396 | * @return the Set of all values or empty set if there are no matches | ||
397 | * | ||
398 | */ | ||
399 | public Stream<Turnout> streamAllValuesOfT() { | ||
400 | return rawStreamAllValuesOfT(emptyArray()); | ||
401 | } | ||
402 | |||
403 | @Override | ||
404 | protected OutputReflexive.Match tupleToMatch(final Tuple t) { | ||
405 | try { | ||
406 | return OutputReflexive.Match.newMatch((Turnout) t.get(POSITION_T)); | ||
407 | } catch(ClassCastException e) { | ||
408 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
409 | return null; | ||
410 | } | ||
411 | } | ||
412 | |||
413 | @Override | ||
414 | protected OutputReflexive.Match arrayToMatch(final Object[] match) { | ||
415 | try { | ||
416 | return OutputReflexive.Match.newMatch((Turnout) match[POSITION_T]); | ||
417 | } catch(ClassCastException e) { | ||
418 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
419 | return null; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | @Override | ||
424 | protected OutputReflexive.Match arrayToMatchMutable(final Object[] match) { | ||
425 | try { | ||
426 | return OutputReflexive.Match.newMutableMatch((Turnout) match[POSITION_T]); | ||
427 | } catch(ClassCastException e) { | ||
428 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
429 | return null; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * @return the singleton instance of the query specification of this pattern | ||
435 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
436 | * | ||
437 | */ | ||
438 | public static IQuerySpecification<OutputReflexive.Matcher> querySpecification() { | ||
439 | return OutputReflexive.instance(); | ||
440 | } | ||
441 | } | ||
442 | |||
443 | private OutputReflexive() { | ||
444 | super(GeneratedPQuery.INSTANCE); | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @return the singleton instance of the query specification | ||
449 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
450 | * | ||
451 | */ | ||
452 | public static OutputReflexive instance() { | ||
453 | try{ | ||
454 | return LazyHolder.INSTANCE; | ||
455 | } catch (ExceptionInInitializerError err) { | ||
456 | throw processInitializerError(err); | ||
457 | } | ||
458 | } | ||
459 | |||
460 | @Override | ||
461 | protected OutputReflexive.Matcher instantiate(final ViatraQueryEngine engine) { | ||
462 | return OutputReflexive.Matcher.on(engine); | ||
463 | } | ||
464 | |||
465 | @Override | ||
466 | public OutputReflexive.Matcher instantiate() { | ||
467 | return OutputReflexive.Matcher.create(); | ||
468 | } | ||
469 | |||
470 | @Override | ||
471 | public OutputReflexive.Match newEmptyMatch() { | ||
472 | return OutputReflexive.Match.newEmptyMatch(); | ||
473 | } | ||
474 | |||
475 | @Override | ||
476 | public OutputReflexive.Match newMatch(final Object... parameters) { | ||
477 | return OutputReflexive.Match.newMatch((modes3.Turnout) parameters[0]); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Inner class allowing the singleton instance of {@link OutputReflexive} to be created | ||
482 | * <b>not</b> at the class load time of the outer class, | ||
483 | * but rather at the first call to {@link OutputReflexive#instance()}. | ||
484 | * | ||
485 | * <p> This workaround is required e.g. to support recursion. | ||
486 | * | ||
487 | */ | ||
488 | private static class LazyHolder { | ||
489 | private static final OutputReflexive INSTANCE = new OutputReflexive(); | ||
490 | |||
491 | /** | ||
492 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
493 | * This initialization order is required to support indirect recursion. | ||
494 | * | ||
495 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
496 | * | ||
497 | */ | ||
498 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
499 | |||
500 | public static Object ensureInitialized() { | ||
501 | INSTANCE.ensureInitializedInternal(); | ||
502 | return null; | ||
503 | } | ||
504 | } | ||
505 | |||
506 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
507 | private static final OutputReflexive.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
508 | |||
509 | private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); | ||
510 | |||
511 | private final List<PParameter> parameters = Arrays.asList(parameter_T); | ||
512 | |||
513 | private GeneratedPQuery() { | ||
514 | super(PVisibility.PUBLIC); | ||
515 | } | ||
516 | |||
517 | @Override | ||
518 | public String getFullyQualifiedName() { | ||
519 | return "modes3.queries.outputReflexive"; | ||
520 | } | ||
521 | |||
522 | @Override | ||
523 | public List<String> getParameterNames() { | ||
524 | return Arrays.asList("T"); | ||
525 | } | ||
526 | |||
527 | @Override | ||
528 | public List<PParameter> getParameters() { | ||
529 | return parameters; | ||
530 | } | ||
531 | |||
532 | @Override | ||
533 | public Set<PBody> doGetContainedBodies() { | ||
534 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
535 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
536 | { | ||
537 | PBody body = new PBody(this); | ||
538 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
539 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
540 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
541 | new ExportedParameter(body, var_T, parameter_T) | ||
542 | )); | ||
543 | // find turnoutOutput(T, T) | ||
544 | new PositivePatternCall(body, Tuples.flatTupleOf(var_T, var_T), TurnoutOutput.instance().getInternalQueryRepresentation()); | ||
545 | bodies.add(body); | ||
546 | } | ||
547 | { | ||
548 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
549 | annotation.addAttribute("message", "outputReflexive"); | ||
550 | annotation.addAttribute("severity", "error"); | ||
551 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
552 | new ParameterReference("T") | ||
553 | })); | ||
554 | addAnnotation(annotation); | ||
555 | } | ||
556 | return bodies; | ||
557 | } | ||
558 | } | ||
559 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Reachable.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Reachable.java new file mode 100644 index 00000000..93d43c21 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Reachable.java | |||
@@ -0,0 +1,719 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.queries.Adjacent; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern reachable(S1 : Segment, S2 : Segment) { | ||
48 | * S1 == S2; | ||
49 | * } or { | ||
50 | * find adjacent+(S1, S2); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class Reachable extends BaseGeneratedEMFQuerySpecification<Reachable.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.reachable pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Segment fS1; | ||
74 | |||
75 | private Segment fS2; | ||
76 | |||
77 | private static List<String> parameterNames = makeImmutableList("S1", "S2"); | ||
78 | |||
79 | private Match(final Segment pS1, final Segment pS2) { | ||
80 | this.fS1 = pS1; | ||
81 | this.fS2 = pS2; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | switch(parameterName) { | ||
87 | case "S1": return this.fS1; | ||
88 | case "S2": return this.fS2; | ||
89 | default: return null; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | @Override | ||
94 | public Object get(final int index) { | ||
95 | switch(index) { | ||
96 | case 0: return this.fS1; | ||
97 | case 1: return this.fS2; | ||
98 | default: return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public Segment getS1() { | ||
103 | return this.fS1; | ||
104 | } | ||
105 | |||
106 | public Segment getS2() { | ||
107 | return this.fS2; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public boolean set(final String parameterName, final Object newValue) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | if ("S1".equals(parameterName) ) { | ||
114 | this.fS1 = (Segment) newValue; | ||
115 | return true; | ||
116 | } | ||
117 | if ("S2".equals(parameterName) ) { | ||
118 | this.fS2 = (Segment) newValue; | ||
119 | return true; | ||
120 | } | ||
121 | return false; | ||
122 | } | ||
123 | |||
124 | public void setS1(final Segment pS1) { | ||
125 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
126 | this.fS1 = pS1; | ||
127 | } | ||
128 | |||
129 | public void setS2(final Segment pS2) { | ||
130 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
131 | this.fS2 = pS2; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public String patternName() { | ||
136 | return "modes3.queries.reachable"; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public List<String> parameterNames() { | ||
141 | return Reachable.Match.parameterNames; | ||
142 | } | ||
143 | |||
144 | @Override | ||
145 | public Object[] toArray() { | ||
146 | return new Object[]{fS1, fS2}; | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public Reachable.Match toImmutable() { | ||
151 | return isMutable() ? newMatch(fS1, fS2) : this; | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public String prettyPrint() { | ||
156 | StringBuilder result = new StringBuilder(); | ||
157 | result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); | ||
158 | result.append("\"S2\"=" + prettyPrintValue(fS2)); | ||
159 | return result.toString(); | ||
160 | } | ||
161 | |||
162 | @Override | ||
163 | public int hashCode() { | ||
164 | return Objects.hash(fS1, fS2); | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public boolean equals(final Object obj) { | ||
169 | if (this == obj) | ||
170 | return true; | ||
171 | if (obj == null) { | ||
172 | return false; | ||
173 | } | ||
174 | if ((obj instanceof Reachable.Match)) { | ||
175 | Reachable.Match other = (Reachable.Match) obj; | ||
176 | return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); | ||
177 | } else { | ||
178 | // this should be infrequent | ||
179 | if (!(obj instanceof IPatternMatch)) { | ||
180 | return false; | ||
181 | } | ||
182 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
183 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | @Override | ||
188 | public Reachable specification() { | ||
189 | return Reachable.instance(); | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * Returns an empty, mutable match. | ||
194 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
195 | * | ||
196 | * @return the empty match. | ||
197 | * | ||
198 | */ | ||
199 | public static Reachable.Match newEmptyMatch() { | ||
200 | return new Mutable(null, null); | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * Returns a mutable (partial) match. | ||
205 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
206 | * | ||
207 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
208 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
209 | * @return the new, mutable (partial) match object. | ||
210 | * | ||
211 | */ | ||
212 | public static Reachable.Match newMutableMatch(final Segment pS1, final Segment pS2) { | ||
213 | return new Mutable(pS1, pS2); | ||
214 | } | ||
215 | |||
216 | /** | ||
217 | * Returns a new (partial) match. | ||
218 | * This can be used e.g. to call the matcher with a partial match. | ||
219 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
220 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
221 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
222 | * @return the (partial) match object. | ||
223 | * | ||
224 | */ | ||
225 | public static Reachable.Match newMatch(final Segment pS1, final Segment pS2) { | ||
226 | return new Immutable(pS1, pS2); | ||
227 | } | ||
228 | |||
229 | private static final class Mutable extends Reachable.Match { | ||
230 | Mutable(final Segment pS1, final Segment pS2) { | ||
231 | super(pS1, pS2); | ||
232 | } | ||
233 | |||
234 | @Override | ||
235 | public boolean isMutable() { | ||
236 | return true; | ||
237 | } | ||
238 | } | ||
239 | |||
240 | private static final class Immutable extends Reachable.Match { | ||
241 | Immutable(final Segment pS1, final Segment pS2) { | ||
242 | super(pS1, pS2); | ||
243 | } | ||
244 | |||
245 | @Override | ||
246 | public boolean isMutable() { | ||
247 | return false; | ||
248 | } | ||
249 | } | ||
250 | } | ||
251 | |||
252 | /** | ||
253 | * Generated pattern matcher API of the modes3.queries.reachable pattern, | ||
254 | * providing pattern-specific query methods. | ||
255 | * | ||
256 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
257 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
258 | * | ||
259 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
260 | * | ||
261 | * <p>Original source: | ||
262 | * <code><pre> | ||
263 | * pattern reachable(S1 : Segment, S2 : Segment) { | ||
264 | * S1 == S2; | ||
265 | * } or { | ||
266 | * find adjacent+(S1, S2); | ||
267 | * } | ||
268 | * </pre></code> | ||
269 | * | ||
270 | * @see Match | ||
271 | * @see Reachable | ||
272 | * | ||
273 | */ | ||
274 | public static class Matcher extends BaseMatcher<Reachable.Match> { | ||
275 | /** | ||
276 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
277 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
278 | * | ||
279 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
280 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
281 | * | ||
282 | */ | ||
283 | public static Reachable.Matcher on(final ViatraQueryEngine engine) { | ||
284 | // check if matcher already exists | ||
285 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
286 | if (matcher == null) { | ||
287 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
288 | } | ||
289 | return matcher; | ||
290 | } | ||
291 | |||
292 | /** | ||
293 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
294 | * @return an initialized matcher | ||
295 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
296 | * | ||
297 | */ | ||
298 | public static Reachable.Matcher create() { | ||
299 | return new Matcher(); | ||
300 | } | ||
301 | |||
302 | private static final int POSITION_S1 = 0; | ||
303 | |||
304 | private static final int POSITION_S2 = 1; | ||
305 | |||
306 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Reachable.Matcher.class); | ||
307 | |||
308 | /** | ||
309 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
310 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
311 | * | ||
312 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
313 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
314 | * | ||
315 | */ | ||
316 | private Matcher() { | ||
317 | super(querySpecification()); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
322 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
323 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
324 | * @return matches represented as a Match object. | ||
325 | * | ||
326 | */ | ||
327 | public Collection<Reachable.Match> getAllMatches(final Segment pS1, final Segment pS2) { | ||
328 | return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
333 | * </p> | ||
334 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
335 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
336 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
337 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
338 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
339 | * @return a stream of matches represented as a Match object. | ||
340 | * | ||
341 | */ | ||
342 | public Stream<Reachable.Match> streamAllMatches(final Segment pS1, final Segment pS2) { | ||
343 | return rawStreamAllMatches(new Object[]{pS1, pS2}); | ||
344 | } | ||
345 | |||
346 | /** | ||
347 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
348 | * Neither determinism nor randomness of selection is guaranteed. | ||
349 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
350 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
351 | * @return a match represented as a Match object, or null if no match is found. | ||
352 | * | ||
353 | */ | ||
354 | public Optional<Reachable.Match> getOneArbitraryMatch(final Segment pS1, final Segment pS2) { | ||
355 | return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
360 | * under any possible substitution of the unspecified parameters (if any). | ||
361 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
362 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
363 | * @return true if the input is a valid (partial) match of the pattern. | ||
364 | * | ||
365 | */ | ||
366 | public boolean hasMatch(final Segment pS1, final Segment pS2) { | ||
367 | return rawHasMatch(new Object[]{pS1, pS2}); | ||
368 | } | ||
369 | |||
370 | /** | ||
371 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
372 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
373 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
374 | * @return the number of pattern matches found. | ||
375 | * | ||
376 | */ | ||
377 | public int countMatches(final Segment pS1, final Segment pS2) { | ||
378 | return rawCountMatches(new Object[]{pS1, pS2}); | ||
379 | } | ||
380 | |||
381 | /** | ||
382 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
383 | * Neither determinism nor randomness of selection is guaranteed. | ||
384 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
385 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
386 | * @param processor the action that will process the selected match. | ||
387 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
388 | * | ||
389 | */ | ||
390 | public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer<? super Reachable.Match> processor) { | ||
391 | return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Returns a new (partial) match. | ||
396 | * This can be used e.g. to call the matcher with a partial match. | ||
397 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
398 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
399 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
400 | * @return the (partial) match object. | ||
401 | * | ||
402 | */ | ||
403 | public Reachable.Match newMatch(final Segment pS1, final Segment pS2) { | ||
404 | return Reachable.Match.newMatch(pS1, pS2); | ||
405 | } | ||
406 | |||
407 | /** | ||
408 | * Retrieve the set of values that occur in matches for S1. | ||
409 | * @return the Set of all values or empty set if there are no matches | ||
410 | * | ||
411 | */ | ||
412 | protected Stream<Segment> rawStreamAllValuesOfS1(final Object[] parameters) { | ||
413 | return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); | ||
414 | } | ||
415 | |||
416 | /** | ||
417 | * Retrieve the set of values that occur in matches for S1. | ||
418 | * @return the Set of all values or empty set if there are no matches | ||
419 | * | ||
420 | */ | ||
421 | public Set<Segment> getAllValuesOfS1() { | ||
422 | return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); | ||
423 | } | ||
424 | |||
425 | /** | ||
426 | * Retrieve the set of values that occur in matches for S1. | ||
427 | * @return the Set of all values or empty set if there are no matches | ||
428 | * | ||
429 | */ | ||
430 | public Stream<Segment> streamAllValuesOfS1() { | ||
431 | return rawStreamAllValuesOfS1(emptyArray()); | ||
432 | } | ||
433 | |||
434 | /** | ||
435 | * Retrieve the set of values that occur in matches for S1. | ||
436 | * </p> | ||
437 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
438 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
439 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
440 | * | ||
441 | * @return the Stream of all values or empty set if there are no matches | ||
442 | * | ||
443 | */ | ||
444 | public Stream<Segment> streamAllValuesOfS1(final Reachable.Match partialMatch) { | ||
445 | return rawStreamAllValuesOfS1(partialMatch.toArray()); | ||
446 | } | ||
447 | |||
448 | /** | ||
449 | * Retrieve the set of values that occur in matches for S1. | ||
450 | * </p> | ||
451 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
452 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
453 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
454 | * | ||
455 | * @return the Stream of all values or empty set if there are no matches | ||
456 | * | ||
457 | */ | ||
458 | public Stream<Segment> streamAllValuesOfS1(final Segment pS2) { | ||
459 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}); | ||
460 | } | ||
461 | |||
462 | /** | ||
463 | * Retrieve the set of values that occur in matches for S1. | ||
464 | * @return the Set of all values or empty set if there are no matches | ||
465 | * | ||
466 | */ | ||
467 | public Set<Segment> getAllValuesOfS1(final Reachable.Match partialMatch) { | ||
468 | return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); | ||
469 | } | ||
470 | |||
471 | /** | ||
472 | * Retrieve the set of values that occur in matches for S1. | ||
473 | * @return the Set of all values or empty set if there are no matches | ||
474 | * | ||
475 | */ | ||
476 | public Set<Segment> getAllValuesOfS1(final Segment pS2) { | ||
477 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Retrieve the set of values that occur in matches for S2. | ||
482 | * @return the Set of all values or empty set if there are no matches | ||
483 | * | ||
484 | */ | ||
485 | protected Stream<Segment> rawStreamAllValuesOfS2(final Object[] parameters) { | ||
486 | return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); | ||
487 | } | ||
488 | |||
489 | /** | ||
490 | * Retrieve the set of values that occur in matches for S2. | ||
491 | * @return the Set of all values or empty set if there are no matches | ||
492 | * | ||
493 | */ | ||
494 | public Set<Segment> getAllValuesOfS2() { | ||
495 | return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); | ||
496 | } | ||
497 | |||
498 | /** | ||
499 | * Retrieve the set of values that occur in matches for S2. | ||
500 | * @return the Set of all values or empty set if there are no matches | ||
501 | * | ||
502 | */ | ||
503 | public Stream<Segment> streamAllValuesOfS2() { | ||
504 | return rawStreamAllValuesOfS2(emptyArray()); | ||
505 | } | ||
506 | |||
507 | /** | ||
508 | * Retrieve the set of values that occur in matches for S2. | ||
509 | * </p> | ||
510 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
511 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
512 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
513 | * | ||
514 | * @return the Stream of all values or empty set if there are no matches | ||
515 | * | ||
516 | */ | ||
517 | public Stream<Segment> streamAllValuesOfS2(final Reachable.Match partialMatch) { | ||
518 | return rawStreamAllValuesOfS2(partialMatch.toArray()); | ||
519 | } | ||
520 | |||
521 | /** | ||
522 | * Retrieve the set of values that occur in matches for S2. | ||
523 | * </p> | ||
524 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
525 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
526 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
527 | * | ||
528 | * @return the Stream of all values or empty set if there are no matches | ||
529 | * | ||
530 | */ | ||
531 | public Stream<Segment> streamAllValuesOfS2(final Segment pS1) { | ||
532 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}); | ||
533 | } | ||
534 | |||
535 | /** | ||
536 | * Retrieve the set of values that occur in matches for S2. | ||
537 | * @return the Set of all values or empty set if there are no matches | ||
538 | * | ||
539 | */ | ||
540 | public Set<Segment> getAllValuesOfS2(final Reachable.Match partialMatch) { | ||
541 | return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); | ||
542 | } | ||
543 | |||
544 | /** | ||
545 | * Retrieve the set of values that occur in matches for S2. | ||
546 | * @return the Set of all values or empty set if there are no matches | ||
547 | * | ||
548 | */ | ||
549 | public Set<Segment> getAllValuesOfS2(final Segment pS1) { | ||
550 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); | ||
551 | } | ||
552 | |||
553 | @Override | ||
554 | protected Reachable.Match tupleToMatch(final Tuple t) { | ||
555 | try { | ||
556 | return Reachable.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); | ||
557 | } catch(ClassCastException e) { | ||
558 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
559 | return null; | ||
560 | } | ||
561 | } | ||
562 | |||
563 | @Override | ||
564 | protected Reachable.Match arrayToMatch(final Object[] match) { | ||
565 | try { | ||
566 | return Reachable.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
567 | } catch(ClassCastException e) { | ||
568 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
569 | return null; | ||
570 | } | ||
571 | } | ||
572 | |||
573 | @Override | ||
574 | protected Reachable.Match arrayToMatchMutable(final Object[] match) { | ||
575 | try { | ||
576 | return Reachable.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
577 | } catch(ClassCastException e) { | ||
578 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
579 | return null; | ||
580 | } | ||
581 | } | ||
582 | |||
583 | /** | ||
584 | * @return the singleton instance of the query specification of this pattern | ||
585 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
586 | * | ||
587 | */ | ||
588 | public static IQuerySpecification<Reachable.Matcher> querySpecification() { | ||
589 | return Reachable.instance(); | ||
590 | } | ||
591 | } | ||
592 | |||
593 | private Reachable() { | ||
594 | super(GeneratedPQuery.INSTANCE); | ||
595 | } | ||
596 | |||
597 | /** | ||
598 | * @return the singleton instance of the query specification | ||
599 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
600 | * | ||
601 | */ | ||
602 | public static Reachable instance() { | ||
603 | try{ | ||
604 | return LazyHolder.INSTANCE; | ||
605 | } catch (ExceptionInInitializerError err) { | ||
606 | throw processInitializerError(err); | ||
607 | } | ||
608 | } | ||
609 | |||
610 | @Override | ||
611 | protected Reachable.Matcher instantiate(final ViatraQueryEngine engine) { | ||
612 | return Reachable.Matcher.on(engine); | ||
613 | } | ||
614 | |||
615 | @Override | ||
616 | public Reachable.Matcher instantiate() { | ||
617 | return Reachable.Matcher.create(); | ||
618 | } | ||
619 | |||
620 | @Override | ||
621 | public Reachable.Match newEmptyMatch() { | ||
622 | return Reachable.Match.newEmptyMatch(); | ||
623 | } | ||
624 | |||
625 | @Override | ||
626 | public Reachable.Match newMatch(final Object... parameters) { | ||
627 | return Reachable.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); | ||
628 | } | ||
629 | |||
630 | /** | ||
631 | * Inner class allowing the singleton instance of {@link Reachable} to be created | ||
632 | * <b>not</b> at the class load time of the outer class, | ||
633 | * but rather at the first call to {@link Reachable#instance()}. | ||
634 | * | ||
635 | * <p> This workaround is required e.g. to support recursion. | ||
636 | * | ||
637 | */ | ||
638 | private static class LazyHolder { | ||
639 | private static final Reachable INSTANCE = new Reachable(); | ||
640 | |||
641 | /** | ||
642 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
643 | * This initialization order is required to support indirect recursion. | ||
644 | * | ||
645 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
646 | * | ||
647 | */ | ||
648 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
649 | |||
650 | public static Object ensureInitialized() { | ||
651 | INSTANCE.ensureInitializedInternal(); | ||
652 | return null; | ||
653 | } | ||
654 | } | ||
655 | |||
656 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
657 | private static final Reachable.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
658 | |||
659 | private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
660 | |||
661 | private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
662 | |||
663 | private final List<PParameter> parameters = Arrays.asList(parameter_S1, parameter_S2); | ||
664 | |||
665 | private GeneratedPQuery() { | ||
666 | super(PVisibility.PUBLIC); | ||
667 | } | ||
668 | |||
669 | @Override | ||
670 | public String getFullyQualifiedName() { | ||
671 | return "modes3.queries.reachable"; | ||
672 | } | ||
673 | |||
674 | @Override | ||
675 | public List<String> getParameterNames() { | ||
676 | return Arrays.asList("S1","S2"); | ||
677 | } | ||
678 | |||
679 | @Override | ||
680 | public List<PParameter> getParameters() { | ||
681 | return parameters; | ||
682 | } | ||
683 | |||
684 | @Override | ||
685 | public Set<PBody> doGetContainedBodies() { | ||
686 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
687 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
688 | { | ||
689 | PBody body = new PBody(this); | ||
690 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
691 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
692 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
693 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
694 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
695 | new ExportedParameter(body, var_S1, parameter_S1), | ||
696 | new ExportedParameter(body, var_S2, parameter_S2) | ||
697 | )); | ||
698 | // S1 == S2 | ||
699 | new Equality(body, var_S1, var_S2); | ||
700 | bodies.add(body); | ||
701 | } | ||
702 | { | ||
703 | PBody body = new PBody(this); | ||
704 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
705 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
706 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
707 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
708 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
709 | new ExportedParameter(body, var_S1, parameter_S1), | ||
710 | new ExportedParameter(body, var_S2, parameter_S2) | ||
711 | )); | ||
712 | // find adjacent+(S1, S2) | ||
713 | new BinaryTransitiveClosure(body, Tuples.flatTupleOf(var_S1, var_S2), Adjacent.instance().getInternalQueryRepresentation()); | ||
714 | bodies.add(body); | ||
715 | } | ||
716 | return bodies; | ||
717 | } | ||
718 | } | ||
719 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooFewInputsOfTurnout.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooFewInputsOfTurnout.java new file mode 100644 index 00000000..088640ca --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooFewInputsOfTurnout.java | |||
@@ -0,0 +1,559 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Turnout; | ||
17 | import modes3.queries.InputsOfTurnout; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * {@literal @}Constraint(message = "tooFewInputsOfTurnout", severity = "error", key = { T }) | ||
49 | * pattern tooFewInputsOfTurnout(T : Turnout) { | ||
50 | * neg find inputsOfTurnout(T); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class TooFewInputsOfTurnout extends BaseGeneratedEMFQuerySpecification<TooFewInputsOfTurnout.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.tooFewInputsOfTurnout pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Turnout fT; | ||
74 | |||
75 | private static List<String> parameterNames = makeImmutableList("T"); | ||
76 | |||
77 | private Match(final Turnout pT) { | ||
78 | this.fT = pT; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "T": return this.fT; | ||
85 | default: return null; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final int index) { | ||
91 | switch(index) { | ||
92 | case 0: return this.fT; | ||
93 | default: return null; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | public Turnout getT() { | ||
98 | return this.fT; | ||
99 | } | ||
100 | |||
101 | @Override | ||
102 | public boolean set(final String parameterName, final Object newValue) { | ||
103 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
104 | if ("T".equals(parameterName) ) { | ||
105 | this.fT = (Turnout) newValue; | ||
106 | return true; | ||
107 | } | ||
108 | return false; | ||
109 | } | ||
110 | |||
111 | public void setT(final Turnout pT) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | this.fT = pT; | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public String patternName() { | ||
118 | return "modes3.queries.tooFewInputsOfTurnout"; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public List<String> parameterNames() { | ||
123 | return TooFewInputsOfTurnout.Match.parameterNames; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public Object[] toArray() { | ||
128 | return new Object[]{fT}; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public TooFewInputsOfTurnout.Match toImmutable() { | ||
133 | return isMutable() ? newMatch(fT) : this; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public String prettyPrint() { | ||
138 | StringBuilder result = new StringBuilder(); | ||
139 | result.append("\"T\"=" + prettyPrintValue(fT)); | ||
140 | return result.toString(); | ||
141 | } | ||
142 | |||
143 | @Override | ||
144 | public int hashCode() { | ||
145 | return Objects.hash(fT); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public boolean equals(final Object obj) { | ||
150 | if (this == obj) | ||
151 | return true; | ||
152 | if (obj == null) { | ||
153 | return false; | ||
154 | } | ||
155 | if ((obj instanceof TooFewInputsOfTurnout.Match)) { | ||
156 | TooFewInputsOfTurnout.Match other = (TooFewInputsOfTurnout.Match) obj; | ||
157 | return Objects.equals(fT, other.fT); | ||
158 | } else { | ||
159 | // this should be infrequent | ||
160 | if (!(obj instanceof IPatternMatch)) { | ||
161 | return false; | ||
162 | } | ||
163 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
164 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public TooFewInputsOfTurnout specification() { | ||
170 | return TooFewInputsOfTurnout.instance(); | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * Returns an empty, mutable match. | ||
175 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
176 | * | ||
177 | * @return the empty match. | ||
178 | * | ||
179 | */ | ||
180 | public static TooFewInputsOfTurnout.Match newEmptyMatch() { | ||
181 | return new Mutable(null); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Returns a mutable (partial) match. | ||
186 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
187 | * | ||
188 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
189 | * @return the new, mutable (partial) match object. | ||
190 | * | ||
191 | */ | ||
192 | public static TooFewInputsOfTurnout.Match newMutableMatch(final Turnout pT) { | ||
193 | return new Mutable(pT); | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * Returns a new (partial) match. | ||
198 | * This can be used e.g. to call the matcher with a partial match. | ||
199 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
200 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
201 | * @return the (partial) match object. | ||
202 | * | ||
203 | */ | ||
204 | public static TooFewInputsOfTurnout.Match newMatch(final Turnout pT) { | ||
205 | return new Immutable(pT); | ||
206 | } | ||
207 | |||
208 | private static final class Mutable extends TooFewInputsOfTurnout.Match { | ||
209 | Mutable(final Turnout pT) { | ||
210 | super(pT); | ||
211 | } | ||
212 | |||
213 | @Override | ||
214 | public boolean isMutable() { | ||
215 | return true; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | private static final class Immutable extends TooFewInputsOfTurnout.Match { | ||
220 | Immutable(final Turnout pT) { | ||
221 | super(pT); | ||
222 | } | ||
223 | |||
224 | @Override | ||
225 | public boolean isMutable() { | ||
226 | return false; | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * Generated pattern matcher API of the modes3.queries.tooFewInputsOfTurnout pattern, | ||
233 | * providing pattern-specific query methods. | ||
234 | * | ||
235 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
236 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
237 | * | ||
238 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
239 | * | ||
240 | * <p>Original source: | ||
241 | * <code><pre> | ||
242 | * {@literal @}Constraint(message = "tooFewInputsOfTurnout", severity = "error", key = { T }) | ||
243 | * pattern tooFewInputsOfTurnout(T : Turnout) { | ||
244 | * neg find inputsOfTurnout(T); | ||
245 | * } | ||
246 | * </pre></code> | ||
247 | * | ||
248 | * @see Match | ||
249 | * @see TooFewInputsOfTurnout | ||
250 | * | ||
251 | */ | ||
252 | public static class Matcher extends BaseMatcher<TooFewInputsOfTurnout.Match> { | ||
253 | /** | ||
254 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
255 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
256 | * | ||
257 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
258 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
259 | * | ||
260 | */ | ||
261 | public static TooFewInputsOfTurnout.Matcher on(final ViatraQueryEngine engine) { | ||
262 | // check if matcher already exists | ||
263 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
264 | if (matcher == null) { | ||
265 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
266 | } | ||
267 | return matcher; | ||
268 | } | ||
269 | |||
270 | /** | ||
271 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
272 | * @return an initialized matcher | ||
273 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
274 | * | ||
275 | */ | ||
276 | public static TooFewInputsOfTurnout.Matcher create() { | ||
277 | return new Matcher(); | ||
278 | } | ||
279 | |||
280 | private static final int POSITION_T = 0; | ||
281 | |||
282 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TooFewInputsOfTurnout.Matcher.class); | ||
283 | |||
284 | /** | ||
285 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
286 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
287 | * | ||
288 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
289 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
290 | * | ||
291 | */ | ||
292 | private Matcher() { | ||
293 | super(querySpecification()); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
298 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
299 | * @return matches represented as a Match object. | ||
300 | * | ||
301 | */ | ||
302 | public Collection<TooFewInputsOfTurnout.Match> getAllMatches(final Turnout pT) { | ||
303 | return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); | ||
304 | } | ||
305 | |||
306 | /** | ||
307 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
308 | * </p> | ||
309 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
310 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
311 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
312 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
313 | * @return a stream of matches represented as a Match object. | ||
314 | * | ||
315 | */ | ||
316 | public Stream<TooFewInputsOfTurnout.Match> streamAllMatches(final Turnout pT) { | ||
317 | return rawStreamAllMatches(new Object[]{pT}); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
322 | * Neither determinism nor randomness of selection is guaranteed. | ||
323 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
324 | * @return a match represented as a Match object, or null if no match is found. | ||
325 | * | ||
326 | */ | ||
327 | public Optional<TooFewInputsOfTurnout.Match> getOneArbitraryMatch(final Turnout pT) { | ||
328 | return rawGetOneArbitraryMatch(new Object[]{pT}); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
333 | * under any possible substitution of the unspecified parameters (if any). | ||
334 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
335 | * @return true if the input is a valid (partial) match of the pattern. | ||
336 | * | ||
337 | */ | ||
338 | public boolean hasMatch(final Turnout pT) { | ||
339 | return rawHasMatch(new Object[]{pT}); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
344 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
345 | * @return the number of pattern matches found. | ||
346 | * | ||
347 | */ | ||
348 | public int countMatches(final Turnout pT) { | ||
349 | return rawCountMatches(new Object[]{pT}); | ||
350 | } | ||
351 | |||
352 | /** | ||
353 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
354 | * Neither determinism nor randomness of selection is guaranteed. | ||
355 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
356 | * @param processor the action that will process the selected match. | ||
357 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
358 | * | ||
359 | */ | ||
360 | public boolean forOneArbitraryMatch(final Turnout pT, final Consumer<? super TooFewInputsOfTurnout.Match> processor) { | ||
361 | return rawForOneArbitraryMatch(new Object[]{pT}, processor); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Returns a new (partial) match. | ||
366 | * This can be used e.g. to call the matcher with a partial match. | ||
367 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
368 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
369 | * @return the (partial) match object. | ||
370 | * | ||
371 | */ | ||
372 | public TooFewInputsOfTurnout.Match newMatch(final Turnout pT) { | ||
373 | return TooFewInputsOfTurnout.Match.newMatch(pT); | ||
374 | } | ||
375 | |||
376 | /** | ||
377 | * Retrieve the set of values that occur in matches for T. | ||
378 | * @return the Set of all values or empty set if there are no matches | ||
379 | * | ||
380 | */ | ||
381 | protected Stream<Turnout> rawStreamAllValuesOfT(final Object[] parameters) { | ||
382 | return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * Retrieve the set of values that occur in matches for T. | ||
387 | * @return the Set of all values or empty set if there are no matches | ||
388 | * | ||
389 | */ | ||
390 | public Set<Turnout> getAllValuesOfT() { | ||
391 | return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Retrieve the set of values that occur in matches for T. | ||
396 | * @return the Set of all values or empty set if there are no matches | ||
397 | * | ||
398 | */ | ||
399 | public Stream<Turnout> streamAllValuesOfT() { | ||
400 | return rawStreamAllValuesOfT(emptyArray()); | ||
401 | } | ||
402 | |||
403 | @Override | ||
404 | protected TooFewInputsOfTurnout.Match tupleToMatch(final Tuple t) { | ||
405 | try { | ||
406 | return TooFewInputsOfTurnout.Match.newMatch((Turnout) t.get(POSITION_T)); | ||
407 | } catch(ClassCastException e) { | ||
408 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
409 | return null; | ||
410 | } | ||
411 | } | ||
412 | |||
413 | @Override | ||
414 | protected TooFewInputsOfTurnout.Match arrayToMatch(final Object[] match) { | ||
415 | try { | ||
416 | return TooFewInputsOfTurnout.Match.newMatch((Turnout) match[POSITION_T]); | ||
417 | } catch(ClassCastException e) { | ||
418 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
419 | return null; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | @Override | ||
424 | protected TooFewInputsOfTurnout.Match arrayToMatchMutable(final Object[] match) { | ||
425 | try { | ||
426 | return TooFewInputsOfTurnout.Match.newMutableMatch((Turnout) match[POSITION_T]); | ||
427 | } catch(ClassCastException e) { | ||
428 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
429 | return null; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * @return the singleton instance of the query specification of this pattern | ||
435 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
436 | * | ||
437 | */ | ||
438 | public static IQuerySpecification<TooFewInputsOfTurnout.Matcher> querySpecification() { | ||
439 | return TooFewInputsOfTurnout.instance(); | ||
440 | } | ||
441 | } | ||
442 | |||
443 | private TooFewInputsOfTurnout() { | ||
444 | super(GeneratedPQuery.INSTANCE); | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @return the singleton instance of the query specification | ||
449 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
450 | * | ||
451 | */ | ||
452 | public static TooFewInputsOfTurnout instance() { | ||
453 | try{ | ||
454 | return LazyHolder.INSTANCE; | ||
455 | } catch (ExceptionInInitializerError err) { | ||
456 | throw processInitializerError(err); | ||
457 | } | ||
458 | } | ||
459 | |||
460 | @Override | ||
461 | protected TooFewInputsOfTurnout.Matcher instantiate(final ViatraQueryEngine engine) { | ||
462 | return TooFewInputsOfTurnout.Matcher.on(engine); | ||
463 | } | ||
464 | |||
465 | @Override | ||
466 | public TooFewInputsOfTurnout.Matcher instantiate() { | ||
467 | return TooFewInputsOfTurnout.Matcher.create(); | ||
468 | } | ||
469 | |||
470 | @Override | ||
471 | public TooFewInputsOfTurnout.Match newEmptyMatch() { | ||
472 | return TooFewInputsOfTurnout.Match.newEmptyMatch(); | ||
473 | } | ||
474 | |||
475 | @Override | ||
476 | public TooFewInputsOfTurnout.Match newMatch(final Object... parameters) { | ||
477 | return TooFewInputsOfTurnout.Match.newMatch((modes3.Turnout) parameters[0]); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Inner class allowing the singleton instance of {@link TooFewInputsOfTurnout} to be created | ||
482 | * <b>not</b> at the class load time of the outer class, | ||
483 | * but rather at the first call to {@link TooFewInputsOfTurnout#instance()}. | ||
484 | * | ||
485 | * <p> This workaround is required e.g. to support recursion. | ||
486 | * | ||
487 | */ | ||
488 | private static class LazyHolder { | ||
489 | private static final TooFewInputsOfTurnout INSTANCE = new TooFewInputsOfTurnout(); | ||
490 | |||
491 | /** | ||
492 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
493 | * This initialization order is required to support indirect recursion. | ||
494 | * | ||
495 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
496 | * | ||
497 | */ | ||
498 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
499 | |||
500 | public static Object ensureInitialized() { | ||
501 | INSTANCE.ensureInitializedInternal(); | ||
502 | return null; | ||
503 | } | ||
504 | } | ||
505 | |||
506 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
507 | private static final TooFewInputsOfTurnout.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
508 | |||
509 | private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); | ||
510 | |||
511 | private final List<PParameter> parameters = Arrays.asList(parameter_T); | ||
512 | |||
513 | private GeneratedPQuery() { | ||
514 | super(PVisibility.PUBLIC); | ||
515 | } | ||
516 | |||
517 | @Override | ||
518 | public String getFullyQualifiedName() { | ||
519 | return "modes3.queries.tooFewInputsOfTurnout"; | ||
520 | } | ||
521 | |||
522 | @Override | ||
523 | public List<String> getParameterNames() { | ||
524 | return Arrays.asList("T"); | ||
525 | } | ||
526 | |||
527 | @Override | ||
528 | public List<PParameter> getParameters() { | ||
529 | return parameters; | ||
530 | } | ||
531 | |||
532 | @Override | ||
533 | public Set<PBody> doGetContainedBodies() { | ||
534 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
535 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
536 | { | ||
537 | PBody body = new PBody(this); | ||
538 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
539 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
540 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
541 | new ExportedParameter(body, var_T, parameter_T) | ||
542 | )); | ||
543 | // neg find inputsOfTurnout(T) | ||
544 | new NegativePatternCall(body, Tuples.flatTupleOf(var_T), InputsOfTurnout.instance().getInternalQueryRepresentation()); | ||
545 | bodies.add(body); | ||
546 | } | ||
547 | { | ||
548 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
549 | annotation.addAttribute("message", "tooFewInputsOfTurnout"); | ||
550 | annotation.addAttribute("severity", "error"); | ||
551 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
552 | new ParameterReference("T") | ||
553 | })); | ||
554 | addAnnotation(annotation); | ||
555 | } | ||
556 | return bodies; | ||
557 | } | ||
558 | } | ||
559 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfSegment.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfSegment.java new file mode 100644 index 00000000..d12ec23e --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfSegment.java | |||
@@ -0,0 +1,583 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.SimpleSegment; | ||
17 | import modes3.queries.Output; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
42 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
43 | |||
44 | /** | ||
45 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
46 | * | ||
47 | * <p>Original source: | ||
48 | * <code><pre> | ||
49 | * {@literal @}Constraint(message = "tooManyInputsOfSegment", severity = "error", key = { S }) | ||
50 | * pattern tooManyInputsOfSegment(S : SimpleSegment) { | ||
51 | * find output(I1, S); | ||
52 | * find output(I2, S); | ||
53 | * find output(I3, S); | ||
54 | * I1 != I2; | ||
55 | * I1 != I3; | ||
56 | * I2 != I3; | ||
57 | * } | ||
58 | * </pre></code> | ||
59 | * | ||
60 | * @see Matcher | ||
61 | * @see Match | ||
62 | * | ||
63 | */ | ||
64 | @SuppressWarnings("all") | ||
65 | public final class TooManyInputsOfSegment extends BaseGeneratedEMFQuerySpecification<TooManyInputsOfSegment.Matcher> { | ||
66 | /** | ||
67 | * Pattern-specific match representation of the modes3.queries.tooManyInputsOfSegment pattern, | ||
68 | * to be used in conjunction with {@link Matcher}. | ||
69 | * | ||
70 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
71 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
72 | * usable to represent a match of the pattern in the result of a query, | ||
73 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
74 | * | ||
75 | * @see Matcher | ||
76 | * | ||
77 | */ | ||
78 | public static abstract class Match extends BasePatternMatch { | ||
79 | private SimpleSegment fS; | ||
80 | |||
81 | private static List<String> parameterNames = makeImmutableList("S"); | ||
82 | |||
83 | private Match(final SimpleSegment pS) { | ||
84 | this.fS = pS; | ||
85 | } | ||
86 | |||
87 | @Override | ||
88 | public Object get(final String parameterName) { | ||
89 | switch(parameterName) { | ||
90 | case "S": return this.fS; | ||
91 | default: return null; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | @Override | ||
96 | public Object get(final int index) { | ||
97 | switch(index) { | ||
98 | case 0: return this.fS; | ||
99 | default: return null; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | public SimpleSegment getS() { | ||
104 | return this.fS; | ||
105 | } | ||
106 | |||
107 | @Override | ||
108 | public boolean set(final String parameterName, final Object newValue) { | ||
109 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
110 | if ("S".equals(parameterName) ) { | ||
111 | this.fS = (SimpleSegment) newValue; | ||
112 | return true; | ||
113 | } | ||
114 | return false; | ||
115 | } | ||
116 | |||
117 | public void setS(final SimpleSegment pS) { | ||
118 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
119 | this.fS = pS; | ||
120 | } | ||
121 | |||
122 | @Override | ||
123 | public String patternName() { | ||
124 | return "modes3.queries.tooManyInputsOfSegment"; | ||
125 | } | ||
126 | |||
127 | @Override | ||
128 | public List<String> parameterNames() { | ||
129 | return TooManyInputsOfSegment.Match.parameterNames; | ||
130 | } | ||
131 | |||
132 | @Override | ||
133 | public Object[] toArray() { | ||
134 | return new Object[]{fS}; | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public TooManyInputsOfSegment.Match toImmutable() { | ||
139 | return isMutable() ? newMatch(fS) : this; | ||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public String prettyPrint() { | ||
144 | StringBuilder result = new StringBuilder(); | ||
145 | result.append("\"S\"=" + prettyPrintValue(fS)); | ||
146 | return result.toString(); | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public int hashCode() { | ||
151 | return Objects.hash(fS); | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public boolean equals(final Object obj) { | ||
156 | if (this == obj) | ||
157 | return true; | ||
158 | if (obj == null) { | ||
159 | return false; | ||
160 | } | ||
161 | if ((obj instanceof TooManyInputsOfSegment.Match)) { | ||
162 | TooManyInputsOfSegment.Match other = (TooManyInputsOfSegment.Match) obj; | ||
163 | return Objects.equals(fS, other.fS); | ||
164 | } else { | ||
165 | // this should be infrequent | ||
166 | if (!(obj instanceof IPatternMatch)) { | ||
167 | return false; | ||
168 | } | ||
169 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
170 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
171 | } | ||
172 | } | ||
173 | |||
174 | @Override | ||
175 | public TooManyInputsOfSegment specification() { | ||
176 | return TooManyInputsOfSegment.instance(); | ||
177 | } | ||
178 | |||
179 | /** | ||
180 | * Returns an empty, mutable match. | ||
181 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
182 | * | ||
183 | * @return the empty match. | ||
184 | * | ||
185 | */ | ||
186 | public static TooManyInputsOfSegment.Match newEmptyMatch() { | ||
187 | return new Mutable(null); | ||
188 | } | ||
189 | |||
190 | /** | ||
191 | * Returns a mutable (partial) match. | ||
192 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
193 | * | ||
194 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
195 | * @return the new, mutable (partial) match object. | ||
196 | * | ||
197 | */ | ||
198 | public static TooManyInputsOfSegment.Match newMutableMatch(final SimpleSegment pS) { | ||
199 | return new Mutable(pS); | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * Returns a new (partial) match. | ||
204 | * This can be used e.g. to call the matcher with a partial match. | ||
205 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
206 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
207 | * @return the (partial) match object. | ||
208 | * | ||
209 | */ | ||
210 | public static TooManyInputsOfSegment.Match newMatch(final SimpleSegment pS) { | ||
211 | return new Immutable(pS); | ||
212 | } | ||
213 | |||
214 | private static final class Mutable extends TooManyInputsOfSegment.Match { | ||
215 | Mutable(final SimpleSegment pS) { | ||
216 | super(pS); | ||
217 | } | ||
218 | |||
219 | @Override | ||
220 | public boolean isMutable() { | ||
221 | return true; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | private static final class Immutable extends TooManyInputsOfSegment.Match { | ||
226 | Immutable(final SimpleSegment pS) { | ||
227 | super(pS); | ||
228 | } | ||
229 | |||
230 | @Override | ||
231 | public boolean isMutable() { | ||
232 | return false; | ||
233 | } | ||
234 | } | ||
235 | } | ||
236 | |||
237 | /** | ||
238 | * Generated pattern matcher API of the modes3.queries.tooManyInputsOfSegment pattern, | ||
239 | * providing pattern-specific query methods. | ||
240 | * | ||
241 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
242 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
243 | * | ||
244 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
245 | * | ||
246 | * <p>Original source: | ||
247 | * <code><pre> | ||
248 | * {@literal @}Constraint(message = "tooManyInputsOfSegment", severity = "error", key = { S }) | ||
249 | * pattern tooManyInputsOfSegment(S : SimpleSegment) { | ||
250 | * find output(I1, S); | ||
251 | * find output(I2, S); | ||
252 | * find output(I3, S); | ||
253 | * I1 != I2; | ||
254 | * I1 != I3; | ||
255 | * I2 != I3; | ||
256 | * } | ||
257 | * </pre></code> | ||
258 | * | ||
259 | * @see Match | ||
260 | * @see TooManyInputsOfSegment | ||
261 | * | ||
262 | */ | ||
263 | public static class Matcher extends BaseMatcher<TooManyInputsOfSegment.Match> { | ||
264 | /** | ||
265 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
266 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
267 | * | ||
268 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
269 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
270 | * | ||
271 | */ | ||
272 | public static TooManyInputsOfSegment.Matcher on(final ViatraQueryEngine engine) { | ||
273 | // check if matcher already exists | ||
274 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
275 | if (matcher == null) { | ||
276 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
277 | } | ||
278 | return matcher; | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
283 | * @return an initialized matcher | ||
284 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
285 | * | ||
286 | */ | ||
287 | public static TooManyInputsOfSegment.Matcher create() { | ||
288 | return new Matcher(); | ||
289 | } | ||
290 | |||
291 | private static final int POSITION_S = 0; | ||
292 | |||
293 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TooManyInputsOfSegment.Matcher.class); | ||
294 | |||
295 | /** | ||
296 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
297 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
298 | * | ||
299 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
300 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
301 | * | ||
302 | */ | ||
303 | private Matcher() { | ||
304 | super(querySpecification()); | ||
305 | } | ||
306 | |||
307 | /** | ||
308 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
309 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
310 | * @return matches represented as a Match object. | ||
311 | * | ||
312 | */ | ||
313 | public Collection<TooManyInputsOfSegment.Match> getAllMatches(final SimpleSegment pS) { | ||
314 | return rawStreamAllMatches(new Object[]{pS}).collect(Collectors.toSet()); | ||
315 | } | ||
316 | |||
317 | /** | ||
318 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
319 | * </p> | ||
320 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
321 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
322 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
323 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
324 | * @return a stream of matches represented as a Match object. | ||
325 | * | ||
326 | */ | ||
327 | public Stream<TooManyInputsOfSegment.Match> streamAllMatches(final SimpleSegment pS) { | ||
328 | return rawStreamAllMatches(new Object[]{pS}); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
333 | * Neither determinism nor randomness of selection is guaranteed. | ||
334 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
335 | * @return a match represented as a Match object, or null if no match is found. | ||
336 | * | ||
337 | */ | ||
338 | public Optional<TooManyInputsOfSegment.Match> getOneArbitraryMatch(final SimpleSegment pS) { | ||
339 | return rawGetOneArbitraryMatch(new Object[]{pS}); | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
344 | * under any possible substitution of the unspecified parameters (if any). | ||
345 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
346 | * @return true if the input is a valid (partial) match of the pattern. | ||
347 | * | ||
348 | */ | ||
349 | public boolean hasMatch(final SimpleSegment pS) { | ||
350 | return rawHasMatch(new Object[]{pS}); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
355 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
356 | * @return the number of pattern matches found. | ||
357 | * | ||
358 | */ | ||
359 | public int countMatches(final SimpleSegment pS) { | ||
360 | return rawCountMatches(new Object[]{pS}); | ||
361 | } | ||
362 | |||
363 | /** | ||
364 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
365 | * Neither determinism nor randomness of selection is guaranteed. | ||
366 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
367 | * @param processor the action that will process the selected match. | ||
368 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
369 | * | ||
370 | */ | ||
371 | public boolean forOneArbitraryMatch(final SimpleSegment pS, final Consumer<? super TooManyInputsOfSegment.Match> processor) { | ||
372 | return rawForOneArbitraryMatch(new Object[]{pS}, processor); | ||
373 | } | ||
374 | |||
375 | /** | ||
376 | * Returns a new (partial) match. | ||
377 | * This can be used e.g. to call the matcher with a partial match. | ||
378 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
379 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
380 | * @return the (partial) match object. | ||
381 | * | ||
382 | */ | ||
383 | public TooManyInputsOfSegment.Match newMatch(final SimpleSegment pS) { | ||
384 | return TooManyInputsOfSegment.Match.newMatch(pS); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * Retrieve the set of values that occur in matches for S. | ||
389 | * @return the Set of all values or empty set if there are no matches | ||
390 | * | ||
391 | */ | ||
392 | protected Stream<SimpleSegment> rawStreamAllValuesOfS(final Object[] parameters) { | ||
393 | return rawStreamAllValues(POSITION_S, parameters).map(SimpleSegment.class::cast); | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * Retrieve the set of values that occur in matches for S. | ||
398 | * @return the Set of all values or empty set if there are no matches | ||
399 | * | ||
400 | */ | ||
401 | public Set<SimpleSegment> getAllValuesOfS() { | ||
402 | return rawStreamAllValuesOfS(emptyArray()).collect(Collectors.toSet()); | ||
403 | } | ||
404 | |||
405 | /** | ||
406 | * Retrieve the set of values that occur in matches for S. | ||
407 | * @return the Set of all values or empty set if there are no matches | ||
408 | * | ||
409 | */ | ||
410 | public Stream<SimpleSegment> streamAllValuesOfS() { | ||
411 | return rawStreamAllValuesOfS(emptyArray()); | ||
412 | } | ||
413 | |||
414 | @Override | ||
415 | protected TooManyInputsOfSegment.Match tupleToMatch(final Tuple t) { | ||
416 | try { | ||
417 | return TooManyInputsOfSegment.Match.newMatch((SimpleSegment) t.get(POSITION_S)); | ||
418 | } catch(ClassCastException e) { | ||
419 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
420 | return null; | ||
421 | } | ||
422 | } | ||
423 | |||
424 | @Override | ||
425 | protected TooManyInputsOfSegment.Match arrayToMatch(final Object[] match) { | ||
426 | try { | ||
427 | return TooManyInputsOfSegment.Match.newMatch((SimpleSegment) match[POSITION_S]); | ||
428 | } catch(ClassCastException e) { | ||
429 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
430 | return null; | ||
431 | } | ||
432 | } | ||
433 | |||
434 | @Override | ||
435 | protected TooManyInputsOfSegment.Match arrayToMatchMutable(final Object[] match) { | ||
436 | try { | ||
437 | return TooManyInputsOfSegment.Match.newMutableMatch((SimpleSegment) match[POSITION_S]); | ||
438 | } catch(ClassCastException e) { | ||
439 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
440 | return null; | ||
441 | } | ||
442 | } | ||
443 | |||
444 | /** | ||
445 | * @return the singleton instance of the query specification of this pattern | ||
446 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
447 | * | ||
448 | */ | ||
449 | public static IQuerySpecification<TooManyInputsOfSegment.Matcher> querySpecification() { | ||
450 | return TooManyInputsOfSegment.instance(); | ||
451 | } | ||
452 | } | ||
453 | |||
454 | private TooManyInputsOfSegment() { | ||
455 | super(GeneratedPQuery.INSTANCE); | ||
456 | } | ||
457 | |||
458 | /** | ||
459 | * @return the singleton instance of the query specification | ||
460 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
461 | * | ||
462 | */ | ||
463 | public static TooManyInputsOfSegment instance() { | ||
464 | try{ | ||
465 | return LazyHolder.INSTANCE; | ||
466 | } catch (ExceptionInInitializerError err) { | ||
467 | throw processInitializerError(err); | ||
468 | } | ||
469 | } | ||
470 | |||
471 | @Override | ||
472 | protected TooManyInputsOfSegment.Matcher instantiate(final ViatraQueryEngine engine) { | ||
473 | return TooManyInputsOfSegment.Matcher.on(engine); | ||
474 | } | ||
475 | |||
476 | @Override | ||
477 | public TooManyInputsOfSegment.Matcher instantiate() { | ||
478 | return TooManyInputsOfSegment.Matcher.create(); | ||
479 | } | ||
480 | |||
481 | @Override | ||
482 | public TooManyInputsOfSegment.Match newEmptyMatch() { | ||
483 | return TooManyInputsOfSegment.Match.newEmptyMatch(); | ||
484 | } | ||
485 | |||
486 | @Override | ||
487 | public TooManyInputsOfSegment.Match newMatch(final Object... parameters) { | ||
488 | return TooManyInputsOfSegment.Match.newMatch((modes3.SimpleSegment) parameters[0]); | ||
489 | } | ||
490 | |||
491 | /** | ||
492 | * Inner class allowing the singleton instance of {@link TooManyInputsOfSegment} to be created | ||
493 | * <b>not</b> at the class load time of the outer class, | ||
494 | * but rather at the first call to {@link TooManyInputsOfSegment#instance()}. | ||
495 | * | ||
496 | * <p> This workaround is required e.g. to support recursion. | ||
497 | * | ||
498 | */ | ||
499 | private static class LazyHolder { | ||
500 | private static final TooManyInputsOfSegment INSTANCE = new TooManyInputsOfSegment(); | ||
501 | |||
502 | /** | ||
503 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
504 | * This initialization order is required to support indirect recursion. | ||
505 | * | ||
506 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
507 | * | ||
508 | */ | ||
509 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
510 | |||
511 | public static Object ensureInitialized() { | ||
512 | INSTANCE.ensureInitializedInternal(); | ||
513 | return null; | ||
514 | } | ||
515 | } | ||
516 | |||
517 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
518 | private static final TooManyInputsOfSegment.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
519 | |||
520 | private final PParameter parameter_S = new PParameter("S", "modes3.SimpleSegment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "SimpleSegment")), PParameterDirection.INOUT); | ||
521 | |||
522 | private final List<PParameter> parameters = Arrays.asList(parameter_S); | ||
523 | |||
524 | private GeneratedPQuery() { | ||
525 | super(PVisibility.PUBLIC); | ||
526 | } | ||
527 | |||
528 | @Override | ||
529 | public String getFullyQualifiedName() { | ||
530 | return "modes3.queries.tooManyInputsOfSegment"; | ||
531 | } | ||
532 | |||
533 | @Override | ||
534 | public List<String> getParameterNames() { | ||
535 | return Arrays.asList("S"); | ||
536 | } | ||
537 | |||
538 | @Override | ||
539 | public List<PParameter> getParameters() { | ||
540 | return parameters; | ||
541 | } | ||
542 | |||
543 | @Override | ||
544 | public Set<PBody> doGetContainedBodies() { | ||
545 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
546 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
547 | { | ||
548 | PBody body = new PBody(this); | ||
549 | PVariable var_S = body.getOrCreateVariableByName("S"); | ||
550 | PVariable var_I1 = body.getOrCreateVariableByName("I1"); | ||
551 | PVariable var_I2 = body.getOrCreateVariableByName("I2"); | ||
552 | PVariable var_I3 = body.getOrCreateVariableByName("I3"); | ||
553 | new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "SimpleSegment"))); | ||
554 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
555 | new ExportedParameter(body, var_S, parameter_S) | ||
556 | )); | ||
557 | // find output(I1, S) | ||
558 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I1, var_S), Output.instance().getInternalQueryRepresentation()); | ||
559 | // find output(I2, S) | ||
560 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I2, var_S), Output.instance().getInternalQueryRepresentation()); | ||
561 | // find output(I3, S) | ||
562 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I3, var_S), Output.instance().getInternalQueryRepresentation()); | ||
563 | // I1 != I2 | ||
564 | new Inequality(body, var_I1, var_I2); | ||
565 | // I1 != I3 | ||
566 | new Inequality(body, var_I1, var_I3); | ||
567 | // I2 != I3 | ||
568 | new Inequality(body, var_I2, var_I3); | ||
569 | bodies.add(body); | ||
570 | } | ||
571 | { | ||
572 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
573 | annotation.addAttribute("message", "tooManyInputsOfSegment"); | ||
574 | annotation.addAttribute("severity", "error"); | ||
575 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
576 | new ParameterReference("S") | ||
577 | })); | ||
578 | addAnnotation(annotation); | ||
579 | } | ||
580 | return bodies; | ||
581 | } | ||
582 | } | ||
583 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfTurnout.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfTurnout.java new file mode 100644 index 00000000..93076cbb --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfTurnout.java | |||
@@ -0,0 +1,600 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Turnout; | ||
17 | import modes3.queries.Adjacent; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
42 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
43 | |||
44 | /** | ||
45 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
46 | * | ||
47 | * <p>Original source: | ||
48 | * <code><pre> | ||
49 | * {@literal @}Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) | ||
50 | * pattern tooManyInputsOfTurnout(T : Turnout) { | ||
51 | * find adjacent(I1, T); | ||
52 | * find adjacent(I2, T); | ||
53 | * find adjacent(I3, T); | ||
54 | * find adjacent(I4, T); | ||
55 | * I1 != I2; | ||
56 | * I1 != I3; | ||
57 | * I1 != I4; | ||
58 | * I2 != I3; | ||
59 | * I2 != I4; | ||
60 | * I3 != I4; | ||
61 | * } | ||
62 | * </pre></code> | ||
63 | * | ||
64 | * @see Matcher | ||
65 | * @see Match | ||
66 | * | ||
67 | */ | ||
68 | @SuppressWarnings("all") | ||
69 | public final class TooManyInputsOfTurnout extends BaseGeneratedEMFQuerySpecification<TooManyInputsOfTurnout.Matcher> { | ||
70 | /** | ||
71 | * Pattern-specific match representation of the modes3.queries.tooManyInputsOfTurnout pattern, | ||
72 | * to be used in conjunction with {@link Matcher}. | ||
73 | * | ||
74 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
75 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
76 | * usable to represent a match of the pattern in the result of a query, | ||
77 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
78 | * | ||
79 | * @see Matcher | ||
80 | * | ||
81 | */ | ||
82 | public static abstract class Match extends BasePatternMatch { | ||
83 | private Turnout fT; | ||
84 | |||
85 | private static List<String> parameterNames = makeImmutableList("T"); | ||
86 | |||
87 | private Match(final Turnout pT) { | ||
88 | this.fT = pT; | ||
89 | } | ||
90 | |||
91 | @Override | ||
92 | public Object get(final String parameterName) { | ||
93 | switch(parameterName) { | ||
94 | case "T": return this.fT; | ||
95 | default: return null; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | @Override | ||
100 | public Object get(final int index) { | ||
101 | switch(index) { | ||
102 | case 0: return this.fT; | ||
103 | default: return null; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | public Turnout getT() { | ||
108 | return this.fT; | ||
109 | } | ||
110 | |||
111 | @Override | ||
112 | public boolean set(final String parameterName, final Object newValue) { | ||
113 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
114 | if ("T".equals(parameterName) ) { | ||
115 | this.fT = (Turnout) newValue; | ||
116 | return true; | ||
117 | } | ||
118 | return false; | ||
119 | } | ||
120 | |||
121 | public void setT(final Turnout pT) { | ||
122 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
123 | this.fT = pT; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public String patternName() { | ||
128 | return "modes3.queries.tooManyInputsOfTurnout"; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public List<String> parameterNames() { | ||
133 | return TooManyInputsOfTurnout.Match.parameterNames; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public Object[] toArray() { | ||
138 | return new Object[]{fT}; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public TooManyInputsOfTurnout.Match toImmutable() { | ||
143 | return isMutable() ? newMatch(fT) : this; | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public String prettyPrint() { | ||
148 | StringBuilder result = new StringBuilder(); | ||
149 | result.append("\"T\"=" + prettyPrintValue(fT)); | ||
150 | return result.toString(); | ||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public int hashCode() { | ||
155 | return Objects.hash(fT); | ||
156 | } | ||
157 | |||
158 | @Override | ||
159 | public boolean equals(final Object obj) { | ||
160 | if (this == obj) | ||
161 | return true; | ||
162 | if (obj == null) { | ||
163 | return false; | ||
164 | } | ||
165 | if ((obj instanceof TooManyInputsOfTurnout.Match)) { | ||
166 | TooManyInputsOfTurnout.Match other = (TooManyInputsOfTurnout.Match) obj; | ||
167 | return Objects.equals(fT, other.fT); | ||
168 | } else { | ||
169 | // this should be infrequent | ||
170 | if (!(obj instanceof IPatternMatch)) { | ||
171 | return false; | ||
172 | } | ||
173 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
174 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
175 | } | ||
176 | } | ||
177 | |||
178 | @Override | ||
179 | public TooManyInputsOfTurnout specification() { | ||
180 | return TooManyInputsOfTurnout.instance(); | ||
181 | } | ||
182 | |||
183 | /** | ||
184 | * Returns an empty, mutable match. | ||
185 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
186 | * | ||
187 | * @return the empty match. | ||
188 | * | ||
189 | */ | ||
190 | public static TooManyInputsOfTurnout.Match newEmptyMatch() { | ||
191 | return new Mutable(null); | ||
192 | } | ||
193 | |||
194 | /** | ||
195 | * Returns a mutable (partial) match. | ||
196 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
197 | * | ||
198 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
199 | * @return the new, mutable (partial) match object. | ||
200 | * | ||
201 | */ | ||
202 | public static TooManyInputsOfTurnout.Match newMutableMatch(final Turnout pT) { | ||
203 | return new Mutable(pT); | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * Returns a new (partial) match. | ||
208 | * This can be used e.g. to call the matcher with a partial match. | ||
209 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
210 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
211 | * @return the (partial) match object. | ||
212 | * | ||
213 | */ | ||
214 | public static TooManyInputsOfTurnout.Match newMatch(final Turnout pT) { | ||
215 | return new Immutable(pT); | ||
216 | } | ||
217 | |||
218 | private static final class Mutable extends TooManyInputsOfTurnout.Match { | ||
219 | Mutable(final Turnout pT) { | ||
220 | super(pT); | ||
221 | } | ||
222 | |||
223 | @Override | ||
224 | public boolean isMutable() { | ||
225 | return true; | ||
226 | } | ||
227 | } | ||
228 | |||
229 | private static final class Immutable extends TooManyInputsOfTurnout.Match { | ||
230 | Immutable(final Turnout pT) { | ||
231 | super(pT); | ||
232 | } | ||
233 | |||
234 | @Override | ||
235 | public boolean isMutable() { | ||
236 | return false; | ||
237 | } | ||
238 | } | ||
239 | } | ||
240 | |||
241 | /** | ||
242 | * Generated pattern matcher API of the modes3.queries.tooManyInputsOfTurnout pattern, | ||
243 | * providing pattern-specific query methods. | ||
244 | * | ||
245 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
246 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
247 | * | ||
248 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
249 | * | ||
250 | * <p>Original source: | ||
251 | * <code><pre> | ||
252 | * {@literal @}Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) | ||
253 | * pattern tooManyInputsOfTurnout(T : Turnout) { | ||
254 | * find adjacent(I1, T); | ||
255 | * find adjacent(I2, T); | ||
256 | * find adjacent(I3, T); | ||
257 | * find adjacent(I4, T); | ||
258 | * I1 != I2; | ||
259 | * I1 != I3; | ||
260 | * I1 != I4; | ||
261 | * I2 != I3; | ||
262 | * I2 != I4; | ||
263 | * I3 != I4; | ||
264 | * } | ||
265 | * </pre></code> | ||
266 | * | ||
267 | * @see Match | ||
268 | * @see TooManyInputsOfTurnout | ||
269 | * | ||
270 | */ | ||
271 | public static class Matcher extends BaseMatcher<TooManyInputsOfTurnout.Match> { | ||
272 | /** | ||
273 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
274 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
275 | * | ||
276 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
277 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
278 | * | ||
279 | */ | ||
280 | public static TooManyInputsOfTurnout.Matcher on(final ViatraQueryEngine engine) { | ||
281 | // check if matcher already exists | ||
282 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
283 | if (matcher == null) { | ||
284 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
285 | } | ||
286 | return matcher; | ||
287 | } | ||
288 | |||
289 | /** | ||
290 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
291 | * @return an initialized matcher | ||
292 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
293 | * | ||
294 | */ | ||
295 | public static TooManyInputsOfTurnout.Matcher create() { | ||
296 | return new Matcher(); | ||
297 | } | ||
298 | |||
299 | private static final int POSITION_T = 0; | ||
300 | |||
301 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TooManyInputsOfTurnout.Matcher.class); | ||
302 | |||
303 | /** | ||
304 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
305 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
306 | * | ||
307 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
308 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
309 | * | ||
310 | */ | ||
311 | private Matcher() { | ||
312 | super(querySpecification()); | ||
313 | } | ||
314 | |||
315 | /** | ||
316 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
317 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
318 | * @return matches represented as a Match object. | ||
319 | * | ||
320 | */ | ||
321 | public Collection<TooManyInputsOfTurnout.Match> getAllMatches(final Turnout pT) { | ||
322 | return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); | ||
323 | } | ||
324 | |||
325 | /** | ||
326 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
327 | * </p> | ||
328 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
329 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
330 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
331 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
332 | * @return a stream of matches represented as a Match object. | ||
333 | * | ||
334 | */ | ||
335 | public Stream<TooManyInputsOfTurnout.Match> streamAllMatches(final Turnout pT) { | ||
336 | return rawStreamAllMatches(new Object[]{pT}); | ||
337 | } | ||
338 | |||
339 | /** | ||
340 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
341 | * Neither determinism nor randomness of selection is guaranteed. | ||
342 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
343 | * @return a match represented as a Match object, or null if no match is found. | ||
344 | * | ||
345 | */ | ||
346 | public Optional<TooManyInputsOfTurnout.Match> getOneArbitraryMatch(final Turnout pT) { | ||
347 | return rawGetOneArbitraryMatch(new Object[]{pT}); | ||
348 | } | ||
349 | |||
350 | /** | ||
351 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
352 | * under any possible substitution of the unspecified parameters (if any). | ||
353 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
354 | * @return true if the input is a valid (partial) match of the pattern. | ||
355 | * | ||
356 | */ | ||
357 | public boolean hasMatch(final Turnout pT) { | ||
358 | return rawHasMatch(new Object[]{pT}); | ||
359 | } | ||
360 | |||
361 | /** | ||
362 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
363 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
364 | * @return the number of pattern matches found. | ||
365 | * | ||
366 | */ | ||
367 | public int countMatches(final Turnout pT) { | ||
368 | return rawCountMatches(new Object[]{pT}); | ||
369 | } | ||
370 | |||
371 | /** | ||
372 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
373 | * Neither determinism nor randomness of selection is guaranteed. | ||
374 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
375 | * @param processor the action that will process the selected match. | ||
376 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
377 | * | ||
378 | */ | ||
379 | public boolean forOneArbitraryMatch(final Turnout pT, final Consumer<? super TooManyInputsOfTurnout.Match> processor) { | ||
380 | return rawForOneArbitraryMatch(new Object[]{pT}, processor); | ||
381 | } | ||
382 | |||
383 | /** | ||
384 | * Returns a new (partial) match. | ||
385 | * This can be used e.g. to call the matcher with a partial match. | ||
386 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
387 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
388 | * @return the (partial) match object. | ||
389 | * | ||
390 | */ | ||
391 | public TooManyInputsOfTurnout.Match newMatch(final Turnout pT) { | ||
392 | return TooManyInputsOfTurnout.Match.newMatch(pT); | ||
393 | } | ||
394 | |||
395 | /** | ||
396 | * Retrieve the set of values that occur in matches for T. | ||
397 | * @return the Set of all values or empty set if there are no matches | ||
398 | * | ||
399 | */ | ||
400 | protected Stream<Turnout> rawStreamAllValuesOfT(final Object[] parameters) { | ||
401 | return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); | ||
402 | } | ||
403 | |||
404 | /** | ||
405 | * Retrieve the set of values that occur in matches for T. | ||
406 | * @return the Set of all values or empty set if there are no matches | ||
407 | * | ||
408 | */ | ||
409 | public Set<Turnout> getAllValuesOfT() { | ||
410 | return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); | ||
411 | } | ||
412 | |||
413 | /** | ||
414 | * Retrieve the set of values that occur in matches for T. | ||
415 | * @return the Set of all values or empty set if there are no matches | ||
416 | * | ||
417 | */ | ||
418 | public Stream<Turnout> streamAllValuesOfT() { | ||
419 | return rawStreamAllValuesOfT(emptyArray()); | ||
420 | } | ||
421 | |||
422 | @Override | ||
423 | protected TooManyInputsOfTurnout.Match tupleToMatch(final Tuple t) { | ||
424 | try { | ||
425 | return TooManyInputsOfTurnout.Match.newMatch((Turnout) t.get(POSITION_T)); | ||
426 | } catch(ClassCastException e) { | ||
427 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
428 | return null; | ||
429 | } | ||
430 | } | ||
431 | |||
432 | @Override | ||
433 | protected TooManyInputsOfTurnout.Match arrayToMatch(final Object[] match) { | ||
434 | try { | ||
435 | return TooManyInputsOfTurnout.Match.newMatch((Turnout) match[POSITION_T]); | ||
436 | } catch(ClassCastException e) { | ||
437 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
438 | return null; | ||
439 | } | ||
440 | } | ||
441 | |||
442 | @Override | ||
443 | protected TooManyInputsOfTurnout.Match arrayToMatchMutable(final Object[] match) { | ||
444 | try { | ||
445 | return TooManyInputsOfTurnout.Match.newMutableMatch((Turnout) match[POSITION_T]); | ||
446 | } catch(ClassCastException e) { | ||
447 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
448 | return null; | ||
449 | } | ||
450 | } | ||
451 | |||
452 | /** | ||
453 | * @return the singleton instance of the query specification of this pattern | ||
454 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
455 | * | ||
456 | */ | ||
457 | public static IQuerySpecification<TooManyInputsOfTurnout.Matcher> querySpecification() { | ||
458 | return TooManyInputsOfTurnout.instance(); | ||
459 | } | ||
460 | } | ||
461 | |||
462 | private TooManyInputsOfTurnout() { | ||
463 | super(GeneratedPQuery.INSTANCE); | ||
464 | } | ||
465 | |||
466 | /** | ||
467 | * @return the singleton instance of the query specification | ||
468 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
469 | * | ||
470 | */ | ||
471 | public static TooManyInputsOfTurnout instance() { | ||
472 | try{ | ||
473 | return LazyHolder.INSTANCE; | ||
474 | } catch (ExceptionInInitializerError err) { | ||
475 | throw processInitializerError(err); | ||
476 | } | ||
477 | } | ||
478 | |||
479 | @Override | ||
480 | protected TooManyInputsOfTurnout.Matcher instantiate(final ViatraQueryEngine engine) { | ||
481 | return TooManyInputsOfTurnout.Matcher.on(engine); | ||
482 | } | ||
483 | |||
484 | @Override | ||
485 | public TooManyInputsOfTurnout.Matcher instantiate() { | ||
486 | return TooManyInputsOfTurnout.Matcher.create(); | ||
487 | } | ||
488 | |||
489 | @Override | ||
490 | public TooManyInputsOfTurnout.Match newEmptyMatch() { | ||
491 | return TooManyInputsOfTurnout.Match.newEmptyMatch(); | ||
492 | } | ||
493 | |||
494 | @Override | ||
495 | public TooManyInputsOfTurnout.Match newMatch(final Object... parameters) { | ||
496 | return TooManyInputsOfTurnout.Match.newMatch((modes3.Turnout) parameters[0]); | ||
497 | } | ||
498 | |||
499 | /** | ||
500 | * Inner class allowing the singleton instance of {@link TooManyInputsOfTurnout} to be created | ||
501 | * <b>not</b> at the class load time of the outer class, | ||
502 | * but rather at the first call to {@link TooManyInputsOfTurnout#instance()}. | ||
503 | * | ||
504 | * <p> This workaround is required e.g. to support recursion. | ||
505 | * | ||
506 | */ | ||
507 | private static class LazyHolder { | ||
508 | private static final TooManyInputsOfTurnout INSTANCE = new TooManyInputsOfTurnout(); | ||
509 | |||
510 | /** | ||
511 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
512 | * This initialization order is required to support indirect recursion. | ||
513 | * | ||
514 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
515 | * | ||
516 | */ | ||
517 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
518 | |||
519 | public static Object ensureInitialized() { | ||
520 | INSTANCE.ensureInitializedInternal(); | ||
521 | return null; | ||
522 | } | ||
523 | } | ||
524 | |||
525 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
526 | private static final TooManyInputsOfTurnout.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
527 | |||
528 | private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); | ||
529 | |||
530 | private final List<PParameter> parameters = Arrays.asList(parameter_T); | ||
531 | |||
532 | private GeneratedPQuery() { | ||
533 | super(PVisibility.PUBLIC); | ||
534 | } | ||
535 | |||
536 | @Override | ||
537 | public String getFullyQualifiedName() { | ||
538 | return "modes3.queries.tooManyInputsOfTurnout"; | ||
539 | } | ||
540 | |||
541 | @Override | ||
542 | public List<String> getParameterNames() { | ||
543 | return Arrays.asList("T"); | ||
544 | } | ||
545 | |||
546 | @Override | ||
547 | public List<PParameter> getParameters() { | ||
548 | return parameters; | ||
549 | } | ||
550 | |||
551 | @Override | ||
552 | public Set<PBody> doGetContainedBodies() { | ||
553 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
554 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
555 | { | ||
556 | PBody body = new PBody(this); | ||
557 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
558 | PVariable var_I1 = body.getOrCreateVariableByName("I1"); | ||
559 | PVariable var_I2 = body.getOrCreateVariableByName("I2"); | ||
560 | PVariable var_I3 = body.getOrCreateVariableByName("I3"); | ||
561 | PVariable var_I4 = body.getOrCreateVariableByName("I4"); | ||
562 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
563 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
564 | new ExportedParameter(body, var_T, parameter_T) | ||
565 | )); | ||
566 | // find adjacent(I1, T) | ||
567 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I1, var_T), Adjacent.instance().getInternalQueryRepresentation()); | ||
568 | // find adjacent(I2, T) | ||
569 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I2, var_T), Adjacent.instance().getInternalQueryRepresentation()); | ||
570 | // find adjacent(I3, T) | ||
571 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I3, var_T), Adjacent.instance().getInternalQueryRepresentation()); | ||
572 | // find adjacent(I4, T) | ||
573 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I4, var_T), Adjacent.instance().getInternalQueryRepresentation()); | ||
574 | // I1 != I2 | ||
575 | new Inequality(body, var_I1, var_I2); | ||
576 | // I1 != I3 | ||
577 | new Inequality(body, var_I1, var_I3); | ||
578 | // I1 != I4 | ||
579 | new Inequality(body, var_I1, var_I4); | ||
580 | // I2 != I3 | ||
581 | new Inequality(body, var_I2, var_I3); | ||
582 | // I2 != I4 | ||
583 | new Inequality(body, var_I2, var_I4); | ||
584 | // I3 != I4 | ||
585 | new Inequality(body, var_I3, var_I4); | ||
586 | bodies.add(body); | ||
587 | } | ||
588 | { | ||
589 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
590 | annotation.addAttribute("message", "turnoutConnectedToBothOutputs"); | ||
591 | annotation.addAttribute("severity", "error"); | ||
592 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
593 | new ParameterReference("T") | ||
594 | })); | ||
595 | addAnnotation(annotation); | ||
596 | } | ||
597 | return bodies; | ||
598 | } | ||
599 | } | ||
600 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TrainLocations_step_2.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TrainLocations_step_2.java new file mode 100644 index 00000000..5bf153c3 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TrainLocations_step_2.java | |||
@@ -0,0 +1,564 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Train; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
37 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
38 | |||
39 | /** | ||
40 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
41 | * | ||
42 | * <p>Original source: | ||
43 | * <code><pre> | ||
44 | * // | ||
45 | * // trainLocations | ||
46 | * // | ||
47 | * | ||
48 | * pattern trainLocations_step_2(in train : Train) { | ||
49 | * // frame-{@literal >}train = model-{@literal >}trains[i0]; | ||
50 | * // frame-{@literal >}location = frame-{@literal >}train-{@literal >}location; | ||
51 | * // if (frame-{@literal >}location != NULL) { | ||
52 | * // ... | ||
53 | * // } | ||
54 | * | ||
55 | * Train(train); | ||
56 | * } | ||
57 | * </pre></code> | ||
58 | * | ||
59 | * @see Matcher | ||
60 | * @see Match | ||
61 | * | ||
62 | */ | ||
63 | @SuppressWarnings("all") | ||
64 | public final class TrainLocations_step_2 extends BaseGeneratedEMFQuerySpecification<TrainLocations_step_2.Matcher> { | ||
65 | /** | ||
66 | * Pattern-specific match representation of the modes3.queries.trainLocations_step_2 pattern, | ||
67 | * to be used in conjunction with {@link Matcher}. | ||
68 | * | ||
69 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
70 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
71 | * usable to represent a match of the pattern in the result of a query, | ||
72 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
73 | * | ||
74 | * @see Matcher | ||
75 | * | ||
76 | */ | ||
77 | public static abstract class Match extends BasePatternMatch { | ||
78 | private Train fTrain; | ||
79 | |||
80 | private static List<String> parameterNames = makeImmutableList("train"); | ||
81 | |||
82 | private Match(final Train pTrain) { | ||
83 | this.fTrain = pTrain; | ||
84 | } | ||
85 | |||
86 | @Override | ||
87 | public Object get(final String parameterName) { | ||
88 | switch(parameterName) { | ||
89 | case "train": return this.fTrain; | ||
90 | default: return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | @Override | ||
95 | public Object get(final int index) { | ||
96 | switch(index) { | ||
97 | case 0: return this.fTrain; | ||
98 | default: return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public Train getTrain() { | ||
103 | return this.fTrain; | ||
104 | } | ||
105 | |||
106 | @Override | ||
107 | public boolean set(final String parameterName, final Object newValue) { | ||
108 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
109 | if ("train".equals(parameterName) ) { | ||
110 | this.fTrain = (Train) newValue; | ||
111 | return true; | ||
112 | } | ||
113 | return false; | ||
114 | } | ||
115 | |||
116 | public void setTrain(final Train pTrain) { | ||
117 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
118 | this.fTrain = pTrain; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public String patternName() { | ||
123 | return "modes3.queries.trainLocations_step_2"; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public List<String> parameterNames() { | ||
128 | return TrainLocations_step_2.Match.parameterNames; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public Object[] toArray() { | ||
133 | return new Object[]{fTrain}; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public TrainLocations_step_2.Match toImmutable() { | ||
138 | return isMutable() ? newMatch(fTrain) : this; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public String prettyPrint() { | ||
143 | StringBuilder result = new StringBuilder(); | ||
144 | result.append("\"train\"=" + prettyPrintValue(fTrain)); | ||
145 | return result.toString(); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public int hashCode() { | ||
150 | return Objects.hash(fTrain); | ||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public boolean equals(final Object obj) { | ||
155 | if (this == obj) | ||
156 | return true; | ||
157 | if (obj == null) { | ||
158 | return false; | ||
159 | } | ||
160 | if ((obj instanceof TrainLocations_step_2.Match)) { | ||
161 | TrainLocations_step_2.Match other = (TrainLocations_step_2.Match) obj; | ||
162 | return Objects.equals(fTrain, other.fTrain); | ||
163 | } else { | ||
164 | // this should be infrequent | ||
165 | if (!(obj instanceof IPatternMatch)) { | ||
166 | return false; | ||
167 | } | ||
168 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
169 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | @Override | ||
174 | public TrainLocations_step_2 specification() { | ||
175 | return TrainLocations_step_2.instance(); | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * Returns an empty, mutable match. | ||
180 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
181 | * | ||
182 | * @return the empty match. | ||
183 | * | ||
184 | */ | ||
185 | public static TrainLocations_step_2.Match newEmptyMatch() { | ||
186 | return new Mutable(null); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * Returns a mutable (partial) match. | ||
191 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
192 | * | ||
193 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
194 | * @return the new, mutable (partial) match object. | ||
195 | * | ||
196 | */ | ||
197 | public static TrainLocations_step_2.Match newMutableMatch(final Train pTrain) { | ||
198 | return new Mutable(pTrain); | ||
199 | } | ||
200 | |||
201 | /** | ||
202 | * Returns a new (partial) match. | ||
203 | * This can be used e.g. to call the matcher with a partial match. | ||
204 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
205 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
206 | * @return the (partial) match object. | ||
207 | * | ||
208 | */ | ||
209 | public static TrainLocations_step_2.Match newMatch(final Train pTrain) { | ||
210 | return new Immutable(pTrain); | ||
211 | } | ||
212 | |||
213 | private static final class Mutable extends TrainLocations_step_2.Match { | ||
214 | Mutable(final Train pTrain) { | ||
215 | super(pTrain); | ||
216 | } | ||
217 | |||
218 | @Override | ||
219 | public boolean isMutable() { | ||
220 | return true; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | private static final class Immutable extends TrainLocations_step_2.Match { | ||
225 | Immutable(final Train pTrain) { | ||
226 | super(pTrain); | ||
227 | } | ||
228 | |||
229 | @Override | ||
230 | public boolean isMutable() { | ||
231 | return false; | ||
232 | } | ||
233 | } | ||
234 | } | ||
235 | |||
236 | /** | ||
237 | * Generated pattern matcher API of the modes3.queries.trainLocations_step_2 pattern, | ||
238 | * providing pattern-specific query methods. | ||
239 | * | ||
240 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
241 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
242 | * | ||
243 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
244 | * | ||
245 | * <p>Original source: | ||
246 | * <code><pre> | ||
247 | * // | ||
248 | * // trainLocations | ||
249 | * // | ||
250 | * | ||
251 | * pattern trainLocations_step_2(in train : Train) { | ||
252 | * // frame-{@literal >}train = model-{@literal >}trains[i0]; | ||
253 | * // frame-{@literal >}location = frame-{@literal >}train-{@literal >}location; | ||
254 | * // if (frame-{@literal >}location != NULL) { | ||
255 | * // ... | ||
256 | * // } | ||
257 | * | ||
258 | * Train(train); | ||
259 | * } | ||
260 | * </pre></code> | ||
261 | * | ||
262 | * @see Match | ||
263 | * @see TrainLocations_step_2 | ||
264 | * | ||
265 | */ | ||
266 | public static class Matcher extends BaseMatcher<TrainLocations_step_2.Match> { | ||
267 | /** | ||
268 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
269 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
270 | * | ||
271 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
272 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
273 | * | ||
274 | */ | ||
275 | public static TrainLocations_step_2.Matcher on(final ViatraQueryEngine engine) { | ||
276 | // check if matcher already exists | ||
277 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
278 | if (matcher == null) { | ||
279 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
280 | } | ||
281 | return matcher; | ||
282 | } | ||
283 | |||
284 | /** | ||
285 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
286 | * @return an initialized matcher | ||
287 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
288 | * | ||
289 | */ | ||
290 | public static TrainLocations_step_2.Matcher create() { | ||
291 | return new Matcher(); | ||
292 | } | ||
293 | |||
294 | private static final int POSITION_TRAIN = 0; | ||
295 | |||
296 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TrainLocations_step_2.Matcher.class); | ||
297 | |||
298 | /** | ||
299 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
300 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
301 | * | ||
302 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
303 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
304 | * | ||
305 | */ | ||
306 | private Matcher() { | ||
307 | super(querySpecification()); | ||
308 | } | ||
309 | |||
310 | /** | ||
311 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
312 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
313 | * @return matches represented as a Match object. | ||
314 | * | ||
315 | */ | ||
316 | public Collection<TrainLocations_step_2.Match> getAllMatches(final Train pTrain) { | ||
317 | return rawStreamAllMatches(new Object[]{pTrain}).collect(Collectors.toSet()); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
322 | * </p> | ||
323 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
324 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
325 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
326 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
327 | * @return a stream of matches represented as a Match object. | ||
328 | * | ||
329 | */ | ||
330 | public Stream<TrainLocations_step_2.Match> streamAllMatches(final Train pTrain) { | ||
331 | return rawStreamAllMatches(new Object[]{pTrain}); | ||
332 | } | ||
333 | |||
334 | /** | ||
335 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
336 | * Neither determinism nor randomness of selection is guaranteed. | ||
337 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
338 | * @return a match represented as a Match object, or null if no match is found. | ||
339 | * | ||
340 | */ | ||
341 | public Optional<TrainLocations_step_2.Match> getOneArbitraryMatch(final Train pTrain) { | ||
342 | return rawGetOneArbitraryMatch(new Object[]{pTrain}); | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
347 | * under any possible substitution of the unspecified parameters (if any). | ||
348 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
349 | * @return true if the input is a valid (partial) match of the pattern. | ||
350 | * | ||
351 | */ | ||
352 | public boolean hasMatch(final Train pTrain) { | ||
353 | return rawHasMatch(new Object[]{pTrain}); | ||
354 | } | ||
355 | |||
356 | /** | ||
357 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
358 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
359 | * @return the number of pattern matches found. | ||
360 | * | ||
361 | */ | ||
362 | public int countMatches(final Train pTrain) { | ||
363 | return rawCountMatches(new Object[]{pTrain}); | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
368 | * Neither determinism nor randomness of selection is guaranteed. | ||
369 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
370 | * @param processor the action that will process the selected match. | ||
371 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
372 | * | ||
373 | */ | ||
374 | public boolean forOneArbitraryMatch(final Train pTrain, final Consumer<? super TrainLocations_step_2.Match> processor) { | ||
375 | return rawForOneArbitraryMatch(new Object[]{pTrain}, processor); | ||
376 | } | ||
377 | |||
378 | /** | ||
379 | * Returns a new (partial) match. | ||
380 | * This can be used e.g. to call the matcher with a partial match. | ||
381 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
382 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
383 | * @return the (partial) match object. | ||
384 | * | ||
385 | */ | ||
386 | public TrainLocations_step_2.Match newMatch(final Train pTrain) { | ||
387 | return TrainLocations_step_2.Match.newMatch(pTrain); | ||
388 | } | ||
389 | |||
390 | /** | ||
391 | * Retrieve the set of values that occur in matches for train. | ||
392 | * @return the Set of all values or empty set if there are no matches | ||
393 | * | ||
394 | */ | ||
395 | protected Stream<Train> rawStreamAllValuesOftrain(final Object[] parameters) { | ||
396 | return rawStreamAllValues(POSITION_TRAIN, parameters).map(Train.class::cast); | ||
397 | } | ||
398 | |||
399 | /** | ||
400 | * Retrieve the set of values that occur in matches for train. | ||
401 | * @return the Set of all values or empty set if there are no matches | ||
402 | * | ||
403 | */ | ||
404 | public Set<Train> getAllValuesOftrain() { | ||
405 | return rawStreamAllValuesOftrain(emptyArray()).collect(Collectors.toSet()); | ||
406 | } | ||
407 | |||
408 | /** | ||
409 | * Retrieve the set of values that occur in matches for train. | ||
410 | * @return the Set of all values or empty set if there are no matches | ||
411 | * | ||
412 | */ | ||
413 | public Stream<Train> streamAllValuesOftrain() { | ||
414 | return rawStreamAllValuesOftrain(emptyArray()); | ||
415 | } | ||
416 | |||
417 | @Override | ||
418 | protected TrainLocations_step_2.Match tupleToMatch(final Tuple t) { | ||
419 | try { | ||
420 | return TrainLocations_step_2.Match.newMatch((Train) t.get(POSITION_TRAIN)); | ||
421 | } catch(ClassCastException e) { | ||
422 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
423 | return null; | ||
424 | } | ||
425 | } | ||
426 | |||
427 | @Override | ||
428 | protected TrainLocations_step_2.Match arrayToMatch(final Object[] match) { | ||
429 | try { | ||
430 | return TrainLocations_step_2.Match.newMatch((Train) match[POSITION_TRAIN]); | ||
431 | } catch(ClassCastException e) { | ||
432 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
433 | return null; | ||
434 | } | ||
435 | } | ||
436 | |||
437 | @Override | ||
438 | protected TrainLocations_step_2.Match arrayToMatchMutable(final Object[] match) { | ||
439 | try { | ||
440 | return TrainLocations_step_2.Match.newMutableMatch((Train) match[POSITION_TRAIN]); | ||
441 | } catch(ClassCastException e) { | ||
442 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
443 | return null; | ||
444 | } | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @return the singleton instance of the query specification of this pattern | ||
449 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
450 | * | ||
451 | */ | ||
452 | public static IQuerySpecification<TrainLocations_step_2.Matcher> querySpecification() { | ||
453 | return TrainLocations_step_2.instance(); | ||
454 | } | ||
455 | } | ||
456 | |||
457 | private TrainLocations_step_2() { | ||
458 | super(GeneratedPQuery.INSTANCE); | ||
459 | } | ||
460 | |||
461 | /** | ||
462 | * @return the singleton instance of the query specification | ||
463 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
464 | * | ||
465 | */ | ||
466 | public static TrainLocations_step_2 instance() { | ||
467 | try{ | ||
468 | return LazyHolder.INSTANCE; | ||
469 | } catch (ExceptionInInitializerError err) { | ||
470 | throw processInitializerError(err); | ||
471 | } | ||
472 | } | ||
473 | |||
474 | @Override | ||
475 | protected TrainLocations_step_2.Matcher instantiate(final ViatraQueryEngine engine) { | ||
476 | return TrainLocations_step_2.Matcher.on(engine); | ||
477 | } | ||
478 | |||
479 | @Override | ||
480 | public TrainLocations_step_2.Matcher instantiate() { | ||
481 | return TrainLocations_step_2.Matcher.create(); | ||
482 | } | ||
483 | |||
484 | @Override | ||
485 | public TrainLocations_step_2.Match newEmptyMatch() { | ||
486 | return TrainLocations_step_2.Match.newEmptyMatch(); | ||
487 | } | ||
488 | |||
489 | @Override | ||
490 | public TrainLocations_step_2.Match newMatch(final Object... parameters) { | ||
491 | return TrainLocations_step_2.Match.newMatch((modes3.Train) parameters[0]); | ||
492 | } | ||
493 | |||
494 | /** | ||
495 | * Inner class allowing the singleton instance of {@link TrainLocations_step_2} to be created | ||
496 | * <b>not</b> at the class load time of the outer class, | ||
497 | * but rather at the first call to {@link TrainLocations_step_2#instance()}. | ||
498 | * | ||
499 | * <p> This workaround is required e.g. to support recursion. | ||
500 | * | ||
501 | */ | ||
502 | private static class LazyHolder { | ||
503 | private static final TrainLocations_step_2 INSTANCE = new TrainLocations_step_2(); | ||
504 | |||
505 | /** | ||
506 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
507 | * This initialization order is required to support indirect recursion. | ||
508 | * | ||
509 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
510 | * | ||
511 | */ | ||
512 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
513 | |||
514 | public static Object ensureInitialized() { | ||
515 | INSTANCE.ensureInitializedInternal(); | ||
516 | return null; | ||
517 | } | ||
518 | } | ||
519 | |||
520 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
521 | private static final TrainLocations_step_2.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
522 | |||
523 | private final PParameter parameter_train = new PParameter("train", "modes3.Train", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Train")), PParameterDirection.INOUT); | ||
524 | |||
525 | private final List<PParameter> parameters = Arrays.asList(parameter_train); | ||
526 | |||
527 | private GeneratedPQuery() { | ||
528 | super(PVisibility.PUBLIC); | ||
529 | } | ||
530 | |||
531 | @Override | ||
532 | public String getFullyQualifiedName() { | ||
533 | return "modes3.queries.trainLocations_step_2"; | ||
534 | } | ||
535 | |||
536 | @Override | ||
537 | public List<String> getParameterNames() { | ||
538 | return Arrays.asList("train"); | ||
539 | } | ||
540 | |||
541 | @Override | ||
542 | public List<PParameter> getParameters() { | ||
543 | return parameters; | ||
544 | } | ||
545 | |||
546 | @Override | ||
547 | public Set<PBody> doGetContainedBodies() { | ||
548 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
549 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
550 | { | ||
551 | PBody body = new PBody(this); | ||
552 | PVariable var_train = body.getOrCreateVariableByName("train"); | ||
553 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
554 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
555 | new ExportedParameter(body, var_train, parameter_train) | ||
556 | )); | ||
557 | // // frame->train = model->trains[i0];// frame->location = frame->train->location;// if (frame->location != NULL) {// ...// } Train(train) | ||
558 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
559 | bodies.add(body); | ||
560 | } | ||
561 | return bodies; | ||
562 | } | ||
563 | } | ||
564 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TrainLocations_step_3.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TrainLocations_step_3.java new file mode 100644 index 00000000..edbd4af3 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TrainLocations_step_3.java | |||
@@ -0,0 +1,713 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.Train; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern trainLocations_step_3(in train : Train, in location : Segment) { | ||
48 | * // results-{@literal >}matches[match_cntr].location = frame-{@literal >}location; | ||
49 | * // results-{@literal >}matches[match_cntr++].train = frame-{@literal >}train; | ||
50 | * Train(train); | ||
51 | * Train.location(train, location); | ||
52 | * } | ||
53 | * </pre></code> | ||
54 | * | ||
55 | * @see Matcher | ||
56 | * @see Match | ||
57 | * | ||
58 | */ | ||
59 | @SuppressWarnings("all") | ||
60 | public final class TrainLocations_step_3 extends BaseGeneratedEMFQuerySpecification<TrainLocations_step_3.Matcher> { | ||
61 | /** | ||
62 | * Pattern-specific match representation of the modes3.queries.trainLocations_step_3 pattern, | ||
63 | * to be used in conjunction with {@link Matcher}. | ||
64 | * | ||
65 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
66 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
67 | * usable to represent a match of the pattern in the result of a query, | ||
68 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
69 | * | ||
70 | * @see Matcher | ||
71 | * | ||
72 | */ | ||
73 | public static abstract class Match extends BasePatternMatch { | ||
74 | private Train fTrain; | ||
75 | |||
76 | private Segment fLocation; | ||
77 | |||
78 | private static List<String> parameterNames = makeImmutableList("train", "location"); | ||
79 | |||
80 | private Match(final Train pTrain, final Segment pLocation) { | ||
81 | this.fTrain = pTrain; | ||
82 | this.fLocation = pLocation; | ||
83 | } | ||
84 | |||
85 | @Override | ||
86 | public Object get(final String parameterName) { | ||
87 | switch(parameterName) { | ||
88 | case "train": return this.fTrain; | ||
89 | case "location": return this.fLocation; | ||
90 | default: return null; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | @Override | ||
95 | public Object get(final int index) { | ||
96 | switch(index) { | ||
97 | case 0: return this.fTrain; | ||
98 | case 1: return this.fLocation; | ||
99 | default: return null; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | public Train getTrain() { | ||
104 | return this.fTrain; | ||
105 | } | ||
106 | |||
107 | public Segment getLocation() { | ||
108 | return this.fLocation; | ||
109 | } | ||
110 | |||
111 | @Override | ||
112 | public boolean set(final String parameterName, final Object newValue) { | ||
113 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
114 | if ("train".equals(parameterName) ) { | ||
115 | this.fTrain = (Train) newValue; | ||
116 | return true; | ||
117 | } | ||
118 | if ("location".equals(parameterName) ) { | ||
119 | this.fLocation = (Segment) newValue; | ||
120 | return true; | ||
121 | } | ||
122 | return false; | ||
123 | } | ||
124 | |||
125 | public void setTrain(final Train pTrain) { | ||
126 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
127 | this.fTrain = pTrain; | ||
128 | } | ||
129 | |||
130 | public void setLocation(final Segment pLocation) { | ||
131 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
132 | this.fLocation = pLocation; | ||
133 | } | ||
134 | |||
135 | @Override | ||
136 | public String patternName() { | ||
137 | return "modes3.queries.trainLocations_step_3"; | ||
138 | } | ||
139 | |||
140 | @Override | ||
141 | public List<String> parameterNames() { | ||
142 | return TrainLocations_step_3.Match.parameterNames; | ||
143 | } | ||
144 | |||
145 | @Override | ||
146 | public Object[] toArray() { | ||
147 | return new Object[]{fTrain, fLocation}; | ||
148 | } | ||
149 | |||
150 | @Override | ||
151 | public TrainLocations_step_3.Match toImmutable() { | ||
152 | return isMutable() ? newMatch(fTrain, fLocation) : this; | ||
153 | } | ||
154 | |||
155 | @Override | ||
156 | public String prettyPrint() { | ||
157 | StringBuilder result = new StringBuilder(); | ||
158 | result.append("\"train\"=" + prettyPrintValue(fTrain) + ", "); | ||
159 | result.append("\"location\"=" + prettyPrintValue(fLocation)); | ||
160 | return result.toString(); | ||
161 | } | ||
162 | |||
163 | @Override | ||
164 | public int hashCode() { | ||
165 | return Objects.hash(fTrain, fLocation); | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public boolean equals(final Object obj) { | ||
170 | if (this == obj) | ||
171 | return true; | ||
172 | if (obj == null) { | ||
173 | return false; | ||
174 | } | ||
175 | if ((obj instanceof TrainLocations_step_3.Match)) { | ||
176 | TrainLocations_step_3.Match other = (TrainLocations_step_3.Match) obj; | ||
177 | return Objects.equals(fTrain, other.fTrain) && Objects.equals(fLocation, other.fLocation); | ||
178 | } else { | ||
179 | // this should be infrequent | ||
180 | if (!(obj instanceof IPatternMatch)) { | ||
181 | return false; | ||
182 | } | ||
183 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
184 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
185 | } | ||
186 | } | ||
187 | |||
188 | @Override | ||
189 | public TrainLocations_step_3 specification() { | ||
190 | return TrainLocations_step_3.instance(); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * Returns an empty, mutable match. | ||
195 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
196 | * | ||
197 | * @return the empty match. | ||
198 | * | ||
199 | */ | ||
200 | public static TrainLocations_step_3.Match newEmptyMatch() { | ||
201 | return new Mutable(null, null); | ||
202 | } | ||
203 | |||
204 | /** | ||
205 | * Returns a mutable (partial) match. | ||
206 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
207 | * | ||
208 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
209 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
210 | * @return the new, mutable (partial) match object. | ||
211 | * | ||
212 | */ | ||
213 | public static TrainLocations_step_3.Match newMutableMatch(final Train pTrain, final Segment pLocation) { | ||
214 | return new Mutable(pTrain, pLocation); | ||
215 | } | ||
216 | |||
217 | /** | ||
218 | * Returns a new (partial) match. | ||
219 | * This can be used e.g. to call the matcher with a partial match. | ||
220 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
221 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
222 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
223 | * @return the (partial) match object. | ||
224 | * | ||
225 | */ | ||
226 | public static TrainLocations_step_3.Match newMatch(final Train pTrain, final Segment pLocation) { | ||
227 | return new Immutable(pTrain, pLocation); | ||
228 | } | ||
229 | |||
230 | private static final class Mutable extends TrainLocations_step_3.Match { | ||
231 | Mutable(final Train pTrain, final Segment pLocation) { | ||
232 | super(pTrain, pLocation); | ||
233 | } | ||
234 | |||
235 | @Override | ||
236 | public boolean isMutable() { | ||
237 | return true; | ||
238 | } | ||
239 | } | ||
240 | |||
241 | private static final class Immutable extends TrainLocations_step_3.Match { | ||
242 | Immutable(final Train pTrain, final Segment pLocation) { | ||
243 | super(pTrain, pLocation); | ||
244 | } | ||
245 | |||
246 | @Override | ||
247 | public boolean isMutable() { | ||
248 | return false; | ||
249 | } | ||
250 | } | ||
251 | } | ||
252 | |||
253 | /** | ||
254 | * Generated pattern matcher API of the modes3.queries.trainLocations_step_3 pattern, | ||
255 | * providing pattern-specific query methods. | ||
256 | * | ||
257 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
258 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
259 | * | ||
260 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
261 | * | ||
262 | * <p>Original source: | ||
263 | * <code><pre> | ||
264 | * pattern trainLocations_step_3(in train : Train, in location : Segment) { | ||
265 | * // results-{@literal >}matches[match_cntr].location = frame-{@literal >}location; | ||
266 | * // results-{@literal >}matches[match_cntr++].train = frame-{@literal >}train; | ||
267 | * Train(train); | ||
268 | * Train.location(train, location); | ||
269 | * } | ||
270 | * </pre></code> | ||
271 | * | ||
272 | * @see Match | ||
273 | * @see TrainLocations_step_3 | ||
274 | * | ||
275 | */ | ||
276 | public static class Matcher extends BaseMatcher<TrainLocations_step_3.Match> { | ||
277 | /** | ||
278 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
279 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
280 | * | ||
281 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
282 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
283 | * | ||
284 | */ | ||
285 | public static TrainLocations_step_3.Matcher on(final ViatraQueryEngine engine) { | ||
286 | // check if matcher already exists | ||
287 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
288 | if (matcher == null) { | ||
289 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
290 | } | ||
291 | return matcher; | ||
292 | } | ||
293 | |||
294 | /** | ||
295 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
296 | * @return an initialized matcher | ||
297 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
298 | * | ||
299 | */ | ||
300 | public static TrainLocations_step_3.Matcher create() { | ||
301 | return new Matcher(); | ||
302 | } | ||
303 | |||
304 | private static final int POSITION_TRAIN = 0; | ||
305 | |||
306 | private static final int POSITION_LOCATION = 1; | ||
307 | |||
308 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TrainLocations_step_3.Matcher.class); | ||
309 | |||
310 | /** | ||
311 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
312 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
313 | * | ||
314 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
315 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
316 | * | ||
317 | */ | ||
318 | private Matcher() { | ||
319 | super(querySpecification()); | ||
320 | } | ||
321 | |||
322 | /** | ||
323 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
324 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
325 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
326 | * @return matches represented as a Match object. | ||
327 | * | ||
328 | */ | ||
329 | public Collection<TrainLocations_step_3.Match> getAllMatches(final Train pTrain, final Segment pLocation) { | ||
330 | return rawStreamAllMatches(new Object[]{pTrain, pLocation}).collect(Collectors.toSet()); | ||
331 | } | ||
332 | |||
333 | /** | ||
334 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
335 | * </p> | ||
336 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
337 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
338 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
339 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
340 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
341 | * @return a stream of matches represented as a Match object. | ||
342 | * | ||
343 | */ | ||
344 | public Stream<TrainLocations_step_3.Match> streamAllMatches(final Train pTrain, final Segment pLocation) { | ||
345 | return rawStreamAllMatches(new Object[]{pTrain, pLocation}); | ||
346 | } | ||
347 | |||
348 | /** | ||
349 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
350 | * Neither determinism nor randomness of selection is guaranteed. | ||
351 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
352 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
353 | * @return a match represented as a Match object, or null if no match is found. | ||
354 | * | ||
355 | */ | ||
356 | public Optional<TrainLocations_step_3.Match> getOneArbitraryMatch(final Train pTrain, final Segment pLocation) { | ||
357 | return rawGetOneArbitraryMatch(new Object[]{pTrain, pLocation}); | ||
358 | } | ||
359 | |||
360 | /** | ||
361 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
362 | * under any possible substitution of the unspecified parameters (if any). | ||
363 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
364 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
365 | * @return true if the input is a valid (partial) match of the pattern. | ||
366 | * | ||
367 | */ | ||
368 | public boolean hasMatch(final Train pTrain, final Segment pLocation) { | ||
369 | return rawHasMatch(new Object[]{pTrain, pLocation}); | ||
370 | } | ||
371 | |||
372 | /** | ||
373 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
374 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
375 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
376 | * @return the number of pattern matches found. | ||
377 | * | ||
378 | */ | ||
379 | public int countMatches(final Train pTrain, final Segment pLocation) { | ||
380 | return rawCountMatches(new Object[]{pTrain, pLocation}); | ||
381 | } | ||
382 | |||
383 | /** | ||
384 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
385 | * Neither determinism nor randomness of selection is guaranteed. | ||
386 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
387 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
388 | * @param processor the action that will process the selected match. | ||
389 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
390 | * | ||
391 | */ | ||
392 | public boolean forOneArbitraryMatch(final Train pTrain, final Segment pLocation, final Consumer<? super TrainLocations_step_3.Match> processor) { | ||
393 | return rawForOneArbitraryMatch(new Object[]{pTrain, pLocation}, processor); | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * Returns a new (partial) match. | ||
398 | * This can be used e.g. to call the matcher with a partial match. | ||
399 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
400 | * @param pTrain the fixed value of pattern parameter train, or null if not bound. | ||
401 | * @param pLocation the fixed value of pattern parameter location, or null if not bound. | ||
402 | * @return the (partial) match object. | ||
403 | * | ||
404 | */ | ||
405 | public TrainLocations_step_3.Match newMatch(final Train pTrain, final Segment pLocation) { | ||
406 | return TrainLocations_step_3.Match.newMatch(pTrain, pLocation); | ||
407 | } | ||
408 | |||
409 | /** | ||
410 | * Retrieve the set of values that occur in matches for train. | ||
411 | * @return the Set of all values or empty set if there are no matches | ||
412 | * | ||
413 | */ | ||
414 | protected Stream<Train> rawStreamAllValuesOftrain(final Object[] parameters) { | ||
415 | return rawStreamAllValues(POSITION_TRAIN, parameters).map(Train.class::cast); | ||
416 | } | ||
417 | |||
418 | /** | ||
419 | * Retrieve the set of values that occur in matches for train. | ||
420 | * @return the Set of all values or empty set if there are no matches | ||
421 | * | ||
422 | */ | ||
423 | public Set<Train> getAllValuesOftrain() { | ||
424 | return rawStreamAllValuesOftrain(emptyArray()).collect(Collectors.toSet()); | ||
425 | } | ||
426 | |||
427 | /** | ||
428 | * Retrieve the set of values that occur in matches for train. | ||
429 | * @return the Set of all values or empty set if there are no matches | ||
430 | * | ||
431 | */ | ||
432 | public Stream<Train> streamAllValuesOftrain() { | ||
433 | return rawStreamAllValuesOftrain(emptyArray()); | ||
434 | } | ||
435 | |||
436 | /** | ||
437 | * Retrieve the set of values that occur in matches for train. | ||
438 | * </p> | ||
439 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
440 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
441 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
442 | * | ||
443 | * @return the Stream of all values or empty set if there are no matches | ||
444 | * | ||
445 | */ | ||
446 | public Stream<Train> streamAllValuesOftrain(final TrainLocations_step_3.Match partialMatch) { | ||
447 | return rawStreamAllValuesOftrain(partialMatch.toArray()); | ||
448 | } | ||
449 | |||
450 | /** | ||
451 | * Retrieve the set of values that occur in matches for train. | ||
452 | * </p> | ||
453 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
454 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
455 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
456 | * | ||
457 | * @return the Stream of all values or empty set if there are no matches | ||
458 | * | ||
459 | */ | ||
460 | public Stream<Train> streamAllValuesOftrain(final Segment pLocation) { | ||
461 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation}); | ||
462 | } | ||
463 | |||
464 | /** | ||
465 | * Retrieve the set of values that occur in matches for train. | ||
466 | * @return the Set of all values or empty set if there are no matches | ||
467 | * | ||
468 | */ | ||
469 | public Set<Train> getAllValuesOftrain(final TrainLocations_step_3.Match partialMatch) { | ||
470 | return rawStreamAllValuesOftrain(partialMatch.toArray()).collect(Collectors.toSet()); | ||
471 | } | ||
472 | |||
473 | /** | ||
474 | * Retrieve the set of values that occur in matches for train. | ||
475 | * @return the Set of all values or empty set if there are no matches | ||
476 | * | ||
477 | */ | ||
478 | public Set<Train> getAllValuesOftrain(final Segment pLocation) { | ||
479 | return rawStreamAllValuesOftrain(new Object[]{null, pLocation}).collect(Collectors.toSet()); | ||
480 | } | ||
481 | |||
482 | /** | ||
483 | * Retrieve the set of values that occur in matches for location. | ||
484 | * @return the Set of all values or empty set if there are no matches | ||
485 | * | ||
486 | */ | ||
487 | protected Stream<Segment> rawStreamAllValuesOflocation(final Object[] parameters) { | ||
488 | return rawStreamAllValues(POSITION_LOCATION, parameters).map(Segment.class::cast); | ||
489 | } | ||
490 | |||
491 | /** | ||
492 | * Retrieve the set of values that occur in matches for location. | ||
493 | * @return the Set of all values or empty set if there are no matches | ||
494 | * | ||
495 | */ | ||
496 | public Set<Segment> getAllValuesOflocation() { | ||
497 | return rawStreamAllValuesOflocation(emptyArray()).collect(Collectors.toSet()); | ||
498 | } | ||
499 | |||
500 | /** | ||
501 | * Retrieve the set of values that occur in matches for location. | ||
502 | * @return the Set of all values or empty set if there are no matches | ||
503 | * | ||
504 | */ | ||
505 | public Stream<Segment> streamAllValuesOflocation() { | ||
506 | return rawStreamAllValuesOflocation(emptyArray()); | ||
507 | } | ||
508 | |||
509 | /** | ||
510 | * Retrieve the set of values that occur in matches for location. | ||
511 | * </p> | ||
512 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
513 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
514 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
515 | * | ||
516 | * @return the Stream of all values or empty set if there are no matches | ||
517 | * | ||
518 | */ | ||
519 | public Stream<Segment> streamAllValuesOflocation(final TrainLocations_step_3.Match partialMatch) { | ||
520 | return rawStreamAllValuesOflocation(partialMatch.toArray()); | ||
521 | } | ||
522 | |||
523 | /** | ||
524 | * Retrieve the set of values that occur in matches for location. | ||
525 | * </p> | ||
526 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
527 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
528 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
529 | * | ||
530 | * @return the Stream of all values or empty set if there are no matches | ||
531 | * | ||
532 | */ | ||
533 | public Stream<Segment> streamAllValuesOflocation(final Train pTrain) { | ||
534 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null}); | ||
535 | } | ||
536 | |||
537 | /** | ||
538 | * Retrieve the set of values that occur in matches for location. | ||
539 | * @return the Set of all values or empty set if there are no matches | ||
540 | * | ||
541 | */ | ||
542 | public Set<Segment> getAllValuesOflocation(final TrainLocations_step_3.Match partialMatch) { | ||
543 | return rawStreamAllValuesOflocation(partialMatch.toArray()).collect(Collectors.toSet()); | ||
544 | } | ||
545 | |||
546 | /** | ||
547 | * Retrieve the set of values that occur in matches for location. | ||
548 | * @return the Set of all values or empty set if there are no matches | ||
549 | * | ||
550 | */ | ||
551 | public Set<Segment> getAllValuesOflocation(final Train pTrain) { | ||
552 | return rawStreamAllValuesOflocation(new Object[]{pTrain, null}).collect(Collectors.toSet()); | ||
553 | } | ||
554 | |||
555 | @Override | ||
556 | protected TrainLocations_step_3.Match tupleToMatch(final Tuple t) { | ||
557 | try { | ||
558 | return TrainLocations_step_3.Match.newMatch((Train) t.get(POSITION_TRAIN), (Segment) t.get(POSITION_LOCATION)); | ||
559 | } catch(ClassCastException e) { | ||
560 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
561 | return null; | ||
562 | } | ||
563 | } | ||
564 | |||
565 | @Override | ||
566 | protected TrainLocations_step_3.Match arrayToMatch(final Object[] match) { | ||
567 | try { | ||
568 | return TrainLocations_step_3.Match.newMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION]); | ||
569 | } catch(ClassCastException e) { | ||
570 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
571 | return null; | ||
572 | } | ||
573 | } | ||
574 | |||
575 | @Override | ||
576 | protected TrainLocations_step_3.Match arrayToMatchMutable(final Object[] match) { | ||
577 | try { | ||
578 | return TrainLocations_step_3.Match.newMutableMatch((Train) match[POSITION_TRAIN], (Segment) match[POSITION_LOCATION]); | ||
579 | } catch(ClassCastException e) { | ||
580 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
581 | return null; | ||
582 | } | ||
583 | } | ||
584 | |||
585 | /** | ||
586 | * @return the singleton instance of the query specification of this pattern | ||
587 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
588 | * | ||
589 | */ | ||
590 | public static IQuerySpecification<TrainLocations_step_3.Matcher> querySpecification() { | ||
591 | return TrainLocations_step_3.instance(); | ||
592 | } | ||
593 | } | ||
594 | |||
595 | private TrainLocations_step_3() { | ||
596 | super(GeneratedPQuery.INSTANCE); | ||
597 | } | ||
598 | |||
599 | /** | ||
600 | * @return the singleton instance of the query specification | ||
601 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
602 | * | ||
603 | */ | ||
604 | public static TrainLocations_step_3 instance() { | ||
605 | try{ | ||
606 | return LazyHolder.INSTANCE; | ||
607 | } catch (ExceptionInInitializerError err) { | ||
608 | throw processInitializerError(err); | ||
609 | } | ||
610 | } | ||
611 | |||
612 | @Override | ||
613 | protected TrainLocations_step_3.Matcher instantiate(final ViatraQueryEngine engine) { | ||
614 | return TrainLocations_step_3.Matcher.on(engine); | ||
615 | } | ||
616 | |||
617 | @Override | ||
618 | public TrainLocations_step_3.Matcher instantiate() { | ||
619 | return TrainLocations_step_3.Matcher.create(); | ||
620 | } | ||
621 | |||
622 | @Override | ||
623 | public TrainLocations_step_3.Match newEmptyMatch() { | ||
624 | return TrainLocations_step_3.Match.newEmptyMatch(); | ||
625 | } | ||
626 | |||
627 | @Override | ||
628 | public TrainLocations_step_3.Match newMatch(final Object... parameters) { | ||
629 | return TrainLocations_step_3.Match.newMatch((modes3.Train) parameters[0], (modes3.Segment) parameters[1]); | ||
630 | } | ||
631 | |||
632 | /** | ||
633 | * Inner class allowing the singleton instance of {@link TrainLocations_step_3} to be created | ||
634 | * <b>not</b> at the class load time of the outer class, | ||
635 | * but rather at the first call to {@link TrainLocations_step_3#instance()}. | ||
636 | * | ||
637 | * <p> This workaround is required e.g. to support recursion. | ||
638 | * | ||
639 | */ | ||
640 | private static class LazyHolder { | ||
641 | private static final TrainLocations_step_3 INSTANCE = new TrainLocations_step_3(); | ||
642 | |||
643 | /** | ||
644 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
645 | * This initialization order is required to support indirect recursion. | ||
646 | * | ||
647 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
648 | * | ||
649 | */ | ||
650 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
651 | |||
652 | public static Object ensureInitialized() { | ||
653 | INSTANCE.ensureInitializedInternal(); | ||
654 | return null; | ||
655 | } | ||
656 | } | ||
657 | |||
658 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
659 | private static final TrainLocations_step_3.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
660 | |||
661 | private final PParameter parameter_train = new PParameter("train", "modes3.Train", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Train")), PParameterDirection.INOUT); | ||
662 | |||
663 | private final PParameter parameter_location = new PParameter("location", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
664 | |||
665 | private final List<PParameter> parameters = Arrays.asList(parameter_train, parameter_location); | ||
666 | |||
667 | private GeneratedPQuery() { | ||
668 | super(PVisibility.PUBLIC); | ||
669 | } | ||
670 | |||
671 | @Override | ||
672 | public String getFullyQualifiedName() { | ||
673 | return "modes3.queries.trainLocations_step_3"; | ||
674 | } | ||
675 | |||
676 | @Override | ||
677 | public List<String> getParameterNames() { | ||
678 | return Arrays.asList("train","location"); | ||
679 | } | ||
680 | |||
681 | @Override | ||
682 | public List<PParameter> getParameters() { | ||
683 | return parameters; | ||
684 | } | ||
685 | |||
686 | @Override | ||
687 | public Set<PBody> doGetContainedBodies() { | ||
688 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
689 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
690 | { | ||
691 | PBody body = new PBody(this); | ||
692 | PVariable var_train = body.getOrCreateVariableByName("train"); | ||
693 | PVariable var_location = body.getOrCreateVariableByName("location"); | ||
694 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
695 | new TypeConstraint(body, Tuples.flatTupleOf(var_location), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
696 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
697 | new ExportedParameter(body, var_train, parameter_train), | ||
698 | new ExportedParameter(body, var_location, parameter_location) | ||
699 | )); | ||
700 | // // results->matches[match_cntr].location = frame->location;// results->matches[match_cntr++].train = frame->train; Train(train) | ||
701 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
702 | // Train.location(train, location) | ||
703 | new TypeConstraint(body, Tuples.flatTupleOf(var_train), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train"))); | ||
704 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
705 | new TypeConstraint(body, Tuples.flatTupleOf(var_train, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Train", "location"))); | ||
706 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
707 | new Equality(body, var__virtual_0_, var_location); | ||
708 | bodies.add(body); | ||
709 | } | ||
710 | return bodies; | ||
711 | } | ||
712 | } | ||
713 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutConnectedToBothOutputs.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutConnectedToBothOutputs.java new file mode 100644 index 00000000..674bb275 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutConnectedToBothOutputs.java | |||
@@ -0,0 +1,589 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Turnout; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * {@literal @}Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) | ||
49 | * pattern turnoutConnectedToBothOutputs(T : Turnout) { | ||
50 | * Turnout.straight(T, Straight); | ||
51 | * Turnout.divergent(T, Divergent); | ||
52 | * Segment.connectedTo(T, Straight); | ||
53 | * Segment.connectedTo(T, Divergent); | ||
54 | * } | ||
55 | * </pre></code> | ||
56 | * | ||
57 | * @see Matcher | ||
58 | * @see Match | ||
59 | * | ||
60 | */ | ||
61 | @SuppressWarnings("all") | ||
62 | public final class TurnoutConnectedToBothOutputs extends BaseGeneratedEMFQuerySpecification<TurnoutConnectedToBothOutputs.Matcher> { | ||
63 | /** | ||
64 | * Pattern-specific match representation of the modes3.queries.turnoutConnectedToBothOutputs pattern, | ||
65 | * to be used in conjunction with {@link Matcher}. | ||
66 | * | ||
67 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
68 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
69 | * usable to represent a match of the pattern in the result of a query, | ||
70 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
71 | * | ||
72 | * @see Matcher | ||
73 | * | ||
74 | */ | ||
75 | public static abstract class Match extends BasePatternMatch { | ||
76 | private Turnout fT; | ||
77 | |||
78 | private static List<String> parameterNames = makeImmutableList("T"); | ||
79 | |||
80 | private Match(final Turnout pT) { | ||
81 | this.fT = pT; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | switch(parameterName) { | ||
87 | case "T": return this.fT; | ||
88 | default: return null; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | @Override | ||
93 | public Object get(final int index) { | ||
94 | switch(index) { | ||
95 | case 0: return this.fT; | ||
96 | default: return null; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | public Turnout getT() { | ||
101 | return this.fT; | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public boolean set(final String parameterName, final Object newValue) { | ||
106 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
107 | if ("T".equals(parameterName) ) { | ||
108 | this.fT = (Turnout) newValue; | ||
109 | return true; | ||
110 | } | ||
111 | return false; | ||
112 | } | ||
113 | |||
114 | public void setT(final Turnout pT) { | ||
115 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
116 | this.fT = pT; | ||
117 | } | ||
118 | |||
119 | @Override | ||
120 | public String patternName() { | ||
121 | return "modes3.queries.turnoutConnectedToBothOutputs"; | ||
122 | } | ||
123 | |||
124 | @Override | ||
125 | public List<String> parameterNames() { | ||
126 | return TurnoutConnectedToBothOutputs.Match.parameterNames; | ||
127 | } | ||
128 | |||
129 | @Override | ||
130 | public Object[] toArray() { | ||
131 | return new Object[]{fT}; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public TurnoutConnectedToBothOutputs.Match toImmutable() { | ||
136 | return isMutable() ? newMatch(fT) : this; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public String prettyPrint() { | ||
141 | StringBuilder result = new StringBuilder(); | ||
142 | result.append("\"T\"=" + prettyPrintValue(fT)); | ||
143 | return result.toString(); | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public int hashCode() { | ||
148 | return Objects.hash(fT); | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public boolean equals(final Object obj) { | ||
153 | if (this == obj) | ||
154 | return true; | ||
155 | if (obj == null) { | ||
156 | return false; | ||
157 | } | ||
158 | if ((obj instanceof TurnoutConnectedToBothOutputs.Match)) { | ||
159 | TurnoutConnectedToBothOutputs.Match other = (TurnoutConnectedToBothOutputs.Match) obj; | ||
160 | return Objects.equals(fT, other.fT); | ||
161 | } else { | ||
162 | // this should be infrequent | ||
163 | if (!(obj instanceof IPatternMatch)) { | ||
164 | return false; | ||
165 | } | ||
166 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
167 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
168 | } | ||
169 | } | ||
170 | |||
171 | @Override | ||
172 | public TurnoutConnectedToBothOutputs specification() { | ||
173 | return TurnoutConnectedToBothOutputs.instance(); | ||
174 | } | ||
175 | |||
176 | /** | ||
177 | * Returns an empty, mutable match. | ||
178 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
179 | * | ||
180 | * @return the empty match. | ||
181 | * | ||
182 | */ | ||
183 | public static TurnoutConnectedToBothOutputs.Match newEmptyMatch() { | ||
184 | return new Mutable(null); | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * Returns a mutable (partial) match. | ||
189 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
190 | * | ||
191 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
192 | * @return the new, mutable (partial) match object. | ||
193 | * | ||
194 | */ | ||
195 | public static TurnoutConnectedToBothOutputs.Match newMutableMatch(final Turnout pT) { | ||
196 | return new Mutable(pT); | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * Returns a new (partial) match. | ||
201 | * This can be used e.g. to call the matcher with a partial match. | ||
202 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
203 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
204 | * @return the (partial) match object. | ||
205 | * | ||
206 | */ | ||
207 | public static TurnoutConnectedToBothOutputs.Match newMatch(final Turnout pT) { | ||
208 | return new Immutable(pT); | ||
209 | } | ||
210 | |||
211 | private static final class Mutable extends TurnoutConnectedToBothOutputs.Match { | ||
212 | Mutable(final Turnout pT) { | ||
213 | super(pT); | ||
214 | } | ||
215 | |||
216 | @Override | ||
217 | public boolean isMutable() { | ||
218 | return true; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | private static final class Immutable extends TurnoutConnectedToBothOutputs.Match { | ||
223 | Immutable(final Turnout pT) { | ||
224 | super(pT); | ||
225 | } | ||
226 | |||
227 | @Override | ||
228 | public boolean isMutable() { | ||
229 | return false; | ||
230 | } | ||
231 | } | ||
232 | } | ||
233 | |||
234 | /** | ||
235 | * Generated pattern matcher API of the modes3.queries.turnoutConnectedToBothOutputs pattern, | ||
236 | * providing pattern-specific query methods. | ||
237 | * | ||
238 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
239 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
240 | * | ||
241 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
242 | * | ||
243 | * <p>Original source: | ||
244 | * <code><pre> | ||
245 | * {@literal @}Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) | ||
246 | * pattern turnoutConnectedToBothOutputs(T : Turnout) { | ||
247 | * Turnout.straight(T, Straight); | ||
248 | * Turnout.divergent(T, Divergent); | ||
249 | * Segment.connectedTo(T, Straight); | ||
250 | * Segment.connectedTo(T, Divergent); | ||
251 | * } | ||
252 | * </pre></code> | ||
253 | * | ||
254 | * @see Match | ||
255 | * @see TurnoutConnectedToBothOutputs | ||
256 | * | ||
257 | */ | ||
258 | public static class Matcher extends BaseMatcher<TurnoutConnectedToBothOutputs.Match> { | ||
259 | /** | ||
260 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
261 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
262 | * | ||
263 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
264 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
265 | * | ||
266 | */ | ||
267 | public static TurnoutConnectedToBothOutputs.Matcher on(final ViatraQueryEngine engine) { | ||
268 | // check if matcher already exists | ||
269 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
270 | if (matcher == null) { | ||
271 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
272 | } | ||
273 | return matcher; | ||
274 | } | ||
275 | |||
276 | /** | ||
277 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
278 | * @return an initialized matcher | ||
279 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
280 | * | ||
281 | */ | ||
282 | public static TurnoutConnectedToBothOutputs.Matcher create() { | ||
283 | return new Matcher(); | ||
284 | } | ||
285 | |||
286 | private static final int POSITION_T = 0; | ||
287 | |||
288 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TurnoutConnectedToBothOutputs.Matcher.class); | ||
289 | |||
290 | /** | ||
291 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
292 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
293 | * | ||
294 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
295 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
296 | * | ||
297 | */ | ||
298 | private Matcher() { | ||
299 | super(querySpecification()); | ||
300 | } | ||
301 | |||
302 | /** | ||
303 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
304 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
305 | * @return matches represented as a Match object. | ||
306 | * | ||
307 | */ | ||
308 | public Collection<TurnoutConnectedToBothOutputs.Match> getAllMatches(final Turnout pT) { | ||
309 | return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); | ||
310 | } | ||
311 | |||
312 | /** | ||
313 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
314 | * </p> | ||
315 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
316 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
317 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
318 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
319 | * @return a stream of matches represented as a Match object. | ||
320 | * | ||
321 | */ | ||
322 | public Stream<TurnoutConnectedToBothOutputs.Match> streamAllMatches(final Turnout pT) { | ||
323 | return rawStreamAllMatches(new Object[]{pT}); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
328 | * Neither determinism nor randomness of selection is guaranteed. | ||
329 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
330 | * @return a match represented as a Match object, or null if no match is found. | ||
331 | * | ||
332 | */ | ||
333 | public Optional<TurnoutConnectedToBothOutputs.Match> getOneArbitraryMatch(final Turnout pT) { | ||
334 | return rawGetOneArbitraryMatch(new Object[]{pT}); | ||
335 | } | ||
336 | |||
337 | /** | ||
338 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
339 | * under any possible substitution of the unspecified parameters (if any). | ||
340 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
341 | * @return true if the input is a valid (partial) match of the pattern. | ||
342 | * | ||
343 | */ | ||
344 | public boolean hasMatch(final Turnout pT) { | ||
345 | return rawHasMatch(new Object[]{pT}); | ||
346 | } | ||
347 | |||
348 | /** | ||
349 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
350 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
351 | * @return the number of pattern matches found. | ||
352 | * | ||
353 | */ | ||
354 | public int countMatches(final Turnout pT) { | ||
355 | return rawCountMatches(new Object[]{pT}); | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
360 | * Neither determinism nor randomness of selection is guaranteed. | ||
361 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
362 | * @param processor the action that will process the selected match. | ||
363 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
364 | * | ||
365 | */ | ||
366 | public boolean forOneArbitraryMatch(final Turnout pT, final Consumer<? super TurnoutConnectedToBothOutputs.Match> processor) { | ||
367 | return rawForOneArbitraryMatch(new Object[]{pT}, processor); | ||
368 | } | ||
369 | |||
370 | /** | ||
371 | * Returns a new (partial) match. | ||
372 | * This can be used e.g. to call the matcher with a partial match. | ||
373 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
374 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
375 | * @return the (partial) match object. | ||
376 | * | ||
377 | */ | ||
378 | public TurnoutConnectedToBothOutputs.Match newMatch(final Turnout pT) { | ||
379 | return TurnoutConnectedToBothOutputs.Match.newMatch(pT); | ||
380 | } | ||
381 | |||
382 | /** | ||
383 | * Retrieve the set of values that occur in matches for T. | ||
384 | * @return the Set of all values or empty set if there are no matches | ||
385 | * | ||
386 | */ | ||
387 | protected Stream<Turnout> rawStreamAllValuesOfT(final Object[] parameters) { | ||
388 | return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); | ||
389 | } | ||
390 | |||
391 | /** | ||
392 | * Retrieve the set of values that occur in matches for T. | ||
393 | * @return the Set of all values or empty set if there are no matches | ||
394 | * | ||
395 | */ | ||
396 | public Set<Turnout> getAllValuesOfT() { | ||
397 | return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); | ||
398 | } | ||
399 | |||
400 | /** | ||
401 | * Retrieve the set of values that occur in matches for T. | ||
402 | * @return the Set of all values or empty set if there are no matches | ||
403 | * | ||
404 | */ | ||
405 | public Stream<Turnout> streamAllValuesOfT() { | ||
406 | return rawStreamAllValuesOfT(emptyArray()); | ||
407 | } | ||
408 | |||
409 | @Override | ||
410 | protected TurnoutConnectedToBothOutputs.Match tupleToMatch(final Tuple t) { | ||
411 | try { | ||
412 | return TurnoutConnectedToBothOutputs.Match.newMatch((Turnout) t.get(POSITION_T)); | ||
413 | } catch(ClassCastException e) { | ||
414 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
415 | return null; | ||
416 | } | ||
417 | } | ||
418 | |||
419 | @Override | ||
420 | protected TurnoutConnectedToBothOutputs.Match arrayToMatch(final Object[] match) { | ||
421 | try { | ||
422 | return TurnoutConnectedToBothOutputs.Match.newMatch((Turnout) match[POSITION_T]); | ||
423 | } catch(ClassCastException e) { | ||
424 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
425 | return null; | ||
426 | } | ||
427 | } | ||
428 | |||
429 | @Override | ||
430 | protected TurnoutConnectedToBothOutputs.Match arrayToMatchMutable(final Object[] match) { | ||
431 | try { | ||
432 | return TurnoutConnectedToBothOutputs.Match.newMutableMatch((Turnout) match[POSITION_T]); | ||
433 | } catch(ClassCastException e) { | ||
434 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
435 | return null; | ||
436 | } | ||
437 | } | ||
438 | |||
439 | /** | ||
440 | * @return the singleton instance of the query specification of this pattern | ||
441 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
442 | * | ||
443 | */ | ||
444 | public static IQuerySpecification<TurnoutConnectedToBothOutputs.Matcher> querySpecification() { | ||
445 | return TurnoutConnectedToBothOutputs.instance(); | ||
446 | } | ||
447 | } | ||
448 | |||
449 | private TurnoutConnectedToBothOutputs() { | ||
450 | super(GeneratedPQuery.INSTANCE); | ||
451 | } | ||
452 | |||
453 | /** | ||
454 | * @return the singleton instance of the query specification | ||
455 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
456 | * | ||
457 | */ | ||
458 | public static TurnoutConnectedToBothOutputs instance() { | ||
459 | try{ | ||
460 | return LazyHolder.INSTANCE; | ||
461 | } catch (ExceptionInInitializerError err) { | ||
462 | throw processInitializerError(err); | ||
463 | } | ||
464 | } | ||
465 | |||
466 | @Override | ||
467 | protected TurnoutConnectedToBothOutputs.Matcher instantiate(final ViatraQueryEngine engine) { | ||
468 | return TurnoutConnectedToBothOutputs.Matcher.on(engine); | ||
469 | } | ||
470 | |||
471 | @Override | ||
472 | public TurnoutConnectedToBothOutputs.Matcher instantiate() { | ||
473 | return TurnoutConnectedToBothOutputs.Matcher.create(); | ||
474 | } | ||
475 | |||
476 | @Override | ||
477 | public TurnoutConnectedToBothOutputs.Match newEmptyMatch() { | ||
478 | return TurnoutConnectedToBothOutputs.Match.newEmptyMatch(); | ||
479 | } | ||
480 | |||
481 | @Override | ||
482 | public TurnoutConnectedToBothOutputs.Match newMatch(final Object... parameters) { | ||
483 | return TurnoutConnectedToBothOutputs.Match.newMatch((modes3.Turnout) parameters[0]); | ||
484 | } | ||
485 | |||
486 | /** | ||
487 | * Inner class allowing the singleton instance of {@link TurnoutConnectedToBothOutputs} to be created | ||
488 | * <b>not</b> at the class load time of the outer class, | ||
489 | * but rather at the first call to {@link TurnoutConnectedToBothOutputs#instance()}. | ||
490 | * | ||
491 | * <p> This workaround is required e.g. to support recursion. | ||
492 | * | ||
493 | */ | ||
494 | private static class LazyHolder { | ||
495 | private static final TurnoutConnectedToBothOutputs INSTANCE = new TurnoutConnectedToBothOutputs(); | ||
496 | |||
497 | /** | ||
498 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
499 | * This initialization order is required to support indirect recursion. | ||
500 | * | ||
501 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
502 | * | ||
503 | */ | ||
504 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
505 | |||
506 | public static Object ensureInitialized() { | ||
507 | INSTANCE.ensureInitializedInternal(); | ||
508 | return null; | ||
509 | } | ||
510 | } | ||
511 | |||
512 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
513 | private static final TurnoutConnectedToBothOutputs.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
514 | |||
515 | private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); | ||
516 | |||
517 | private final List<PParameter> parameters = Arrays.asList(parameter_T); | ||
518 | |||
519 | private GeneratedPQuery() { | ||
520 | super(PVisibility.PUBLIC); | ||
521 | } | ||
522 | |||
523 | @Override | ||
524 | public String getFullyQualifiedName() { | ||
525 | return "modes3.queries.turnoutConnectedToBothOutputs"; | ||
526 | } | ||
527 | |||
528 | @Override | ||
529 | public List<String> getParameterNames() { | ||
530 | return Arrays.asList("T"); | ||
531 | } | ||
532 | |||
533 | @Override | ||
534 | public List<PParameter> getParameters() { | ||
535 | return parameters; | ||
536 | } | ||
537 | |||
538 | @Override | ||
539 | public Set<PBody> doGetContainedBodies() { | ||
540 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
541 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
542 | { | ||
543 | PBody body = new PBody(this); | ||
544 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
545 | PVariable var_Straight = body.getOrCreateVariableByName("Straight"); | ||
546 | PVariable var_Divergent = body.getOrCreateVariableByName("Divergent"); | ||
547 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
548 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
549 | new ExportedParameter(body, var_T, parameter_T) | ||
550 | )); | ||
551 | // Turnout.straight(T, Straight) | ||
552 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
553 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
554 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "straight"))); | ||
555 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
556 | new Equality(body, var__virtual_0_, var_Straight); | ||
557 | // Turnout.divergent(T, Divergent) | ||
558 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
559 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
560 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "divergent"))); | ||
561 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
562 | new Equality(body, var__virtual_1_, var_Divergent); | ||
563 | // Segment.connectedTo(T, Straight) | ||
564 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
565 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
566 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
567 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
568 | new Equality(body, var__virtual_2_, var_Straight); | ||
569 | // Segment.connectedTo(T, Divergent) | ||
570 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
571 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); | ||
572 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment", "connectedTo"))); | ||
573 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
574 | new Equality(body, var__virtual_3_, var_Divergent); | ||
575 | bodies.add(body); | ||
576 | } | ||
577 | { | ||
578 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
579 | annotation.addAttribute("message", "turnoutConnectedToBothOutputs"); | ||
580 | annotation.addAttribute("severity", "error"); | ||
581 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
582 | new ParameterReference("T") | ||
583 | })); | ||
584 | addAnnotation(annotation); | ||
585 | } | ||
586 | return bodies; | ||
587 | } | ||
588 | } | ||
589 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutOutput.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutOutput.java new file mode 100644 index 00000000..87cccfde --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutOutput.java | |||
@@ -0,0 +1,727 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.Turnout; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
40 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
41 | |||
42 | /** | ||
43 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
44 | * | ||
45 | * <p>Original source: | ||
46 | * <code><pre> | ||
47 | * pattern turnoutOutput(T : Turnout, S : Segment) { | ||
48 | * Turnout.straight(T, S); | ||
49 | * } or { | ||
50 | * Turnout.divergent(T, S); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class TurnoutOutput extends BaseGeneratedEMFQuerySpecification<TurnoutOutput.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.turnoutOutput pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Turnout fT; | ||
74 | |||
75 | private Segment fS; | ||
76 | |||
77 | private static List<String> parameterNames = makeImmutableList("T", "S"); | ||
78 | |||
79 | private Match(final Turnout pT, final Segment pS) { | ||
80 | this.fT = pT; | ||
81 | this.fS = pS; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | switch(parameterName) { | ||
87 | case "T": return this.fT; | ||
88 | case "S": return this.fS; | ||
89 | default: return null; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | @Override | ||
94 | public Object get(final int index) { | ||
95 | switch(index) { | ||
96 | case 0: return this.fT; | ||
97 | case 1: return this.fS; | ||
98 | default: return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public Turnout getT() { | ||
103 | return this.fT; | ||
104 | } | ||
105 | |||
106 | public Segment getS() { | ||
107 | return this.fS; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public boolean set(final String parameterName, final Object newValue) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | if ("T".equals(parameterName) ) { | ||
114 | this.fT = (Turnout) newValue; | ||
115 | return true; | ||
116 | } | ||
117 | if ("S".equals(parameterName) ) { | ||
118 | this.fS = (Segment) newValue; | ||
119 | return true; | ||
120 | } | ||
121 | return false; | ||
122 | } | ||
123 | |||
124 | public void setT(final Turnout pT) { | ||
125 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
126 | this.fT = pT; | ||
127 | } | ||
128 | |||
129 | public void setS(final Segment pS) { | ||
130 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
131 | this.fS = pS; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public String patternName() { | ||
136 | return "modes3.queries.turnoutOutput"; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public List<String> parameterNames() { | ||
141 | return TurnoutOutput.Match.parameterNames; | ||
142 | } | ||
143 | |||
144 | @Override | ||
145 | public Object[] toArray() { | ||
146 | return new Object[]{fT, fS}; | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public TurnoutOutput.Match toImmutable() { | ||
151 | return isMutable() ? newMatch(fT, fS) : this; | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public String prettyPrint() { | ||
156 | StringBuilder result = new StringBuilder(); | ||
157 | result.append("\"T\"=" + prettyPrintValue(fT) + ", "); | ||
158 | result.append("\"S\"=" + prettyPrintValue(fS)); | ||
159 | return result.toString(); | ||
160 | } | ||
161 | |||
162 | @Override | ||
163 | public int hashCode() { | ||
164 | return Objects.hash(fT, fS); | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public boolean equals(final Object obj) { | ||
169 | if (this == obj) | ||
170 | return true; | ||
171 | if (obj == null) { | ||
172 | return false; | ||
173 | } | ||
174 | if ((obj instanceof TurnoutOutput.Match)) { | ||
175 | TurnoutOutput.Match other = (TurnoutOutput.Match) obj; | ||
176 | return Objects.equals(fT, other.fT) && Objects.equals(fS, other.fS); | ||
177 | } else { | ||
178 | // this should be infrequent | ||
179 | if (!(obj instanceof IPatternMatch)) { | ||
180 | return false; | ||
181 | } | ||
182 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
183 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | @Override | ||
188 | public TurnoutOutput specification() { | ||
189 | return TurnoutOutput.instance(); | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * Returns an empty, mutable match. | ||
194 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
195 | * | ||
196 | * @return the empty match. | ||
197 | * | ||
198 | */ | ||
199 | public static TurnoutOutput.Match newEmptyMatch() { | ||
200 | return new Mutable(null, null); | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * Returns a mutable (partial) match. | ||
205 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
206 | * | ||
207 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
208 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
209 | * @return the new, mutable (partial) match object. | ||
210 | * | ||
211 | */ | ||
212 | public static TurnoutOutput.Match newMutableMatch(final Turnout pT, final Segment pS) { | ||
213 | return new Mutable(pT, pS); | ||
214 | } | ||
215 | |||
216 | /** | ||
217 | * Returns a new (partial) match. | ||
218 | * This can be used e.g. to call the matcher with a partial match. | ||
219 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
220 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
221 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
222 | * @return the (partial) match object. | ||
223 | * | ||
224 | */ | ||
225 | public static TurnoutOutput.Match newMatch(final Turnout pT, final Segment pS) { | ||
226 | return new Immutable(pT, pS); | ||
227 | } | ||
228 | |||
229 | private static final class Mutable extends TurnoutOutput.Match { | ||
230 | Mutable(final Turnout pT, final Segment pS) { | ||
231 | super(pT, pS); | ||
232 | } | ||
233 | |||
234 | @Override | ||
235 | public boolean isMutable() { | ||
236 | return true; | ||
237 | } | ||
238 | } | ||
239 | |||
240 | private static final class Immutable extends TurnoutOutput.Match { | ||
241 | Immutable(final Turnout pT, final Segment pS) { | ||
242 | super(pT, pS); | ||
243 | } | ||
244 | |||
245 | @Override | ||
246 | public boolean isMutable() { | ||
247 | return false; | ||
248 | } | ||
249 | } | ||
250 | } | ||
251 | |||
252 | /** | ||
253 | * Generated pattern matcher API of the modes3.queries.turnoutOutput pattern, | ||
254 | * providing pattern-specific query methods. | ||
255 | * | ||
256 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
257 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
258 | * | ||
259 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
260 | * | ||
261 | * <p>Original source: | ||
262 | * <code><pre> | ||
263 | * pattern turnoutOutput(T : Turnout, S : Segment) { | ||
264 | * Turnout.straight(T, S); | ||
265 | * } or { | ||
266 | * Turnout.divergent(T, S); | ||
267 | * } | ||
268 | * </pre></code> | ||
269 | * | ||
270 | * @see Match | ||
271 | * @see TurnoutOutput | ||
272 | * | ||
273 | */ | ||
274 | public static class Matcher extends BaseMatcher<TurnoutOutput.Match> { | ||
275 | /** | ||
276 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
277 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
278 | * | ||
279 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
280 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
281 | * | ||
282 | */ | ||
283 | public static TurnoutOutput.Matcher on(final ViatraQueryEngine engine) { | ||
284 | // check if matcher already exists | ||
285 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
286 | if (matcher == null) { | ||
287 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
288 | } | ||
289 | return matcher; | ||
290 | } | ||
291 | |||
292 | /** | ||
293 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
294 | * @return an initialized matcher | ||
295 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
296 | * | ||
297 | */ | ||
298 | public static TurnoutOutput.Matcher create() { | ||
299 | return new Matcher(); | ||
300 | } | ||
301 | |||
302 | private static final int POSITION_T = 0; | ||
303 | |||
304 | private static final int POSITION_S = 1; | ||
305 | |||
306 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TurnoutOutput.Matcher.class); | ||
307 | |||
308 | /** | ||
309 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
310 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
311 | * | ||
312 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
313 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
314 | * | ||
315 | */ | ||
316 | private Matcher() { | ||
317 | super(querySpecification()); | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
322 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
323 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
324 | * @return matches represented as a Match object. | ||
325 | * | ||
326 | */ | ||
327 | public Collection<TurnoutOutput.Match> getAllMatches(final Turnout pT, final Segment pS) { | ||
328 | return rawStreamAllMatches(new Object[]{pT, pS}).collect(Collectors.toSet()); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
333 | * </p> | ||
334 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
335 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
336 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
337 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
338 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
339 | * @return a stream of matches represented as a Match object. | ||
340 | * | ||
341 | */ | ||
342 | public Stream<TurnoutOutput.Match> streamAllMatches(final Turnout pT, final Segment pS) { | ||
343 | return rawStreamAllMatches(new Object[]{pT, pS}); | ||
344 | } | ||
345 | |||
346 | /** | ||
347 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
348 | * Neither determinism nor randomness of selection is guaranteed. | ||
349 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
350 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
351 | * @return a match represented as a Match object, or null if no match is found. | ||
352 | * | ||
353 | */ | ||
354 | public Optional<TurnoutOutput.Match> getOneArbitraryMatch(final Turnout pT, final Segment pS) { | ||
355 | return rawGetOneArbitraryMatch(new Object[]{pT, pS}); | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
360 | * under any possible substitution of the unspecified parameters (if any). | ||
361 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
362 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
363 | * @return true if the input is a valid (partial) match of the pattern. | ||
364 | * | ||
365 | */ | ||
366 | public boolean hasMatch(final Turnout pT, final Segment pS) { | ||
367 | return rawHasMatch(new Object[]{pT, pS}); | ||
368 | } | ||
369 | |||
370 | /** | ||
371 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
372 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
373 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
374 | * @return the number of pattern matches found. | ||
375 | * | ||
376 | */ | ||
377 | public int countMatches(final Turnout pT, final Segment pS) { | ||
378 | return rawCountMatches(new Object[]{pT, pS}); | ||
379 | } | ||
380 | |||
381 | /** | ||
382 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
383 | * Neither determinism nor randomness of selection is guaranteed. | ||
384 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
385 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
386 | * @param processor the action that will process the selected match. | ||
387 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
388 | * | ||
389 | */ | ||
390 | public boolean forOneArbitraryMatch(final Turnout pT, final Segment pS, final Consumer<? super TurnoutOutput.Match> processor) { | ||
391 | return rawForOneArbitraryMatch(new Object[]{pT, pS}, processor); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Returns a new (partial) match. | ||
396 | * This can be used e.g. to call the matcher with a partial match. | ||
397 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
398 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
399 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
400 | * @return the (partial) match object. | ||
401 | * | ||
402 | */ | ||
403 | public TurnoutOutput.Match newMatch(final Turnout pT, final Segment pS) { | ||
404 | return TurnoutOutput.Match.newMatch(pT, pS); | ||
405 | } | ||
406 | |||
407 | /** | ||
408 | * Retrieve the set of values that occur in matches for T. | ||
409 | * @return the Set of all values or empty set if there are no matches | ||
410 | * | ||
411 | */ | ||
412 | protected Stream<Turnout> rawStreamAllValuesOfT(final Object[] parameters) { | ||
413 | return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); | ||
414 | } | ||
415 | |||
416 | /** | ||
417 | * Retrieve the set of values that occur in matches for T. | ||
418 | * @return the Set of all values or empty set if there are no matches | ||
419 | * | ||
420 | */ | ||
421 | public Set<Turnout> getAllValuesOfT() { | ||
422 | return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); | ||
423 | } | ||
424 | |||
425 | /** | ||
426 | * Retrieve the set of values that occur in matches for T. | ||
427 | * @return the Set of all values or empty set if there are no matches | ||
428 | * | ||
429 | */ | ||
430 | public Stream<Turnout> streamAllValuesOfT() { | ||
431 | return rawStreamAllValuesOfT(emptyArray()); | ||
432 | } | ||
433 | |||
434 | /** | ||
435 | * Retrieve the set of values that occur in matches for T. | ||
436 | * </p> | ||
437 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
438 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
439 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
440 | * | ||
441 | * @return the Stream of all values or empty set if there are no matches | ||
442 | * | ||
443 | */ | ||
444 | public Stream<Turnout> streamAllValuesOfT(final TurnoutOutput.Match partialMatch) { | ||
445 | return rawStreamAllValuesOfT(partialMatch.toArray()); | ||
446 | } | ||
447 | |||
448 | /** | ||
449 | * Retrieve the set of values that occur in matches for T. | ||
450 | * </p> | ||
451 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
452 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
453 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
454 | * | ||
455 | * @return the Stream of all values or empty set if there are no matches | ||
456 | * | ||
457 | */ | ||
458 | public Stream<Turnout> streamAllValuesOfT(final Segment pS) { | ||
459 | return rawStreamAllValuesOfT(new Object[]{null, pS}); | ||
460 | } | ||
461 | |||
462 | /** | ||
463 | * Retrieve the set of values that occur in matches for T. | ||
464 | * @return the Set of all values or empty set if there are no matches | ||
465 | * | ||
466 | */ | ||
467 | public Set<Turnout> getAllValuesOfT(final TurnoutOutput.Match partialMatch) { | ||
468 | return rawStreamAllValuesOfT(partialMatch.toArray()).collect(Collectors.toSet()); | ||
469 | } | ||
470 | |||
471 | /** | ||
472 | * Retrieve the set of values that occur in matches for T. | ||
473 | * @return the Set of all values or empty set if there are no matches | ||
474 | * | ||
475 | */ | ||
476 | public Set<Turnout> getAllValuesOfT(final Segment pS) { | ||
477 | return rawStreamAllValuesOfT(new Object[]{null, pS}).collect(Collectors.toSet()); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Retrieve the set of values that occur in matches for S. | ||
482 | * @return the Set of all values or empty set if there are no matches | ||
483 | * | ||
484 | */ | ||
485 | protected Stream<Segment> rawStreamAllValuesOfS(final Object[] parameters) { | ||
486 | return rawStreamAllValues(POSITION_S, parameters).map(Segment.class::cast); | ||
487 | } | ||
488 | |||
489 | /** | ||
490 | * Retrieve the set of values that occur in matches for S. | ||
491 | * @return the Set of all values or empty set if there are no matches | ||
492 | * | ||
493 | */ | ||
494 | public Set<Segment> getAllValuesOfS() { | ||
495 | return rawStreamAllValuesOfS(emptyArray()).collect(Collectors.toSet()); | ||
496 | } | ||
497 | |||
498 | /** | ||
499 | * Retrieve the set of values that occur in matches for S. | ||
500 | * @return the Set of all values or empty set if there are no matches | ||
501 | * | ||
502 | */ | ||
503 | public Stream<Segment> streamAllValuesOfS() { | ||
504 | return rawStreamAllValuesOfS(emptyArray()); | ||
505 | } | ||
506 | |||
507 | /** | ||
508 | * Retrieve the set of values that occur in matches for S. | ||
509 | * </p> | ||
510 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
511 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
512 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
513 | * | ||
514 | * @return the Stream of all values or empty set if there are no matches | ||
515 | * | ||
516 | */ | ||
517 | public Stream<Segment> streamAllValuesOfS(final TurnoutOutput.Match partialMatch) { | ||
518 | return rawStreamAllValuesOfS(partialMatch.toArray()); | ||
519 | } | ||
520 | |||
521 | /** | ||
522 | * Retrieve the set of values that occur in matches for S. | ||
523 | * </p> | ||
524 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
525 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
526 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
527 | * | ||
528 | * @return the Stream of all values or empty set if there are no matches | ||
529 | * | ||
530 | */ | ||
531 | public Stream<Segment> streamAllValuesOfS(final Turnout pT) { | ||
532 | return rawStreamAllValuesOfS(new Object[]{pT, null}); | ||
533 | } | ||
534 | |||
535 | /** | ||
536 | * Retrieve the set of values that occur in matches for S. | ||
537 | * @return the Set of all values or empty set if there are no matches | ||
538 | * | ||
539 | */ | ||
540 | public Set<Segment> getAllValuesOfS(final TurnoutOutput.Match partialMatch) { | ||
541 | return rawStreamAllValuesOfS(partialMatch.toArray()).collect(Collectors.toSet()); | ||
542 | } | ||
543 | |||
544 | /** | ||
545 | * Retrieve the set of values that occur in matches for S. | ||
546 | * @return the Set of all values or empty set if there are no matches | ||
547 | * | ||
548 | */ | ||
549 | public Set<Segment> getAllValuesOfS(final Turnout pT) { | ||
550 | return rawStreamAllValuesOfS(new Object[]{pT, null}).collect(Collectors.toSet()); | ||
551 | } | ||
552 | |||
553 | @Override | ||
554 | protected TurnoutOutput.Match tupleToMatch(final Tuple t) { | ||
555 | try { | ||
556 | return TurnoutOutput.Match.newMatch((Turnout) t.get(POSITION_T), (Segment) t.get(POSITION_S)); | ||
557 | } catch(ClassCastException e) { | ||
558 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
559 | return null; | ||
560 | } | ||
561 | } | ||
562 | |||
563 | @Override | ||
564 | protected TurnoutOutput.Match arrayToMatch(final Object[] match) { | ||
565 | try { | ||
566 | return TurnoutOutput.Match.newMatch((Turnout) match[POSITION_T], (Segment) match[POSITION_S]); | ||
567 | } catch(ClassCastException e) { | ||
568 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
569 | return null; | ||
570 | } | ||
571 | } | ||
572 | |||
573 | @Override | ||
574 | protected TurnoutOutput.Match arrayToMatchMutable(final Object[] match) { | ||
575 | try { | ||
576 | return TurnoutOutput.Match.newMutableMatch((Turnout) match[POSITION_T], (Segment) match[POSITION_S]); | ||
577 | } catch(ClassCastException e) { | ||
578 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
579 | return null; | ||
580 | } | ||
581 | } | ||
582 | |||
583 | /** | ||
584 | * @return the singleton instance of the query specification of this pattern | ||
585 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
586 | * | ||
587 | */ | ||
588 | public static IQuerySpecification<TurnoutOutput.Matcher> querySpecification() { | ||
589 | return TurnoutOutput.instance(); | ||
590 | } | ||
591 | } | ||
592 | |||
593 | private TurnoutOutput() { | ||
594 | super(GeneratedPQuery.INSTANCE); | ||
595 | } | ||
596 | |||
597 | /** | ||
598 | * @return the singleton instance of the query specification | ||
599 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
600 | * | ||
601 | */ | ||
602 | public static TurnoutOutput instance() { | ||
603 | try{ | ||
604 | return LazyHolder.INSTANCE; | ||
605 | } catch (ExceptionInInitializerError err) { | ||
606 | throw processInitializerError(err); | ||
607 | } | ||
608 | } | ||
609 | |||
610 | @Override | ||
611 | protected TurnoutOutput.Matcher instantiate(final ViatraQueryEngine engine) { | ||
612 | return TurnoutOutput.Matcher.on(engine); | ||
613 | } | ||
614 | |||
615 | @Override | ||
616 | public TurnoutOutput.Matcher instantiate() { | ||
617 | return TurnoutOutput.Matcher.create(); | ||
618 | } | ||
619 | |||
620 | @Override | ||
621 | public TurnoutOutput.Match newEmptyMatch() { | ||
622 | return TurnoutOutput.Match.newEmptyMatch(); | ||
623 | } | ||
624 | |||
625 | @Override | ||
626 | public TurnoutOutput.Match newMatch(final Object... parameters) { | ||
627 | return TurnoutOutput.Match.newMatch((modes3.Turnout) parameters[0], (modes3.Segment) parameters[1]); | ||
628 | } | ||
629 | |||
630 | /** | ||
631 | * Inner class allowing the singleton instance of {@link TurnoutOutput} to be created | ||
632 | * <b>not</b> at the class load time of the outer class, | ||
633 | * but rather at the first call to {@link TurnoutOutput#instance()}. | ||
634 | * | ||
635 | * <p> This workaround is required e.g. to support recursion. | ||
636 | * | ||
637 | */ | ||
638 | private static class LazyHolder { | ||
639 | private static final TurnoutOutput INSTANCE = new TurnoutOutput(); | ||
640 | |||
641 | /** | ||
642 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
643 | * This initialization order is required to support indirect recursion. | ||
644 | * | ||
645 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
646 | * | ||
647 | */ | ||
648 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
649 | |||
650 | public static Object ensureInitialized() { | ||
651 | INSTANCE.ensureInitializedInternal(); | ||
652 | return null; | ||
653 | } | ||
654 | } | ||
655 | |||
656 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
657 | private static final TurnoutOutput.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
658 | |||
659 | private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); | ||
660 | |||
661 | private final PParameter parameter_S = new PParameter("S", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
662 | |||
663 | private final List<PParameter> parameters = Arrays.asList(parameter_T, parameter_S); | ||
664 | |||
665 | private GeneratedPQuery() { | ||
666 | super(PVisibility.PUBLIC); | ||
667 | } | ||
668 | |||
669 | @Override | ||
670 | public String getFullyQualifiedName() { | ||
671 | return "modes3.queries.turnoutOutput"; | ||
672 | } | ||
673 | |||
674 | @Override | ||
675 | public List<String> getParameterNames() { | ||
676 | return Arrays.asList("T","S"); | ||
677 | } | ||
678 | |||
679 | @Override | ||
680 | public List<PParameter> getParameters() { | ||
681 | return parameters; | ||
682 | } | ||
683 | |||
684 | @Override | ||
685 | public Set<PBody> doGetContainedBodies() { | ||
686 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
687 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
688 | { | ||
689 | PBody body = new PBody(this); | ||
690 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
691 | PVariable var_S = body.getOrCreateVariableByName("S"); | ||
692 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
693 | new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
694 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
695 | new ExportedParameter(body, var_T, parameter_T), | ||
696 | new ExportedParameter(body, var_S, parameter_S) | ||
697 | )); | ||
698 | // Turnout.straight(T, S) | ||
699 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
700 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
701 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "straight"))); | ||
702 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
703 | new Equality(body, var__virtual_0_, var_S); | ||
704 | bodies.add(body); | ||
705 | } | ||
706 | { | ||
707 | PBody body = new PBody(this); | ||
708 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
709 | PVariable var_S = body.getOrCreateVariableByName("S"); | ||
710 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
711 | new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
712 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
713 | new ExportedParameter(body, var_T, parameter_T), | ||
714 | new ExportedParameter(body, var_S, parameter_S) | ||
715 | )); | ||
716 | // Turnout.divergent(T, S) | ||
717 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
718 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
719 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "divergent"))); | ||
720 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
721 | new Equality(body, var__virtual_0_, var_S); | ||
722 | bodies.add(body); | ||
723 | } | ||
724 | return bodies; | ||
725 | } | ||
726 | } | ||
727 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutOutputsAreSame.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutOutputsAreSame.java new file mode 100644 index 00000000..ba59d45c --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TurnoutOutputsAreSame.java | |||
@@ -0,0 +1,572 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Turnout; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * {@literal @}Constraint(message = "turnoutOutputsAreSame", severity = "error", key = { T }) | ||
49 | * pattern turnoutOutputsAreSame(T : Turnout) { | ||
50 | * Turnout.straight(T, S); | ||
51 | * Turnout.divergent(T, S); | ||
52 | * } | ||
53 | * </pre></code> | ||
54 | * | ||
55 | * @see Matcher | ||
56 | * @see Match | ||
57 | * | ||
58 | */ | ||
59 | @SuppressWarnings("all") | ||
60 | public final class TurnoutOutputsAreSame extends BaseGeneratedEMFQuerySpecification<TurnoutOutputsAreSame.Matcher> { | ||
61 | /** | ||
62 | * Pattern-specific match representation of the modes3.queries.turnoutOutputsAreSame pattern, | ||
63 | * to be used in conjunction with {@link Matcher}. | ||
64 | * | ||
65 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
66 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
67 | * usable to represent a match of the pattern in the result of a query, | ||
68 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
69 | * | ||
70 | * @see Matcher | ||
71 | * | ||
72 | */ | ||
73 | public static abstract class Match extends BasePatternMatch { | ||
74 | private Turnout fT; | ||
75 | |||
76 | private static List<String> parameterNames = makeImmutableList("T"); | ||
77 | |||
78 | private Match(final Turnout pT) { | ||
79 | this.fT = pT; | ||
80 | } | ||
81 | |||
82 | @Override | ||
83 | public Object get(final String parameterName) { | ||
84 | switch(parameterName) { | ||
85 | case "T": return this.fT; | ||
86 | default: return null; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | @Override | ||
91 | public Object get(final int index) { | ||
92 | switch(index) { | ||
93 | case 0: return this.fT; | ||
94 | default: return null; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public Turnout getT() { | ||
99 | return this.fT; | ||
100 | } | ||
101 | |||
102 | @Override | ||
103 | public boolean set(final String parameterName, final Object newValue) { | ||
104 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
105 | if ("T".equals(parameterName) ) { | ||
106 | this.fT = (Turnout) newValue; | ||
107 | return true; | ||
108 | } | ||
109 | return false; | ||
110 | } | ||
111 | |||
112 | public void setT(final Turnout pT) { | ||
113 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
114 | this.fT = pT; | ||
115 | } | ||
116 | |||
117 | @Override | ||
118 | public String patternName() { | ||
119 | return "modes3.queries.turnoutOutputsAreSame"; | ||
120 | } | ||
121 | |||
122 | @Override | ||
123 | public List<String> parameterNames() { | ||
124 | return TurnoutOutputsAreSame.Match.parameterNames; | ||
125 | } | ||
126 | |||
127 | @Override | ||
128 | public Object[] toArray() { | ||
129 | return new Object[]{fT}; | ||
130 | } | ||
131 | |||
132 | @Override | ||
133 | public TurnoutOutputsAreSame.Match toImmutable() { | ||
134 | return isMutable() ? newMatch(fT) : this; | ||
135 | } | ||
136 | |||
137 | @Override | ||
138 | public String prettyPrint() { | ||
139 | StringBuilder result = new StringBuilder(); | ||
140 | result.append("\"T\"=" + prettyPrintValue(fT)); | ||
141 | return result.toString(); | ||
142 | } | ||
143 | |||
144 | @Override | ||
145 | public int hashCode() { | ||
146 | return Objects.hash(fT); | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public boolean equals(final Object obj) { | ||
151 | if (this == obj) | ||
152 | return true; | ||
153 | if (obj == null) { | ||
154 | return false; | ||
155 | } | ||
156 | if ((obj instanceof TurnoutOutputsAreSame.Match)) { | ||
157 | TurnoutOutputsAreSame.Match other = (TurnoutOutputsAreSame.Match) obj; | ||
158 | return Objects.equals(fT, other.fT); | ||
159 | } else { | ||
160 | // this should be infrequent | ||
161 | if (!(obj instanceof IPatternMatch)) { | ||
162 | return false; | ||
163 | } | ||
164 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
165 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
166 | } | ||
167 | } | ||
168 | |||
169 | @Override | ||
170 | public TurnoutOutputsAreSame specification() { | ||
171 | return TurnoutOutputsAreSame.instance(); | ||
172 | } | ||
173 | |||
174 | /** | ||
175 | * Returns an empty, mutable match. | ||
176 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
177 | * | ||
178 | * @return the empty match. | ||
179 | * | ||
180 | */ | ||
181 | public static TurnoutOutputsAreSame.Match newEmptyMatch() { | ||
182 | return new Mutable(null); | ||
183 | } | ||
184 | |||
185 | /** | ||
186 | * Returns a mutable (partial) match. | ||
187 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
188 | * | ||
189 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
190 | * @return the new, mutable (partial) match object. | ||
191 | * | ||
192 | */ | ||
193 | public static TurnoutOutputsAreSame.Match newMutableMatch(final Turnout pT) { | ||
194 | return new Mutable(pT); | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * Returns a new (partial) match. | ||
199 | * This can be used e.g. to call the matcher with a partial match. | ||
200 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
201 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
202 | * @return the (partial) match object. | ||
203 | * | ||
204 | */ | ||
205 | public static TurnoutOutputsAreSame.Match newMatch(final Turnout pT) { | ||
206 | return new Immutable(pT); | ||
207 | } | ||
208 | |||
209 | private static final class Mutable extends TurnoutOutputsAreSame.Match { | ||
210 | Mutable(final Turnout pT) { | ||
211 | super(pT); | ||
212 | } | ||
213 | |||
214 | @Override | ||
215 | public boolean isMutable() { | ||
216 | return true; | ||
217 | } | ||
218 | } | ||
219 | |||
220 | private static final class Immutable extends TurnoutOutputsAreSame.Match { | ||
221 | Immutable(final Turnout pT) { | ||
222 | super(pT); | ||
223 | } | ||
224 | |||
225 | @Override | ||
226 | public boolean isMutable() { | ||
227 | return false; | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | |||
232 | /** | ||
233 | * Generated pattern matcher API of the modes3.queries.turnoutOutputsAreSame pattern, | ||
234 | * providing pattern-specific query methods. | ||
235 | * | ||
236 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
237 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
238 | * | ||
239 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
240 | * | ||
241 | * <p>Original source: | ||
242 | * <code><pre> | ||
243 | * {@literal @}Constraint(message = "turnoutOutputsAreSame", severity = "error", key = { T }) | ||
244 | * pattern turnoutOutputsAreSame(T : Turnout) { | ||
245 | * Turnout.straight(T, S); | ||
246 | * Turnout.divergent(T, S); | ||
247 | * } | ||
248 | * </pre></code> | ||
249 | * | ||
250 | * @see Match | ||
251 | * @see TurnoutOutputsAreSame | ||
252 | * | ||
253 | */ | ||
254 | public static class Matcher extends BaseMatcher<TurnoutOutputsAreSame.Match> { | ||
255 | /** | ||
256 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
257 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
258 | * | ||
259 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
260 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
261 | * | ||
262 | */ | ||
263 | public static TurnoutOutputsAreSame.Matcher on(final ViatraQueryEngine engine) { | ||
264 | // check if matcher already exists | ||
265 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
266 | if (matcher == null) { | ||
267 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
268 | } | ||
269 | return matcher; | ||
270 | } | ||
271 | |||
272 | /** | ||
273 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
274 | * @return an initialized matcher | ||
275 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
276 | * | ||
277 | */ | ||
278 | public static TurnoutOutputsAreSame.Matcher create() { | ||
279 | return new Matcher(); | ||
280 | } | ||
281 | |||
282 | private static final int POSITION_T = 0; | ||
283 | |||
284 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TurnoutOutputsAreSame.Matcher.class); | ||
285 | |||
286 | /** | ||
287 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
288 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
289 | * | ||
290 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
291 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
292 | * | ||
293 | */ | ||
294 | private Matcher() { | ||
295 | super(querySpecification()); | ||
296 | } | ||
297 | |||
298 | /** | ||
299 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
300 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
301 | * @return matches represented as a Match object. | ||
302 | * | ||
303 | */ | ||
304 | public Collection<TurnoutOutputsAreSame.Match> getAllMatches(final Turnout pT) { | ||
305 | return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet()); | ||
306 | } | ||
307 | |||
308 | /** | ||
309 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
310 | * </p> | ||
311 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
312 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
313 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
314 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
315 | * @return a stream of matches represented as a Match object. | ||
316 | * | ||
317 | */ | ||
318 | public Stream<TurnoutOutputsAreSame.Match> streamAllMatches(final Turnout pT) { | ||
319 | return rawStreamAllMatches(new Object[]{pT}); | ||
320 | } | ||
321 | |||
322 | /** | ||
323 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
324 | * Neither determinism nor randomness of selection is guaranteed. | ||
325 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
326 | * @return a match represented as a Match object, or null if no match is found. | ||
327 | * | ||
328 | */ | ||
329 | public Optional<TurnoutOutputsAreSame.Match> getOneArbitraryMatch(final Turnout pT) { | ||
330 | return rawGetOneArbitraryMatch(new Object[]{pT}); | ||
331 | } | ||
332 | |||
333 | /** | ||
334 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
335 | * under any possible substitution of the unspecified parameters (if any). | ||
336 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
337 | * @return true if the input is a valid (partial) match of the pattern. | ||
338 | * | ||
339 | */ | ||
340 | public boolean hasMatch(final Turnout pT) { | ||
341 | return rawHasMatch(new Object[]{pT}); | ||
342 | } | ||
343 | |||
344 | /** | ||
345 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
346 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
347 | * @return the number of pattern matches found. | ||
348 | * | ||
349 | */ | ||
350 | public int countMatches(final Turnout pT) { | ||
351 | return rawCountMatches(new Object[]{pT}); | ||
352 | } | ||
353 | |||
354 | /** | ||
355 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
356 | * Neither determinism nor randomness of selection is guaranteed. | ||
357 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
358 | * @param processor the action that will process the selected match. | ||
359 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
360 | * | ||
361 | */ | ||
362 | public boolean forOneArbitraryMatch(final Turnout pT, final Consumer<? super TurnoutOutputsAreSame.Match> processor) { | ||
363 | return rawForOneArbitraryMatch(new Object[]{pT}, processor); | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * Returns a new (partial) match. | ||
368 | * This can be used e.g. to call the matcher with a partial match. | ||
369 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
370 | * @param pT the fixed value of pattern parameter T, or null if not bound. | ||
371 | * @return the (partial) match object. | ||
372 | * | ||
373 | */ | ||
374 | public TurnoutOutputsAreSame.Match newMatch(final Turnout pT) { | ||
375 | return TurnoutOutputsAreSame.Match.newMatch(pT); | ||
376 | } | ||
377 | |||
378 | /** | ||
379 | * Retrieve the set of values that occur in matches for T. | ||
380 | * @return the Set of all values or empty set if there are no matches | ||
381 | * | ||
382 | */ | ||
383 | protected Stream<Turnout> rawStreamAllValuesOfT(final Object[] parameters) { | ||
384 | return rawStreamAllValues(POSITION_T, parameters).map(Turnout.class::cast); | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * Retrieve the set of values that occur in matches for T. | ||
389 | * @return the Set of all values or empty set if there are no matches | ||
390 | * | ||
391 | */ | ||
392 | public Set<Turnout> getAllValuesOfT() { | ||
393 | return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet()); | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * Retrieve the set of values that occur in matches for T. | ||
398 | * @return the Set of all values or empty set if there are no matches | ||
399 | * | ||
400 | */ | ||
401 | public Stream<Turnout> streamAllValuesOfT() { | ||
402 | return rawStreamAllValuesOfT(emptyArray()); | ||
403 | } | ||
404 | |||
405 | @Override | ||
406 | protected TurnoutOutputsAreSame.Match tupleToMatch(final Tuple t) { | ||
407 | try { | ||
408 | return TurnoutOutputsAreSame.Match.newMatch((Turnout) t.get(POSITION_T)); | ||
409 | } catch(ClassCastException e) { | ||
410 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
411 | return null; | ||
412 | } | ||
413 | } | ||
414 | |||
415 | @Override | ||
416 | protected TurnoutOutputsAreSame.Match arrayToMatch(final Object[] match) { | ||
417 | try { | ||
418 | return TurnoutOutputsAreSame.Match.newMatch((Turnout) match[POSITION_T]); | ||
419 | } catch(ClassCastException e) { | ||
420 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
421 | return null; | ||
422 | } | ||
423 | } | ||
424 | |||
425 | @Override | ||
426 | protected TurnoutOutputsAreSame.Match arrayToMatchMutable(final Object[] match) { | ||
427 | try { | ||
428 | return TurnoutOutputsAreSame.Match.newMutableMatch((Turnout) match[POSITION_T]); | ||
429 | } catch(ClassCastException e) { | ||
430 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
431 | return null; | ||
432 | } | ||
433 | } | ||
434 | |||
435 | /** | ||
436 | * @return the singleton instance of the query specification of this pattern | ||
437 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
438 | * | ||
439 | */ | ||
440 | public static IQuerySpecification<TurnoutOutputsAreSame.Matcher> querySpecification() { | ||
441 | return TurnoutOutputsAreSame.instance(); | ||
442 | } | ||
443 | } | ||
444 | |||
445 | private TurnoutOutputsAreSame() { | ||
446 | super(GeneratedPQuery.INSTANCE); | ||
447 | } | ||
448 | |||
449 | /** | ||
450 | * @return the singleton instance of the query specification | ||
451 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
452 | * | ||
453 | */ | ||
454 | public static TurnoutOutputsAreSame instance() { | ||
455 | try{ | ||
456 | return LazyHolder.INSTANCE; | ||
457 | } catch (ExceptionInInitializerError err) { | ||
458 | throw processInitializerError(err); | ||
459 | } | ||
460 | } | ||
461 | |||
462 | @Override | ||
463 | protected TurnoutOutputsAreSame.Matcher instantiate(final ViatraQueryEngine engine) { | ||
464 | return TurnoutOutputsAreSame.Matcher.on(engine); | ||
465 | } | ||
466 | |||
467 | @Override | ||
468 | public TurnoutOutputsAreSame.Matcher instantiate() { | ||
469 | return TurnoutOutputsAreSame.Matcher.create(); | ||
470 | } | ||
471 | |||
472 | @Override | ||
473 | public TurnoutOutputsAreSame.Match newEmptyMatch() { | ||
474 | return TurnoutOutputsAreSame.Match.newEmptyMatch(); | ||
475 | } | ||
476 | |||
477 | @Override | ||
478 | public TurnoutOutputsAreSame.Match newMatch(final Object... parameters) { | ||
479 | return TurnoutOutputsAreSame.Match.newMatch((modes3.Turnout) parameters[0]); | ||
480 | } | ||
481 | |||
482 | /** | ||
483 | * Inner class allowing the singleton instance of {@link TurnoutOutputsAreSame} to be created | ||
484 | * <b>not</b> at the class load time of the outer class, | ||
485 | * but rather at the first call to {@link TurnoutOutputsAreSame#instance()}. | ||
486 | * | ||
487 | * <p> This workaround is required e.g. to support recursion. | ||
488 | * | ||
489 | */ | ||
490 | private static class LazyHolder { | ||
491 | private static final TurnoutOutputsAreSame INSTANCE = new TurnoutOutputsAreSame(); | ||
492 | |||
493 | /** | ||
494 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
495 | * This initialization order is required to support indirect recursion. | ||
496 | * | ||
497 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
498 | * | ||
499 | */ | ||
500 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
501 | |||
502 | public static Object ensureInitialized() { | ||
503 | INSTANCE.ensureInitializedInternal(); | ||
504 | return null; | ||
505 | } | ||
506 | } | ||
507 | |||
508 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
509 | private static final TurnoutOutputsAreSame.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
510 | |||
511 | private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT); | ||
512 | |||
513 | private final List<PParameter> parameters = Arrays.asList(parameter_T); | ||
514 | |||
515 | private GeneratedPQuery() { | ||
516 | super(PVisibility.PUBLIC); | ||
517 | } | ||
518 | |||
519 | @Override | ||
520 | public String getFullyQualifiedName() { | ||
521 | return "modes3.queries.turnoutOutputsAreSame"; | ||
522 | } | ||
523 | |||
524 | @Override | ||
525 | public List<String> getParameterNames() { | ||
526 | return Arrays.asList("T"); | ||
527 | } | ||
528 | |||
529 | @Override | ||
530 | public List<PParameter> getParameters() { | ||
531 | return parameters; | ||
532 | } | ||
533 | |||
534 | @Override | ||
535 | public Set<PBody> doGetContainedBodies() { | ||
536 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
537 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
538 | { | ||
539 | PBody body = new PBody(this); | ||
540 | PVariable var_T = body.getOrCreateVariableByName("T"); | ||
541 | PVariable var_S = body.getOrCreateVariableByName("S"); | ||
542 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
543 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
544 | new ExportedParameter(body, var_T, parameter_T) | ||
545 | )); | ||
546 | // Turnout.straight(T, S) | ||
547 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
548 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
549 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "straight"))); | ||
550 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
551 | new Equality(body, var__virtual_0_, var_S); | ||
552 | // Turnout.divergent(T, S) | ||
553 | new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout"))); | ||
554 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
555 | new TypeConstraint(body, Tuples.flatTupleOf(var_T, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout", "divergent"))); | ||
556 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
557 | new Equality(body, var__virtual_1_, var_S); | ||
558 | bodies.add(body); | ||
559 | } | ||
560 | { | ||
561 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
562 | annotation.addAttribute("message", "turnoutOutputsAreSame"); | ||
563 | annotation.addAttribute("severity", "error"); | ||
564 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
565 | new ParameterReference("T") | ||
566 | })); | ||
567 | addAnnotation(annotation); | ||
568 | } | ||
569 | return bodies; | ||
570 | } | ||
571 | } | ||
572 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Unreachable.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Unreachable.java new file mode 100644 index 00000000..a1b76f83 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Unreachable.java | |||
@@ -0,0 +1,714 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | ||
3 | */ | ||
4 | package modes3.queries; | ||
5 | |||
6 | import java.util.Arrays; | ||
7 | import java.util.Collection; | ||
8 | import java.util.LinkedHashSet; | ||
9 | import java.util.List; | ||
10 | import java.util.Objects; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import modes3.Segment; | ||
17 | import modes3.queries.Reachable; | ||
18 | import org.apache.log4j.Logger; | ||
19 | import org.eclipse.emf.ecore.EClass; | ||
20 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
21 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
22 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
27 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
41 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
42 | |||
43 | /** | ||
44 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
45 | * | ||
46 | * <p>Original source: | ||
47 | * <code><pre> | ||
48 | * {@literal @}Constraint(message = "unreachable", severity = "error", key = { S1, S2 }) | ||
49 | * pattern unreachable(S1 : Segment, S2 : Segment) { | ||
50 | * neg find reachable(S1, S2); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class Unreachable extends BaseGeneratedEMFQuerySpecification<Unreachable.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the modes3.queries.unreachable pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Segment fS1; | ||
74 | |||
75 | private Segment fS2; | ||
76 | |||
77 | private static List<String> parameterNames = makeImmutableList("S1", "S2"); | ||
78 | |||
79 | private Match(final Segment pS1, final Segment pS2) { | ||
80 | this.fS1 = pS1; | ||
81 | this.fS2 = pS2; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public Object get(final String parameterName) { | ||
86 | switch(parameterName) { | ||
87 | case "S1": return this.fS1; | ||
88 | case "S2": return this.fS2; | ||
89 | default: return null; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | @Override | ||
94 | public Object get(final int index) { | ||
95 | switch(index) { | ||
96 | case 0: return this.fS1; | ||
97 | case 1: return this.fS2; | ||
98 | default: return null; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public Segment getS1() { | ||
103 | return this.fS1; | ||
104 | } | ||
105 | |||
106 | public Segment getS2() { | ||
107 | return this.fS2; | ||
108 | } | ||
109 | |||
110 | @Override | ||
111 | public boolean set(final String parameterName, final Object newValue) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | if ("S1".equals(parameterName) ) { | ||
114 | this.fS1 = (Segment) newValue; | ||
115 | return true; | ||
116 | } | ||
117 | if ("S2".equals(parameterName) ) { | ||
118 | this.fS2 = (Segment) newValue; | ||
119 | return true; | ||
120 | } | ||
121 | return false; | ||
122 | } | ||
123 | |||
124 | public void setS1(final Segment pS1) { | ||
125 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
126 | this.fS1 = pS1; | ||
127 | } | ||
128 | |||
129 | public void setS2(final Segment pS2) { | ||
130 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
131 | this.fS2 = pS2; | ||
132 | } | ||
133 | |||
134 | @Override | ||
135 | public String patternName() { | ||
136 | return "modes3.queries.unreachable"; | ||
137 | } | ||
138 | |||
139 | @Override | ||
140 | public List<String> parameterNames() { | ||
141 | return Unreachable.Match.parameterNames; | ||
142 | } | ||
143 | |||
144 | @Override | ||
145 | public Object[] toArray() { | ||
146 | return new Object[]{fS1, fS2}; | ||
147 | } | ||
148 | |||
149 | @Override | ||
150 | public Unreachable.Match toImmutable() { | ||
151 | return isMutable() ? newMatch(fS1, fS2) : this; | ||
152 | } | ||
153 | |||
154 | @Override | ||
155 | public String prettyPrint() { | ||
156 | StringBuilder result = new StringBuilder(); | ||
157 | result.append("\"S1\"=" + prettyPrintValue(fS1) + ", "); | ||
158 | result.append("\"S2\"=" + prettyPrintValue(fS2)); | ||
159 | return result.toString(); | ||
160 | } | ||
161 | |||
162 | @Override | ||
163 | public int hashCode() { | ||
164 | return Objects.hash(fS1, fS2); | ||
165 | } | ||
166 | |||
167 | @Override | ||
168 | public boolean equals(final Object obj) { | ||
169 | if (this == obj) | ||
170 | return true; | ||
171 | if (obj == null) { | ||
172 | return false; | ||
173 | } | ||
174 | if ((obj instanceof Unreachable.Match)) { | ||
175 | Unreachable.Match other = (Unreachable.Match) obj; | ||
176 | return Objects.equals(fS1, other.fS1) && Objects.equals(fS2, other.fS2); | ||
177 | } else { | ||
178 | // this should be infrequent | ||
179 | if (!(obj instanceof IPatternMatch)) { | ||
180 | return false; | ||
181 | } | ||
182 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
183 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | @Override | ||
188 | public Unreachable specification() { | ||
189 | return Unreachable.instance(); | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * Returns an empty, mutable match. | ||
194 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
195 | * | ||
196 | * @return the empty match. | ||
197 | * | ||
198 | */ | ||
199 | public static Unreachable.Match newEmptyMatch() { | ||
200 | return new Mutable(null, null); | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * Returns a mutable (partial) match. | ||
205 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
206 | * | ||
207 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
208 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
209 | * @return the new, mutable (partial) match object. | ||
210 | * | ||
211 | */ | ||
212 | public static Unreachable.Match newMutableMatch(final Segment pS1, final Segment pS2) { | ||
213 | return new Mutable(pS1, pS2); | ||
214 | } | ||
215 | |||
216 | /** | ||
217 | * Returns a new (partial) match. | ||
218 | * This can be used e.g. to call the matcher with a partial match. | ||
219 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
220 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
221 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
222 | * @return the (partial) match object. | ||
223 | * | ||
224 | */ | ||
225 | public static Unreachable.Match newMatch(final Segment pS1, final Segment pS2) { | ||
226 | return new Immutable(pS1, pS2); | ||
227 | } | ||
228 | |||
229 | private static final class Mutable extends Unreachable.Match { | ||
230 | Mutable(final Segment pS1, final Segment pS2) { | ||
231 | super(pS1, pS2); | ||
232 | } | ||
233 | |||
234 | @Override | ||
235 | public boolean isMutable() { | ||
236 | return true; | ||
237 | } | ||
238 | } | ||
239 | |||
240 | private static final class Immutable extends Unreachable.Match { | ||
241 | Immutable(final Segment pS1, final Segment pS2) { | ||
242 | super(pS1, pS2); | ||
243 | } | ||
244 | |||
245 | @Override | ||
246 | public boolean isMutable() { | ||
247 | return false; | ||
248 | } | ||
249 | } | ||
250 | } | ||
251 | |||
252 | /** | ||
253 | * Generated pattern matcher API of the modes3.queries.unreachable pattern, | ||
254 | * providing pattern-specific query methods. | ||
255 | * | ||
256 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
257 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
258 | * | ||
259 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
260 | * | ||
261 | * <p>Original source: | ||
262 | * <code><pre> | ||
263 | * {@literal @}Constraint(message = "unreachable", severity = "error", key = { S1, S2 }) | ||
264 | * pattern unreachable(S1 : Segment, S2 : Segment) { | ||
265 | * neg find reachable(S1, S2); | ||
266 | * } | ||
267 | * </pre></code> | ||
268 | * | ||
269 | * @see Match | ||
270 | * @see Unreachable | ||
271 | * | ||
272 | */ | ||
273 | public static class Matcher extends BaseMatcher<Unreachable.Match> { | ||
274 | /** | ||
275 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
276 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
277 | * | ||
278 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
279 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
280 | * | ||
281 | */ | ||
282 | public static Unreachable.Matcher on(final ViatraQueryEngine engine) { | ||
283 | // check if matcher already exists | ||
284 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
285 | if (matcher == null) { | ||
286 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
287 | } | ||
288 | return matcher; | ||
289 | } | ||
290 | |||
291 | /** | ||
292 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
293 | * @return an initialized matcher | ||
294 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
295 | * | ||
296 | */ | ||
297 | public static Unreachable.Matcher create() { | ||
298 | return new Matcher(); | ||
299 | } | ||
300 | |||
301 | private static final int POSITION_S1 = 0; | ||
302 | |||
303 | private static final int POSITION_S2 = 1; | ||
304 | |||
305 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Unreachable.Matcher.class); | ||
306 | |||
307 | /** | ||
308 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
309 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
310 | * | ||
311 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
312 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
313 | * | ||
314 | */ | ||
315 | private Matcher() { | ||
316 | super(querySpecification()); | ||
317 | } | ||
318 | |||
319 | /** | ||
320 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
321 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
322 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
323 | * @return matches represented as a Match object. | ||
324 | * | ||
325 | */ | ||
326 | public Collection<Unreachable.Match> getAllMatches(final Segment pS1, final Segment pS2) { | ||
327 | return rawStreamAllMatches(new Object[]{pS1, pS2}).collect(Collectors.toSet()); | ||
328 | } | ||
329 | |||
330 | /** | ||
331 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
332 | * </p> | ||
333 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
334 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
335 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
336 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
337 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
338 | * @return a stream of matches represented as a Match object. | ||
339 | * | ||
340 | */ | ||
341 | public Stream<Unreachable.Match> streamAllMatches(final Segment pS1, final Segment pS2) { | ||
342 | return rawStreamAllMatches(new Object[]{pS1, pS2}); | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
347 | * Neither determinism nor randomness of selection is guaranteed. | ||
348 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
349 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
350 | * @return a match represented as a Match object, or null if no match is found. | ||
351 | * | ||
352 | */ | ||
353 | public Optional<Unreachable.Match> getOneArbitraryMatch(final Segment pS1, final Segment pS2) { | ||
354 | return rawGetOneArbitraryMatch(new Object[]{pS1, pS2}); | ||
355 | } | ||
356 | |||
357 | /** | ||
358 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
359 | * under any possible substitution of the unspecified parameters (if any). | ||
360 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
361 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
362 | * @return true if the input is a valid (partial) match of the pattern. | ||
363 | * | ||
364 | */ | ||
365 | public boolean hasMatch(final Segment pS1, final Segment pS2) { | ||
366 | return rawHasMatch(new Object[]{pS1, pS2}); | ||
367 | } | ||
368 | |||
369 | /** | ||
370 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
371 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
372 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
373 | * @return the number of pattern matches found. | ||
374 | * | ||
375 | */ | ||
376 | public int countMatches(final Segment pS1, final Segment pS2) { | ||
377 | return rawCountMatches(new Object[]{pS1, pS2}); | ||
378 | } | ||
379 | |||
380 | /** | ||
381 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
382 | * Neither determinism nor randomness of selection is guaranteed. | ||
383 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
384 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
385 | * @param processor the action that will process the selected match. | ||
386 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
387 | * | ||
388 | */ | ||
389 | public boolean forOneArbitraryMatch(final Segment pS1, final Segment pS2, final Consumer<? super Unreachable.Match> processor) { | ||
390 | return rawForOneArbitraryMatch(new Object[]{pS1, pS2}, processor); | ||
391 | } | ||
392 | |||
393 | /** | ||
394 | * Returns a new (partial) match. | ||
395 | * This can be used e.g. to call the matcher with a partial match. | ||
396 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
397 | * @param pS1 the fixed value of pattern parameter S1, or null if not bound. | ||
398 | * @param pS2 the fixed value of pattern parameter S2, or null if not bound. | ||
399 | * @return the (partial) match object. | ||
400 | * | ||
401 | */ | ||
402 | public Unreachable.Match newMatch(final Segment pS1, final Segment pS2) { | ||
403 | return Unreachable.Match.newMatch(pS1, pS2); | ||
404 | } | ||
405 | |||
406 | /** | ||
407 | * Retrieve the set of values that occur in matches for S1. | ||
408 | * @return the Set of all values or empty set if there are no matches | ||
409 | * | ||
410 | */ | ||
411 | protected Stream<Segment> rawStreamAllValuesOfS1(final Object[] parameters) { | ||
412 | return rawStreamAllValues(POSITION_S1, parameters).map(Segment.class::cast); | ||
413 | } | ||
414 | |||
415 | /** | ||
416 | * Retrieve the set of values that occur in matches for S1. | ||
417 | * @return the Set of all values or empty set if there are no matches | ||
418 | * | ||
419 | */ | ||
420 | public Set<Segment> getAllValuesOfS1() { | ||
421 | return rawStreamAllValuesOfS1(emptyArray()).collect(Collectors.toSet()); | ||
422 | } | ||
423 | |||
424 | /** | ||
425 | * Retrieve the set of values that occur in matches for S1. | ||
426 | * @return the Set of all values or empty set if there are no matches | ||
427 | * | ||
428 | */ | ||
429 | public Stream<Segment> streamAllValuesOfS1() { | ||
430 | return rawStreamAllValuesOfS1(emptyArray()); | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * Retrieve the set of values that occur in matches for S1. | ||
435 | * </p> | ||
436 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
437 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
438 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
439 | * | ||
440 | * @return the Stream of all values or empty set if there are no matches | ||
441 | * | ||
442 | */ | ||
443 | public Stream<Segment> streamAllValuesOfS1(final Unreachable.Match partialMatch) { | ||
444 | return rawStreamAllValuesOfS1(partialMatch.toArray()); | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * Retrieve the set of values that occur in matches for S1. | ||
449 | * </p> | ||
450 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
451 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
452 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
453 | * | ||
454 | * @return the Stream of all values or empty set if there are no matches | ||
455 | * | ||
456 | */ | ||
457 | public Stream<Segment> streamAllValuesOfS1(final Segment pS2) { | ||
458 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}); | ||
459 | } | ||
460 | |||
461 | /** | ||
462 | * Retrieve the set of values that occur in matches for S1. | ||
463 | * @return the Set of all values or empty set if there are no matches | ||
464 | * | ||
465 | */ | ||
466 | public Set<Segment> getAllValuesOfS1(final Unreachable.Match partialMatch) { | ||
467 | return rawStreamAllValuesOfS1(partialMatch.toArray()).collect(Collectors.toSet()); | ||
468 | } | ||
469 | |||
470 | /** | ||
471 | * Retrieve the set of values that occur in matches for S1. | ||
472 | * @return the Set of all values or empty set if there are no matches | ||
473 | * | ||
474 | */ | ||
475 | public Set<Segment> getAllValuesOfS1(final Segment pS2) { | ||
476 | return rawStreamAllValuesOfS1(new Object[]{null, pS2}).collect(Collectors.toSet()); | ||
477 | } | ||
478 | |||
479 | /** | ||
480 | * Retrieve the set of values that occur in matches for S2. | ||
481 | * @return the Set of all values or empty set if there are no matches | ||
482 | * | ||
483 | */ | ||
484 | protected Stream<Segment> rawStreamAllValuesOfS2(final Object[] parameters) { | ||
485 | return rawStreamAllValues(POSITION_S2, parameters).map(Segment.class::cast); | ||
486 | } | ||
487 | |||
488 | /** | ||
489 | * Retrieve the set of values that occur in matches for S2. | ||
490 | * @return the Set of all values or empty set if there are no matches | ||
491 | * | ||
492 | */ | ||
493 | public Set<Segment> getAllValuesOfS2() { | ||
494 | return rawStreamAllValuesOfS2(emptyArray()).collect(Collectors.toSet()); | ||
495 | } | ||
496 | |||
497 | /** | ||
498 | * Retrieve the set of values that occur in matches for S2. | ||
499 | * @return the Set of all values or empty set if there are no matches | ||
500 | * | ||
501 | */ | ||
502 | public Stream<Segment> streamAllValuesOfS2() { | ||
503 | return rawStreamAllValuesOfS2(emptyArray()); | ||
504 | } | ||
505 | |||
506 | /** | ||
507 | * Retrieve the set of values that occur in matches for S2. | ||
508 | * </p> | ||
509 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
510 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
511 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
512 | * | ||
513 | * @return the Stream of all values or empty set if there are no matches | ||
514 | * | ||
515 | */ | ||
516 | public Stream<Segment> streamAllValuesOfS2(final Unreachable.Match partialMatch) { | ||
517 | return rawStreamAllValuesOfS2(partialMatch.toArray()); | ||
518 | } | ||
519 | |||
520 | /** | ||
521 | * Retrieve the set of values that occur in matches for S2. | ||
522 | * </p> | ||
523 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
524 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
525 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
526 | * | ||
527 | * @return the Stream of all values or empty set if there are no matches | ||
528 | * | ||
529 | */ | ||
530 | public Stream<Segment> streamAllValuesOfS2(final Segment pS1) { | ||
531 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}); | ||
532 | } | ||
533 | |||
534 | /** | ||
535 | * Retrieve the set of values that occur in matches for S2. | ||
536 | * @return the Set of all values or empty set if there are no matches | ||
537 | * | ||
538 | */ | ||
539 | public Set<Segment> getAllValuesOfS2(final Unreachable.Match partialMatch) { | ||
540 | return rawStreamAllValuesOfS2(partialMatch.toArray()).collect(Collectors.toSet()); | ||
541 | } | ||
542 | |||
543 | /** | ||
544 | * Retrieve the set of values that occur in matches for S2. | ||
545 | * @return the Set of all values or empty set if there are no matches | ||
546 | * | ||
547 | */ | ||
548 | public Set<Segment> getAllValuesOfS2(final Segment pS1) { | ||
549 | return rawStreamAllValuesOfS2(new Object[]{pS1, null}).collect(Collectors.toSet()); | ||
550 | } | ||
551 | |||
552 | @Override | ||
553 | protected Unreachable.Match tupleToMatch(final Tuple t) { | ||
554 | try { | ||
555 | return Unreachable.Match.newMatch((Segment) t.get(POSITION_S1), (Segment) t.get(POSITION_S2)); | ||
556 | } catch(ClassCastException e) { | ||
557 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
558 | return null; | ||
559 | } | ||
560 | } | ||
561 | |||
562 | @Override | ||
563 | protected Unreachable.Match arrayToMatch(final Object[] match) { | ||
564 | try { | ||
565 | return Unreachable.Match.newMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
566 | } catch(ClassCastException e) { | ||
567 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
568 | return null; | ||
569 | } | ||
570 | } | ||
571 | |||
572 | @Override | ||
573 | protected Unreachable.Match arrayToMatchMutable(final Object[] match) { | ||
574 | try { | ||
575 | return Unreachable.Match.newMutableMatch((Segment) match[POSITION_S1], (Segment) match[POSITION_S2]); | ||
576 | } catch(ClassCastException e) { | ||
577 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
578 | return null; | ||
579 | } | ||
580 | } | ||
581 | |||
582 | /** | ||
583 | * @return the singleton instance of the query specification of this pattern | ||
584 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
585 | * | ||
586 | */ | ||
587 | public static IQuerySpecification<Unreachable.Matcher> querySpecification() { | ||
588 | return Unreachable.instance(); | ||
589 | } | ||
590 | } | ||
591 | |||
592 | private Unreachable() { | ||
593 | super(GeneratedPQuery.INSTANCE); | ||
594 | } | ||
595 | |||
596 | /** | ||
597 | * @return the singleton instance of the query specification | ||
598 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
599 | * | ||
600 | */ | ||
601 | public static Unreachable instance() { | ||
602 | try{ | ||
603 | return LazyHolder.INSTANCE; | ||
604 | } catch (ExceptionInInitializerError err) { | ||
605 | throw processInitializerError(err); | ||
606 | } | ||
607 | } | ||
608 | |||
609 | @Override | ||
610 | protected Unreachable.Matcher instantiate(final ViatraQueryEngine engine) { | ||
611 | return Unreachable.Matcher.on(engine); | ||
612 | } | ||
613 | |||
614 | @Override | ||
615 | public Unreachable.Matcher instantiate() { | ||
616 | return Unreachable.Matcher.create(); | ||
617 | } | ||
618 | |||
619 | @Override | ||
620 | public Unreachable.Match newEmptyMatch() { | ||
621 | return Unreachable.Match.newEmptyMatch(); | ||
622 | } | ||
623 | |||
624 | @Override | ||
625 | public Unreachable.Match newMatch(final Object... parameters) { | ||
626 | return Unreachable.Match.newMatch((modes3.Segment) parameters[0], (modes3.Segment) parameters[1]); | ||
627 | } | ||
628 | |||
629 | /** | ||
630 | * Inner class allowing the singleton instance of {@link Unreachable} to be created | ||
631 | * <b>not</b> at the class load time of the outer class, | ||
632 | * but rather at the first call to {@link Unreachable#instance()}. | ||
633 | * | ||
634 | * <p> This workaround is required e.g. to support recursion. | ||
635 | * | ||
636 | */ | ||
637 | private static class LazyHolder { | ||
638 | private static final Unreachable INSTANCE = new Unreachable(); | ||
639 | |||
640 | /** | ||
641 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
642 | * This initialization order is required to support indirect recursion. | ||
643 | * | ||
644 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
645 | * | ||
646 | */ | ||
647 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
648 | |||
649 | public static Object ensureInitialized() { | ||
650 | INSTANCE.ensureInitializedInternal(); | ||
651 | return null; | ||
652 | } | ||
653 | } | ||
654 | |||
655 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
656 | private static final Unreachable.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
657 | |||
658 | private final PParameter parameter_S1 = new PParameter("S1", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
659 | |||
660 | private final PParameter parameter_S2 = new PParameter("S2", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
661 | |||
662 | private final List<PParameter> parameters = Arrays.asList(parameter_S1, parameter_S2); | ||
663 | |||
664 | private GeneratedPQuery() { | ||
665 | super(PVisibility.PUBLIC); | ||
666 | } | ||
667 | |||
668 | @Override | ||
669 | public String getFullyQualifiedName() { | ||
670 | return "modes3.queries.unreachable"; | ||
671 | } | ||
672 | |||
673 | @Override | ||
674 | public List<String> getParameterNames() { | ||
675 | return Arrays.asList("S1","S2"); | ||
676 | } | ||
677 | |||
678 | @Override | ||
679 | public List<PParameter> getParameters() { | ||
680 | return parameters; | ||
681 | } | ||
682 | |||
683 | @Override | ||
684 | public Set<PBody> doGetContainedBodies() { | ||
685 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
686 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
687 | { | ||
688 | PBody body = new PBody(this); | ||
689 | PVariable var_S1 = body.getOrCreateVariableByName("S1"); | ||
690 | PVariable var_S2 = body.getOrCreateVariableByName("S2"); | ||
691 | new TypeConstraint(body, Tuples.flatTupleOf(var_S1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
692 | new TypeConstraint(body, Tuples.flatTupleOf(var_S2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
693 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
694 | new ExportedParameter(body, var_S1, parameter_S1), | ||
695 | new ExportedParameter(body, var_S2, parameter_S2) | ||
696 | )); | ||
697 | // neg find reachable(S1, S2) | ||
698 | new NegativePatternCall(body, Tuples.flatTupleOf(var_S1, var_S2), Reachable.instance().getInternalQueryRepresentation()); | ||
699 | bodies.add(body); | ||
700 | } | ||
701 | { | ||
702 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
703 | annotation.addAttribute("message", "unreachable"); | ||
704 | annotation.addAttribute("severity", "error"); | ||
705 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
706 | new ParameterReference("S1"), | ||
707 | new ParameterReference("S2") | ||
708 | })); | ||
709 | addAnnotation(annotation); | ||
710 | } | ||
711 | return bodies; | ||
712 | } | ||
713 | } | ||
714 | } | ||
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..ddc8ea74 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.CloseTrainsObjectiveHint.xtendbin | |||
Binary files 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..e89ea81c --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.EndOfSidingObjectiveHint.xtendbin | |||
Binary files 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..e006abd7 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.MisalignedTurnoutObjectiveHint.xtendbin | |||
Binary files 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 new file mode 100644 index 00000000..11227a1c --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3ModelGenerator.xtendbin | |||
Binary files 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 new file mode 100644 index 00000000..90728c00 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3TypeScopeHint.xtendbin | |||
Binary files 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 new file mode 100644 index 00000000..4625dcf2 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.Modes3UnitPropagationGenerator.xtendbin | |||
Binary files 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..d74342ba --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.TrainLocationsObjectiveHint.xtendbin | |||
Binary files 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 new file mode 100644 index 00000000..1a7df1d9 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/.gitignore | |||
@@ -0,0 +1,13 @@ | |||
1 | /.Modes3ModelGenerator.java._trace | ||
2 | /.Modes3UnitPropagationGenerator.java._trace | ||
3 | /.Modes3TypeScopeHint.java._trace | ||
4 | /.Modes3TypeScopeHint.xtendbin | ||
5 | /.Modes3UnitPropagationGenerator.xtendbin | ||
6 | /Modes3TypeScopeHint.java | ||
7 | /.Modes3ModelGenerator.xtendbin | ||
8 | /Modes3ModelGenerator.java | ||
9 | /Modes3UnitPropagationGenerator.java | ||
10 | /.CloseTrainsObjectiveHint.java._trace | ||
11 | /.TrainLocationsObjectiveHint.java._trace | ||
12 | /.MisalignedTurnoutObjectiveHint.java._trace | ||
13 | /.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 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import com.google.common.collect.ImmutableList; | ||
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
6 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Dimension; | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilder; | ||
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory; | ||
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator; | ||
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch; | ||
13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers; | ||
14 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint; | ||
15 | import java.util.Collection; | ||
16 | import java.util.List; | ||
17 | import java.util.Map; | ||
18 | import java.util.Set; | ||
19 | import modes3.Modes3Package; | ||
20 | import modes3.queries.CloseTrains_step_2; | ||
21 | import modes3.queries.CloseTrains_step_3; | ||
22 | import modes3.queries.CloseTrains_step_4; | ||
23 | import modes3.queries.CloseTrains_step_5; | ||
24 | import modes3.queries.CloseTrains_step_6; | ||
25 | import modes3.queries.CloseTrains_step_7; | ||
26 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
27 | import org.eclipse.xtext.xbase.lib.Extension; | ||
28 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
29 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
30 | |||
31 | @SuppressWarnings("all") | ||
32 | public class CloseTrainsObjectiveHint extends CostObjectiveHint { | ||
33 | private final Type segmentType; | ||
34 | |||
35 | private final Type trainType; | ||
36 | |||
37 | public CloseTrainsObjectiveHint(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { | ||
38 | @Extension | ||
39 | final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; | ||
40 | this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); | ||
41 | this.trainType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTrain()); | ||
42 | } | ||
43 | |||
44 | @Override | ||
45 | public boolean isExact() { | ||
46 | return true; | ||
47 | } | ||
48 | |||
49 | @Override | ||
50 | public PolyhedronExtensionOperator createPolyhedronExtensionOperator(final Map<String, CostElementMatchers> costElementMatchers) { | ||
51 | PolyhedronExtensionOperator _xblockexpression = null; | ||
52 | { | ||
53 | final CostElementMatchers step2 = costElementMatchers.get(CloseTrains_step_2.instance().getFullyQualifiedName()); | ||
54 | final CostElementMatchers step3 = costElementMatchers.get(CloseTrains_step_3.instance().getFullyQualifiedName()); | ||
55 | final CostElementMatchers step4 = costElementMatchers.get(CloseTrains_step_4.instance().getFullyQualifiedName()); | ||
56 | final CostElementMatchers step5 = costElementMatchers.get(CloseTrains_step_5.instance().getFullyQualifiedName()); | ||
57 | final CostElementMatchers step6 = costElementMatchers.get(CloseTrains_step_6.instance().getFullyQualifiedName()); | ||
58 | final CostElementMatchers step7 = costElementMatchers.get(CloseTrains_step_7.instance().getFullyQualifiedName()); | ||
59 | final PolyhedronExtensionOperator _function = (ExtendedLinearExpressionBuilderFactory it) -> { | ||
60 | final ExtendedLinearExpressionBuilder objectiveBuilder = it.createBuilder(); | ||
61 | ImmutableList<CostElementMatch> _matches = step2.getMatches(); | ||
62 | for (final CostElementMatch m : _matches) { | ||
63 | { | ||
64 | final Dimension dimension = it.getDimension(m.getMatch()); | ||
65 | objectiveBuilder.add(step2.getWeight(), dimension); | ||
66 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
67 | boolean _isMulti = m.isMulti(); | ||
68 | if (_isMulti) { | ||
69 | it.createBuilder().add(1, dimension).add((-1), this.trainType).build().assertEqualsTo(0); | ||
70 | } else { | ||
71 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
72 | boolean _isMust = m.isMust(); | ||
73 | if (_isMust) { | ||
74 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 | final ImmutableList<CostElementMatch> step3Matches = step3.getMatches(); | ||
80 | for (final CostElementMatch m_1 : step3Matches) { | ||
81 | { | ||
82 | final Dimension dimension = it.getDimension(m_1.getMatch()); | ||
83 | objectiveBuilder.add(step3.getWeight(), dimension); | ||
84 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
85 | boolean _isMulti = m_1.isMulti(); | ||
86 | boolean _not = (!_isMulti); | ||
87 | if (_not) { | ||
88 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
89 | boolean _isMust = m_1.isMust(); | ||
90 | if (_isMust) { | ||
91 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | } | ||
96 | final Function1<CostElementMatch, IPatternMatch> _function_1 = (CostElementMatch it_1) -> { | ||
97 | return step2.projectMayMatch(it_1.getMatch(), 2); | ||
98 | }; | ||
99 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step3Matches, _function_1).entrySet(); | ||
100 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair : _entrySet) { | ||
101 | { | ||
102 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
103 | List<CostElementMatch> _value = pair.getValue(); | ||
104 | for (final CostElementMatch m_2 : _value) { | ||
105 | multiplicityBuilder.add(1, m_2.getMatch()); | ||
106 | } | ||
107 | multiplicityBuilder.add((-1), pair.getKey()); | ||
108 | multiplicityBuilder.build().assertEqualsTo(0); | ||
109 | } | ||
110 | } | ||
111 | CloseTrainsObjectiveHint.boundLimit(it, step3Matches, 2, this.trainType, 1); | ||
112 | CloseTrainsObjectiveHint.boundLimit(it, step3Matches, 3, this.segmentType, 1); | ||
113 | final ImmutableList<CostElementMatch> step4Matches = step4.getMatches(); | ||
114 | for (final CostElementMatch m_2 : step4Matches) { | ||
115 | { | ||
116 | final Dimension dimension = it.getDimension(m_2.getMatch()); | ||
117 | objectiveBuilder.add(step4.getWeight(), dimension); | ||
118 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
119 | boolean _isMulti = m_2.isMulti(); | ||
120 | boolean _not = (!_isMulti); | ||
121 | if (_not) { | ||
122 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
123 | boolean _isMust = m_2.isMust(); | ||
124 | if (_isMust) { | ||
125 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | final Function1<CostElementMatch, IPatternMatch> _function_2 = (CostElementMatch it_1) -> { | ||
131 | return step3.projectMayMatch(it_1.getMatch(), 2, 3); | ||
132 | }; | ||
133 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet_1 = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step4Matches, _function_2).entrySet(); | ||
134 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair_1 : _entrySet_1) { | ||
135 | { | ||
136 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
137 | List<CostElementMatch> _value = pair_1.getValue(); | ||
138 | for (final CostElementMatch m_3 : _value) { | ||
139 | multiplicityBuilder.add(1, m_3.getMatch()); | ||
140 | } | ||
141 | multiplicityBuilder.add((-2), pair_1.getKey()); | ||
142 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
143 | } | ||
144 | } | ||
145 | CloseTrainsObjectiveHint.boundLimit(it, step4Matches, 2, this.trainType, 2); | ||
146 | CloseTrainsObjectiveHint.boundLimit(it, step4Matches, 3, this.segmentType, 2); | ||
147 | CloseTrainsObjectiveHint.boundLimit(it, step4Matches, 4, this.segmentType, 2); | ||
148 | final ImmutableList<CostElementMatch> step5Matches = step5.getMatches(); | ||
149 | for (final CostElementMatch m_3 : step5Matches) { | ||
150 | { | ||
151 | final Dimension dimension = it.getDimension(m_3.getMatch()); | ||
152 | objectiveBuilder.add(step5.getWeight(), dimension); | ||
153 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
154 | boolean _isMulti = m_3.isMulti(); | ||
155 | boolean _not = (!_isMulti); | ||
156 | if (_not) { | ||
157 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
158 | boolean _isMust = m_3.isMust(); | ||
159 | if (_isMust) { | ||
160 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
161 | } | ||
162 | } | ||
163 | } | ||
164 | } | ||
165 | final Function1<CostElementMatch, IPatternMatch> _function_3 = (CostElementMatch it_1) -> { | ||
166 | return step4.projectMayMatch(it_1.getMatch(), 2, 3, 4); | ||
167 | }; | ||
168 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet_2 = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step5Matches, _function_3).entrySet(); | ||
169 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair_2 : _entrySet_2) { | ||
170 | { | ||
171 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
172 | List<CostElementMatch> _value = pair_2.getValue(); | ||
173 | for (final CostElementMatch m_4 : _value) { | ||
174 | multiplicityBuilder.add(1, m_4.getMatch()); | ||
175 | } | ||
176 | multiplicityBuilder.add((-2), pair_2.getKey()); | ||
177 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
178 | } | ||
179 | } | ||
180 | CloseTrainsObjectiveHint.boundLimit(it, step5Matches, 2, this.trainType, 4); | ||
181 | CloseTrainsObjectiveHint.boundLimit(it, step5Matches, 3, this.segmentType, 4); | ||
182 | CloseTrainsObjectiveHint.boundLimit(it, step5Matches, 4, this.segmentType, 4); | ||
183 | CloseTrainsObjectiveHint.boundLimit(it, step5Matches, 5, this.segmentType, 4); | ||
184 | final ImmutableList<CostElementMatch> step6Matches = step6.getMatches(); | ||
185 | for (final CostElementMatch m_4 : step6Matches) { | ||
186 | { | ||
187 | final Dimension dimension = it.getDimension(m_4.getMatch()); | ||
188 | objectiveBuilder.add(step6.getWeight(), dimension); | ||
189 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
190 | boolean _isMulti = m_4.isMulti(); | ||
191 | if (_isMulti) { | ||
192 | Object _get = m_4.getMatch().get(3); | ||
193 | Object _get_1 = m_4.getMatch().get(5); | ||
194 | boolean _equals = Objects.equal(_get, _get_1); | ||
195 | if (_equals) { | ||
196 | it.createBuilder().add(2, m_4.getMatch()).add((-1), step5.projectMayMatch(m_4.getMatch(), 2, 3, 4, 5)).build().assertEqualsTo(0); | ||
197 | } else { | ||
198 | it.createBuilder().add(1, m_4.getMatch()).add((-1), step5.projectMayMatch(m_4.getMatch(), 2, 3, 4, 5)).build().assertEqualsTo(0); | ||
199 | } | ||
200 | } else { | ||
201 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
202 | boolean _isMust = m_4.isMust(); | ||
203 | if (_isMust) { | ||
204 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | CloseTrainsObjectiveHint.boundLimit(it, step6Matches, 2, this.trainType, 2); | ||
210 | CloseTrainsObjectiveHint.boundLimit(it, step6Matches, 3, this.segmentType, 2); | ||
211 | CloseTrainsObjectiveHint.boundLimit(it, step6Matches, 4, this.segmentType, 2); | ||
212 | CloseTrainsObjectiveHint.boundLimit(it, step6Matches, 5, this.segmentType, 2); | ||
213 | final ImmutableList<CostElementMatch> step7Matches = step7.getMatches(); | ||
214 | for (final CostElementMatch m_5 : step7Matches) { | ||
215 | { | ||
216 | final Dimension dimension = it.getDimension(m_5.getMatch()); | ||
217 | objectiveBuilder.add(step7.getWeight(), dimension); | ||
218 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
219 | boolean _isMulti = m_5.isMulti(); | ||
220 | boolean _not = (!_isMulti); | ||
221 | if (_not) { | ||
222 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
223 | boolean _isMust = m_5.isMust(); | ||
224 | if (_isMust) { | ||
225 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | final Function1<CostElementMatch, IPatternMatch> _function_4 = (CostElementMatch it_1) -> { | ||
231 | return step6.projectMayMatch(it_1.getMatch(), 2, 3, 4, 5); | ||
232 | }; | ||
233 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet_3 = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step7Matches, _function_4).entrySet(); | ||
234 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair_3 : _entrySet_3) { | ||
235 | { | ||
236 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
237 | List<CostElementMatch> _value = pair_3.getValue(); | ||
238 | for (final CostElementMatch m_6 : _value) { | ||
239 | multiplicityBuilder.add(1, m_6.getMatch()); | ||
240 | } | ||
241 | multiplicityBuilder.add((-1), pair_3.getKey()); | ||
242 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
243 | } | ||
244 | } | ||
245 | CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 2, this.trainType, 2); | ||
246 | CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 3, this.segmentType, 2); | ||
247 | CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 4, this.segmentType, 2); | ||
248 | CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 5, this.segmentType, 2); | ||
249 | CloseTrainsObjectiveHint.boundLimit(it, step7Matches, 6, this.trainType, 2); | ||
250 | this.buildWithBounds(objectiveBuilder); | ||
251 | }; | ||
252 | _xblockexpression = _function; | ||
253 | } | ||
254 | return _xblockexpression; | ||
255 | } | ||
256 | |||
257 | private static void boundLimit(@Extension final ExtendedLinearExpressionBuilderFactory factory, final Collection<CostElementMatch> matches, final int index, final Type type, final int count) { | ||
258 | final Function1<CostElementMatch, Object> _function = (CostElementMatch it) -> { | ||
259 | return it.getMatch().get(index); | ||
260 | }; | ||
261 | Set<Map.Entry<Object, List<CostElementMatch>>> _entrySet = IterableExtensions.<Object, CostElementMatch>groupBy(matches, _function).entrySet(); | ||
262 | for (final Map.Entry<Object, List<CostElementMatch>> pair : _entrySet) { | ||
263 | { | ||
264 | final ExtendedLinearExpressionBuilder multiplicityBuilder = factory.createBuilder(); | ||
265 | List<CostElementMatch> _value = pair.getValue(); | ||
266 | for (final CostElementMatch m : _value) { | ||
267 | multiplicityBuilder.add(1, m.getMatch()); | ||
268 | } | ||
269 | boolean _isMulti = CostElementMatchers.isMulti(pair.getKey()); | ||
270 | if (_isMulti) { | ||
271 | multiplicityBuilder.add((-count), type); | ||
272 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
273 | } else { | ||
274 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(count)); | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | } | ||
279 | } | ||
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 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import com.google.common.collect.ImmutableList; | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Dimension; | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilder; | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory; | ||
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator; | ||
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch; | ||
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers; | ||
13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint; | ||
14 | import java.util.Collection; | ||
15 | import java.util.List; | ||
16 | import java.util.Map; | ||
17 | import java.util.Set; | ||
18 | import modes3.Modes3Package; | ||
19 | import modes3.queries.EndOfSiding_step_2; | ||
20 | import modes3.queries.EndOfSiding_step_3; | ||
21 | import modes3.queries.EndOfSiding_step_4; | ||
22 | import modes3.queries.EndOfSiding_step_5; | ||
23 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
24 | import org.eclipse.xtext.xbase.lib.Extension; | ||
25 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
26 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
27 | |||
28 | @SuppressWarnings("all") | ||
29 | public class EndOfSidingObjectiveHint extends CostObjectiveHint { | ||
30 | private final Type segmentType; | ||
31 | |||
32 | private final Type trainType; | ||
33 | |||
34 | public EndOfSidingObjectiveHint(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { | ||
35 | @Extension | ||
36 | final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; | ||
37 | this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); | ||
38 | this.trainType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTrain()); | ||
39 | } | ||
40 | |||
41 | @Override | ||
42 | public boolean isExact() { | ||
43 | return true; | ||
44 | } | ||
45 | |||
46 | @Override | ||
47 | public PolyhedronExtensionOperator createPolyhedronExtensionOperator(final Map<String, CostElementMatchers> costElementMatchers) { | ||
48 | PolyhedronExtensionOperator _xblockexpression = null; | ||
49 | { | ||
50 | final CostElementMatchers step2 = costElementMatchers.get(EndOfSiding_step_2.instance().getFullyQualifiedName()); | ||
51 | final CostElementMatchers step3 = costElementMatchers.get(EndOfSiding_step_3.instance().getFullyQualifiedName()); | ||
52 | final CostElementMatchers step4 = costElementMatchers.get(EndOfSiding_step_4.instance().getFullyQualifiedName()); | ||
53 | final CostElementMatchers step5 = costElementMatchers.get(EndOfSiding_step_5.instance().getFullyQualifiedName()); | ||
54 | final PolyhedronExtensionOperator _function = (ExtendedLinearExpressionBuilderFactory it) -> { | ||
55 | final ExtendedLinearExpressionBuilder objectiveBuilder = it.createBuilder(); | ||
56 | ImmutableList<CostElementMatch> _matches = step2.getMatches(); | ||
57 | for (final CostElementMatch m : _matches) { | ||
58 | { | ||
59 | final Dimension dimension = it.getDimension(m.getMatch()); | ||
60 | objectiveBuilder.add(step2.getWeight(), dimension); | ||
61 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
62 | boolean _isMulti = m.isMulti(); | ||
63 | if (_isMulti) { | ||
64 | it.createBuilder().add(1, dimension).add((-1), this.trainType).build().assertEqualsTo(0); | ||
65 | } else { | ||
66 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
67 | boolean _isMust = m.isMust(); | ||
68 | if (_isMust) { | ||
69 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
70 | } | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | final ImmutableList<CostElementMatch> step3Matches = step3.getMatches(); | ||
75 | for (final CostElementMatch m_1 : step3Matches) { | ||
76 | { | ||
77 | final Dimension dimension = it.getDimension(m_1.getMatch()); | ||
78 | objectiveBuilder.add(step3.getWeight(), dimension); | ||
79 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
80 | boolean _isMulti = m_1.isMulti(); | ||
81 | boolean _not = (!_isMulti); | ||
82 | if (_not) { | ||
83 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
84 | boolean _isMust = m_1.isMust(); | ||
85 | if (_isMust) { | ||
86 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | } | ||
91 | final Function1<CostElementMatch, IPatternMatch> _function_1 = (CostElementMatch it_1) -> { | ||
92 | return step2.projectMayMatch(it_1.getMatch(), 2); | ||
93 | }; | ||
94 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step3Matches, _function_1).entrySet(); | ||
95 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair : _entrySet) { | ||
96 | { | ||
97 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
98 | List<CostElementMatch> _value = pair.getValue(); | ||
99 | for (final CostElementMatch m_2 : _value) { | ||
100 | multiplicityBuilder.add(1, m_2.getMatch()); | ||
101 | } | ||
102 | multiplicityBuilder.add((-1), pair.getKey()); | ||
103 | multiplicityBuilder.build().assertEqualsTo(0); | ||
104 | } | ||
105 | } | ||
106 | EndOfSidingObjectiveHint.boundLimit(it, step3Matches, 2, this.trainType, 1); | ||
107 | EndOfSidingObjectiveHint.boundLimit(it, step3Matches, 3, this.segmentType, 1); | ||
108 | final ImmutableList<CostElementMatch> step4Matches = step4.getMatches(); | ||
109 | for (final CostElementMatch m_2 : step4Matches) { | ||
110 | { | ||
111 | final Dimension dimension = it.getDimension(m_2.getMatch()); | ||
112 | objectiveBuilder.add(step4.getWeight(), dimension); | ||
113 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
114 | boolean _isMulti = m_2.isMulti(); | ||
115 | boolean _not = (!_isMulti); | ||
116 | if (_not) { | ||
117 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
118 | boolean _isMust = m_2.isMust(); | ||
119 | if (_isMust) { | ||
120 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | final Function1<CostElementMatch, IPatternMatch> _function_2 = (CostElementMatch it_1) -> { | ||
126 | return step3.projectMayMatch(it_1.getMatch(), 2, 3); | ||
127 | }; | ||
128 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet_1 = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step4Matches, _function_2).entrySet(); | ||
129 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair_1 : _entrySet_1) { | ||
130 | { | ||
131 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
132 | List<CostElementMatch> _value = pair_1.getValue(); | ||
133 | for (final CostElementMatch m_3 : _value) { | ||
134 | multiplicityBuilder.add(1, m_3.getMatch()); | ||
135 | } | ||
136 | multiplicityBuilder.add((-2), pair_1.getKey()); | ||
137 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
138 | } | ||
139 | } | ||
140 | EndOfSidingObjectiveHint.boundLimit(it, step4Matches, 2, this.trainType, 2); | ||
141 | EndOfSidingObjectiveHint.boundLimit(it, step4Matches, 3, this.segmentType, 2); | ||
142 | EndOfSidingObjectiveHint.boundLimit(it, step4Matches, 4, this.segmentType, 2); | ||
143 | final ImmutableList<CostElementMatch> step5Matches = step5.getMatches(); | ||
144 | for (final CostElementMatch m_3 : step5Matches) { | ||
145 | { | ||
146 | final Dimension dimension = it.getDimension(m_3.getMatch()); | ||
147 | objectiveBuilder.add(step5.getWeight(), dimension); | ||
148 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
149 | boolean _isMulti = m_3.isMulti(); | ||
150 | boolean _not = (!_isMulti); | ||
151 | if (_not) { | ||
152 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
153 | boolean _isMust = m_3.isMust(); | ||
154 | if (_isMust) { | ||
155 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
156 | } | ||
157 | } | ||
158 | it.createBuilder().add(1, m_3.getMatch()).add((-1), step4.projectMayMatch(m_3.getMatch(), 2, 3, 4)).build().tightenUpperBound(Integer.valueOf(0)); | ||
159 | } | ||
160 | } | ||
161 | EndOfSidingObjectiveHint.boundLimit(it, step5Matches, 2, this.trainType, 1); | ||
162 | EndOfSidingObjectiveHint.boundLimit(it, step5Matches, 3, this.segmentType, 2); | ||
163 | EndOfSidingObjectiveHint.boundLimit(it, step5Matches, 4, this.segmentType, 1); | ||
164 | this.buildWithBounds(objectiveBuilder); | ||
165 | }; | ||
166 | _xblockexpression = _function; | ||
167 | } | ||
168 | return _xblockexpression; | ||
169 | } | ||
170 | |||
171 | private static void boundLimit(@Extension final ExtendedLinearExpressionBuilderFactory factory, final Collection<CostElementMatch> matches, final int index, final Type type, final int count) { | ||
172 | final Function1<CostElementMatch, Object> _function = (CostElementMatch it) -> { | ||
173 | return it.getMatch().get(index); | ||
174 | }; | ||
175 | Set<Map.Entry<Object, List<CostElementMatch>>> _entrySet = IterableExtensions.<Object, CostElementMatch>groupBy(matches, _function).entrySet(); | ||
176 | for (final Map.Entry<Object, List<CostElementMatch>> pair : _entrySet) { | ||
177 | { | ||
178 | final ExtendedLinearExpressionBuilder multiplicityBuilder = factory.createBuilder(); | ||
179 | List<CostElementMatch> _value = pair.getValue(); | ||
180 | for (final CostElementMatch m : _value) { | ||
181 | multiplicityBuilder.add(1, m.getMatch()); | ||
182 | } | ||
183 | boolean _isMulti = CostElementMatchers.isMulti(pair.getKey()); | ||
184 | if (_isMulti) { | ||
185 | multiplicityBuilder.add((-count), type); | ||
186 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
187 | } else { | ||
188 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(count)); | ||
189 | } | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | } | ||
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 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import com.google.common.collect.ImmutableList; | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Dimension; | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilder; | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory; | ||
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator; | ||
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch; | ||
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers; | ||
13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint; | ||
14 | import java.util.Collection; | ||
15 | import java.util.List; | ||
16 | import java.util.Map; | ||
17 | import java.util.Set; | ||
18 | import modes3.Modes3Package; | ||
19 | import modes3.queries.MisalignedTurnout_step_2; | ||
20 | import modes3.queries.MisalignedTurnout_step_3; | ||
21 | import modes3.queries.MisalignedTurnout_step_4; | ||
22 | import modes3.queries.MisalignedTurnout_step_5; | ||
23 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
24 | import org.eclipse.xtext.xbase.lib.Extension; | ||
25 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
26 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
27 | |||
28 | @SuppressWarnings("all") | ||
29 | public class MisalignedTurnoutObjectiveHint extends CostObjectiveHint { | ||
30 | private final Type segmentType; | ||
31 | |||
32 | private final Type turnoutType; | ||
33 | |||
34 | private final Type trainType; | ||
35 | |||
36 | public MisalignedTurnoutObjectiveHint(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { | ||
37 | @Extension | ||
38 | final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; | ||
39 | this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); | ||
40 | this.turnoutType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTurnout()); | ||
41 | this.trainType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTrain()); | ||
42 | } | ||
43 | |||
44 | @Override | ||
45 | public boolean isExact() { | ||
46 | return true; | ||
47 | } | ||
48 | |||
49 | @Override | ||
50 | public PolyhedronExtensionOperator createPolyhedronExtensionOperator(final Map<String, CostElementMatchers> costElementMatchers) { | ||
51 | PolyhedronExtensionOperator _xblockexpression = null; | ||
52 | { | ||
53 | final CostElementMatchers step2 = costElementMatchers.get(MisalignedTurnout_step_2.instance().getFullyQualifiedName()); | ||
54 | final CostElementMatchers step3 = costElementMatchers.get(MisalignedTurnout_step_3.instance().getFullyQualifiedName()); | ||
55 | final CostElementMatchers step4 = costElementMatchers.get(MisalignedTurnout_step_4.instance().getFullyQualifiedName()); | ||
56 | final CostElementMatchers step5 = costElementMatchers.get(MisalignedTurnout_step_5.instance().getFullyQualifiedName()); | ||
57 | final PolyhedronExtensionOperator _function = (ExtendedLinearExpressionBuilderFactory it) -> { | ||
58 | final ExtendedLinearExpressionBuilder objectiveBuilder = it.createBuilder(); | ||
59 | ImmutableList<CostElementMatch> _matches = step2.getMatches(); | ||
60 | for (final CostElementMatch m : _matches) { | ||
61 | { | ||
62 | final Dimension dimension = it.getDimension(m.getMatch()); | ||
63 | objectiveBuilder.add(step2.getWeight(), dimension); | ||
64 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
65 | boolean _isMulti = m.isMulti(); | ||
66 | if (_isMulti) { | ||
67 | it.createBuilder().add(1, dimension).add((-1), this.turnoutType).build().assertEqualsTo(0); | ||
68 | } else { | ||
69 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
70 | boolean _isMust = m.isMust(); | ||
71 | if (_isMust) { | ||
72 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | final ImmutableList<CostElementMatch> step3Matches = step3.getMatches(); | ||
78 | for (final CostElementMatch m_1 : step3Matches) { | ||
79 | { | ||
80 | final Dimension dimension = it.getDimension(m_1.getMatch()); | ||
81 | objectiveBuilder.add(step3.getWeight(), dimension); | ||
82 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
83 | boolean _isMulti = m_1.isMulti(); | ||
84 | boolean _not = (!_isMulti); | ||
85 | if (_not) { | ||
86 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
87 | boolean _isMust = m_1.isMust(); | ||
88 | if (_isMust) { | ||
89 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | final Function1<CostElementMatch, IPatternMatch> _function_1 = (CostElementMatch it_1) -> { | ||
95 | return step2.projectMayMatch(it_1.getMatch(), 2); | ||
96 | }; | ||
97 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step3Matches, _function_1).entrySet(); | ||
98 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair : _entrySet) { | ||
99 | { | ||
100 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
101 | List<CostElementMatch> _value = pair.getValue(); | ||
102 | for (final CostElementMatch m_2 : _value) { | ||
103 | multiplicityBuilder.add(1, m_2.getMatch()); | ||
104 | } | ||
105 | multiplicityBuilder.add((-1), pair.getKey()); | ||
106 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
107 | } | ||
108 | } | ||
109 | MisalignedTurnoutObjectiveHint.boundLimit(it, step3Matches, 2, this.turnoutType, 1); | ||
110 | MisalignedTurnoutObjectiveHint.boundLimit(it, step3Matches, 3, this.segmentType, 2); | ||
111 | final ImmutableList<CostElementMatch> step4Matches = step4.getMatches(); | ||
112 | for (final CostElementMatch m_2 : step4Matches) { | ||
113 | { | ||
114 | final Dimension dimension = it.getDimension(m_2.getMatch()); | ||
115 | objectiveBuilder.add(step4.getWeight(), dimension); | ||
116 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
117 | boolean _isMulti = m_2.isMulti(); | ||
118 | boolean _not = (!_isMulti); | ||
119 | if (_not) { | ||
120 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
121 | boolean _isMust = m_2.isMust(); | ||
122 | if (_isMust) { | ||
123 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
124 | } | ||
125 | } | ||
126 | it.createBuilder().add(1, m_2.getMatch()).add((-1), step3.projectMayMatch(m_2.getMatch(), 2, 3)).build().tightenUpperBound(Integer.valueOf(0)); | ||
127 | } | ||
128 | } | ||
129 | MisalignedTurnoutObjectiveHint.boundLimit(it, step4Matches, 2, this.turnoutType, 1); | ||
130 | MisalignedTurnoutObjectiveHint.boundLimit(it, step4Matches, 3, this.segmentType, 2); | ||
131 | final ImmutableList<CostElementMatch> step5Matches = step5.getMatches(); | ||
132 | for (final CostElementMatch m_3 : step5Matches) { | ||
133 | { | ||
134 | final Dimension dimension = it.getDimension(m_3.getMatch()); | ||
135 | objectiveBuilder.add(step5.getWeight(), dimension); | ||
136 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
137 | boolean _isMulti = m_3.isMulti(); | ||
138 | boolean _not = (!_isMulti); | ||
139 | if (_not) { | ||
140 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
141 | boolean _isMust = m_3.isMust(); | ||
142 | if (_isMust) { | ||
143 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
144 | } | ||
145 | } | ||
146 | } | ||
147 | } | ||
148 | final Function1<CostElementMatch, IPatternMatch> _function_2 = (CostElementMatch it_1) -> { | ||
149 | return step4.projectMayMatch(it_1.getMatch(), 2, 3); | ||
150 | }; | ||
151 | Set<Map.Entry<IPatternMatch, List<CostElementMatch>>> _entrySet_1 = IterableExtensions.<IPatternMatch, CostElementMatch>groupBy(step5Matches, _function_2).entrySet(); | ||
152 | for (final Map.Entry<IPatternMatch, List<CostElementMatch>> pair_1 : _entrySet_1) { | ||
153 | { | ||
154 | final ExtendedLinearExpressionBuilder multiplicityBuilder = it.createBuilder(); | ||
155 | List<CostElementMatch> _value = pair_1.getValue(); | ||
156 | for (final CostElementMatch m_4 : _value) { | ||
157 | multiplicityBuilder.add(1, m_4.getMatch()); | ||
158 | } | ||
159 | multiplicityBuilder.add((-1), pair_1.getKey()); | ||
160 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
161 | } | ||
162 | } | ||
163 | MisalignedTurnoutObjectiveHint.boundLimit(it, step5Matches, 2, this.turnoutType, 1); | ||
164 | MisalignedTurnoutObjectiveHint.boundLimit(it, step5Matches, 3, this.segmentType, 2); | ||
165 | MisalignedTurnoutObjectiveHint.boundLimit(it, step5Matches, 4, this.trainType, 2); | ||
166 | this.buildWithBounds(objectiveBuilder); | ||
167 | }; | ||
168 | _xblockexpression = _function; | ||
169 | } | ||
170 | return _xblockexpression; | ||
171 | } | ||
172 | |||
173 | private static void boundLimit(@Extension final ExtendedLinearExpressionBuilderFactory factory, final Collection<CostElementMatch> matches, final int index, final Type type, final int count) { | ||
174 | final Function1<CostElementMatch, Object> _function = (CostElementMatch it) -> { | ||
175 | return it.getMatch().get(index); | ||
176 | }; | ||
177 | Set<Map.Entry<Object, List<CostElementMatch>>> _entrySet = IterableExtensions.<Object, CostElementMatch>groupBy(matches, _function).entrySet(); | ||
178 | for (final Map.Entry<Object, List<CostElementMatch>> pair : _entrySet) { | ||
179 | { | ||
180 | final ExtendedLinearExpressionBuilder multiplicityBuilder = factory.createBuilder(); | ||
181 | List<CostElementMatch> _value = pair.getValue(); | ||
182 | for (final CostElementMatch m : _value) { | ||
183 | multiplicityBuilder.add(1, m.getMatch()); | ||
184 | } | ||
185 | boolean _isMulti = CostElementMatchers.isMulti(pair.getKey()); | ||
186 | if (_isMulti) { | ||
187 | multiplicityBuilder.add((-count), type); | ||
188 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
189 | } else { | ||
190 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(count)); | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | } | ||
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 new file mode 100644 index 00000000..a0661c87 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3ModelGenerator.java | |||
@@ -0,0 +1,597 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import com.google.common.base.Objects; | ||
4 | import com.google.common.collect.ImmutableList; | ||
5 | import com.google.common.collect.ImmutableSet; | ||
6 | import com.google.common.collect.Iterables; | ||
7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EReferenceMapper_RelationsOverTypes_Trace; | ||
8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
9 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration; | ||
10 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
11 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | ||
12 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsFactory; | ||
13 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.Ecore2logicannotationsPackage; | ||
14 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion; | ||
15 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; | ||
16 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicModelInterpretation; | ||
17 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder; | ||
18 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.SolutionScope; | ||
19 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput; | ||
20 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes; | ||
21 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.VariableContext; | ||
22 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Assertion; | ||
23 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Iff; | ||
24 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage; | ||
25 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration; | ||
26 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.SymbolicValue; | ||
27 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TermDescription; | ||
28 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
29 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition; | ||
30 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Variable; | ||
31 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.Annotation; | ||
32 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; | ||
33 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage; | ||
34 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; | ||
35 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult; | ||
36 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore; | ||
37 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic; | ||
38 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration; | ||
39 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicTrace; | ||
40 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; | ||
41 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.Viatra2LogicAnnotationsPackage; | ||
42 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod; | ||
43 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorConstraints; | ||
44 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorSolver; | ||
45 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy; | ||
46 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic; | ||
47 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink; | ||
48 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation; | ||
49 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; | ||
50 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation; | ||
51 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage; | ||
52 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.RelationLink; | ||
53 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml; | ||
54 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; | ||
55 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.CostObjectiveConfiguration; | ||
56 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.CostObjectiveElementConfiguration; | ||
57 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.DebugConfiguration; | ||
58 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.StateCoderStrategy; | ||
59 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner; | ||
60 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; | ||
61 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.PartialModelAsLogicInterpretation; | ||
62 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind; | ||
63 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold; | ||
64 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser; | ||
65 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace; | ||
66 | import java.util.Collections; | ||
67 | import java.util.List; | ||
68 | import java.util.Map; | ||
69 | import java.util.Set; | ||
70 | import java.util.function.Predicate; | ||
71 | import modes3.Modes3Factory; | ||
72 | import modes3.Modes3ModelRoot; | ||
73 | import modes3.Modes3Package; | ||
74 | import modes3.queries.CloseTrains_step_2; | ||
75 | import modes3.queries.CloseTrains_step_3; | ||
76 | import modes3.queries.CloseTrains_step_4; | ||
77 | import modes3.queries.CloseTrains_step_5; | ||
78 | import modes3.queries.CloseTrains_step_6; | ||
79 | import modes3.queries.CloseTrains_step_7; | ||
80 | import modes3.queries.EndOfSiding_step_2; | ||
81 | import modes3.queries.EndOfSiding_step_3; | ||
82 | import modes3.queries.EndOfSiding_step_4; | ||
83 | import modes3.queries.EndOfSiding_step_5; | ||
84 | import modes3.queries.MisalignedTurnout_step_2; | ||
85 | import modes3.queries.MisalignedTurnout_step_3; | ||
86 | import modes3.queries.MisalignedTurnout_step_4; | ||
87 | import modes3.queries.MisalignedTurnout_step_5; | ||
88 | import modes3.queries.Modes3Queries; | ||
89 | import modes3.queries.TrainLocations_step_2; | ||
90 | import modes3.queries.TrainLocations_step_3; | ||
91 | import modes3.run.CloseTrainsObjectiveHint; | ||
92 | import modes3.run.EndOfSidingObjectiveHint; | ||
93 | import modes3.run.MisalignedTurnoutObjectiveHint; | ||
94 | import modes3.run.Modes3TypeScopeHint; | ||
95 | import modes3.run.Modes3UnitPropagationGenerator; | ||
96 | import modes3.run.TrainLocationsObjectiveHint; | ||
97 | import org.eclipse.emf.common.util.EList; | ||
98 | import org.eclipse.emf.common.util.TreeIterator; | ||
99 | import org.eclipse.emf.common.util.URI; | ||
100 | import org.eclipse.emf.ecore.EAttribute; | ||
101 | import org.eclipse.emf.ecore.EClass; | ||
102 | import org.eclipse.emf.ecore.EEnum; | ||
103 | import org.eclipse.emf.ecore.EEnumLiteral; | ||
104 | import org.eclipse.emf.ecore.EObject; | ||
105 | import org.eclipse.emf.ecore.EReference; | ||
106 | import org.eclipse.emf.ecore.EStructuralFeature; | ||
107 | import org.eclipse.emf.ecore.resource.Resource; | ||
108 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; | ||
109 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup; | ||
110 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
111 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions; | ||
112 | import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchEMFBackendFactory; | ||
113 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
114 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory; | ||
115 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor; | ||
116 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
117 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
118 | import org.eclipse.xtext.xbase.lib.Exceptions; | ||
119 | import org.eclipse.xtext.xbase.lib.ExclusiveRange; | ||
120 | import org.eclipse.xtext.xbase.lib.Extension; | ||
121 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
122 | import org.eclipse.xtext.xbase.lib.InputOutput; | ||
123 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
124 | import org.eclipse.xtext.xbase.lib.ObjectExtensions; | ||
125 | import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; | ||
126 | |||
127 | @FinalFieldsConstructor | ||
128 | @SuppressWarnings("all") | ||
129 | public class Modes3ModelGenerator { | ||
130 | private enum MonitoringQuery { | ||
131 | closeTrains, | ||
132 | |||
133 | trainLocations, | ||
134 | |||
135 | endOfSiding, | ||
136 | |||
137 | misalignedTurnout; | ||
138 | } | ||
139 | |||
140 | private final Modes3ModelGenerator.MonitoringQuery monitoringQuery; | ||
141 | |||
142 | private final int modelSize; | ||
143 | |||
144 | private final Ecore2Logic ecore2Logic = new Ecore2Logic(); | ||
145 | |||
146 | private final InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic(); | ||
147 | |||
148 | private final Viatra2Logic viatra2Logic = new Viatra2Logic(this.ecore2Logic); | ||
149 | |||
150 | private final ViatraReasoner solver = new ViatraReasoner(); | ||
151 | |||
152 | @Extension | ||
153 | private final LogicProblemBuilder _logicProblemBuilder = new LogicProblemBuilder(); | ||
154 | |||
155 | public URI generate() { | ||
156 | try { | ||
157 | URI _xblockexpression = null; | ||
158 | { | ||
159 | final EcoreMetamodelDescriptor metamodel = Modes3ModelGenerator.createMetamodelDescriptor(); | ||
160 | Ecore2LogicConfiguration _ecore2LogicConfiguration = new Ecore2LogicConfiguration(); | ||
161 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelLogic = this.ecore2Logic.transformMetamodel(metamodel, _ecore2LogicConfiguration); | ||
162 | final Type segment = this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getSegment()); | ||
163 | final RelationDeclaration connectedTo = this.ecore2Logic.relationOfReference(metamodelLogic.getTrace(), | ||
164 | Modes3Package.eINSTANCE.getSegment_ConnectedTo()); | ||
165 | final RelationDeclaration connectedToIndicator = ((EReferenceMapper_RelationsOverTypes_Trace) metamodelLogic.getTrace().referenceMapperTrace).indicators.get( | ||
166 | Modes3Package.eINSTANCE.getSegment_ConnectedTo()); | ||
167 | StringConcatenation _builder = new StringConcatenation(); | ||
168 | _builder.append("oppositeReference "); | ||
169 | String _name = connectedTo.getName(); | ||
170 | _builder.append(_name); | ||
171 | _builder.append(" "); | ||
172 | String _name_1 = connectedTo.getName(); | ||
173 | _builder.append(_name_1); | ||
174 | final Function1<VariableContext, TermDescription> _function = (VariableContext it) -> { | ||
175 | Iff _xblockexpression_1 = null; | ||
176 | { | ||
177 | StringConcatenation _builder_1 = new StringConcatenation(); | ||
178 | _builder_1.append("src"); | ||
179 | final Variable src = it.addVar(_builder_1, segment); | ||
180 | StringConcatenation _builder_2 = new StringConcatenation(); | ||
181 | _builder_2.append("trg"); | ||
182 | final Variable trg = it.addVar(_builder_2, segment); | ||
183 | SymbolicValue _call = this._logicProblemBuilder.call(connectedToIndicator, src, trg); | ||
184 | SymbolicValue _call_1 = this._logicProblemBuilder.call(connectedToIndicator, trg, src); | ||
185 | _xblockexpression_1 = this._logicProblemBuilder.operator_spaceship(_call, _call_1); | ||
186 | } | ||
187 | return _xblockexpression_1; | ||
188 | }; | ||
189 | final Assertion inverseAssertion = this._logicProblemBuilder.Assertion(_builder, | ||
190 | this._logicProblemBuilder.Forall(_function)); | ||
191 | EList<Assertion> _assertions = metamodelLogic.getOutput().getAssertions(); | ||
192 | _assertions.add(inverseAssertion); | ||
193 | InverseRelationAssertion _createInverseRelationAssertion = Ecore2logicannotationsFactory.eINSTANCE.createInverseRelationAssertion(); | ||
194 | final Procedure1<InverseRelationAssertion> _function_1 = (InverseRelationAssertion it) -> { | ||
195 | it.setTarget(inverseAssertion); | ||
196 | it.setInverseA(connectedTo); | ||
197 | it.setInverseB(connectedTo); | ||
198 | }; | ||
199 | final InverseRelationAssertion inverseAnnotation = ObjectExtensions.<InverseRelationAssertion>operator_doubleArrow(_createInverseRelationAssertion, _function_1); | ||
200 | EList<Annotation> _annotations = metamodelLogic.getOutput().getAnnotations(); | ||
201 | _annotations.add(inverseAnnotation); | ||
202 | final List<EObject> initialModel = Modes3ModelGenerator.loadInitialModel(); | ||
203 | final TracedOutput<LogicProblem, Ecore2Logic_Trace> initialModelLogic = this.instanceModel2Logic.transform(metamodelLogic, initialModel); | ||
204 | final ViatraQuerySetDescriptor queries = this.loadQueries(); | ||
205 | Viatra2LogicConfiguration _viatra2LogicConfiguration = new Viatra2LogicConfiguration(); | ||
206 | final TracedOutput<LogicProblem, Viatra2LogicTrace> logic = this.viatra2Logic.transformQueries(queries, initialModelLogic, _viatra2LogicConfiguration); | ||
207 | ViatraReasonerConfiguration _viatraReasonerConfiguration = new ViatraReasonerConfiguration(); | ||
208 | final Procedure1<ViatraReasonerConfiguration> _function_2 = (ViatraReasonerConfiguration it) -> { | ||
209 | it.runtimeLimit = 3600; | ||
210 | final Procedure1<TypeScopes> _function_3 = (TypeScopes it_1) -> { | ||
211 | it_1.minNewElements = this.modelSize; | ||
212 | it_1.maxNewElements = this.modelSize; | ||
213 | final Procedure1<Map<Type, Integer>> _function_4 = (Map<Type, Integer> it_2) -> { | ||
214 | }; | ||
215 | ObjectExtensions.<Map<Type, Integer>>operator_doubleArrow( | ||
216 | it_1.minNewElementsByType, _function_4); | ||
217 | final Procedure1<Map<Type, Integer>> _function_5 = (Map<Type, Integer> it_2) -> { | ||
218 | it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTrain()), Integer.valueOf((this.modelSize / 5))); | ||
219 | it_2.put(this.ecore2Logic.TypeofEClass(metamodelLogic.getTrace(), Modes3Package.eINSTANCE.getTurnout()), Integer.valueOf((this.modelSize / 5))); | ||
220 | }; | ||
221 | ObjectExtensions.<Map<Type, Integer>>operator_doubleArrow( | ||
222 | it_1.maxNewElementsByType, _function_5); | ||
223 | }; | ||
224 | ObjectExtensions.<TypeScopes>operator_doubleArrow( | ||
225 | it.typeScopes, _function_3); | ||
226 | final Procedure1<SolutionScope> _function_4 = (SolutionScope it_1) -> { | ||
227 | it_1.numberOfRequiredSolutions = 1; | ||
228 | }; | ||
229 | ObjectExtensions.<SolutionScope>operator_doubleArrow( | ||
230 | it.solutionScope, _function_4); | ||
231 | CostObjectiveConfiguration _objective = this.getObjective(this.ecore2Logic, metamodelLogic.getTrace()); | ||
232 | it.costObjectives.add(_objective); | ||
233 | it.scopeWeight = 6; | ||
234 | it.nameNewElements = false; | ||
235 | it.typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis; | ||
236 | it.stateCoderStrategy = StateCoderStrategy.PairwiseNeighbourhood; | ||
237 | ScopePropagatorStrategy.Polyhedral _polyhedral = new ScopePropagatorStrategy.Polyhedral( | ||
238 | PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp); | ||
239 | it.scopePropagatorStrategy = _polyhedral; | ||
240 | Ecore2Logic_Trace _trace = metamodelLogic.getTrace(); | ||
241 | Modes3TypeScopeHint _modes3TypeScopeHint = new Modes3TypeScopeHint(this.ecore2Logic, _trace); | ||
242 | it.hints.add(_modes3TypeScopeHint); | ||
243 | Ecore2Logic_Trace _trace_1 = metamodelLogic.getTrace(); | ||
244 | Modes3UnitPropagationGenerator _modes3UnitPropagationGenerator = new Modes3UnitPropagationGenerator(this.ecore2Logic, _trace_1); | ||
245 | it.unitPropagationPatternGenerators.add(_modes3UnitPropagationGenerator); | ||
246 | final Procedure1<DebugConfiguration> _function_5 = (DebugConfiguration it_1) -> { | ||
247 | GraphvizVisualiser _graphvizVisualiser = new GraphvizVisualiser(); | ||
248 | it_1.partialInterpretatioVisualiser = _graphvizVisualiser; | ||
249 | }; | ||
250 | ObjectExtensions.<DebugConfiguration>operator_doubleArrow( | ||
251 | it.debugConfiguration, _function_5); | ||
252 | it.documentationLevel = DocumentationLevel.NORMAL; | ||
253 | }; | ||
254 | final ViatraReasonerConfiguration config = ObjectExtensions.<ViatraReasonerConfiguration>operator_doubleArrow(_viatraReasonerConfiguration, _function_2); | ||
255 | final FileSystemWorkspace workspace = new FileSystemWorkspace("output/", ""); | ||
256 | workspace.writeModel(logic.getOutput(), "problem.logicproblem"); | ||
257 | final LogicResult solution = this.solver.solve(logic.getOutput(), config, workspace); | ||
258 | URI _xifexpression = null; | ||
259 | if ((solution instanceof ModelResult)) { | ||
260 | InputOutput.<String>println("Saving generated solutions"); | ||
261 | final Logic2Ecore logic2Ecore = new Logic2Ecore(this.ecore2Logic); | ||
262 | final List<? extends LogicModelInterpretation> interpretations = this.solver.getInterpretations(((ModelResult)solution)); | ||
263 | int _size = interpretations.size(); | ||
264 | ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _size, true); | ||
265 | for (final Integer representationIndex : _doubleDotLessThan) { | ||
266 | { | ||
267 | final LogicModelInterpretation interpretation = interpretations.get((representationIndex).intValue()); | ||
268 | final int representationNumber = ((representationIndex).intValue() + 1); | ||
269 | if ((interpretation instanceof PartialModelAsLogicInterpretation)) { | ||
270 | final PartialInterpretation representation = ((PartialModelAsLogicInterpretation)interpretation).getPartialInterpretation(); | ||
271 | StringConcatenation _builder_1 = new StringConcatenation(); | ||
272 | _builder_1.append("solution"); | ||
273 | _builder_1.append(representationNumber); | ||
274 | _builder_1.append(".partialinterpretation"); | ||
275 | workspace.writeModel(representation, _builder_1.toString()); | ||
276 | final PartialInterpretation2Gml partialInterpretation2GML = new PartialInterpretation2Gml(); | ||
277 | final String gml = partialInterpretation2GML.transform(representation); | ||
278 | StringConcatenation _builder_2 = new StringConcatenation(); | ||
279 | _builder_2.append("solution"); | ||
280 | _builder_2.append(representationNumber); | ||
281 | _builder_2.append(".gml"); | ||
282 | workspace.writeText(_builder_2.toString(), gml); | ||
283 | final EObject model = logic2Ecore.transformInterpretation(interpretation, metamodelLogic.getTrace()); | ||
284 | final TreeIterator<EObject> iterator = model.eAllContents(); | ||
285 | int id = 0; | ||
286 | while (iterator.hasNext()) { | ||
287 | { | ||
288 | final EObject obj = iterator.next(); | ||
289 | final Function1<EAttribute, Boolean> _function_3 = (EAttribute it) -> { | ||
290 | String _name_2 = it.getName(); | ||
291 | return Boolean.valueOf(Objects.equal(_name_2, "id")); | ||
292 | }; | ||
293 | final EAttribute idFeature = IterableExtensions.<EAttribute>findFirst(obj.eClass().getEAllAttributes(), _function_3); | ||
294 | if ((idFeature != null)) { | ||
295 | obj.eSet(idFeature, Integer.valueOf(id)); | ||
296 | id++; | ||
297 | } | ||
298 | } | ||
299 | } | ||
300 | StringConcatenation _builder_3 = new StringConcatenation(); | ||
301 | _builder_3.append("solution"); | ||
302 | _builder_3.append(representationNumber); | ||
303 | _builder_3.append(".modes3"); | ||
304 | workspace.writeModel(model, _builder_3.toString()); | ||
305 | int _size_1 = representation.getNewElements().size(); | ||
306 | boolean _lessThan = (_size_1 < 160); | ||
307 | if (_lessThan) { | ||
308 | final Function1<Type, Boolean> _function_3 = (Type it) -> { | ||
309 | String _name_2 = it.getName(); | ||
310 | return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class DefinedPart")); | ||
311 | }; | ||
312 | Type _findFirst = IterableExtensions.<Type>findFirst(representation.getProblem().getTypes(), _function_3); | ||
313 | final TypeDefinition rootType = ((TypeDefinition) _findFirst); | ||
314 | final Function1<PartialComplexTypeInterpretation, Boolean> _function_4 = (PartialComplexTypeInterpretation it) -> { | ||
315 | String _name_2 = it.getInterpretationOf().getName(); | ||
316 | return Boolean.valueOf(Objects.equal(_name_2, "Modes3ModelRoot class")); | ||
317 | }; | ||
318 | final PartialComplexTypeInterpretation rootIntepretation = IterableExtensions.<PartialComplexTypeInterpretation>findFirst(Iterables.<PartialComplexTypeInterpretation>filter(representation.getPartialtypeinterpratation(), | ||
319 | PartialComplexTypeInterpretation.class), _function_4); | ||
320 | rootIntepretation.getElements().removeAll(rootType.getElements()); | ||
321 | representation.getProblem().getElements().removeAll(rootType.getElements()); | ||
322 | EList<PartialRelationInterpretation> _partialrelationinterpretation = representation.getPartialrelationinterpretation(); | ||
323 | for (final PartialRelationInterpretation relationInterpretation : _partialrelationinterpretation) { | ||
324 | final Predicate<RelationLink> _function_5 = (RelationLink link) -> { | ||
325 | boolean _xifexpression_1 = false; | ||
326 | if ((link instanceof BinaryElementRelationLink)) { | ||
327 | _xifexpression_1 = (rootType.getElements().contains(((BinaryElementRelationLink)link).getParam1()) || | ||
328 | rootType.getElements().contains(((BinaryElementRelationLink)link).getParam2())); | ||
329 | } else { | ||
330 | _xifexpression_1 = false; | ||
331 | } | ||
332 | return _xifexpression_1; | ||
333 | }; | ||
334 | relationInterpretation.getRelationlinks().removeIf(_function_5); | ||
335 | } | ||
336 | rootType.getElements().clear(); | ||
337 | final GraphvizVisualiser visualiser = new GraphvizVisualiser(); | ||
338 | final PartialInterpretationVisualisation visualisation = visualiser.visualiseConcretization(representation); | ||
339 | StringConcatenation _builder_4 = new StringConcatenation(); | ||
340 | _builder_4.append("solution"); | ||
341 | _builder_4.append(representationNumber); | ||
342 | _builder_4.append(".png"); | ||
343 | visualisation.writeToFile(workspace, _builder_4.toString()); | ||
344 | } | ||
345 | } else { | ||
346 | StringConcatenation _builder_5 = new StringConcatenation(); | ||
347 | _builder_5.append("solution"); | ||
348 | _builder_5.append(representationNumber); | ||
349 | _builder_5.append(".txt"); | ||
350 | workspace.writeText(_builder_5.toString(), interpretation.toString()); | ||
351 | } | ||
352 | } | ||
353 | } | ||
354 | } else { | ||
355 | URI _xblockexpression_1 = null; | ||
356 | { | ||
357 | InputOutput.<String>println("Failed to solve problem"); | ||
358 | final LogicProblem partial = logic.getOutput(); | ||
359 | _xblockexpression_1 = workspace.writeModel(partial, "solution.partialinterpretation"); | ||
360 | } | ||
361 | _xifexpression = _xblockexpression_1; | ||
362 | } | ||
363 | _xblockexpression = _xifexpression; | ||
364 | } | ||
365 | return _xblockexpression; | ||
366 | } catch (Throwable _e) { | ||
367 | throw Exceptions.sneakyThrow(_e); | ||
368 | } | ||
369 | } | ||
370 | |||
371 | public static EcoreMetamodelDescriptor createMetamodelDescriptor() { | ||
372 | EcoreMetamodelDescriptor _xblockexpression = null; | ||
373 | { | ||
374 | final ImmutableList<EClass> eClasses = ImmutableList.<EClass>copyOf(Iterables.<EClass>filter(Modes3Package.eINSTANCE.getEClassifiers(), EClass.class)); | ||
375 | Set<EClass> _emptySet = CollectionLiterals.<EClass>emptySet(); | ||
376 | List<EEnum> _emptyList = CollectionLiterals.<EEnum>emptyList(); | ||
377 | List<EEnumLiteral> _emptyList_1 = CollectionLiterals.<EEnumLiteral>emptyList(); | ||
378 | final Function1<EClass, EList<EReference>> _function = (EClass it) -> { | ||
379 | return it.getEReferences(); | ||
380 | }; | ||
381 | ImmutableList<EReference> _copyOf = ImmutableList.<EReference>copyOf(IterableExtensions.<EClass, EReference>flatMap(eClasses, _function)); | ||
382 | List<EAttribute> _emptyList_2 = CollectionLiterals.<EAttribute>emptyList(); | ||
383 | _xblockexpression = new EcoreMetamodelDescriptor(eClasses, _emptySet, | ||
384 | false, _emptyList, _emptyList_1, _copyOf, _emptyList_2); | ||
385 | } | ||
386 | return _xblockexpression; | ||
387 | } | ||
388 | |||
389 | public static List<EObject> loadInitialModel() { | ||
390 | Modes3ModelRoot _createModes3ModelRoot = Modes3Factory.eINSTANCE.createModes3ModelRoot(); | ||
391 | return Collections.<EObject>unmodifiableList(CollectionLiterals.<EObject>newArrayList(_createModes3ModelRoot)); | ||
392 | } | ||
393 | |||
394 | public ViatraQuerySetDescriptor loadQueries() { | ||
395 | ViatraQuerySetDescriptor _xblockexpression = null; | ||
396 | { | ||
397 | final ImmutableList.Builder<IQuerySpecification<?>> patternsBuilder = ImmutableList.<IQuerySpecification<?>>builder(); | ||
398 | patternsBuilder.addAll(Modes3Queries.instance().getSpecifications()); | ||
399 | final ImmutableList<IQuerySpecification<?>> patterns = patternsBuilder.build(); | ||
400 | final Function1<IQuerySpecification<?>, Boolean> _function = (IQuerySpecification<?> pattern) -> { | ||
401 | final Function1<PAnnotation, Boolean> _function_1 = (PAnnotation it) -> { | ||
402 | String _name = it.getName(); | ||
403 | return Boolean.valueOf(Objects.equal(_name, "Constraint")); | ||
404 | }; | ||
405 | return Boolean.valueOf(IterableExtensions.<PAnnotation>exists(pattern.getAllAnnotations(), _function_1)); | ||
406 | }; | ||
407 | final ImmutableSet<IQuerySpecification<?>> validationPatterns = ImmutableSet.<IQuerySpecification<?>>copyOf(IterableExtensions.<IQuerySpecification<?>>filter(patterns, _function)); | ||
408 | Map<IQuerySpecification<?>, EStructuralFeature> _emptyMap = CollectionLiterals.<IQuerySpecification<?>, EStructuralFeature>emptyMap(); | ||
409 | _xblockexpression = new ViatraQuerySetDescriptor(patterns, validationPatterns, _emptyMap); | ||
410 | } | ||
411 | return _xblockexpression; | ||
412 | } | ||
413 | |||
414 | public CostObjectiveConfiguration getObjective(final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { | ||
415 | CostObjectiveConfiguration _costObjectiveConfiguration = new CostObjectiveConfiguration(); | ||
416 | final Procedure1<CostObjectiveConfiguration> _function = (CostObjectiveConfiguration it) -> { | ||
417 | final Modes3ModelGenerator.MonitoringQuery monitoringQuery = this.monitoringQuery; | ||
418 | if (monitoringQuery != null) { | ||
419 | switch (monitoringQuery) { | ||
420 | case closeTrains: | ||
421 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration = new CostObjectiveElementConfiguration(); | ||
422 | final Procedure1<CostObjectiveElementConfiguration> _function_1 = (CostObjectiveElementConfiguration it_1) -> { | ||
423 | it_1.patternQualifiedName = CloseTrains_step_2.instance().getFullyQualifiedName(); | ||
424 | it_1.weight = ((14 + 53) + 11); | ||
425 | }; | ||
426 | CostObjectiveElementConfiguration _doubleArrow = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration, _function_1); | ||
427 | it.elements.add(_doubleArrow); | ||
428 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_1 = new CostObjectiveElementConfiguration(); | ||
429 | final Procedure1<CostObjectiveElementConfiguration> _function_2 = (CostObjectiveElementConfiguration it_1) -> { | ||
430 | it_1.patternQualifiedName = CloseTrains_step_3.instance().getFullyQualifiedName(); | ||
431 | it_1.weight = (21 + 14); | ||
432 | }; | ||
433 | CostObjectiveElementConfiguration _doubleArrow_1 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_1, _function_2); | ||
434 | it.elements.add(_doubleArrow_1); | ||
435 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_2 = new CostObjectiveElementConfiguration(); | ||
436 | final Procedure1<CostObjectiveElementConfiguration> _function_3 = (CostObjectiveElementConfiguration it_1) -> { | ||
437 | it_1.patternQualifiedName = CloseTrains_step_4.instance().getFullyQualifiedName(); | ||
438 | it_1.weight = (((14 + 44) + 14) + 9); | ||
439 | }; | ||
440 | CostObjectiveElementConfiguration _doubleArrow_2 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_2, _function_3); | ||
441 | it.elements.add(_doubleArrow_2); | ||
442 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_3 = new CostObjectiveElementConfiguration(); | ||
443 | final Procedure1<CostObjectiveElementConfiguration> _function_4 = (CostObjectiveElementConfiguration it_1) -> { | ||
444 | it_1.patternQualifiedName = CloseTrains_step_5.instance().getFullyQualifiedName(); | ||
445 | it_1.weight = ((14 + 41) + 11); | ||
446 | }; | ||
447 | CostObjectiveElementConfiguration _doubleArrow_3 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_3, _function_4); | ||
448 | it.elements.add(_doubleArrow_3); | ||
449 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_4 = new CostObjectiveElementConfiguration(); | ||
450 | final Procedure1<CostObjectiveElementConfiguration> _function_5 = (CostObjectiveElementConfiguration it_1) -> { | ||
451 | it_1.patternQualifiedName = CloseTrains_step_6.instance().getFullyQualifiedName(); | ||
452 | it_1.weight = 27; | ||
453 | }; | ||
454 | CostObjectiveElementConfiguration _doubleArrow_4 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_4, _function_5); | ||
455 | it.elements.add(_doubleArrow_4); | ||
456 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_5 = new CostObjectiveElementConfiguration(); | ||
457 | final Procedure1<CostObjectiveElementConfiguration> _function_6 = (CostObjectiveElementConfiguration it_1) -> { | ||
458 | it_1.patternQualifiedName = CloseTrains_step_7.instance().getFullyQualifiedName(); | ||
459 | it_1.weight = 48; | ||
460 | }; | ||
461 | CostObjectiveElementConfiguration _doubleArrow_5 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_5, _function_6); | ||
462 | it.elements.add(_doubleArrow_5); | ||
463 | CloseTrainsObjectiveHint _closeTrainsObjectiveHint = new CloseTrainsObjectiveHint(ecore2Logic, ecore2LogicTrace); | ||
464 | it.hint = _closeTrainsObjectiveHint; | ||
465 | break; | ||
466 | case trainLocations: | ||
467 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_6 = new CostObjectiveElementConfiguration(); | ||
468 | final Procedure1<CostObjectiveElementConfiguration> _function_7 = (CostObjectiveElementConfiguration it_1) -> { | ||
469 | it_1.patternQualifiedName = TrainLocations_step_2.instance().getFullyQualifiedName(); | ||
470 | it_1.weight = ((14 + 53) + 11); | ||
471 | }; | ||
472 | CostObjectiveElementConfiguration _doubleArrow_6 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_6, _function_7); | ||
473 | it.elements.add(_doubleArrow_6); | ||
474 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_7 = new CostObjectiveElementConfiguration(); | ||
475 | final Procedure1<CostObjectiveElementConfiguration> _function_8 = (CostObjectiveElementConfiguration it_1) -> { | ||
476 | it_1.patternQualifiedName = TrainLocations_step_3.instance().getFullyQualifiedName(); | ||
477 | it_1.weight = 48; | ||
478 | }; | ||
479 | CostObjectiveElementConfiguration _doubleArrow_7 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_7, _function_8); | ||
480 | it.elements.add(_doubleArrow_7); | ||
481 | TrainLocationsObjectiveHint _trainLocationsObjectiveHint = new TrainLocationsObjectiveHint(ecore2Logic, ecore2LogicTrace); | ||
482 | it.hint = _trainLocationsObjectiveHint; | ||
483 | break; | ||
484 | case misalignedTurnout: | ||
485 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_8 = new CostObjectiveElementConfiguration(); | ||
486 | final Procedure1<CostObjectiveElementConfiguration> _function_9 = (CostObjectiveElementConfiguration it_1) -> { | ||
487 | it_1.patternQualifiedName = MisalignedTurnout_step_2.instance().getFullyQualifiedName(); | ||
488 | it_1.weight = ((14 + 53) + 11); | ||
489 | }; | ||
490 | CostObjectiveElementConfiguration _doubleArrow_8 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_8, _function_9); | ||
491 | it.elements.add(_doubleArrow_8); | ||
492 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_9 = new CostObjectiveElementConfiguration(); | ||
493 | final Procedure1<CostObjectiveElementConfiguration> _function_10 = (CostObjectiveElementConfiguration it_1) -> { | ||
494 | it_1.patternQualifiedName = MisalignedTurnout_step_3.instance().getFullyQualifiedName(); | ||
495 | it_1.weight = 108; | ||
496 | }; | ||
497 | CostObjectiveElementConfiguration _doubleArrow_9 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_9, _function_10); | ||
498 | it.elements.add(_doubleArrow_9); | ||
499 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_10 = new CostObjectiveElementConfiguration(); | ||
500 | final Procedure1<CostObjectiveElementConfiguration> _function_11 = (CostObjectiveElementConfiguration it_1) -> { | ||
501 | it_1.patternQualifiedName = MisalignedTurnout_step_4.instance().getFullyQualifiedName(); | ||
502 | it_1.weight = 27; | ||
503 | }; | ||
504 | CostObjectiveElementConfiguration _doubleArrow_10 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_10, _function_11); | ||
505 | it.elements.add(_doubleArrow_10); | ||
506 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_11 = new CostObjectiveElementConfiguration(); | ||
507 | final Procedure1<CostObjectiveElementConfiguration> _function_12 = (CostObjectiveElementConfiguration it_1) -> { | ||
508 | it_1.patternQualifiedName = MisalignedTurnout_step_5.instance().getFullyQualifiedName(); | ||
509 | it_1.weight = 48; | ||
510 | }; | ||
511 | CostObjectiveElementConfiguration _doubleArrow_11 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_11, _function_12); | ||
512 | it.elements.add(_doubleArrow_11); | ||
513 | MisalignedTurnoutObjectiveHint _misalignedTurnoutObjectiveHint = new MisalignedTurnoutObjectiveHint(ecore2Logic, ecore2LogicTrace); | ||
514 | it.hint = _misalignedTurnoutObjectiveHint; | ||
515 | break; | ||
516 | case endOfSiding: | ||
517 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_12 = new CostObjectiveElementConfiguration(); | ||
518 | final Procedure1<CostObjectiveElementConfiguration> _function_13 = (CostObjectiveElementConfiguration it_1) -> { | ||
519 | it_1.patternQualifiedName = EndOfSiding_step_2.instance().getFullyQualifiedName(); | ||
520 | it_1.weight = ((14 + 53) + 11); | ||
521 | }; | ||
522 | CostObjectiveElementConfiguration _doubleArrow_12 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_12, _function_13); | ||
523 | it.elements.add(_doubleArrow_12); | ||
524 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_13 = new CostObjectiveElementConfiguration(); | ||
525 | final Procedure1<CostObjectiveElementConfiguration> _function_14 = (CostObjectiveElementConfiguration it_1) -> { | ||
526 | it_1.patternQualifiedName = EndOfSiding_step_3.instance().getFullyQualifiedName(); | ||
527 | it_1.weight = (21 + 14); | ||
528 | }; | ||
529 | CostObjectiveElementConfiguration _doubleArrow_13 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_13, _function_14); | ||
530 | it.elements.add(_doubleArrow_13); | ||
531 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_14 = new CostObjectiveElementConfiguration(); | ||
532 | final Procedure1<CostObjectiveElementConfiguration> _function_15 = (CostObjectiveElementConfiguration it_1) -> { | ||
533 | it_1.patternQualifiedName = EndOfSiding_step_4.instance().getFullyQualifiedName(); | ||
534 | it_1.weight = (((((((14 + 35) + 21) + 15) + 14) + 21) + 15) + 11); | ||
535 | }; | ||
536 | CostObjectiveElementConfiguration _doubleArrow_14 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_14, _function_15); | ||
537 | it.elements.add(_doubleArrow_14); | ||
538 | CostObjectiveElementConfiguration _costObjectiveElementConfiguration_15 = new CostObjectiveElementConfiguration(); | ||
539 | final Procedure1<CostObjectiveElementConfiguration> _function_16 = (CostObjectiveElementConfiguration it_1) -> { | ||
540 | it_1.patternQualifiedName = EndOfSiding_step_5.instance().getFullyQualifiedName(); | ||
541 | it_1.weight = 48; | ||
542 | }; | ||
543 | CostObjectiveElementConfiguration _doubleArrow_15 = ObjectExtensions.<CostObjectiveElementConfiguration>operator_doubleArrow(_costObjectiveElementConfiguration_15, _function_16); | ||
544 | it.elements.add(_doubleArrow_15); | ||
545 | EndOfSidingObjectiveHint _endOfSidingObjectiveHint = new EndOfSidingObjectiveHint(ecore2Logic, ecore2LogicTrace); | ||
546 | it.hint = _endOfSidingObjectiveHint; | ||
547 | break; | ||
548 | default: | ||
549 | throw new IllegalArgumentException(("Unknown monitoring query: " + this.monitoringQuery)); | ||
550 | } | ||
551 | } else { | ||
552 | throw new IllegalArgumentException(("Unknown monitoring query: " + this.monitoringQuery)); | ||
553 | } | ||
554 | it.kind = ObjectiveKind.HIGHER_IS_BETTER; | ||
555 | it.threshold = ObjectiveThreshold.NO_THRESHOLD; | ||
556 | it.findExtremum = true; | ||
557 | }; | ||
558 | return ObjectExtensions.<CostObjectiveConfiguration>operator_doubleArrow(_costObjectiveConfiguration, _function); | ||
559 | } | ||
560 | |||
561 | public static Object init() { | ||
562 | Object _xblockexpression = null; | ||
563 | { | ||
564 | EMFPatternLanguageStandaloneSetup.doSetup(); | ||
565 | ViatraQueryEngineOptions.setSystemDefaultBackends(ReteBackendFactory.INSTANCE, ReteBackendFactory.INSTANCE, | ||
566 | LocalSearchEMFBackendFactory.INSTANCE); | ||
567 | LogiclanguagePackage.eINSTANCE.getClass(); | ||
568 | LogicproblemPackage.eINSTANCE.getClass(); | ||
569 | PartialinterpretationPackage.eINSTANCE.getClass(); | ||
570 | Ecore2logicannotationsPackage.eINSTANCE.getClass(); | ||
571 | Viatra2LogicAnnotationsPackage.eINSTANCE.getClass(); | ||
572 | Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); | ||
573 | XMIResourceFactoryImpl _xMIResourceFactoryImpl = new XMIResourceFactoryImpl(); | ||
574 | _xblockexpression = _extensionToFactoryMap.put("*", _xMIResourceFactoryImpl); | ||
575 | } | ||
576 | return _xblockexpression; | ||
577 | } | ||
578 | |||
579 | public static void main(final String[] args) { | ||
580 | int _length = args.length; | ||
581 | boolean _notEquals = (_length != 2); | ||
582 | if (_notEquals) { | ||
583 | System.err.println("Usage: <query> <model size>"); | ||
584 | } | ||
585 | final Modes3ModelGenerator.MonitoringQuery monitoringQuery = Modes3ModelGenerator.MonitoringQuery.valueOf(args[0]); | ||
586 | final int modelSize = Integer.parseInt(args[1]); | ||
587 | Modes3ModelGenerator.init(); | ||
588 | final Modes3ModelGenerator generator = new Modes3ModelGenerator(monitoringQuery, modelSize); | ||
589 | generator.generate(); | ||
590 | } | ||
591 | |||
592 | public Modes3ModelGenerator(final Modes3ModelGenerator.MonitoringQuery monitoringQuery, final int modelSize) { | ||
593 | super(); | ||
594 | this.monitoringQuery = monitoringQuery; | ||
595 | this.modelSize = modelSize; | ||
596 | } | ||
597 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3TypeScopeHint.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3TypeScopeHint.java new file mode 100644 index 00000000..adb69760 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3TypeScopeHint.java | |||
@@ -0,0 +1,133 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality; | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearBoundedExpression; | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint; | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory; | ||
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationConstraintUpdater; | ||
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator; | ||
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; | ||
13 | import java.util.Iterator; | ||
14 | import java.util.Map; | ||
15 | import modes3.Modes3Package; | ||
16 | import modes3.queries.Adjacent; | ||
17 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
18 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher; | ||
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; | ||
20 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
21 | import org.eclipse.xtext.xbase.lib.Extension; | ||
22 | |||
23 | @SuppressWarnings("all") | ||
24 | public class Modes3TypeScopeHint implements LinearTypeConstraintHint { | ||
25 | private static final String TURNOUT_NEIGHBOR_COUNT = "turnoutNeighborCount"; | ||
26 | |||
27 | private final Type segmentType; | ||
28 | |||
29 | private final Type turnoutType; | ||
30 | |||
31 | public Modes3TypeScopeHint(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { | ||
32 | @Extension | ||
33 | final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; | ||
34 | this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); | ||
35 | this.turnoutType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTurnout()); | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | public CharSequence getAdditionalPatterns(@Extension final PatternGenerator patternGenerator, final Map<String, PQuery> fqnToPQuery) { | ||
40 | StringConcatenation _builder = new StringConcatenation(); | ||
41 | _builder.append("\t"); | ||
42 | _builder.append("pattern "); | ||
43 | _builder.append(Modes3TypeScopeHint.TURNOUT_NEIGHBOR_COUNT, "\t"); | ||
44 | _builder.append("_helper(problem: LogicProblem, interpretation: PartialInterpretation, source: DefinedElement, target: DefinedElement) {"); | ||
45 | _builder.newLineIfNotEmpty(); | ||
46 | _builder.append("\t\t"); | ||
47 | _builder.append("find interpretation(problem, interpretation);"); | ||
48 | _builder.newLine(); | ||
49 | _builder.append("\t\t"); | ||
50 | _builder.append("find mustExist(problem, interpretation, source);"); | ||
51 | _builder.newLine(); | ||
52 | _builder.append("\t\t"); | ||
53 | _builder.append("find mustExist(problem, interpretation, target);"); | ||
54 | _builder.newLine(); | ||
55 | _builder.append("\t\t"); | ||
56 | CharSequence _referInstanceOf = patternGenerator.getTypeIndexer().referInstanceOf(this.turnoutType, Modality.MUST, "source"); | ||
57 | _builder.append(_referInstanceOf, "\t\t"); | ||
58 | _builder.newLineIfNotEmpty(); | ||
59 | _builder.append("\t\t"); | ||
60 | CharSequence _referInstanceOf_1 = patternGenerator.getTypeIndexer().referInstanceOf(this.segmentType, Modality.MUST, "target"); | ||
61 | _builder.append(_referInstanceOf_1, "\t\t"); | ||
62 | _builder.newLineIfNotEmpty(); | ||
63 | _builder.append("\t\t"); | ||
64 | CharSequence _referPattern = patternGenerator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "source", "target" }, Modality.MUST, true, false); | ||
65 | _builder.append(_referPattern, "\t\t"); | ||
66 | _builder.newLineIfNotEmpty(); | ||
67 | _builder.append("\t"); | ||
68 | _builder.append("}"); | ||
69 | _builder.newLine(); | ||
70 | _builder.newLine(); | ||
71 | _builder.append("\t"); | ||
72 | _builder.append("pattern "); | ||
73 | _builder.append(Modes3TypeScopeHint.TURNOUT_NEIGHBOR_COUNT, "\t"); | ||
74 | _builder.append("(problem: LogicProblem, interpretation: PartialInterpretation, element: DefinedElement, N) {"); | ||
75 | _builder.newLineIfNotEmpty(); | ||
76 | _builder.append("\t\t"); | ||
77 | _builder.append("find interpretation(problem, interpretation);"); | ||
78 | _builder.newLine(); | ||
79 | _builder.append("\t\t"); | ||
80 | _builder.append("find mustExist(problem, interpretation, element);"); | ||
81 | _builder.newLine(); | ||
82 | _builder.append("\t\t"); | ||
83 | CharSequence _referInstanceOf_2 = patternGenerator.getTypeIndexer().referInstanceOf(this.turnoutType, Modality.MUST, "element"); | ||
84 | _builder.append(_referInstanceOf_2, "\t\t"); | ||
85 | _builder.newLineIfNotEmpty(); | ||
86 | _builder.append("\t\t"); | ||
87 | _builder.append("N == count find "); | ||
88 | _builder.append(Modes3TypeScopeHint.TURNOUT_NEIGHBOR_COUNT, "\t\t"); | ||
89 | _builder.append("_helper(problem, interpretation, element, _);"); | ||
90 | _builder.newLineIfNotEmpty(); | ||
91 | _builder.append("\t"); | ||
92 | _builder.append("}"); | ||
93 | _builder.newLine(); | ||
94 | return _builder; | ||
95 | } | ||
96 | |||
97 | @Override | ||
98 | public RelationConstraintUpdater createConstraintUpdater(final LinearTypeExpressionBuilderFactory builderFactory) { | ||
99 | final ViatraQueryMatcher<? extends IPatternMatch> turnoutNeighborCountMatcher = builderFactory.createMatcher(Modes3TypeScopeHint.TURNOUT_NEIGHBOR_COUNT); | ||
100 | final LinearBoundedExpression newNeighbors = builderFactory.createBuilder().add(1, this.segmentType).build(); | ||
101 | final RelationConstraintUpdater _function = (PartialInterpretation partialInterpretation) -> { | ||
102 | final int requiredNeighbbors = Modes3TypeScopeHint.getRemainingCount(turnoutNeighborCountMatcher, partialInterpretation, 3); | ||
103 | newNeighbors.tightenLowerBound(Integer.valueOf(requiredNeighbbors)); | ||
104 | }; | ||
105 | return _function; | ||
106 | } | ||
107 | |||
108 | private static <T extends IPatternMatch> int getRemainingCount(final ViatraQueryMatcher<T> matcher, final PartialInterpretation partialInterpretation, final int capacity) { | ||
109 | int _xblockexpression = (int) 0; | ||
110 | { | ||
111 | final T partialMatch = matcher.newEmptyMatch(); | ||
112 | partialMatch.set(0, partialInterpretation.getProblem()); | ||
113 | partialMatch.set(1, partialInterpretation); | ||
114 | final Iterator<T> iterator = matcher.streamAllMatches(partialMatch).iterator(); | ||
115 | int max = 0; | ||
116 | while (iterator.hasNext()) { | ||
117 | { | ||
118 | final T match = iterator.next(); | ||
119 | Object _get = match.get(3); | ||
120 | final int n = ((Integer) _get).intValue(); | ||
121 | if ((n < capacity)) { | ||
122 | final int required = (capacity - n); | ||
123 | if ((max < required)) { | ||
124 | max = required; | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | _xblockexpression = max; | ||
130 | } | ||
131 | return _xblockexpression; | ||
132 | } | ||
133 | } | ||
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3UnitPropagationGenerator.java b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3UnitPropagationGenerator.java new file mode 100644 index 00000000..5c5f82c5 --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/xtend-gen/modes3/run/Modes3UnitPropagationGenerator.java | |||
@@ -0,0 +1,1174 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation; | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality; | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator; | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.UnitPropagationPatternGenerator; | ||
10 | import java.util.Collections; | ||
11 | import java.util.Map; | ||
12 | import modes3.Modes3Package; | ||
13 | import modes3.queries.Adjacent; | ||
14 | import modes3.queries.Output; | ||
15 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery; | ||
16 | import org.eclipse.xtend2.lib.StringConcatenationClient; | ||
17 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
18 | import org.eclipse.xtext.xbase.lib.Extension; | ||
19 | import org.eclipse.xtext.xbase.lib.Pair; | ||
20 | |||
21 | @SuppressWarnings("all") | ||
22 | public class Modes3UnitPropagationGenerator implements UnitPropagationPatternGenerator { | ||
23 | private static final String MUST_NOT_CONNECTED_TO = "mustNotConnectedTo"; | ||
24 | |||
25 | private static final String MUST_NOT_STRAIGHT = "mustNotStraight"; | ||
26 | |||
27 | private static final String MUST_NOT_DIVERGENT = "mustNotDivergent"; | ||
28 | |||
29 | private static final String MUST_CONNECTED_TO = "mustConnectedTo"; | ||
30 | |||
31 | private static final String MUST_STRAIGHT = "mustStraight"; | ||
32 | |||
33 | private static final String MUST_DIVERGENT = "mustDivergent"; | ||
34 | |||
35 | private final Type segmentType; | ||
36 | |||
37 | private final Type simpleSegmentType; | ||
38 | |||
39 | private final Type turnoutType; | ||
40 | |||
41 | private final Relation connectedToRelation; | ||
42 | |||
43 | private final Relation straightRelation; | ||
44 | |||
45 | private final Relation divergentRelation; | ||
46 | |||
47 | public Modes3UnitPropagationGenerator(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { | ||
48 | @Extension | ||
49 | final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; | ||
50 | this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); | ||
51 | this.simpleSegmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSimpleSegment()); | ||
52 | this.turnoutType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTurnout()); | ||
53 | this.connectedToRelation = ecore2Logic.relationOfReference(ecore2LogicTrace, Modes3Package.getSegment_ConnectedTo()); | ||
54 | this.straightRelation = ecore2Logic.relationOfReference(ecore2LogicTrace, Modes3Package.getTurnout_Straight()); | ||
55 | this.divergentRelation = ecore2Logic.relationOfReference(ecore2LogicTrace, Modes3Package.getTurnout_Divergent()); | ||
56 | } | ||
57 | |||
58 | @Override | ||
59 | public Map<Relation, String> getMustPatterns() { | ||
60 | Pair<Relation, String> _mappedTo = Pair.<Relation, String>of(this.connectedToRelation, Modes3UnitPropagationGenerator.MUST_CONNECTED_TO); | ||
61 | Pair<Relation, String> _mappedTo_1 = Pair.<Relation, String>of(this.straightRelation, Modes3UnitPropagationGenerator.MUST_STRAIGHT); | ||
62 | Pair<Relation, String> _mappedTo_2 = Pair.<Relation, String>of(this.divergentRelation, Modes3UnitPropagationGenerator.MUST_DIVERGENT); | ||
63 | return Collections.<Relation, String>unmodifiableMap(CollectionLiterals.<Relation, String>newHashMap(_mappedTo, _mappedTo_1, _mappedTo_2)); | ||
64 | } | ||
65 | |||
66 | @Override | ||
67 | public Map<Relation, String> getMustNotPatterns() { | ||
68 | Pair<Relation, String> _mappedTo = Pair.<Relation, String>of(this.connectedToRelation, Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO); | ||
69 | Pair<Relation, String> _mappedTo_1 = Pair.<Relation, String>of(this.straightRelation, Modes3UnitPropagationGenerator.MUST_NOT_STRAIGHT); | ||
70 | Pair<Relation, String> _mappedTo_2 = Pair.<Relation, String>of(this.divergentRelation, Modes3UnitPropagationGenerator.MUST_NOT_DIVERGENT); | ||
71 | return Collections.<Relation, String>unmodifiableMap(CollectionLiterals.<Relation, String>newHashMap(_mappedTo, _mappedTo_1, _mappedTo_2)); | ||
72 | } | ||
73 | |||
74 | @Override | ||
75 | public StringConcatenationClient getAdditionalPatterns(@Extension final PatternGenerator generator, final Map<String, PQuery> fqnToPQuery) { | ||
76 | StringConcatenationClient _xblockexpression = null; | ||
77 | { | ||
78 | StringConcatenationClient _client = new StringConcatenationClient() { | ||
79 | @Override | ||
80 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
81 | _builder.append("problem: LogicProblem, interpretation: PartialInterpretation,"); | ||
82 | _builder.newLine(); | ||
83 | _builder.append("source: DefinedElement, target: DefinedElement"); | ||
84 | _builder.newLine(); | ||
85 | } | ||
86 | }; | ||
87 | final StringConcatenationClient parameters = _client; | ||
88 | StringConcatenationClient _client_1 = new StringConcatenationClient() { | ||
89 | @Override | ||
90 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
91 | _builder.append("find interpretation(problem, interpretation);"); | ||
92 | _builder.newLine(); | ||
93 | _builder.append("find mustExist(problem, interpretation, source);"); | ||
94 | _builder.newLine(); | ||
95 | _builder.append("find mustExist(problem, interpretation, target);"); | ||
96 | _builder.newLine(); | ||
97 | } | ||
98 | }; | ||
99 | final StringConcatenationClient commonMustParameterConstraints = _client_1; | ||
100 | StringConcatenationClient _client_2 = new StringConcatenationClient() { | ||
101 | @Override | ||
102 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
103 | _builder.append("find interpretation(problem, interpretation);"); | ||
104 | _builder.newLine(); | ||
105 | _builder.append("find mayExist(problem, interpretation, source);"); | ||
106 | _builder.newLine(); | ||
107 | _builder.append("find mayExist(problem, interpretation, target);"); | ||
108 | _builder.newLine(); | ||
109 | } | ||
110 | }; | ||
111 | final StringConcatenationClient commonMayParameterConstraints = _client_2; | ||
112 | StringConcatenationClient _client_3 = new StringConcatenationClient() { | ||
113 | @Override | ||
114 | protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { | ||
115 | _builder.append("pattern mayInput("); | ||
116 | _builder.append(parameters); | ||
117 | _builder.append(") {"); | ||
118 | _builder.newLineIfNotEmpty(); | ||
119 | _builder.append("\t"); | ||
120 | _builder.append(commonMayParameterConstraints, "\t"); | ||
121 | _builder.newLineIfNotEmpty(); | ||
122 | _builder.append("\t"); | ||
123 | CharSequence _referInstanceOf = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
124 | _builder.append(_referInstanceOf, "\t"); | ||
125 | _builder.newLineIfNotEmpty(); | ||
126 | _builder.append("\t"); | ||
127 | CharSequence _referPattern = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "target", "source" }, Modality.MAY, true, false); | ||
128 | _builder.append(_referPattern, "\t"); | ||
129 | _builder.newLineIfNotEmpty(); | ||
130 | _builder.append("\t"); | ||
131 | _builder.append("neg "); | ||
132 | CharSequence _referRelation = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "target", "source", Modality.MUST, fqnToPQuery); | ||
133 | _builder.append(_referRelation, "\t"); | ||
134 | _builder.newLineIfNotEmpty(); | ||
135 | _builder.append("\t"); | ||
136 | _builder.append("neg "); | ||
137 | CharSequence _referRelation_1 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "target", "source", Modality.MUST, fqnToPQuery); | ||
138 | _builder.append(_referRelation_1, "\t"); | ||
139 | _builder.newLineIfNotEmpty(); | ||
140 | _builder.append("}"); | ||
141 | _builder.newLine(); | ||
142 | _builder.newLine(); | ||
143 | _builder.append("pattern multipleMayInput(problem: LogicProblem, interpretation: PartialInterpretation,"); | ||
144 | _builder.newLine(); | ||
145 | _builder.append("\t\t\t"); | ||
146 | _builder.append("target: DefinedElement) {"); | ||
147 | _builder.newLine(); | ||
148 | _builder.append("\t"); | ||
149 | _builder.append("find interpretation(problem, interpretation);"); | ||
150 | _builder.newLine(); | ||
151 | _builder.append("\t"); | ||
152 | _builder.append("find mustExist(problem, interpretation, target);"); | ||
153 | _builder.newLine(); | ||
154 | _builder.append("\t"); | ||
155 | _builder.append("find mayInput(problem, interpretaton, source1, target);"); | ||
156 | _builder.newLine(); | ||
157 | _builder.append("\t"); | ||
158 | _builder.append("find mayInput(problem, interpretaton, source2, target);"); | ||
159 | _builder.newLine(); | ||
160 | _builder.append("\t"); | ||
161 | _builder.append("neg find mustEquivalent(problem, interpretation, source1, source2);"); | ||
162 | _builder.newLine(); | ||
163 | _builder.append("}"); | ||
164 | _builder.newLine(); | ||
165 | _builder.newLine(); | ||
166 | _builder.append("pattern multipleMayStraight(problem: LogicProblem, interpretation: PartialInterpretation,"); | ||
167 | _builder.newLine(); | ||
168 | _builder.append("\t\t\t"); | ||
169 | _builder.append("source: DefinedElement) {"); | ||
170 | _builder.newLine(); | ||
171 | _builder.append("\t"); | ||
172 | _builder.append("find interpretation(problem, interpretation);"); | ||
173 | _builder.newLine(); | ||
174 | _builder.append("\t"); | ||
175 | _builder.append("find mustExist(problem, interpretation, source);"); | ||
176 | _builder.newLine(); | ||
177 | _builder.append("\t"); | ||
178 | CharSequence _referInstanceOf_1 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
179 | _builder.append(_referInstanceOf_1, "\t"); | ||
180 | _builder.newLineIfNotEmpty(); | ||
181 | _builder.append("\t"); | ||
182 | CharSequence _referRelation_2 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target1", Modality.MAY, fqnToPQuery); | ||
183 | _builder.append(_referRelation_2, "\t"); | ||
184 | _builder.newLineIfNotEmpty(); | ||
185 | _builder.append("\t"); | ||
186 | CharSequence _referRelation_3 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target2", Modality.MAY, fqnToPQuery); | ||
187 | _builder.append(_referRelation_3, "\t"); | ||
188 | _builder.newLineIfNotEmpty(); | ||
189 | _builder.append("\t"); | ||
190 | _builder.append("neg find mustEquivalent(problem, interpretation, target1, target2);"); | ||
191 | _builder.newLine(); | ||
192 | _builder.append("}"); | ||
193 | _builder.newLine(); | ||
194 | _builder.newLine(); | ||
195 | _builder.append("pattern multipleMayDivergent(problem: LogicProblem, interpretation: PartialInterpretation,"); | ||
196 | _builder.newLine(); | ||
197 | _builder.append("\t\t\t"); | ||
198 | _builder.append("source: DefinedElement) {"); | ||
199 | _builder.newLine(); | ||
200 | _builder.append("\t"); | ||
201 | _builder.append("find interpretation(problem, interpretation);"); | ||
202 | _builder.newLine(); | ||
203 | _builder.append("\t"); | ||
204 | _builder.append("find mustExist(problem, interpretation, source);"); | ||
205 | _builder.newLine(); | ||
206 | _builder.append("\t"); | ||
207 | CharSequence _referInstanceOf_2 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
208 | _builder.append(_referInstanceOf_2, "\t"); | ||
209 | _builder.newLineIfNotEmpty(); | ||
210 | _builder.append("\t"); | ||
211 | CharSequence _referRelation_4 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target1", Modality.MAY, fqnToPQuery); | ||
212 | _builder.append(_referRelation_4, "\t"); | ||
213 | _builder.newLineIfNotEmpty(); | ||
214 | _builder.append("\t"); | ||
215 | CharSequence _referRelation_5 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target2", Modality.MAY, fqnToPQuery); | ||
216 | _builder.append(_referRelation_5, "\t"); | ||
217 | _builder.newLineIfNotEmpty(); | ||
218 | _builder.append("\t"); | ||
219 | _builder.append("neg find mustEquivalent(problem, interpretation, target1, target2);"); | ||
220 | _builder.newLine(); | ||
221 | _builder.append("}"); | ||
222 | _builder.newLine(); | ||
223 | _builder.newLine(); | ||
224 | _builder.append("pattern "); | ||
225 | _builder.append(Modes3UnitPropagationGenerator.MUST_CONNECTED_TO); | ||
226 | _builder.append("("); | ||
227 | _builder.append(parameters); | ||
228 | _builder.append(") {"); | ||
229 | _builder.newLineIfNotEmpty(); | ||
230 | _builder.append("\t"); | ||
231 | _builder.append(commonMustParameterConstraints, "\t"); | ||
232 | _builder.newLineIfNotEmpty(); | ||
233 | _builder.append("\t"); | ||
234 | CharSequence _referInstanceOf_3 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
235 | _builder.append(_referInstanceOf_3, "\t"); | ||
236 | _builder.newLineIfNotEmpty(); | ||
237 | _builder.append("\t"); | ||
238 | _builder.append("find mayInput(problem, interpretaton, source, target);"); | ||
239 | _builder.newLine(); | ||
240 | _builder.append("\t"); | ||
241 | _builder.append("neg find multipleMayInput(problem, interpretaton, target);"); | ||
242 | _builder.newLine(); | ||
243 | _builder.append("\t"); | ||
244 | CharSequence _referRelation_6 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
245 | _builder.append(_referRelation_6, "\t"); | ||
246 | _builder.newLineIfNotEmpty(); | ||
247 | _builder.append("\t"); | ||
248 | _builder.append("neg "); | ||
249 | CharSequence _referRelation_7 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "target", Modality.MUST, fqnToPQuery); | ||
250 | _builder.append(_referRelation_7, "\t"); | ||
251 | _builder.newLineIfNotEmpty(); | ||
252 | _builder.append("\t"); | ||
253 | _builder.append("neg "); | ||
254 | CharSequence _referRelation_8 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
255 | _builder.append(_referRelation_8, "\t"); | ||
256 | _builder.newLineIfNotEmpty(); | ||
257 | _builder.append("\t"); | ||
258 | _builder.append("neg "); | ||
259 | CharSequence _referRelation_9 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
260 | _builder.append(_referRelation_9, "\t"); | ||
261 | _builder.newLineIfNotEmpty(); | ||
262 | _builder.append("}"); | ||
263 | _builder.newLine(); | ||
264 | _builder.newLine(); | ||
265 | _builder.append("pattern "); | ||
266 | _builder.append(Modes3UnitPropagationGenerator.MUST_STRAIGHT); | ||
267 | _builder.append("("); | ||
268 | _builder.append(parameters); | ||
269 | _builder.append(") {"); | ||
270 | _builder.newLineIfNotEmpty(); | ||
271 | _builder.append("\t"); | ||
272 | _builder.append(commonMustParameterConstraints, "\t"); | ||
273 | _builder.newLineIfNotEmpty(); | ||
274 | _builder.append("\t"); | ||
275 | _builder.append("neg "); | ||
276 | CharSequence _referRelation_10 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "_", Modality.MUST, fqnToPQuery); | ||
277 | _builder.append(_referRelation_10, "\t"); | ||
278 | _builder.newLineIfNotEmpty(); | ||
279 | _builder.append("\t"); | ||
280 | _builder.append("neg find multipleMayStraight(problem, interpretation, source);"); | ||
281 | _builder.newLine(); | ||
282 | _builder.append("\t"); | ||
283 | CharSequence _referRelation_11 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
284 | _builder.append(_referRelation_11, "\t"); | ||
285 | _builder.newLineIfNotEmpty(); | ||
286 | _builder.append("\t"); | ||
287 | _builder.append("neg "); | ||
288 | CharSequence _referRelation_12 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target", Modality.MUST, fqnToPQuery); | ||
289 | _builder.append(_referRelation_12, "\t"); | ||
290 | _builder.newLineIfNotEmpty(); | ||
291 | _builder.append("} or {"); | ||
292 | _builder.newLine(); | ||
293 | _builder.append("\t"); | ||
294 | _builder.append(commonMustParameterConstraints, "\t"); | ||
295 | _builder.newLineIfNotEmpty(); | ||
296 | _builder.append("\t"); | ||
297 | CharSequence _referInstanceOf_4 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
298 | _builder.append(_referInstanceOf_4, "\t"); | ||
299 | _builder.newLineIfNotEmpty(); | ||
300 | _builder.append("\t"); | ||
301 | _builder.append("find mayInput(problem, interpretaton, source, target);"); | ||
302 | _builder.newLine(); | ||
303 | _builder.append("\t"); | ||
304 | _builder.append("neg find multipleMayInput(problem, interpretaton, target);"); | ||
305 | _builder.newLine(); | ||
306 | _builder.append("\t"); | ||
307 | _builder.append("neg "); | ||
308 | CharSequence _referRelation_13 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
309 | _builder.append(_referRelation_13, "\t"); | ||
310 | _builder.newLineIfNotEmpty(); | ||
311 | _builder.append("\t"); | ||
312 | CharSequence _referRelation_14 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
313 | _builder.append(_referRelation_14, "\t"); | ||
314 | _builder.newLineIfNotEmpty(); | ||
315 | _builder.append("\t"); | ||
316 | _builder.append("neg "); | ||
317 | CharSequence _referRelation_15 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target", Modality.MUST, fqnToPQuery); | ||
318 | _builder.append(_referRelation_15, "\t"); | ||
319 | _builder.newLineIfNotEmpty(); | ||
320 | _builder.append("\t"); | ||
321 | _builder.append("neg "); | ||
322 | CharSequence _referRelation_16 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
323 | _builder.append(_referRelation_16, "\t"); | ||
324 | _builder.newLineIfNotEmpty(); | ||
325 | _builder.append("}"); | ||
326 | _builder.newLine(); | ||
327 | _builder.newLine(); | ||
328 | _builder.append("pattern "); | ||
329 | _builder.append(Modes3UnitPropagationGenerator.MUST_DIVERGENT); | ||
330 | _builder.append("("); | ||
331 | _builder.append(parameters); | ||
332 | _builder.append(") {"); | ||
333 | _builder.newLineIfNotEmpty(); | ||
334 | _builder.append("\t"); | ||
335 | _builder.append(commonMustParameterConstraints, "\t"); | ||
336 | _builder.newLineIfNotEmpty(); | ||
337 | _builder.append("\t"); | ||
338 | _builder.append("neg "); | ||
339 | CharSequence _referRelation_17 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "_", Modality.MUST, fqnToPQuery); | ||
340 | _builder.append(_referRelation_17, "\t"); | ||
341 | _builder.newLineIfNotEmpty(); | ||
342 | _builder.append("\t"); | ||
343 | _builder.append("neg find multipleMayDivergent(problem, interpretation, source);"); | ||
344 | _builder.newLine(); | ||
345 | _builder.append("\t"); | ||
346 | CharSequence _referRelation_18 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
347 | _builder.append(_referRelation_18, "\t"); | ||
348 | _builder.newLineIfNotEmpty(); | ||
349 | _builder.append("\t"); | ||
350 | _builder.append("neg "); | ||
351 | CharSequence _referRelation_19 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target", Modality.MUST, fqnToPQuery); | ||
352 | _builder.append(_referRelation_19, "\t"); | ||
353 | _builder.newLineIfNotEmpty(); | ||
354 | _builder.append("} or {"); | ||
355 | _builder.newLine(); | ||
356 | _builder.append("\t"); | ||
357 | _builder.append(commonMustParameterConstraints, "\t"); | ||
358 | _builder.newLineIfNotEmpty(); | ||
359 | _builder.append("\t"); | ||
360 | CharSequence _referInstanceOf_5 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
361 | _builder.append(_referInstanceOf_5, "\t"); | ||
362 | _builder.newLineIfNotEmpty(); | ||
363 | _builder.append("\t"); | ||
364 | _builder.append("find mayInput(problem, interpretaton, source, target);"); | ||
365 | _builder.newLine(); | ||
366 | _builder.append("\t"); | ||
367 | _builder.append("neg find multipleMayInput(problem, interpretaton, target);"); | ||
368 | _builder.newLine(); | ||
369 | _builder.append("\t"); | ||
370 | _builder.append("neg "); | ||
371 | CharSequence _referRelation_20 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
372 | _builder.append(_referRelation_20, "\t"); | ||
373 | _builder.newLineIfNotEmpty(); | ||
374 | _builder.append("\t"); | ||
375 | _builder.append("neg "); | ||
376 | CharSequence _referRelation_21 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
377 | _builder.append(_referRelation_21, "\t"); | ||
378 | _builder.newLineIfNotEmpty(); | ||
379 | _builder.append("\t"); | ||
380 | CharSequence _referRelation_22 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target", Modality.MAY, fqnToPQuery); | ||
381 | _builder.append(_referRelation_22, "\t"); | ||
382 | _builder.newLineIfNotEmpty(); | ||
383 | _builder.append("\t"); | ||
384 | _builder.append("neg "); | ||
385 | CharSequence _referRelation_23 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "source", "target", Modality.MUST, fqnToPQuery); | ||
386 | _builder.append(_referRelation_23, "\t"); | ||
387 | _builder.newLineIfNotEmpty(); | ||
388 | _builder.append("}"); | ||
389 | _builder.newLine(); | ||
390 | _builder.newLine(); | ||
391 | _builder.append("pattern turnoutOutput_must_to_true_by_straight("); | ||
392 | _builder.append(parameters); | ||
393 | _builder.append(", T : DefinedElement, S : DefinedElement) {"); | ||
394 | _builder.newLineIfNotEmpty(); | ||
395 | _builder.append("\t"); | ||
396 | _builder.append(commonMayParameterConstraints, "\t"); | ||
397 | _builder.newLineIfNotEmpty(); | ||
398 | _builder.append("\t"); | ||
399 | CharSequence _referInstanceOf_6 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
400 | _builder.append(_referInstanceOf_6, "\t"); | ||
401 | _builder.newLineIfNotEmpty(); | ||
402 | _builder.append("\t"); | ||
403 | CharSequence _referInstanceOf_7 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
404 | _builder.append(_referInstanceOf_7, "\t"); | ||
405 | _builder.newLineIfNotEmpty(); | ||
406 | _builder.append("\t"); | ||
407 | _builder.append("T == source;"); | ||
408 | _builder.newLine(); | ||
409 | _builder.append("\t"); | ||
410 | _builder.append("S == target;"); | ||
411 | _builder.newLine(); | ||
412 | _builder.append("}"); | ||
413 | _builder.newLine(); | ||
414 | _builder.newLine(); | ||
415 | _builder.append("pattern turnoutOutput_must_to_true_by_divergent("); | ||
416 | _builder.append(parameters); | ||
417 | _builder.append(", T : DefinedElement, S : DefinedElement) {"); | ||
418 | _builder.newLineIfNotEmpty(); | ||
419 | _builder.append("\t"); | ||
420 | _builder.append(commonMayParameterConstraints, "\t"); | ||
421 | _builder.newLineIfNotEmpty(); | ||
422 | _builder.append("\t"); | ||
423 | CharSequence _referInstanceOf_8 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
424 | _builder.append(_referInstanceOf_8, "\t"); | ||
425 | _builder.newLineIfNotEmpty(); | ||
426 | _builder.append("\t"); | ||
427 | CharSequence _referInstanceOf_9 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
428 | _builder.append(_referInstanceOf_9, "\t"); | ||
429 | _builder.newLineIfNotEmpty(); | ||
430 | _builder.append("\t"); | ||
431 | _builder.append("T == source;"); | ||
432 | _builder.newLine(); | ||
433 | _builder.append("\t"); | ||
434 | _builder.append("S == target;"); | ||
435 | _builder.newLine(); | ||
436 | _builder.append("}"); | ||
437 | _builder.newLine(); | ||
438 | _builder.newLine(); | ||
439 | _builder.append("pattern output_must_to_true_by_connectedTo("); | ||
440 | _builder.append(parameters); | ||
441 | _builder.append(", S1 : DefinedElement, S2 : DefinedElement) {"); | ||
442 | _builder.newLineIfNotEmpty(); | ||
443 | _builder.append("\t"); | ||
444 | _builder.append(commonMayParameterConstraints, "\t"); | ||
445 | _builder.newLineIfNotEmpty(); | ||
446 | _builder.append("\t"); | ||
447 | CharSequence _referInstanceOf_10 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "source"); | ||
448 | _builder.append(_referInstanceOf_10, "\t"); | ||
449 | _builder.newLineIfNotEmpty(); | ||
450 | _builder.append("\t"); | ||
451 | CharSequence _referInstanceOf_11 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
452 | _builder.append(_referInstanceOf_11, "\t"); | ||
453 | _builder.newLineIfNotEmpty(); | ||
454 | _builder.append("\t"); | ||
455 | _builder.append("S1 == source;"); | ||
456 | _builder.newLine(); | ||
457 | _builder.append("\t"); | ||
458 | _builder.append("S2 == target;"); | ||
459 | _builder.newLine(); | ||
460 | _builder.append("}"); | ||
461 | _builder.newLine(); | ||
462 | _builder.newLine(); | ||
463 | _builder.append("pattern output_must_to_true_by_straight("); | ||
464 | _builder.append(parameters); | ||
465 | _builder.append(", S1 : DefinedElement, S2 : DefinedElement) {"); | ||
466 | _builder.newLineIfNotEmpty(); | ||
467 | _builder.append("\t"); | ||
468 | _builder.append("find turnoutOutput_must_to_true_by_straight(problem, interpretation, source, target, S1, S2);"); | ||
469 | _builder.newLine(); | ||
470 | _builder.append("}"); | ||
471 | _builder.newLine(); | ||
472 | _builder.newLine(); | ||
473 | _builder.append("pattern output_must_to_true_by_divergent("); | ||
474 | _builder.append(parameters); | ||
475 | _builder.append(", S1 : DefinedElement, S2 : DefinedElement) {"); | ||
476 | _builder.newLineIfNotEmpty(); | ||
477 | _builder.append("\t"); | ||
478 | _builder.append("find turnoutOutput_must_to_true_by_divergent(problem, interpretation, source, target, S1, S2);"); | ||
479 | _builder.newLine(); | ||
480 | _builder.append("}"); | ||
481 | _builder.newLine(); | ||
482 | _builder.newLine(); | ||
483 | _builder.append("pattern adjacent_must_to_true_by_connectedTo("); | ||
484 | _builder.append(parameters); | ||
485 | _builder.append(", S1 : DefinedElement, S2 : DefinedElement) {"); | ||
486 | _builder.newLineIfNotEmpty(); | ||
487 | _builder.append("\t"); | ||
488 | _builder.append("find output_must_to_true_by_connectedTo(problem, interpretation, source, target, S1, S2);"); | ||
489 | _builder.newLine(); | ||
490 | _builder.append("}"); | ||
491 | _builder.newLine(); | ||
492 | _builder.newLine(); | ||
493 | _builder.append("pattern adjacent_must_to_true_by_straight("); | ||
494 | _builder.append(parameters); | ||
495 | _builder.append(", S1 : DefinedElement, S2 : DefinedElement) {"); | ||
496 | _builder.newLineIfNotEmpty(); | ||
497 | _builder.append("\t"); | ||
498 | _builder.append("find output_must_to_true_by_straight(problem, interpretation, source, target, S1, S2);"); | ||
499 | _builder.newLine(); | ||
500 | _builder.append("} or {"); | ||
501 | _builder.newLine(); | ||
502 | _builder.append("\t"); | ||
503 | _builder.append("find turnoutOutput_must_to_true_by_straight(problem, interpretation, source, target, S2, S1);"); | ||
504 | _builder.newLine(); | ||
505 | _builder.append("}"); | ||
506 | _builder.newLine(); | ||
507 | _builder.newLine(); | ||
508 | _builder.append("pattern adjacent_must_to_true_by_divergent("); | ||
509 | _builder.append(parameters); | ||
510 | _builder.append(", S1 : DefinedElement, S2 : DefinedElement) {"); | ||
511 | _builder.newLineIfNotEmpty(); | ||
512 | _builder.append("\t"); | ||
513 | _builder.append("find output_must_to_true_by_divergent(problem, interpretation, source, target, S1, S2);"); | ||
514 | _builder.newLine(); | ||
515 | _builder.append("} or {"); | ||
516 | _builder.newLine(); | ||
517 | _builder.append("\t"); | ||
518 | _builder.append("find turnoutOutput_must_to_true_by_divergent(problem, interpretation, source, target, S2, S1);"); | ||
519 | _builder.newLine(); | ||
520 | _builder.append("}"); | ||
521 | _builder.newLine(); | ||
522 | _builder.newLine(); | ||
523 | _builder.append("pattern connectedToReflexive_must_to_true_by_connectedTo("); | ||
524 | _builder.append(parameters); | ||
525 | _builder.append(", S : DefinedElement) {"); | ||
526 | _builder.newLineIfNotEmpty(); | ||
527 | _builder.append("\t"); | ||
528 | _builder.append("find mustExist(problem, interpretation, source);"); | ||
529 | _builder.newLine(); | ||
530 | _builder.append("\t"); | ||
531 | CharSequence _referInstanceOf_12 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "source"); | ||
532 | _builder.append(_referInstanceOf_12, "\t"); | ||
533 | _builder.newLineIfNotEmpty(); | ||
534 | _builder.append("\t"); | ||
535 | _builder.append("S == source;"); | ||
536 | _builder.newLine(); | ||
537 | _builder.append("\t"); | ||
538 | _builder.append("S == target;"); | ||
539 | _builder.newLine(); | ||
540 | _builder.append("}"); | ||
541 | _builder.newLine(); | ||
542 | _builder.newLine(); | ||
543 | _builder.append("pattern outputReflexive_must_to_true_by_straight("); | ||
544 | _builder.append(parameters); | ||
545 | _builder.append(", T : DefinedElement) {"); | ||
546 | _builder.newLineIfNotEmpty(); | ||
547 | _builder.append("\t"); | ||
548 | _builder.append("find turnoutOutput_must_to_true_by_straight(problem, interpretation, source, target, T, T);"); | ||
549 | _builder.newLine(); | ||
550 | _builder.append("}"); | ||
551 | _builder.newLine(); | ||
552 | _builder.newLine(); | ||
553 | _builder.append("pattern outputReflexive_must_to_true_by_divergent("); | ||
554 | _builder.append(parameters); | ||
555 | _builder.append(", T : DefinedElement) {"); | ||
556 | _builder.newLineIfNotEmpty(); | ||
557 | _builder.append("\t"); | ||
558 | _builder.append("find turnoutOutput_must_to_true_by_divergent(problem, interpretation, source, target, T, T);"); | ||
559 | _builder.newLine(); | ||
560 | _builder.append("}"); | ||
561 | _builder.newLine(); | ||
562 | _builder.newLine(); | ||
563 | _builder.append("pattern turnoutOutputsAreSame_must_to_true_by_straight("); | ||
564 | _builder.append(parameters); | ||
565 | _builder.append(", T : DefinedElement) {"); | ||
566 | _builder.newLineIfNotEmpty(); | ||
567 | _builder.append("\t"); | ||
568 | _builder.append(commonMayParameterConstraints, "\t"); | ||
569 | _builder.newLineIfNotEmpty(); | ||
570 | _builder.append("\t"); | ||
571 | CharSequence _referInstanceOf_13 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
572 | _builder.append(_referInstanceOf_13, "\t"); | ||
573 | _builder.newLineIfNotEmpty(); | ||
574 | _builder.append("\t"); | ||
575 | CharSequence _referInstanceOf_14 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
576 | _builder.append(_referInstanceOf_14, "\t"); | ||
577 | _builder.newLineIfNotEmpty(); | ||
578 | _builder.append("\t"); | ||
579 | _builder.append("T == source;"); | ||
580 | _builder.newLine(); | ||
581 | _builder.append("\t"); | ||
582 | _builder.append("S == target;"); | ||
583 | _builder.newLine(); | ||
584 | _builder.append("\t"); | ||
585 | CharSequence _referRelation_24 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "T", "S", Modality.MUST, fqnToPQuery); | ||
586 | _builder.append(_referRelation_24, "\t"); | ||
587 | _builder.newLineIfNotEmpty(); | ||
588 | _builder.append("}"); | ||
589 | _builder.newLine(); | ||
590 | _builder.newLine(); | ||
591 | _builder.append("pattern turnoutOutputsAreSame_must_to_true_by_divergent("); | ||
592 | _builder.append(parameters); | ||
593 | _builder.append(", T : DefinedElement) {"); | ||
594 | _builder.newLineIfNotEmpty(); | ||
595 | _builder.append("\t"); | ||
596 | _builder.append(commonMayParameterConstraints, "\t"); | ||
597 | _builder.newLineIfNotEmpty(); | ||
598 | _builder.append("\t"); | ||
599 | CharSequence _referInstanceOf_15 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
600 | _builder.append(_referInstanceOf_15, "\t"); | ||
601 | _builder.newLineIfNotEmpty(); | ||
602 | _builder.append("\t"); | ||
603 | CharSequence _referInstanceOf_16 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
604 | _builder.append(_referInstanceOf_16, "\t"); | ||
605 | _builder.newLineIfNotEmpty(); | ||
606 | _builder.append("\t"); | ||
607 | _builder.append("T == source;"); | ||
608 | _builder.newLine(); | ||
609 | _builder.append("\t"); | ||
610 | _builder.append("S == target;"); | ||
611 | _builder.newLine(); | ||
612 | _builder.append("\t"); | ||
613 | CharSequence _referRelation_25 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "T", "S", Modality.MUST, fqnToPQuery); | ||
614 | _builder.append(_referRelation_25, "\t"); | ||
615 | _builder.newLineIfNotEmpty(); | ||
616 | _builder.append("}"); | ||
617 | _builder.newLine(); | ||
618 | _builder.newLine(); | ||
619 | _builder.append("pattern tooManyInputsOfSegment_must_to_true_by_connectedTo("); | ||
620 | _builder.append(parameters); | ||
621 | _builder.append(", S : DefinedElement) {"); | ||
622 | _builder.newLineIfNotEmpty(); | ||
623 | _builder.append("\t"); | ||
624 | _builder.append("find mustExist(problem, interpretation, S);"); | ||
625 | _builder.newLine(); | ||
626 | _builder.append("\t"); | ||
627 | CharSequence _referInstanceOf_17 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.simpleSegmentType, Modality.MUST, "S"); | ||
628 | _builder.append(_referInstanceOf_17, "\t"); | ||
629 | _builder.newLineIfNotEmpty(); | ||
630 | _builder.append("\t"); | ||
631 | _builder.append("find output_must_to_true_by_connectedTo(problem, interpretation, source, target, I1, S);"); | ||
632 | _builder.newLine(); | ||
633 | _builder.append("\t"); | ||
634 | CharSequence _referPattern_1 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "I2", "S" }, Modality.MUST, true, false); | ||
635 | _builder.append(_referPattern_1, "\t"); | ||
636 | _builder.newLineIfNotEmpty(); | ||
637 | _builder.append("\t"); | ||
638 | CharSequence _referPattern_2 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "I3", "S" }, Modality.MUST, true, false); | ||
639 | _builder.append(_referPattern_2, "\t"); | ||
640 | _builder.newLineIfNotEmpty(); | ||
641 | _builder.append("\t"); | ||
642 | _builder.append("I1 != I2;"); | ||
643 | _builder.newLine(); | ||
644 | _builder.append("\t"); | ||
645 | _builder.append("I1 != I3;"); | ||
646 | _builder.newLine(); | ||
647 | _builder.append("\t"); | ||
648 | _builder.append("I2 != I3;"); | ||
649 | _builder.newLine(); | ||
650 | _builder.append("}"); | ||
651 | _builder.newLine(); | ||
652 | _builder.newLine(); | ||
653 | _builder.append("pattern tooManyInputsOfSegment_must_to_true_by_straight("); | ||
654 | _builder.append(parameters); | ||
655 | _builder.append(", S : DefinedElement) {"); | ||
656 | _builder.newLineIfNotEmpty(); | ||
657 | _builder.append("\t"); | ||
658 | _builder.append("find mustExist(problem, interpretation, S);"); | ||
659 | _builder.newLine(); | ||
660 | _builder.append("\t"); | ||
661 | CharSequence _referInstanceOf_18 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.simpleSegmentType, Modality.MUST, "S"); | ||
662 | _builder.append(_referInstanceOf_18, "\t"); | ||
663 | _builder.newLineIfNotEmpty(); | ||
664 | _builder.append("\t"); | ||
665 | _builder.append("find output_must_to_true_by_straight(problem, interpretation, source, target, I1, S);"); | ||
666 | _builder.newLine(); | ||
667 | _builder.append("\t"); | ||
668 | CharSequence _referPattern_3 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "I2", "S" }, Modality.MUST, true, false); | ||
669 | _builder.append(_referPattern_3, "\t"); | ||
670 | _builder.newLineIfNotEmpty(); | ||
671 | _builder.append("\t"); | ||
672 | CharSequence _referPattern_4 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "I3", "S" }, Modality.MUST, true, false); | ||
673 | _builder.append(_referPattern_4, "\t"); | ||
674 | _builder.newLineIfNotEmpty(); | ||
675 | _builder.append("\t"); | ||
676 | _builder.append("I1 != I2;"); | ||
677 | _builder.newLine(); | ||
678 | _builder.append("\t"); | ||
679 | _builder.append("I1 != I3;"); | ||
680 | _builder.newLine(); | ||
681 | _builder.append("\t"); | ||
682 | _builder.append("I2 != I3;"); | ||
683 | _builder.newLine(); | ||
684 | _builder.append("}"); | ||
685 | _builder.newLine(); | ||
686 | _builder.newLine(); | ||
687 | _builder.append("pattern tooManyInputsOfSegment_must_to_true_by_divergent("); | ||
688 | _builder.append(parameters); | ||
689 | _builder.append(", S : DefinedElement) {"); | ||
690 | _builder.newLineIfNotEmpty(); | ||
691 | _builder.append("\t"); | ||
692 | _builder.append("find mustExist(problem, interpretation, S);"); | ||
693 | _builder.newLine(); | ||
694 | _builder.append("\t"); | ||
695 | CharSequence _referInstanceOf_19 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.simpleSegmentType, Modality.MUST, "S"); | ||
696 | _builder.append(_referInstanceOf_19, "\t"); | ||
697 | _builder.newLineIfNotEmpty(); | ||
698 | _builder.append("\t"); | ||
699 | _builder.append("find output_must_to_true_by_divergent(problem, interpretation, source, target, I1, S);"); | ||
700 | _builder.newLine(); | ||
701 | _builder.append("\t"); | ||
702 | CharSequence _referPattern_5 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "I2", "S" }, Modality.MUST, true, false); | ||
703 | _builder.append(_referPattern_5, "\t"); | ||
704 | _builder.newLineIfNotEmpty(); | ||
705 | _builder.append("\t"); | ||
706 | CharSequence _referPattern_6 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Output.instance().getFullyQualifiedName()), new String[] { "I3", "S" }, Modality.MUST, true, false); | ||
707 | _builder.append(_referPattern_6, "\t"); | ||
708 | _builder.newLineIfNotEmpty(); | ||
709 | _builder.append("\t"); | ||
710 | _builder.append("I1 != I2;"); | ||
711 | _builder.newLine(); | ||
712 | _builder.append("\t"); | ||
713 | _builder.append("I1 != I3;"); | ||
714 | _builder.newLine(); | ||
715 | _builder.append("\t"); | ||
716 | _builder.append("I2 != I3;"); | ||
717 | _builder.newLine(); | ||
718 | _builder.append("}"); | ||
719 | _builder.newLine(); | ||
720 | _builder.newLine(); | ||
721 | _builder.append("pattern turnoutConnectedToBothOutputs_must_to_true_by_connectedTo("); | ||
722 | _builder.append(parameters); | ||
723 | _builder.append(", T : DefinedElement) {"); | ||
724 | _builder.newLineIfNotEmpty(); | ||
725 | _builder.append("\t"); | ||
726 | _builder.append(commonMayParameterConstraints, "\t"); | ||
727 | _builder.newLineIfNotEmpty(); | ||
728 | _builder.append("\t"); | ||
729 | _builder.append("find mustExist(problem, interpretation, Straight);"); | ||
730 | _builder.newLine(); | ||
731 | _builder.append("\t"); | ||
732 | _builder.append("find mustExist(problem, interpretation, Divergent);"); | ||
733 | _builder.newLine(); | ||
734 | _builder.append("\t"); | ||
735 | CharSequence _referInstanceOf_20 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
736 | _builder.append(_referInstanceOf_20, "\t"); | ||
737 | _builder.newLineIfNotEmpty(); | ||
738 | _builder.append("\t"); | ||
739 | CharSequence _referInstanceOf_21 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
740 | _builder.append(_referInstanceOf_21, "\t"); | ||
741 | _builder.newLineIfNotEmpty(); | ||
742 | _builder.append("\t"); | ||
743 | CharSequence _referInstanceOf_22 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Straight"); | ||
744 | _builder.append(_referInstanceOf_22, "\t"); | ||
745 | _builder.newLineIfNotEmpty(); | ||
746 | _builder.append("\t"); | ||
747 | CharSequence _referInstanceOf_23 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Divergent"); | ||
748 | _builder.append(_referInstanceOf_23, "\t"); | ||
749 | _builder.newLineIfNotEmpty(); | ||
750 | _builder.append("\t"); | ||
751 | CharSequence _referRelation_26 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "T", "Straight", Modality.MUST, fqnToPQuery); | ||
752 | _builder.append(_referRelation_26, "\t"); | ||
753 | _builder.newLineIfNotEmpty(); | ||
754 | _builder.append("\t"); | ||
755 | CharSequence _referRelation_27 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "T", "Divergent", Modality.MUST, fqnToPQuery); | ||
756 | _builder.append(_referRelation_27, "\t"); | ||
757 | _builder.newLineIfNotEmpty(); | ||
758 | _builder.append("\t"); | ||
759 | _builder.append("T == source;"); | ||
760 | _builder.newLine(); | ||
761 | _builder.append("\t"); | ||
762 | _builder.append("Straight == target;"); | ||
763 | _builder.newLine(); | ||
764 | _builder.append("\t"); | ||
765 | CharSequence _referRelation_28 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "T", "Divergent", Modality.MUST, fqnToPQuery); | ||
766 | _builder.append(_referRelation_28, "\t"); | ||
767 | _builder.newLineIfNotEmpty(); | ||
768 | _builder.append("} or {"); | ||
769 | _builder.newLine(); | ||
770 | _builder.append("\t"); | ||
771 | _builder.append(commonMayParameterConstraints, "\t"); | ||
772 | _builder.newLineIfNotEmpty(); | ||
773 | _builder.append("\t"); | ||
774 | _builder.append("find mustExist(problem, interpretation, Straight);"); | ||
775 | _builder.newLine(); | ||
776 | _builder.append("\t"); | ||
777 | _builder.append("find mustExist(problem, interpretation, Divergent);"); | ||
778 | _builder.newLine(); | ||
779 | _builder.append("\t"); | ||
780 | CharSequence _referInstanceOf_24 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
781 | _builder.append(_referInstanceOf_24, "\t"); | ||
782 | _builder.newLineIfNotEmpty(); | ||
783 | _builder.append("\t"); | ||
784 | CharSequence _referInstanceOf_25 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
785 | _builder.append(_referInstanceOf_25, "\t"); | ||
786 | _builder.newLineIfNotEmpty(); | ||
787 | _builder.append("\t"); | ||
788 | CharSequence _referInstanceOf_26 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Straight"); | ||
789 | _builder.append(_referInstanceOf_26, "\t"); | ||
790 | _builder.newLineIfNotEmpty(); | ||
791 | _builder.append("\t"); | ||
792 | CharSequence _referInstanceOf_27 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Divergent"); | ||
793 | _builder.append(_referInstanceOf_27, "\t"); | ||
794 | _builder.newLineIfNotEmpty(); | ||
795 | _builder.append("\t"); | ||
796 | CharSequence _referRelation_29 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "T", "Straight", Modality.MUST, fqnToPQuery); | ||
797 | _builder.append(_referRelation_29, "\t"); | ||
798 | _builder.newLineIfNotEmpty(); | ||
799 | _builder.append("\t"); | ||
800 | CharSequence _referRelation_30 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "T", "Divergent", Modality.MUST, fqnToPQuery); | ||
801 | _builder.append(_referRelation_30, "\t"); | ||
802 | _builder.newLineIfNotEmpty(); | ||
803 | _builder.append("\t"); | ||
804 | CharSequence _referRelation_31 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "T", "Straight", Modality.MUST, fqnToPQuery); | ||
805 | _builder.append(_referRelation_31, "\t"); | ||
806 | _builder.newLineIfNotEmpty(); | ||
807 | _builder.append("\t"); | ||
808 | _builder.append("T == source;"); | ||
809 | _builder.newLine(); | ||
810 | _builder.append("\t"); | ||
811 | _builder.append("Straight == target;"); | ||
812 | _builder.newLine(); | ||
813 | _builder.append("}"); | ||
814 | _builder.newLine(); | ||
815 | _builder.newLine(); | ||
816 | _builder.append("pattern turnoutConnectedToBothOutputs_must_to_true_by_straight("); | ||
817 | _builder.append(parameters); | ||
818 | _builder.append(", T : DefinedElement) {"); | ||
819 | _builder.newLineIfNotEmpty(); | ||
820 | _builder.append("\t"); | ||
821 | _builder.append(commonMayParameterConstraints, "\t"); | ||
822 | _builder.newLineIfNotEmpty(); | ||
823 | _builder.append("\t"); | ||
824 | _builder.append("find mustExist(problem, interpretation, Straight);"); | ||
825 | _builder.newLine(); | ||
826 | _builder.append("\t"); | ||
827 | _builder.append("find mustExist(problem, interpretation, Divergent);"); | ||
828 | _builder.newLine(); | ||
829 | _builder.append("\t"); | ||
830 | CharSequence _referInstanceOf_28 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
831 | _builder.append(_referInstanceOf_28, "\t"); | ||
832 | _builder.newLineIfNotEmpty(); | ||
833 | _builder.append("\t"); | ||
834 | CharSequence _referInstanceOf_29 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
835 | _builder.append(_referInstanceOf_29, "\t"); | ||
836 | _builder.newLineIfNotEmpty(); | ||
837 | _builder.append("\t"); | ||
838 | CharSequence _referInstanceOf_30 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Straight"); | ||
839 | _builder.append(_referInstanceOf_30, "\t"); | ||
840 | _builder.newLineIfNotEmpty(); | ||
841 | _builder.append("\t"); | ||
842 | CharSequence _referInstanceOf_31 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Divergent"); | ||
843 | _builder.append(_referInstanceOf_31, "\t"); | ||
844 | _builder.newLineIfNotEmpty(); | ||
845 | _builder.append("\t"); | ||
846 | _builder.append("T == source;"); | ||
847 | _builder.newLine(); | ||
848 | _builder.append("\t"); | ||
849 | _builder.append("Straight == target;"); | ||
850 | _builder.newLine(); | ||
851 | _builder.append("\t"); | ||
852 | CharSequence _referRelation_32 = generator.referRelation(Modes3UnitPropagationGenerator.this.divergentRelation, "T", "Divergent", Modality.MUST, fqnToPQuery); | ||
853 | _builder.append(_referRelation_32, "\t"); | ||
854 | _builder.newLineIfNotEmpty(); | ||
855 | _builder.append("\t"); | ||
856 | CharSequence _referRelation_33 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "T", "Straight", Modality.MUST, fqnToPQuery); | ||
857 | _builder.append(_referRelation_33, "\t"); | ||
858 | _builder.newLineIfNotEmpty(); | ||
859 | _builder.append("\t"); | ||
860 | CharSequence _referRelation_34 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "T", "Divergent", Modality.MUST, fqnToPQuery); | ||
861 | _builder.append(_referRelation_34, "\t"); | ||
862 | _builder.newLineIfNotEmpty(); | ||
863 | _builder.append("}"); | ||
864 | _builder.newLine(); | ||
865 | _builder.newLine(); | ||
866 | _builder.append("pattern turnoutConnectedToBothOutputs_must_to_true_by_divergent("); | ||
867 | _builder.append(parameters); | ||
868 | _builder.append(", T : DefinedElement) {"); | ||
869 | _builder.newLineIfNotEmpty(); | ||
870 | _builder.append("\t"); | ||
871 | _builder.append(commonMayParameterConstraints, "\t"); | ||
872 | _builder.newLineIfNotEmpty(); | ||
873 | _builder.append("\t"); | ||
874 | _builder.append("find mustExist(problem, interpretation, Straight);"); | ||
875 | _builder.newLine(); | ||
876 | _builder.append("\t"); | ||
877 | _builder.append("find mustExist(problem, interpretation, Divergent);"); | ||
878 | _builder.newLine(); | ||
879 | _builder.append("\t"); | ||
880 | CharSequence _referInstanceOf_32 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MAY, "source"); | ||
881 | _builder.append(_referInstanceOf_32, "\t"); | ||
882 | _builder.newLineIfNotEmpty(); | ||
883 | _builder.append("\t"); | ||
884 | CharSequence _referInstanceOf_33 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MAY, "target"); | ||
885 | _builder.append(_referInstanceOf_33, "\t"); | ||
886 | _builder.newLineIfNotEmpty(); | ||
887 | _builder.append("\t"); | ||
888 | CharSequence _referInstanceOf_34 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Straight"); | ||
889 | _builder.append(_referInstanceOf_34, "\t"); | ||
890 | _builder.newLineIfNotEmpty(); | ||
891 | _builder.append("\t"); | ||
892 | CharSequence _referInstanceOf_35 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.segmentType, Modality.MUST, "Divergent"); | ||
893 | _builder.append(_referInstanceOf_35, "\t"); | ||
894 | _builder.newLineIfNotEmpty(); | ||
895 | _builder.append("\t"); | ||
896 | CharSequence _referRelation_35 = generator.referRelation(Modes3UnitPropagationGenerator.this.straightRelation, "T", "Straight", Modality.MUST, fqnToPQuery); | ||
897 | _builder.append(_referRelation_35, "\t"); | ||
898 | _builder.newLineIfNotEmpty(); | ||
899 | _builder.append("\t"); | ||
900 | _builder.append("T == source;"); | ||
901 | _builder.newLine(); | ||
902 | _builder.append("\t"); | ||
903 | _builder.append("Divergent == target;"); | ||
904 | _builder.newLine(); | ||
905 | _builder.append("\t"); | ||
906 | CharSequence _referRelation_36 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "T", "Straight", Modality.MUST, fqnToPQuery); | ||
907 | _builder.append(_referRelation_36, "\t"); | ||
908 | _builder.newLineIfNotEmpty(); | ||
909 | _builder.append("\t"); | ||
910 | CharSequence _referRelation_37 = generator.referRelation(Modes3UnitPropagationGenerator.this.connectedToRelation, "T", "Divergent", Modality.MUST, fqnToPQuery); | ||
911 | _builder.append(_referRelation_37, "\t"); | ||
912 | _builder.newLineIfNotEmpty(); | ||
913 | _builder.append("}"); | ||
914 | _builder.newLine(); | ||
915 | _builder.newLine(); | ||
916 | _builder.append("pattern tooManyInputsOfTurnout_must_to_true_by_connectedTo("); | ||
917 | _builder.append(parameters); | ||
918 | _builder.append(", T : DefinedElement) {"); | ||
919 | _builder.newLineIfNotEmpty(); | ||
920 | _builder.append("\t"); | ||
921 | _builder.append("find mustExist(problem, interpretation, S);"); | ||
922 | _builder.newLine(); | ||
923 | _builder.append("\t"); | ||
924 | CharSequence _referInstanceOf_36 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "S"); | ||
925 | _builder.append(_referInstanceOf_36, "\t"); | ||
926 | _builder.newLineIfNotEmpty(); | ||
927 | _builder.append("\t"); | ||
928 | _builder.append("find adjacent_must_to_true_by_connectedTo(problem, interpretation, source, target, I1, S);"); | ||
929 | _builder.newLine(); | ||
930 | _builder.append("\t"); | ||
931 | CharSequence _referPattern_7 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I2", "S" }, Modality.MUST, true, false); | ||
932 | _builder.append(_referPattern_7, "\t"); | ||
933 | _builder.newLineIfNotEmpty(); | ||
934 | _builder.append("\t"); | ||
935 | CharSequence _referPattern_8 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I3", "S" }, Modality.MUST, true, false); | ||
936 | _builder.append(_referPattern_8, "\t"); | ||
937 | _builder.newLineIfNotEmpty(); | ||
938 | _builder.append("\t"); | ||
939 | CharSequence _referPattern_9 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I4", "S" }, Modality.MUST, true, false); | ||
940 | _builder.append(_referPattern_9, "\t"); | ||
941 | _builder.newLineIfNotEmpty(); | ||
942 | _builder.append("\t"); | ||
943 | _builder.append("I1 != I2;"); | ||
944 | _builder.newLine(); | ||
945 | _builder.append("\t"); | ||
946 | _builder.append("I1 != I3;"); | ||
947 | _builder.newLine(); | ||
948 | _builder.append("\t"); | ||
949 | _builder.append("I1 != I4;"); | ||
950 | _builder.newLine(); | ||
951 | _builder.append("\t"); | ||
952 | _builder.append("I2 != I3;"); | ||
953 | _builder.newLine(); | ||
954 | _builder.append("\t"); | ||
955 | _builder.append("I2 != I4;"); | ||
956 | _builder.newLine(); | ||
957 | _builder.append("\t"); | ||
958 | _builder.append("I3 != I4;"); | ||
959 | _builder.newLine(); | ||
960 | _builder.append("}"); | ||
961 | _builder.newLine(); | ||
962 | _builder.newLine(); | ||
963 | _builder.append("pattern tooManyInputsOfTurnout_must_to_true_by_straight("); | ||
964 | _builder.append(parameters); | ||
965 | _builder.append(", T : DefinedElement) {"); | ||
966 | _builder.newLineIfNotEmpty(); | ||
967 | _builder.append("\t"); | ||
968 | _builder.append("find mustExist(problem, interpretation, S);"); | ||
969 | _builder.newLine(); | ||
970 | _builder.append("\t"); | ||
971 | CharSequence _referInstanceOf_37 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "S"); | ||
972 | _builder.append(_referInstanceOf_37, "\t"); | ||
973 | _builder.newLineIfNotEmpty(); | ||
974 | _builder.append("\t"); | ||
975 | _builder.append("find adjacent_must_to_true_by_straight(problem, interpretation, source, target, I1, S);"); | ||
976 | _builder.newLine(); | ||
977 | _builder.append("\t"); | ||
978 | CharSequence _referPattern_10 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I2", "S" }, Modality.MUST, true, false); | ||
979 | _builder.append(_referPattern_10, "\t"); | ||
980 | _builder.newLineIfNotEmpty(); | ||
981 | _builder.append("\t"); | ||
982 | CharSequence _referPattern_11 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I3", "S" }, Modality.MUST, true, false); | ||
983 | _builder.append(_referPattern_11, "\t"); | ||
984 | _builder.newLineIfNotEmpty(); | ||
985 | _builder.append("\t"); | ||
986 | CharSequence _referPattern_12 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I4", "S" }, Modality.MUST, true, false); | ||
987 | _builder.append(_referPattern_12, "\t"); | ||
988 | _builder.newLineIfNotEmpty(); | ||
989 | _builder.append("\t"); | ||
990 | _builder.append("I1 != I2;"); | ||
991 | _builder.newLine(); | ||
992 | _builder.append("\t"); | ||
993 | _builder.append("I1 != I3;"); | ||
994 | _builder.newLine(); | ||
995 | _builder.append("\t"); | ||
996 | _builder.append("I1 != I4;"); | ||
997 | _builder.newLine(); | ||
998 | _builder.append("\t"); | ||
999 | _builder.append("I2 != I3;"); | ||
1000 | _builder.newLine(); | ||
1001 | _builder.append("\t"); | ||
1002 | _builder.append("I2 != I4;"); | ||
1003 | _builder.newLine(); | ||
1004 | _builder.append("\t"); | ||
1005 | _builder.append("I3 != I4;"); | ||
1006 | _builder.newLine(); | ||
1007 | _builder.append("}"); | ||
1008 | _builder.newLine(); | ||
1009 | _builder.newLine(); | ||
1010 | _builder.append("pattern tooManyInputsOfTurnout_must_to_true_by_divergent("); | ||
1011 | _builder.append(parameters); | ||
1012 | _builder.append(", T : DefinedElement) {"); | ||
1013 | _builder.newLineIfNotEmpty(); | ||
1014 | _builder.append("\t"); | ||
1015 | _builder.append("find mustExist(problem, interpretation, S);"); | ||
1016 | _builder.newLine(); | ||
1017 | _builder.append("\t"); | ||
1018 | CharSequence _referInstanceOf_38 = generator.getTypeIndexer().referInstanceOf(Modes3UnitPropagationGenerator.this.turnoutType, Modality.MUST, "S"); | ||
1019 | _builder.append(_referInstanceOf_38, "\t"); | ||
1020 | _builder.newLineIfNotEmpty(); | ||
1021 | _builder.append("\t"); | ||
1022 | _builder.append("find adjacent_must_to_true_by_divergent(problem, interpretation, source, target, I1, S);"); | ||
1023 | _builder.newLine(); | ||
1024 | _builder.append("\t"); | ||
1025 | CharSequence _referPattern_13 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I2", "S" }, Modality.MUST, true, false); | ||
1026 | _builder.append(_referPattern_13, "\t"); | ||
1027 | _builder.newLineIfNotEmpty(); | ||
1028 | _builder.append("\t"); | ||
1029 | CharSequence _referPattern_14 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I3", "S" }, Modality.MUST, true, false); | ||
1030 | _builder.append(_referPattern_14, "\t"); | ||
1031 | _builder.newLineIfNotEmpty(); | ||
1032 | _builder.append("\t"); | ||
1033 | CharSequence _referPattern_15 = generator.getRelationDefinitionIndexer().referPattern(fqnToPQuery.get(Adjacent.instance().getFullyQualifiedName()), new String[] { "I4", "S" }, Modality.MUST, true, false); | ||
1034 | _builder.append(_referPattern_15, "\t"); | ||
1035 | _builder.newLineIfNotEmpty(); | ||
1036 | _builder.append("\t"); | ||
1037 | _builder.append("I1 != I2;"); | ||
1038 | _builder.newLine(); | ||
1039 | _builder.append("\t"); | ||
1040 | _builder.append("I1 != I3;"); | ||
1041 | _builder.newLine(); | ||
1042 | _builder.append("\t"); | ||
1043 | _builder.append("I1 != I4;"); | ||
1044 | _builder.newLine(); | ||
1045 | _builder.append("\t"); | ||
1046 | _builder.append("I2 != I3;"); | ||
1047 | _builder.newLine(); | ||
1048 | _builder.append("\t"); | ||
1049 | _builder.append("I2 != I4;"); | ||
1050 | _builder.newLine(); | ||
1051 | _builder.append("\t"); | ||
1052 | _builder.append("I3 != I4;"); | ||
1053 | _builder.newLine(); | ||
1054 | _builder.append("}"); | ||
1055 | _builder.newLine(); | ||
1056 | _builder.newLine(); | ||
1057 | _builder.append("pattern "); | ||
1058 | _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO); | ||
1059 | _builder.append("_helper("); | ||
1060 | _builder.append(parameters); | ||
1061 | _builder.append(") {"); | ||
1062 | _builder.newLineIfNotEmpty(); | ||
1063 | _builder.append("\t"); | ||
1064 | _builder.append("find connectedToReflexive_must_to_true_by_connectedTo(problem, interpretation, source, target, _);"); | ||
1065 | _builder.newLine(); | ||
1066 | _builder.append("} or {"); | ||
1067 | _builder.newLine(); | ||
1068 | _builder.append("\t"); | ||
1069 | _builder.append("find tooManyInputsOfSegment_must_to_true_by_connectedTo(problem, interpretation, source, target, _);"); | ||
1070 | _builder.newLine(); | ||
1071 | _builder.append("} or {"); | ||
1072 | _builder.newLine(); | ||
1073 | _builder.append("\t"); | ||
1074 | _builder.append("find turnoutConnectedToBothOutputs_must_to_true_by_connectedTo(problem, interpretation, source, target, _);"); | ||
1075 | _builder.newLine(); | ||
1076 | _builder.append("} or {"); | ||
1077 | _builder.newLine(); | ||
1078 | _builder.append("\t"); | ||
1079 | _builder.append("find tooManyInputsOfTurnout_must_to_true_by_connectedTo(problem, interpretation, source, target, _);"); | ||
1080 | _builder.newLine(); | ||
1081 | _builder.append("}"); | ||
1082 | _builder.newLine(); | ||
1083 | _builder.newLine(); | ||
1084 | _builder.append("pattern "); | ||
1085 | _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO); | ||
1086 | _builder.append("("); | ||
1087 | _builder.append(parameters); | ||
1088 | _builder.append(") {"); | ||
1089 | _builder.newLineIfNotEmpty(); | ||
1090 | _builder.append("\t"); | ||
1091 | _builder.append("find "); | ||
1092 | _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO, "\t"); | ||
1093 | _builder.append("_helper(problem, interpretation, source, target);"); | ||
1094 | _builder.newLineIfNotEmpty(); | ||
1095 | _builder.append("} or {"); | ||
1096 | _builder.newLine(); | ||
1097 | _builder.append("\t"); | ||
1098 | _builder.append("find "); | ||
1099 | _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_CONNECTED_TO, "\t"); | ||
1100 | _builder.append("_helper(problem, interpretation, target, source);"); | ||
1101 | _builder.newLineIfNotEmpty(); | ||
1102 | _builder.append("}"); | ||
1103 | _builder.newLine(); | ||
1104 | _builder.newLine(); | ||
1105 | _builder.append("pattern "); | ||
1106 | _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_STRAIGHT); | ||
1107 | _builder.append("("); | ||
1108 | _builder.append(parameters); | ||
1109 | _builder.append(") {"); | ||
1110 | _builder.newLineIfNotEmpty(); | ||
1111 | _builder.append("\t"); | ||
1112 | _builder.append("find outputReflexive_must_to_true_by_straight(problem, interpretation, source, target, _);"); | ||
1113 | _builder.newLine(); | ||
1114 | _builder.append("} or {"); | ||
1115 | _builder.newLine(); | ||
1116 | _builder.append("\t"); | ||
1117 | _builder.append("find turnoutOutputsAreSame_must_to_true_by_straight(problem, interpretation, source, target, _);"); | ||
1118 | _builder.newLine(); | ||
1119 | _builder.append("} or {"); | ||
1120 | _builder.newLine(); | ||
1121 | _builder.append("\t"); | ||
1122 | _builder.append("find tooManyInputsOfSegment_must_to_true_by_straight(problem, interpretation, source, target, _);"); | ||
1123 | _builder.newLine(); | ||
1124 | _builder.append("} or {"); | ||
1125 | _builder.newLine(); | ||
1126 | _builder.append("\t"); | ||
1127 | _builder.append("find turnoutConnectedToBothOutputs_must_to_true_by_straight(problem, interpretation, source, target, _);"); | ||
1128 | _builder.newLine(); | ||
1129 | _builder.append("} or {"); | ||
1130 | _builder.newLine(); | ||
1131 | _builder.append("\t"); | ||
1132 | _builder.append("find tooManyInputsOfTurnout_must_to_true_by_straight(problem, interpretation, source, target, _);"); | ||
1133 | _builder.newLine(); | ||
1134 | _builder.append("}"); | ||
1135 | _builder.newLine(); | ||
1136 | _builder.newLine(); | ||
1137 | _builder.append("pattern "); | ||
1138 | _builder.append(Modes3UnitPropagationGenerator.MUST_NOT_DIVERGENT); | ||
1139 | _builder.append("("); | ||
1140 | _builder.append(parameters); | ||
1141 | _builder.append(") {"); | ||
1142 | _builder.newLineIfNotEmpty(); | ||
1143 | _builder.append("\t"); | ||
1144 | _builder.append("find outputReflexive_must_to_true_by_divergent(problem, interpretation, source, target, _);"); | ||
1145 | _builder.newLine(); | ||
1146 | _builder.append("} or {"); | ||
1147 | _builder.newLine(); | ||
1148 | _builder.append("\t"); | ||
1149 | _builder.append("find turnoutOutputsAreSame_must_to_true_by_divergent(problem, interpretation, source, target, _);"); | ||
1150 | _builder.newLine(); | ||
1151 | _builder.append("} or {"); | ||
1152 | _builder.newLine(); | ||
1153 | _builder.append("\t"); | ||
1154 | _builder.append("find tooManyInputsOfSegment_must_to_true_by_divergent(problem, interpretation, source, target, _);"); | ||
1155 | _builder.newLine(); | ||
1156 | _builder.append("} or {"); | ||
1157 | _builder.newLine(); | ||
1158 | _builder.append("\t"); | ||
1159 | _builder.append("find turnoutConnectedToBothOutputs_must_to_true_by_divergent(problem, interpretation, source, target, _);"); | ||
1160 | _builder.newLine(); | ||
1161 | _builder.append("} or {"); | ||
1162 | _builder.newLine(); | ||
1163 | _builder.append("\t"); | ||
1164 | _builder.append("find tooManyInputsOfTurnout_must_to_true_by_divergent(problem, interpretation, source, target, _);"); | ||
1165 | _builder.newLine(); | ||
1166 | _builder.append("}"); | ||
1167 | _builder.newLine(); | ||
1168 | } | ||
1169 | }; | ||
1170 | _xblockexpression = _client_3; | ||
1171 | } | ||
1172 | return _xblockexpression; | ||
1173 | } | ||
1174 | } | ||
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 @@ | |||
1 | package modes3.run; | ||
2 | |||
3 | import com.google.common.collect.ImmutableList; | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic; | ||
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace; | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Dimension; | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilder; | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilderFactory; | ||
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator; | ||
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatch; | ||
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostElementMatchers; | ||
13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint; | ||
14 | import java.util.Collection; | ||
15 | import java.util.List; | ||
16 | import java.util.Map; | ||
17 | import java.util.Set; | ||
18 | import modes3.Modes3Package; | ||
19 | import modes3.queries.TrainLocations_step_2; | ||
20 | import modes3.queries.TrainLocations_step_3; | ||
21 | import org.eclipse.xtext.xbase.lib.Extension; | ||
22 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
23 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
24 | |||
25 | @SuppressWarnings("all") | ||
26 | public class TrainLocationsObjectiveHint extends CostObjectiveHint { | ||
27 | private final Type segmentType; | ||
28 | |||
29 | private final Type trainType; | ||
30 | |||
31 | public TrainLocationsObjectiveHint(@Extension final Ecore2Logic ecore2Logic, final Ecore2Logic_Trace ecore2LogicTrace) { | ||
32 | @Extension | ||
33 | final Modes3Package Modes3Package = modes3.Modes3Package.eINSTANCE; | ||
34 | this.segmentType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getSegment()); | ||
35 | this.trainType = ecore2Logic.TypeofEClass(ecore2LogicTrace, Modes3Package.getTrain()); | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | public boolean isExact() { | ||
40 | return true; | ||
41 | } | ||
42 | |||
43 | @Override | ||
44 | public PolyhedronExtensionOperator createPolyhedronExtensionOperator(final Map<String, CostElementMatchers> costElementMatchers) { | ||
45 | PolyhedronExtensionOperator _xblockexpression = null; | ||
46 | { | ||
47 | final CostElementMatchers step2 = costElementMatchers.get(TrainLocations_step_2.instance().getFullyQualifiedName()); | ||
48 | final CostElementMatchers step3 = costElementMatchers.get(TrainLocations_step_3.instance().getFullyQualifiedName()); | ||
49 | final PolyhedronExtensionOperator _function = (ExtendedLinearExpressionBuilderFactory it) -> { | ||
50 | final ExtendedLinearExpressionBuilder objectiveBuilder = it.createBuilder(); | ||
51 | ImmutableList<CostElementMatch> _matches = step2.getMatches(); | ||
52 | for (final CostElementMatch m : _matches) { | ||
53 | { | ||
54 | final Dimension dimension = it.getDimension(m.getMatch()); | ||
55 | objectiveBuilder.add(step2.getWeight(), dimension); | ||
56 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
57 | boolean _isMulti = m.isMulti(); | ||
58 | if (_isMulti) { | ||
59 | it.createBuilder().add(1, dimension).add((-1), this.trainType).build().assertEqualsTo(0); | ||
60 | } else { | ||
61 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
62 | boolean _isMust = m.isMust(); | ||
63 | if (_isMust) { | ||
64 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | final ImmutableList<CostElementMatch> step3Matches = step3.getMatches(); | ||
70 | for (final CostElementMatch m_1 : step3Matches) { | ||
71 | { | ||
72 | final Dimension dimension = it.getDimension(m_1.getMatch()); | ||
73 | objectiveBuilder.add(step3.getWeight(), dimension); | ||
74 | dimension.tightenLowerBound(Integer.valueOf(0)); | ||
75 | boolean _isMulti = m_1.isMulti(); | ||
76 | boolean _not = (!_isMulti); | ||
77 | if (_not) { | ||
78 | dimension.tightenUpperBound(Integer.valueOf(1)); | ||
79 | boolean _isMust = m_1.isMust(); | ||
80 | if (_isMust) { | ||
81 | dimension.tightenLowerBound(Integer.valueOf(1)); | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | TrainLocationsObjectiveHint.boundLimit(it, step3Matches, 2, this.trainType, 1); | ||
87 | TrainLocationsObjectiveHint.boundLimit(it, step3Matches, 3, this.segmentType, 1); | ||
88 | this.buildWithBounds(objectiveBuilder); | ||
89 | }; | ||
90 | _xblockexpression = _function; | ||
91 | } | ||
92 | return _xblockexpression; | ||
93 | } | ||
94 | |||
95 | private static void boundLimit(@Extension final ExtendedLinearExpressionBuilderFactory factory, final Collection<CostElementMatch> matches, final int index, final Type type, final int count) { | ||
96 | final Function1<CostElementMatch, Object> _function = (CostElementMatch it) -> { | ||
97 | return it.getMatch().get(index); | ||
98 | }; | ||
99 | Set<Map.Entry<Object, List<CostElementMatch>>> _entrySet = IterableExtensions.<Object, CostElementMatch>groupBy(matches, _function).entrySet(); | ||
100 | for (final Map.Entry<Object, List<CostElementMatch>> pair : _entrySet) { | ||
101 | { | ||
102 | final ExtendedLinearExpressionBuilder multiplicityBuilder = factory.createBuilder(); | ||
103 | List<CostElementMatch> _value = pair.getValue(); | ||
104 | for (final CostElementMatch m : _value) { | ||
105 | multiplicityBuilder.add(1, m.getMatch()); | ||
106 | } | ||
107 | boolean _isMulti = CostElementMatchers.isMulti(pair.getKey()); | ||
108 | if (_isMulti) { | ||
109 | multiplicityBuilder.add((-count), type); | ||
110 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(0)); | ||
111 | } else { | ||
112 | multiplicityBuilder.build().tightenUpperBound(Integer.valueOf(count)); | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | } | ||
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/META-INF/MANIFEST.MF b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/META-INF/MANIFEST.MF index 5fb85170..cc71bd06 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/META-INF/MANIFEST.MF +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/META-INF/MANIFEST.MF | |||
@@ -15,7 +15,6 @@ Require-Bundle: org.eclipse.viatra.addon.querybasedfeatures.runtime, | |||
15 | org.eclipse.viatra.query.runtime, | 15 | org.eclipse.viatra.query.runtime, |
16 | org.eclipse.core.runtime, | 16 | org.eclipse.core.runtime, |
17 | org.eclipse.emf.ecore;visibility:=reexport, | 17 | org.eclipse.emf.ecore;visibility:=reexport, |
18 | org.eclipse.emf.emfstore.common, | ||
19 | com.google.guava, | 18 | com.google.guava, |
20 | org.eclipse.xtext.xbase.lib, | 19 | org.eclipse.xtext.xbase.lib, |
21 | org.eclipse.xtend.lib, | 20 | org.eclipse.xtend.lib, |
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml index 331e2b61..d4ab204e 100644 --- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml | |||
@@ -39,72 +39,4 @@ | |||
39 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.twoSynch"/> | 39 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.twoSynch"/> |
40 | </group> | 40 | </group> |
41 | </extension> | 41 | </extension> |
42 | <extension id="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.Mutated" point="org.eclipse.viatra.query.runtime.queryspecification"> | ||
43 | <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.Mutated" id="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.Mutated"> | ||
44 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.entryInRegion_M0"/> | ||
45 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.entryInRegion_M1"/> | ||
46 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.entryInRegion_M2"/> | ||
47 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M0"/> | ||
48 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M1"/> | ||
49 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M2"/> | ||
50 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M3"/> | ||
51 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M4"/> | ||
52 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noEntryInRegion_M5"/> | ||
53 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M0"/> | ||
54 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M1"/> | ||
55 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M2"/> | ||
56 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M3"/> | ||
57 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M4"/> | ||
58 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleEntryInRegion_M5"/> | ||
59 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M0"/> | ||
60 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M1"/> | ||
61 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M2"/> | ||
62 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M3"/> | ||
63 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.transition_M4"/> | ||
64 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_M0"/> | ||
65 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_1"/> | ||
66 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_2"/> | ||
67 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_3"/> | ||
68 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_4"/> | ||
69 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.incomingToEntry_5"/> | ||
70 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M0"/> | ||
71 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M1"/> | ||
72 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M2"/> | ||
73 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M3"/> | ||
74 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M4"/> | ||
75 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noOutgoingTransitionFromEntry_M5"/> | ||
76 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M0"/> | ||
77 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M1"/> | ||
78 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M2"/> | ||
79 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M3"/> | ||
80 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.multipleTransitionFromEntry_M4"/> | ||
81 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromExit_M0"/> | ||
82 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromExit_M1"/> | ||
83 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromExit_M2"/> | ||
84 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromFinal_M0"/> | ||
85 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromFinal_M1"/> | ||
86 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.outgoingFromFinal_M2"/> | ||
87 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M0"/> | ||
88 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M1"/> | ||
89 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M2"/> | ||
90 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.noStateInRegion_M3"/> | ||
91 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.StateInRegion_M0"/> | ||
92 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.StateInRegion_M1"/> | ||
93 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.StateInRegion_M2"/> | ||
94 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M0"/> | ||
95 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M1"/> | ||
96 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M2"/> | ||
97 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M3"/> | ||
98 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M4"/> | ||
99 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M5"/> | ||
100 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoOutgoing_M6"/> | ||
101 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M0"/> | ||
102 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M1"/> | ||
103 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M2"/> | ||
104 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M3"/> | ||
105 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M4"/> | ||
106 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M5"/> | ||
107 | <query-specification fqn="hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.choiceHasNoIncoming_M6"/> | ||
108 | </group> | ||
109 | </extension> | ||
110 | </plugin> | 42 | </plugin> |
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/.classpath b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/.classpath index 849e2a7b..2a747353 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/.classpath +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/.classpath | |||
@@ -1,14 +1,13 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <classpath> | 2 | <classpath> |
3 | <classpathentry kind="src" path="ecore-gen"/> | 3 | <classpathentry kind="src" path="ecore-gen"/> |
4 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | 4 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> |
5 | <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
6 | <classpathentry kind="src" path="src"/> | ||
7 | <classpathentry kind="src" path="xtend-gen"/> | ||
8 | <classpathentry kind="lib" path="lib/com.microsoft.z3.jar"> | ||
9 | <attributes> | 5 | <attributes> |
10 | <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="hu.bme.mit.inf.dslreasoner.viatra2logic/lib"/> | 6 | <attribute name="module" value="true"/> |
11 | </attributes> | 7 | </attributes> |
12 | </classpathentry> | 8 | </classpathentry> |
9 | <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
10 | <classpathentry kind="src" path="src"/> | ||
11 | <classpathentry kind="src" path="xtend-gen"/> | ||
13 | <classpathentry kind="output" path="bin"/> | 12 | <classpathentry kind="output" path="bin"/> |
14 | </classpath> | 13 | </classpath> |
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/META-INF/MANIFEST.MF b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/META-INF/MANIFEST.MF index c7242106..23fba304 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/META-INF/MANIFEST.MF +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/META-INF/MANIFEST.MF | |||
@@ -20,11 +20,11 @@ Require-Bundle: com.google.guava, | |||
20 | org.eclipse.viatra.query.patternlanguage.emf;bundle-version="2.0.0", | 20 | org.eclipse.viatra.query.patternlanguage.emf;bundle-version="2.0.0", |
21 | org.eclipse.xtext, | 21 | org.eclipse.xtext, |
22 | org.eclipse.xtext.xbase;bundle-version="2.18.0", | 22 | org.eclipse.xtext.xbase;bundle-version="2.18.0", |
23 | hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage;bundle-version="1.0.0" | 23 | hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage;bundle-version="1.0.0", |
24 | com.microsoft.z3 | ||
24 | Bundle-ActivationPolicy: lazy | 25 | Bundle-ActivationPolicy: lazy |
25 | Export-Package: hu.bme.mit.inf.dslreasoner.viatra2logic, | 26 | Export-Package: |
27 | hu.bme.mit.inf.dslreasoner.viatra2logic, | ||
26 | hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations, | 28 | hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations, |
27 | hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.impl, | 29 | hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.impl, |
28 | hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.util | 30 | hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.util |
29 | Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.viatra2logic | ||
30 | |||
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/lib/.gitignore b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/lib/.gitignore deleted file mode 100644 index e69de29b..00000000 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/lib/.gitignore +++ /dev/null | |||
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Constraint2Logic.xtend b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Constraint2Logic.xtend index b8c52af4..37fb81ae 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Constraint2Logic.xtend +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Constraint2Logic.xtend | |||
@@ -1,5 +1,4 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatra2logic | 1 | package hu.bme.mit.inf.dslreasoner.viatra2logic |
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | 2 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic |
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | 3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder | 4 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder |
@@ -17,27 +16,27 @@ import org.eclipse.emf.ecore.EStructuralFeature | |||
17 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey | 16 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey |
18 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey | 17 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey |
19 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey | 18 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey |
19 | import org.eclipse.viatra.query.runtime.matchers.aggregators.DoubleSumOperator | ||
20 | import org.eclipse.viatra.query.runtime.matchers.aggregators.ExtremumOperator | ||
21 | import org.eclipse.viatra.query.runtime.matchers.aggregators.ExtremumOperator.Extreme | ||
22 | import org.eclipse.viatra.query.runtime.matchers.aggregators.IntegerSumOperator | ||
23 | import org.eclipse.viatra.query.runtime.matchers.aggregators.LongSumOperator | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint | 24 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint |
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable | 25 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable |
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint | ||
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality | 27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality |
23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter | 28 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter |
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation | ||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality | 30 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality |
25 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall | 31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall |
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint | ||
26 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure | 34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure |
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue | 35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue |
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall | 36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall |
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint | 37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint |
30 | 38 | ||
31 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 39 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint | ||
34 | import org.eclipse.viatra.query.runtime.matchers.aggregators.DoubleSumOperator | ||
35 | import org.eclipse.viatra.query.runtime.matchers.aggregators.IntegerSumOperator | ||
36 | import org.eclipse.viatra.query.runtime.matchers.aggregators.LongSumOperator | ||
37 | import org.eclipse.viatra.query.runtime.matchers.aggregators.ExtremumOperator | ||
38 | import org.eclipse.viatra.query.runtime.matchers.aggregators.ExtremumOperator.Extreme | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation | ||
41 | 40 | ||
42 | class Constraint2Logic { | 41 | class Constraint2Logic { |
43 | val extension LogicProblemBuilder builder = new LogicProblemBuilder | 42 | val extension LogicProblemBuilder builder = new LogicProblemBuilder |
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/ExpressionEvaluation2Logic.xtend b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/ExpressionEvaluation2Logic.xtend index b4303739..6393121b 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/ExpressionEvaluation2Logic.xtend +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/ExpressionEvaluation2Logic.xtend | |||
@@ -12,11 +12,15 @@ import org.eclipse.xtext.xbase.XMemberFeatureCall | |||
12 | import org.eclipse.xtext.xbase.XNumberLiteral | 12 | import org.eclipse.xtext.xbase.XNumberLiteral |
13 | import org.eclipse.xtext.xbase.XUnaryOperation | 13 | import org.eclipse.xtext.xbase.XUnaryOperation |
14 | 14 | ||
15 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | ||
16 | |||
17 | class ExpressionEvaluation2Logic { | 15 | class ExpressionEvaluation2Logic { |
18 | val extension LogicProblemBuilder builder = new LogicProblemBuilder | 16 | val extension LogicProblemBuilder builder = new LogicProblemBuilder |
19 | val NumericProblemSolver numericSolver = new NumericProblemSolver | 17 | var NumericProblemSolver _numericSolver = null //new NumericProblemSolver |
18 | def getNumericSolver() { | ||
19 | if(_numericSolver === null) { | ||
20 | _numericSolver = new NumericProblemSolver | ||
21 | } | ||
22 | return _numericSolver | ||
23 | } | ||
20 | 24 | ||
21 | def Term transformCheck(XExpression expression, Map<PVariable, Variable> variable2Variable) { | 25 | def Term transformCheck(XExpression expression, Map<PVariable, Variable> variable2Variable) { |
22 | return expression.transform(variable2Variable) | 26 | return expression.transform(variable2Variable) |
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericProblemSolver.java b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericProblemSolver.java index 0b249962..f1314925 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericProblemSolver.java +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericProblemSolver.java | |||
@@ -1,17 +1,10 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatra2logic; | 1 | package hu.bme.mit.inf.dslreasoner.viatra2logic; |
2 | 2 | ||
3 | import java.math.BigDecimal; | ||
4 | import java.util.ArrayList; | 3 | import java.util.ArrayList; |
5 | import java.util.HashMap; | 4 | import java.util.HashMap; |
6 | import java.util.HashSet; | ||
7 | import java.util.List; | 5 | import java.util.List; |
8 | import java.util.Map; | 6 | import java.util.Map; |
9 | import java.util.Map.Entry; | ||
10 | import java.util.Random; | ||
11 | import java.util.Set; | ||
12 | 7 | ||
13 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint; | ||
14 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
15 | import org.eclipse.xtext.common.types.JvmIdentifiableElement; | 8 | import org.eclipse.xtext.common.types.JvmIdentifiableElement; |
16 | import org.eclipse.xtext.xbase.XBinaryOperation; | 9 | import org.eclipse.xtext.xbase.XBinaryOperation; |
17 | import org.eclipse.xtext.xbase.XExpression; | 10 | import org.eclipse.xtext.xbase.XExpression; |
@@ -29,10 +22,9 @@ import com.microsoft.z3.Solver; | |||
29 | import com.microsoft.z3.Status; | 22 | import com.microsoft.z3.Status; |
30 | import com.microsoft.z3.enumerations.Z3_ast_print_mode; | 23 | import com.microsoft.z3.enumerations.Z3_ast_print_mode; |
31 | 24 | ||
32 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Term; | ||
33 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.IntegerElement; | 25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.IntegerElement; |
34 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.RealElement; | ||
35 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PrimitiveElement; | 26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PrimitiveElement; |
27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.RealElement; | ||
36 | 28 | ||
37 | 29 | ||
38 | public class NumericProblemSolver { | 30 | public class NumericProblemSolver { |
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericTranslator.xtend b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericTranslator.xtend index 81bc1796..b9eda7b3 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericTranslator.xtend +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/NumericTranslator.xtend | |||
@@ -1,19 +1,17 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatra2logic | 1 | package hu.bme.mit.inf.dslreasoner.viatra2logic |
2 | 2 | ||
3 | import org.eclipse.xtext.xbase.XExpression | ||
4 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation | ||
5 | import org.eclipse.xtext.common.types.JvmIdentifiableElement | ||
6 | import java.util.Set | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PrimitiveElement | 3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PrimitiveElement |
8 | import java.util.Map | ||
9 | import com.microsoft.z3.BoolExpr | ||
10 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint | ||
11 | import java.util.Map.Entry | ||
12 | import org.eclipse.xtext.xbase.XFeatureCall | ||
13 | import java.util.Comparator | ||
14 | import java.util.ArrayList | 4 | import java.util.ArrayList |
5 | import java.util.Comparator | ||
15 | import java.util.HashMap | 6 | import java.util.HashMap |
16 | import java.util.List | 7 | import java.util.List |
8 | import java.util.Map | ||
9 | import java.util.Map.Entry | ||
10 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint | ||
11 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation | ||
12 | import org.eclipse.xtext.common.types.JvmIdentifiableElement | ||
13 | import org.eclipse.xtext.xbase.XExpression | ||
14 | import org.eclipse.xtext.xbase.XFeatureCall | ||
17 | 15 | ||
18 | class NumericTranslator { | 16 | class NumericTranslator { |
19 | 17 | ||
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Viatra2Logic.xtend b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Viatra2Logic.xtend index 74e03f71..2f7febd0 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Viatra2Logic.xtend +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Viatra2Logic.xtend | |||
@@ -1,5 +1,6 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatra2logic | 1 | package hu.bme.mit.inf.dslreasoner.viatra2logic |
2 | 2 | ||
3 | import com.google.inject.Injector | ||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | 4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic |
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | 5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder |
@@ -50,7 +51,7 @@ class Viatra2LogicConfiguration { | |||
50 | public var normalize = true | 51 | public var normalize = true |
51 | } | 52 | } |
52 | 53 | ||
53 | class Viatra2Logic { | 54 | class Viatra2Logic { |
54 | val extension LogicProblemBuilder builder = new LogicProblemBuilder | 55 | val extension LogicProblemBuilder builder = new LogicProblemBuilder |
55 | val extension Viatra2LogicAnnotationsFactory factory = Viatra2LogicAnnotationsFactory.eINSTANCE | 56 | val extension Viatra2LogicAnnotationsFactory factory = Viatra2LogicAnnotationsFactory.eINSTANCE |
56 | val normalizer = new PBodyNormalizer(EMFQueryMetaContext.DEFAULT) | 57 | val normalizer = new PBodyNormalizer(EMFQueryMetaContext.DEFAULT) |
@@ -59,12 +60,16 @@ class Viatra2Logic { | |||
59 | val Ecore2Logic ecore2Logic | 60 | val Ecore2Logic ecore2Logic |
60 | Constraint2Logic constraint2Logic | 61 | Constraint2Logic constraint2Logic |
61 | 62 | ||
62 | new(Ecore2Logic ecore2Logic) { | 63 | new(Ecore2Logic ecore2Logic, Injector injector) { |
63 | this.ecore2Logic = ecore2Logic | 64 | this.ecore2Logic = ecore2Logic |
64 | this.typeInferer = new Viatra2LogicTypeInferer(ecore2Logic) | 65 | this.typeInferer = new Viatra2LogicTypeInferer(ecore2Logic, injector) |
65 | this.constraint2Logic = new Constraint2Logic(ecore2Logic) | 66 | this.constraint2Logic = new Constraint2Logic(ecore2Logic) |
66 | } | 67 | } |
67 | 68 | ||
69 | new(Ecore2Logic ecore2Logic) { | ||
70 | this(ecore2Logic, null) | ||
71 | } | ||
72 | |||
68 | def TracedOutput<LogicProblem,Viatra2LogicTrace> transformQueries( | 73 | def TracedOutput<LogicProblem,Viatra2LogicTrace> transformQueries( |
69 | ViatraQuerySetDescriptor queries, | 74 | ViatraQuerySetDescriptor queries, |
70 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, | 75 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, |
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Viatra2LogicTypeInferer.xtend b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Viatra2LogicTypeInferer.xtend index b8a6b9c1..1a96bf07 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Viatra2LogicTypeInferer.xtend +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Viatra2LogicTypeInferer.xtend | |||
@@ -1,5 +1,6 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatra2logic | 1 | package hu.bme.mit.inf.dslreasoner.viatra2logic |
2 | 2 | ||
3 | import com.google.inject.Injector | ||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | 4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic |
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | 5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicProblemBuilder |
@@ -18,7 +19,6 @@ import java.util.Set | |||
18 | import org.eclipse.emf.ecore.EEnum | 19 | import org.eclipse.emf.ecore.EEnum |
19 | import org.eclipse.emf.ecore.EcorePackage | 20 | import org.eclipse.emf.ecore.EcorePackage |
20 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup | 21 | import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup |
21 | import org.eclipse.viatra.query.patternlanguage.emf.specification.XBaseEvaluator | ||
22 | import org.eclipse.viatra.query.runtime.emf.EMFQueryMetaContext | 22 | import org.eclipse.viatra.query.runtime.emf.EMFQueryMetaContext |
23 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey | 23 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey |
24 | import org.eclipse.viatra.query.runtime.emf.types.EClassUnscopedTransitiveInstancesKey | 24 | import org.eclipse.viatra.query.runtime.emf.types.EClassUnscopedTransitiveInstancesKey |
@@ -26,7 +26,6 @@ import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey | |||
26 | import org.eclipse.viatra.query.runtime.matchers.context.IInputKey | 26 | import org.eclipse.viatra.query.runtime.matchers.context.IInputKey |
27 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey | 27 | import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey |
28 | import org.eclipse.viatra.query.runtime.matchers.planning.helpers.TypeHelper | 28 | import org.eclipse.viatra.query.runtime.matchers.planning.helpers.TypeHelper |
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody | 29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody |
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable | 30 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable |
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint | 31 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint |
@@ -40,285 +39,275 @@ import org.eclipse.xtext.xbase.typesystem.IBatchTypeResolver | |||
40 | import org.eclipse.xtext.xbase.typesystem.references.UnknownTypeReference | 39 | import org.eclipse.xtext.xbase.typesystem.references.UnknownTypeReference |
41 | 40 | ||
42 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 41 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
43 | import org.eclipse.xtext.xbase.typesystem.references.InnerTypeReference | ||
44 | 42 | ||
45 | class Viatra2LogicTypeInferer{ | 43 | class Viatra2LogicTypeInferer { |
46 | val Ecore2Logic ecore2Logic | 44 | val Ecore2Logic ecore2Logic |
47 | val extension LogicProblemBuilder builder = new LogicProblemBuilder | 45 | val extension LogicProblemBuilder builder = new LogicProblemBuilder |
48 | /**Typeresolver uses the same resolver as EMFPatternLanguageStandaloneSetup.*/ | 46 | /**Typeresolver uses the same resolver as EMFPatternLanguageStandaloneSetup.*/ |
49 | val IBatchTypeResolver typeResolver = | 47 | val IBatchTypeResolver typeResolver |
50 | (new EMFPatternLanguageStandaloneSetup).createInjector.getInstance(IBatchTypeResolver) | ||
51 | val expressionExtractor = new XExpressionExtractor | 48 | val expressionExtractor = new XExpressionExtractor |
52 | 49 | ||
53 | new(Ecore2Logic ecore2Logic) { | 50 | new(Ecore2Logic ecore2Logic, Injector injector) { |
54 | this.ecore2Logic = ecore2Logic | 51 | this.ecore2Logic = ecore2Logic |
52 | val selectedInjector = injector ?: | ||
53 | new EMFPatternLanguageStandaloneSetup().createStandaloneInjectorWithSeparateModules | ||
54 | this.typeResolver = selectedInjector.getInstance(IBatchTypeResolver) | ||
55 | } | ||
56 | |||
57 | new(Ecore2Logic ecore2Logic) { | ||
58 | this(ecore2Logic, null) | ||
55 | } | 59 | } |
56 | 60 | ||
57 | def Viatra2LogicTypeResult inferTypes(List<PQuery> pQueries, TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, Viatra2LogicTrace viatra2LogicTrace) { | 61 | def Viatra2LogicTypeResult inferTypes(List<PQuery> pQueries, |
58 | val Viatra2LogicTypeResult result = new Viatra2LogicTypeResult(new HashMap,new HashMap); | 62 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, Viatra2LogicTrace viatra2LogicTrace) { |
59 | for(query : pQueries) { | 63 | val Viatra2LogicTypeResult result = new Viatra2LogicTypeResult(new HashMap, new HashMap); |
60 | for(body: query.lookup(viatra2LogicTrace.query2Disjunction).bodies) { | 64 | for (query : pQueries) { |
61 | for(variable : body.uniqueVariables) { | 65 | for (body : query.lookup(viatra2LogicTrace.query2Disjunction).bodies) { |
62 | getOrMakeTypeDecision(result,variable,body,ecore2LogicTrace,viatra2LogicTrace,emptySet) | 66 | for (variable : body.uniqueVariables) { |
67 | getOrMakeTypeDecision(result, variable, body, ecore2LogicTrace, viatra2LogicTrace, emptySet) | ||
63 | } | 68 | } |
64 | } | 69 | } |
65 | for(parameter: query.parameters) { | 70 | for (parameter : query.parameters) { |
66 | getOrMakeTypeDecision(result,query,parameter,ecore2LogicTrace,viatra2LogicTrace,emptySet) | 71 | getOrMakeTypeDecision(result, query, parameter, ecore2LogicTrace, viatra2LogicTrace, emptySet) |
67 | } | 72 | } |
68 | } | 73 | } |
69 | return result | 74 | return result |
70 | } | 75 | } |
71 | 76 | ||
72 | private def TypeReference getOrMakeTypeDecision( | 77 | private def TypeReference getOrMakeTypeDecision(Viatra2LogicTypeResult result, PVariable variable, PBody body, |
73 | Viatra2LogicTypeResult result, | 78 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, Viatra2LogicTrace viatra2LogicTrace, |
74 | PVariable variable, PBody body, | 79 | Set<? extends PParameter> checkedInDecisionMaking) { |
75 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, | 80 | if (result.containsSolution(body, variable)) { |
76 | Viatra2LogicTrace viatra2LogicTrace, | 81 | return result.getType(body, variable) |
77 | Set<? extends PParameter> checkedInDecisionMaking) | ||
78 | { | ||
79 | if(result.containsSolution(body,variable)) { | ||
80 | return result.getType(body,variable) | ||
81 | } else { | 82 | } else { |
82 | val inferredTypesByViatra = TypeHelper::inferUnaryTypesFor(body.uniqueVariables, body.constraints, EMFQueryMetaContext.DEFAULT) | 83 | val inferredTypesByViatra = TypeHelper::inferUnaryTypesFor(body.uniqueVariables, body.constraints, |
84 | EMFQueryMetaContext.DEFAULT) | ||
83 | val constraintsForVariable = variable.lookup(inferredTypesByViatra) | 85 | val constraintsForVariable = variable.lookup(inferredTypesByViatra) |
84 | 86 | ||
85 | val typeConstraintsDerivedByTypeHelper = constraintsForVariable.map[transformTypeReference(ecore2LogicTrace)] | 87 | val typeConstraintsDerivedByTypeHelper = constraintsForVariable.map [ |
88 | transformTypeReference(ecore2LogicTrace) | ||
89 | ] | ||
86 | val typesFromEval = variable.getTypesFromEval(typeResolver) | 90 | val typesFromEval = variable.getTypesFromEval(typeResolver) |
87 | val typesFromAggregatorResult = variable.getTypeFromPassivePatternCallConstraintResult( | 91 | val typesFromAggregatorResult = variable. |
88 | result, | 92 | getTypeFromPassivePatternCallConstraintResult(result, ecore2LogicTrace, viatra2LogicTrace, |
89 | ecore2LogicTrace, | ||
90 | viatra2LogicTrace, | ||
91 | checkedInDecisionMaking) | ||
92 | |||
93 | val typesFromPositiveReasoning = (typeConstraintsDerivedByTypeHelper + typesFromEval + typesFromAggregatorResult).filterNull | ||
94 | |||
95 | val types = if(!typesFromPositiveReasoning.empty) { | ||
96 | typesFromPositiveReasoning | ||
97 | } else { | ||
98 | variable.getTypeFromPassivePatternCallConstraints( | ||
99 | result, | ||
100 | ecore2LogicTrace, | ||
101 | viatra2LogicTrace, | ||
102 | checkedInDecisionMaking) | 93 | checkedInDecisionMaking) |
103 | } | 94 | |
104 | 95 | val typesFromPositiveReasoning = (typeConstraintsDerivedByTypeHelper + typesFromEval + | |
96 | typesFromAggregatorResult).filterNull | ||
97 | |||
98 | val types = if (!typesFromPositiveReasoning.empty) { | ||
99 | typesFromPositiveReasoning | ||
100 | } else { | ||
101 | variable.getTypeFromPassivePatternCallConstraints(result, ecore2LogicTrace, viatra2LogicTrace, | ||
102 | checkedInDecisionMaking) | ||
103 | } | ||
104 | |||
105 | val commonSubtype = this.calculateCommonSubtype(types) | 105 | val commonSubtype = this.calculateCommonSubtype(types) |
106 | 106 | ||
107 | result.addType(body,variable,commonSubtype) | 107 | result.addType(body, variable, commonSubtype) |
108 | return commonSubtype | 108 | return commonSubtype |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | private def TypeReference getOrMakeTypeDecision( | 112 | private def TypeReference getOrMakeTypeDecision(Viatra2LogicTypeResult result, PQuery query, PParameter parameter, |
113 | Viatra2LogicTypeResult result, | 113 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, Viatra2LogicTrace viatra2LogicTrace, |
114 | PQuery query, | 114 | Set<? extends PParameter> checkedInDecisionMaking) { |
115 | PParameter parameter, | 115 | if (checkedInDecisionMaking.contains(parameter)) { |
116 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, | ||
117 | Viatra2LogicTrace viatra2LogicTrace, | ||
118 | Set<? extends PParameter> checkedInDecisionMaking) | ||
119 | { | ||
120 | if(checkedInDecisionMaking.contains(parameter)) { | ||
121 | return null | 116 | return null |
122 | } | 117 | } |
123 | if(result.containsSolution(parameter)) { | 118 | if (result.containsSolution(parameter)) { |
124 | return result.getType(query, parameter) | 119 | return result.getType(query, parameter) |
125 | } | 120 | } |
126 | 121 | ||
127 | var TypeReference typeReference; | 122 | var TypeReference typeReference; |
128 | 123 | ||
129 | if(parameter.declaredUnaryType !== null) { | 124 | if (parameter.declaredUnaryType !== null) { |
130 | val key = parameter.declaredUnaryType | 125 | val key = parameter.declaredUnaryType |
131 | typeReference = key.transformTypeReference(ecore2LogicTrace) | 126 | typeReference = key.transformTypeReference(ecore2LogicTrace) |
132 | } else { | 127 | } else { |
133 | val bodies = query.lookup(viatra2LogicTrace.query2Disjunction).bodies | 128 | val bodies = query.lookup(viatra2LogicTrace.query2Disjunction).bodies |
134 | val newChecked = new HashSet(checkedInDecisionMaking) => [add(parameter)] | 129 | val newChecked = new HashSet(checkedInDecisionMaking) => [add(parameter)] |
135 | val Iterable<TypeReference> variableTypes = bodies.map[body| | 130 | val Iterable<TypeReference> variableTypes = bodies.map [ body | |
136 | val symbolicParameter = body.symbolicParameters.filter[patternParameter === parameter].head | 131 | val symbolicParameter = body.symbolicParameters.filter[patternParameter === parameter].head |
137 | val variable = symbolicParameter.parameterVariable | 132 | val variable = symbolicParameter.parameterVariable |
138 | getOrMakeTypeDecision(result,variable,body,ecore2LogicTrace,viatra2LogicTrace,newChecked) | 133 | getOrMakeTypeDecision(result, variable, body, ecore2LogicTrace, viatra2LogicTrace, newChecked) |
139 | ] | 134 | ] |
140 | typeReference = calculateCommonSupertype(variableTypes) | 135 | typeReference = calculateCommonSupertype(variableTypes) |
141 | } | 136 | } |
142 | result.addType(query,parameter,typeReference) | 137 | result.addType(query, parameter, typeReference) |
143 | return typeReference | 138 | return typeReference |
144 | } | 139 | } |
145 | 140 | ||
146 | private def Iterable<? extends TypeReference> getTypesFromEval(PVariable v, IBatchTypeResolver typeResolver) { | 141 | private def Iterable<? extends TypeReference> getTypesFromEval(PVariable v, IBatchTypeResolver typeResolver) { |
147 | val constraints = v.getReferringConstraintsOfType( | 142 | val constraints = v.getReferringConstraintsOfType( |
148 | typeof(ExpressionEvaluation) | 143 | typeof(ExpressionEvaluation) |
149 | ).filter[ | 144 | ).filter [ |
150 | it.outputVariable === v | 145 | it.outputVariable === v |
151 | ] | 146 | ] |
152 | val res = constraints.map[getTypeFromEval] | 147 | val res = constraints.map[getTypeFromEval] |
153 | return res | 148 | return res |
154 | } | 149 | } |
155 | 150 | ||
156 | def TypeReference getTypeFromEval(ExpressionEvaluation evaluation) { | 151 | def TypeReference getTypeFromEval(ExpressionEvaluation evaluation) { |
157 | val XExpression expression = expressionExtractor.extractExpression(evaluation.evaluator) | 152 | val XExpression expression = expressionExtractor.extractExpression(evaluation.evaluator) |
158 | val returnType = typeResolver.resolveTypes(expression).getReturnType(expression); | 153 | val returnType = typeResolver.resolveTypes(expression).getReturnType(expression); |
159 | if(returnType === null || returnType instanceof UnknownTypeReference) { | 154 | if (returnType === null || returnType instanceof UnknownTypeReference) { |
160 | return null | 155 | return null |
161 | } else { | 156 | } else { |
162 | val javaIdentifier = returnType.wrapperTypeIfPrimitive.javaIdentifier | 157 | val javaIdentifier = returnType.wrapperTypeIfPrimitive.javaIdentifier |
163 | if(javaIdentifier == Boolean.name) { | 158 | if (javaIdentifier == Boolean.name) { |
164 | return LogicBool | 159 | return LogicBool |
165 | } else if(javaIdentifier == Integer.name || javaIdentifier == Short.name) { | 160 | } else if (javaIdentifier == Integer.name || javaIdentifier == Short.name) { |
166 | return LogicInt | 161 | return LogicInt |
167 | } else if(javaIdentifier == Double.name || javaIdentifier == Float.name){ | 162 | } else if (javaIdentifier == Double.name || javaIdentifier == Float.name) { |
168 | return LogicReal | 163 | return LogicReal |
169 | } else if(javaIdentifier == String.name) { | 164 | } else if (javaIdentifier == String.name) { |
170 | return LogicString | 165 | return LogicString |
171 | } else { | 166 | } else { |
172 | throw new UnsupportedOperationException('''Unsupported eval type: "«javaIdentifier»"!''') | 167 | throw new UnsupportedOperationException('''Unsupported eval type: "«javaIdentifier»"!''') |
173 | } | 168 | } |
174 | } | 169 | } |
175 | } | 170 | } |
176 | 171 | ||
177 | private def getTypeFromPassivePatternCallConstraintResult( | 172 | private def getTypeFromPassivePatternCallConstraintResult( |
178 | PVariable v, | 173 | PVariable v, |
179 | Viatra2LogicTypeResult result, | 174 | Viatra2LogicTypeResult result, |
180 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, | 175 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, |
181 | Viatra2LogicTrace viatra2LogicTrace, | 176 | Viatra2LogicTrace viatra2LogicTrace, |
182 | Set<? extends PParameter> checkedInDecisionMaking | 177 | Set<? extends PParameter> checkedInDecisionMaking |
183 | ) { | 178 | ) { |
184 | val referringConstraints = v.referringConstraints | 179 | val referringConstraints = v.referringConstraints |
185 | 180 | ||
186 | val referringCountMatcherTargeting = referringConstraints | 181 | val referringCountMatcherTargeting = referringConstraints.filter(PatternMatchCounter).filter [ |
187 | .filter(PatternMatchCounter) | 182 | it.resultVariable === v |
188 | .filter[it.resultVariable === v] | 183 | ].map[builder.LogicInt] |
189 | .map[builder.LogicInt] | 184 | val referringAggregatorConstraintsTargeting = referringConstraints.filter(AggregatorConstraint).filter [ |
190 | val referringAggregatorConstraintsTargeting = referringConstraints | 185 | it.resultVariable === v |
191 | .filter(AggregatorConstraint) | 186 | ].map [ // get the type of the referred column |
192 | .filter[it.resultVariable === v] | 187 | getOrMakeTypeDecision(result, it.referredQuery, it.referredQuery.parameters.get(aggregatedColumn), |
193 | .map[ // get the type of the referred column | 188 | ecore2LogicTrace, viatra2LogicTrace, checkedInDecisionMaking) |
194 | getOrMakeTypeDecision( | 189 | ] |
195 | result, | 190 | |
196 | it.referredQuery, | ||
197 | it.referredQuery.parameters.get(aggregatedColumn), | ||
198 | ecore2LogicTrace, | ||
199 | viatra2LogicTrace, | ||
200 | checkedInDecisionMaking)] | ||
201 | |||
202 | return referringCountMatcherTargeting + referringAggregatorConstraintsTargeting | 191 | return referringCountMatcherTargeting + referringAggregatorConstraintsTargeting |
203 | } | 192 | } |
204 | 193 | ||
205 | private def getTypeFromPassivePatternCallConstraints( | 194 | private def getTypeFromPassivePatternCallConstraints( |
206 | PVariable v, | 195 | PVariable v, |
207 | Viatra2LogicTypeResult result, | 196 | Viatra2LogicTypeResult result, |
208 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, | 197 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, |
209 | Viatra2LogicTrace viatra2LogicTrace, | 198 | Viatra2LogicTrace viatra2LogicTrace, |
210 | Set<? extends PParameter> checkedInDecisionMaking | 199 | Set<? extends PParameter> checkedInDecisionMaking |
211 | ) { | 200 | ) { |
212 | val referringConstraints = v.referringConstraints | 201 | val referringConstraints = v.referringConstraints |
213 | if(referringConstraints.size === 1) { | 202 | if (referringConstraints.size === 1) { |
214 | val onlyConstraint = referringConstraints.head | 203 | val onlyConstraint = referringConstraints.head |
215 | 204 | ||
216 | if(onlyConstraint instanceof PatternCallBasedDeferred) { | 205 | if (onlyConstraint instanceof PatternCallBasedDeferred) { |
217 | val indexOfVariable = v.lookup(onlyConstraint.actualParametersTuple.invertIndex) | 206 | val indexOfVariable = v.lookup(onlyConstraint.actualParametersTuple.invertIndex) |
218 | val parameter = onlyConstraint.referredQuery.parameters.get(indexOfVariable) | 207 | val parameter = onlyConstraint.referredQuery.parameters.get(indexOfVariable) |
219 | val res = getOrMakeTypeDecision(result, onlyConstraint.referredQuery, parameter, ecore2LogicTrace,viatra2LogicTrace,checkedInDecisionMaking) | 208 | val res = getOrMakeTypeDecision(result, onlyConstraint.referredQuery, parameter, ecore2LogicTrace, |
209 | viatra2LogicTrace, checkedInDecisionMaking) | ||
220 | return #[res] | 210 | return #[res] |
221 | } else { | 211 | } else { |
222 | throw new IllegalArgumentException('''A non-PatternCallBasedDeferred type constraint is referring to the variable "«v.name»"!''') | 212 | throw new IllegalArgumentException('''A non-PatternCallBasedDeferred type constraint is referring to the variable "«v.name»"!''') |
223 | } | 213 | } |
224 | } else { | 214 | } else { |
225 | throw new IllegalArgumentException('''Multiple («referringConstraints.size», «FOR c:referringConstraints SEPARATOR ", "»«c»«ENDFOR») constraints are referring to variable "«v.name»", but no type is inferred!''') | 215 | throw new IllegalArgumentException('''Multiple («referringConstraints.size», «FOR c : referringConstraints SEPARATOR ", "»«c»«ENDFOR») constraints are referring to variable "«v.name»", but no type is inferred!''') |
226 | } | 216 | } |
227 | } | 217 | } |
228 | 218 | ||
229 | def TypeReference calculateCommonSubtype(Iterable<TypeReference> types) { | 219 | def TypeReference calculateCommonSubtype(Iterable<TypeReference> types) { |
230 | val primitiveTypeReferences = types.filter(PrimitiveTypeReference) | 220 | val primitiveTypeReferences = types.filter(PrimitiveTypeReference) |
231 | val complexTypeReferences = types.filter(ComplexTypeReference) | 221 | val complexTypeReferences = types.filter(ComplexTypeReference) |
232 | if(complexTypeReferences.isEmpty) { | 222 | if (complexTypeReferences.isEmpty) { |
233 | // If there is an int type, ... | 223 | // If there is an int type, ... |
234 | if(primitiveTypeReferences.exists[it instanceof IntTypeReference]) { | 224 | if (primitiveTypeReferences.exists[it instanceof IntTypeReference]) { |
235 | // ... and all types are either real or int, then return int! | 225 | // ... and all types are either real or int, then return int! |
236 | if(primitiveTypeReferences.forall[it instanceof RealTypeReference || it instanceof IntTypeReference]) { | 226 | if (primitiveTypeReferences.forall[it instanceof RealTypeReference || it instanceof IntTypeReference]) { |
237 | return primitiveTypeReferences.filter(IntTypeReference).head | 227 | return primitiveTypeReferences.filter(IntTypeReference).head |
238 | } | 228 | } // Otherwise, the types are inconsistent, because they mixing numeric and non-numeric types. |
239 | // Otherwise, the types are inconsistent, because they mixing numeric and non-numeric types. | 229 | else |
240 | else throw new IllegalArgumentException('''Inconsistent types: «primitiveTypeReferences.map[eClass.name].toSet.toList»''') | 230 | throw new IllegalArgumentException('''Inconsistent types: «primitiveTypeReferences.map[eClass.name].toSet.toList»''') |
241 | } | 231 | } |
242 | // If there is no Real, then the types should be homogenious | 232 | // If there is no Real, then the types should be homogenious |
243 | val head = primitiveTypeReferences.head | 233 | val head = primitiveTypeReferences.head |
244 | if(primitiveTypeReferences.exists[it.eClass !== head.eClass]) { | 234 | if (primitiveTypeReferences.exists[it.eClass !== head.eClass]) { |
245 | throw new IllegalArgumentException('''Inconsistent types: «primitiveTypeReferences.map[eClass.name].toSet.toList»''') | 235 | throw new IllegalArgumentException('''Inconsistent types: «primitiveTypeReferences.map[eClass.name].toSet.toList»''') |
246 | } | 236 | } |
247 | return head | 237 | return head |
248 | } else if(primitiveTypeReferences.isEmpty) { | 238 | } else if (primitiveTypeReferences.isEmpty) { |
249 | val complexTypes = complexTypeReferences.map[it.referred].toSet | 239 | val complexTypes = complexTypeReferences.map[it.referred].toSet |
250 | if(complexTypes.size === 1) { | 240 | if (complexTypes.size === 1) { |
251 | return builder.toTypeReference(complexTypes.head) | 241 | return builder.toTypeReference(complexTypes.head) |
252 | } | 242 | } |
253 | // Collect possible subtypes | 243 | // Collect possible subtypes |
254 | val subtypeSets = complexTypes.map[it.transitiveClosureStar[it.subtypes].toSet] | 244 | val subtypeSets = complexTypes.map[it.transitiveClosureStar[it.subtypes].toSet] |
255 | val commonTypeSet = new HashSet(subtypeSets.head) | 245 | val commonTypeSet = new HashSet(subtypeSets.head) |
256 | val otherSets = subtypeSets.tail | 246 | val otherSets = subtypeSets.tail |
257 | for(otherSet : otherSets) { | 247 | for (otherSet : otherSets) { |
258 | commonTypeSet.retainAll(otherSet) | 248 | commonTypeSet.retainAll(otherSet) |
259 | } | 249 | } |
260 | if(commonTypeSet.empty) { | 250 | if (commonTypeSet.empty) { |
261 | throw new IllegalArgumentException('''Inconsistent types: «complexTypes.map[name].toList»''') | 251 | throw new IllegalArgumentException('''Inconsistent types: «complexTypes.map[name].toList»''') |
262 | } | 252 | } |
263 | 253 | ||
264 | |||
265 | return calculateCommonComplexSupertype(commonTypeSet) | 254 | return calculateCommonComplexSupertype(commonTypeSet) |
266 | 255 | ||
267 | } else { | 256 | } else { |
268 | throw new IllegalArgumentException(''' | 257 | throw new IllegalArgumentException(''' |
269 | Inconsistent types, mixing primitive and complex types: | 258 | Inconsistent types, mixing primitive and complex types: |
270 | «primitiveTypeReferences.map[eClass.name].toSet.toList» | 259 | «primitiveTypeReferences.map[eClass.name].toSet.toList» |
271 | and | 260 | and |
272 | «complexTypeReferences.map[it.referred].toSet.map[name].toList»''') | 261 | «complexTypeReferences.map[it.referred].toSet.map[name].toList»''') |
273 | 262 | ||
274 | } | 263 | } |
275 | } | 264 | } |
276 | 265 | ||
277 | |||
278 | def TypeReference calculateCommonSupertype(Iterable<TypeReference> types) { | 266 | def TypeReference calculateCommonSupertype(Iterable<TypeReference> types) { |
279 | val primitiveTypeReferences = types.filter(PrimitiveTypeReference) | 267 | val primitiveTypeReferences = types.filter(PrimitiveTypeReference) |
280 | val complexTypeReferences = types.filter(ComplexTypeReference) | 268 | val complexTypeReferences = types.filter(ComplexTypeReference) |
281 | if(complexTypeReferences.isEmpty) { | 269 | if (complexTypeReferences.isEmpty) { |
282 | // If there is a real type, ... | 270 | // If there is a real type, ... |
283 | if(primitiveTypeReferences.exists[it instanceof RealTypeReference]) { | 271 | if (primitiveTypeReferences.exists[it instanceof RealTypeReference]) { |
284 | // ... and all types are either real or int, then return real! | 272 | // ... and all types are either real or int, then return real! |
285 | if(primitiveTypeReferences.forall[it instanceof RealTypeReference || it instanceof IntTypeReference]) { | 273 | if (primitiveTypeReferences.forall[it instanceof RealTypeReference || it instanceof IntTypeReference]) { |
286 | return primitiveTypeReferences.filter(RealTypeReference).head | 274 | return primitiveTypeReferences.filter(RealTypeReference).head |
287 | } | 275 | } // Otherwise, the types are inconsistent, because they mixing numeric and non-numeric types. |
288 | // Otherwise, the types are inconsistent, because they mixing numeric and non-numeric types. | 276 | else |
289 | else throw new IllegalArgumentException('''Inconsistent types: «primitiveTypeReferences.map[eClass.name].toSet.toList»''') | 277 | throw new IllegalArgumentException('''Inconsistent types: «primitiveTypeReferences.map[eClass.name].toSet.toList»''') |
290 | } | 278 | } |
291 | // If there is no Real, then the types should be homogenious | 279 | // If there is no Real, then the types should be homogenious |
292 | val head = primitiveTypeReferences.head | 280 | val head = primitiveTypeReferences.head |
293 | if(primitiveTypeReferences.exists[it.eClass !== head.eClass]) { | 281 | if (primitiveTypeReferences.exists[it.eClass !== head.eClass]) { |
294 | throw new IllegalArgumentException('''Inconsistent types: «primitiveTypeReferences.map[eClass.name].toSet.toList»''') | 282 | throw new IllegalArgumentException('''Inconsistent types: «primitiveTypeReferences.map[eClass.name].toSet.toList»''') |
295 | } | 283 | } |
296 | return head | 284 | return head |
297 | } else if(primitiveTypeReferences.isEmpty) { | 285 | } else if (primitiveTypeReferences.isEmpty) { |
298 | val complexTypes = complexTypeReferences.map[it.referred].toSet | 286 | val complexTypes = complexTypeReferences.map[it.referred].toSet |
299 | return calculateCommonComplexSupertype(complexTypes) | 287 | return calculateCommonComplexSupertype(complexTypes) |
300 | 288 | ||
301 | } else { | 289 | } else { |
302 | throw new IllegalArgumentException(''' | 290 | throw new IllegalArgumentException(''' |
303 | Inconsistent types, mixing primitive and complex types: | 291 | Inconsistent types, mixing primitive and complex types: |
304 | «primitiveTypeReferences.map[eClass.name].toSet.toList» | 292 | «primitiveTypeReferences.map[eClass.name].toSet.toList» |
305 | and | 293 | and |
306 | «complexTypeReferences.map[it.referred].toSet.map[name].toList»''') | 294 | «complexTypeReferences.map[it.referred].toSet.map[name].toList»''') |
307 | 295 | ||
308 | } | 296 | } |
309 | } | 297 | } |
298 | |||
310 | def TypeReference calculateCommonComplexSupertype(Set<Type> complexTypes) { | 299 | def TypeReference calculateCommonComplexSupertype(Set<Type> complexTypes) { |
311 | if(complexTypes.size === 1) { | 300 | if (complexTypes.size === 1) { |
312 | return builder.toTypeReference(complexTypes.head) | 301 | return builder.toTypeReference(complexTypes.head) |
313 | } | 302 | } |
314 | // Collect possible supertypes | 303 | // Collect possible supertypes |
315 | val supertypeSets = complexTypes.map[it.transitiveClosureStar[it.supertypes].toSet] | 304 | val supertypeSets = complexTypes.map[it.transitiveClosureStar[it.supertypes].toSet] |
316 | val commonTypeSet = new HashSet(supertypeSets.head) | 305 | val commonTypeSet = new HashSet(supertypeSets.head) |
317 | val otherSets = supertypeSets.tail | 306 | val otherSets = supertypeSets.tail |
318 | for(otherSet : otherSets) { | 307 | for (otherSet : otherSets) { |
319 | commonTypeSet.retainAll(otherSet) | 308 | commonTypeSet.retainAll(otherSet) |
320 | } | 309 | } |
321 | if(commonTypeSet.empty) { | 310 | if (commonTypeSet.empty) { |
322 | throw new IllegalArgumentException('''Inconsistent types: «complexTypes.map[name].toList»''') | 311 | throw new IllegalArgumentException('''Inconsistent types: «complexTypes.map[name].toList»''') |
323 | } | 312 | } |
324 | // Remove type that already have covered | 313 | // Remove type that already have covered |
@@ -326,40 +315,44 @@ class Viatra2LogicTypeInferer{ | |||
326 | commonTypeSet.removeAll(coveredTypes) | 315 | commonTypeSet.removeAll(coveredTypes) |
327 | return builder.toTypeReference(commonTypeSet.head) | 316 | return builder.toTypeReference(commonTypeSet.head) |
328 | } | 317 | } |
329 | 318 | ||
330 | /** | 319 | /** |
331 | * Transforms a Viatra type reference to a logic type. | 320 | * Transforms a Viatra type reference to a logic type. |
332 | */ | 321 | */ |
333 | def dispatch TypeReference transformTypeReference(EDataTypeInSlotsKey k,TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace) { | 322 | def dispatch TypeReference transformTypeReference(EDataTypeInSlotsKey k, |
334 | val w = k.wrappedKey | 323 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace) { |
335 | if(w == EcorePackage.Literals.EINT || w == EcorePackage.Literals.ESHORT || w == EcorePackage.Literals.ELONG) { | 324 | val w = k.wrappedKey |
325 | if (w == EcorePackage.Literals.EINT || w == EcorePackage.Literals.ESHORT || w == EcorePackage.Literals.ELONG) { | ||
336 | return builder.LogicInt | 326 | return builder.LogicInt |
337 | } else if(w == EcorePackage.Literals.EDOUBLE || w == EcorePackage.Literals.EFLOAT) { | 327 | } else if (w == EcorePackage.Literals.EDOUBLE || w == EcorePackage.Literals.EFLOAT) { |
338 | return builder.LogicReal | 328 | return builder.LogicReal |
339 | } else if(w == EcorePackage.Literals.EBOOLEAN) { | 329 | } else if (w == EcorePackage.Literals.EBOOLEAN) { |
340 | return builder.LogicBool | 330 | return builder.LogicBool |
341 | } else if(w == EcorePackage.Literals.ESTRING) { | 331 | } else if (w == EcorePackage.Literals.ESTRING) { |
342 | return builder.LogicString | 332 | return builder.LogicString |
343 | } else if(w instanceof EEnum) { | 333 | } else if (w instanceof EEnum) { |
344 | val c = this.ecore2Logic.TypeofEEnum(ecore2LogicTrace.trace,w) | 334 | val c = this.ecore2Logic.TypeofEEnum(ecore2LogicTrace.trace, w) |
345 | return builder.toTypeReference(c); | 335 | return builder.toTypeReference(c); |
346 | } else throw new UnsupportedOperationException('''Unknown reference type «w.class.name»''') | 336 | } else |
337 | throw new UnsupportedOperationException('''Unknown reference type «w.class.name»''') | ||
347 | } | 338 | } |
348 | def dispatch TypeReference transformTypeReference(JavaTransitiveInstancesKey k,TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace) { | 339 | |
340 | def dispatch TypeReference transformTypeReference(JavaTransitiveInstancesKey k, | ||
341 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace) { | ||
349 | val c = k.wrapperInstanceClass | 342 | val c = k.wrapperInstanceClass |
350 | if(c == Integer || c == Long || c == Short) { | 343 | if (c == Integer || c == Long || c == Short) { |
351 | return LogicInt | 344 | return LogicInt |
352 | } else if(c == Float || c == Double) { | 345 | } else if (c == Float || c == Double) { |
353 | return LogicReal | 346 | return LogicReal |
354 | } else if(c == Boolean) { | 347 | } else if (c == Boolean) { |
355 | return LogicBool | 348 | return LogicBool |
356 | } else if(c == String) { | 349 | } else if (c == String) { |
357 | return LogicString | 350 | return LogicString |
358 | } else if(c.superclass == Enum){ | 351 | } else if (c.superclass == Enum) { |
359 | val enums = ecore2Logic.allEnumsInScope(ecore2LogicTrace.trace) | 352 | val enums = ecore2Logic.allEnumsInScope(ecore2LogicTrace.trace) |
360 | for(enum : enums) { | 353 | for (enum : enums) { |
361 | if(c == enum.instanceClass) { | 354 | if (c == enum.instanceClass) { |
362 | return builder.toTypeReference(ecore2Logic.TypeofEEnum(ecore2LogicTrace.trace,enum)) | 355 | return builder.toTypeReference(ecore2Logic.TypeofEEnum(ecore2LogicTrace.trace, enum)) |
363 | } | 356 | } |
364 | } | 357 | } |
365 | throw new IllegalArgumentException('''Enum type «c.simpleName» is not mapped to logic!''') | 358 | throw new IllegalArgumentException('''Enum type «c.simpleName» is not mapped to logic!''') |
@@ -367,26 +360,31 @@ class Viatra2LogicTypeInferer{ | |||
367 | return null | 360 | return null |
368 | } | 361 | } |
369 | } | 362 | } |
370 | def dispatch TypeReference transformTypeReference(EClassTransitiveInstancesKey k,TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace) { | 363 | |
364 | def dispatch TypeReference transformTypeReference(EClassTransitiveInstancesKey k, | ||
365 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace) { | ||
371 | val c = k.wrappedKey | 366 | val c = k.wrappedKey |
372 | 367 | ||
373 | if(this.ecore2Logic.allClassesInScope(ecore2LogicTrace.trace).toList.contains(c)) { | 368 | if (this.ecore2Logic.allClassesInScope(ecore2LogicTrace.trace).toList.contains(c)) { |
374 | return builder.toTypeReference(this.ecore2Logic.TypeofEClass(ecore2LogicTrace.trace,k.wrappedKey)) | 369 | return builder.toTypeReference(this.ecore2Logic.TypeofEClass(ecore2LogicTrace.trace, k.wrappedKey)) |
375 | } else { | 370 | } else { |
376 | return null | 371 | return null |
377 | } | 372 | } |
378 | } | 373 | } |
379 | def dispatch TypeReference transformTypeReference(EClassUnscopedTransitiveInstancesKey k, TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace) { | 374 | |
375 | def dispatch TypeReference transformTypeReference(EClassUnscopedTransitiveInstancesKey k, | ||
376 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace) { | ||
380 | val c = k.wrappedKey | 377 | val c = k.wrappedKey |
381 | 378 | ||
382 | if(this.ecore2Logic.allClassesInScope(ecore2LogicTrace.trace).toList.contains(c)) { | 379 | if (this.ecore2Logic.allClassesInScope(ecore2LogicTrace.trace).toList.contains(c)) { |
383 | return builder.toTypeReference(this.ecore2Logic.TypeofEClass(ecore2LogicTrace.trace,k.wrappedKey)) | 380 | return builder.toTypeReference(this.ecore2Logic.TypeofEClass(ecore2LogicTrace.trace, k.wrappedKey)) |
384 | } else { | 381 | } else { |
385 | return null | 382 | return null |
386 | } | 383 | } |
387 | } | 384 | } |
388 | 385 | ||
389 | def dispatch TypeReference transformTypeReference(IInputKey k,TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace) { | 386 | def dispatch TypeReference transformTypeReference(IInputKey k, |
387 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace) { | ||
390 | throw new IllegalArgumentException('''Unsupported type: «k.class.simpleName»''') | 388 | throw new IllegalArgumentException('''Unsupported type: «k.class.simpleName»''') |
391 | } | 389 | } |
392 | } \ No newline at end of file | 390 | } |
diff --git a/Solvers/SMT-Solver/com.microsoft.z3/.classpath b/Solvers/SMT-Solver/com.microsoft.z3/.classpath index ffdc022a..759c2ecb 100644 --- a/Solvers/SMT-Solver/com.microsoft.z3/.classpath +++ b/Solvers/SMT-Solver/com.microsoft.z3/.classpath | |||
@@ -1,15 +1,15 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <classpath> | 2 | <classpath> |
3 | <classpathentry exported="true" kind="lib" path="com.microsoft.z3.jar"> | ||
4 | <attributes> | ||
5 | <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="com.microsoft.z3/lib"/> | ||
6 | </attributes> | ||
7 | </classpathentry> | ||
8 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> | 3 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> |
9 | <attributes> | 4 | <attributes> |
10 | <attribute name="module" value="true"/> | 5 | <attribute name="module" value="true"/> |
11 | </attributes> | 6 | </attributes> |
12 | </classpathentry> | 7 | </classpathentry> |
13 | <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | 8 | <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> |
9 | <classpathentry exported="true" kind="lib" path="com.microsoft.z3.jar"> | ||
10 | <attributes> | ||
11 | <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="com.microsoft.z3/lib"/> | ||
12 | </attributes> | ||
13 | </classpathentry> | ||
14 | <classpathentry kind="output" path="bin"/> | 14 | <classpathentry kind="output" path="bin"/> |
15 | </classpath> | 15 | </classpath> |
diff --git a/Solvers/SMT-Solver/com.microsoft.z3/META-INF/MANIFEST.MF b/Solvers/SMT-Solver/com.microsoft.z3/META-INF/MANIFEST.MF index d91e3272..9685b5ff 100644 --- a/Solvers/SMT-Solver/com.microsoft.z3/META-INF/MANIFEST.MF +++ b/Solvers/SMT-Solver/com.microsoft.z3/META-INF/MANIFEST.MF | |||
@@ -4,7 +4,6 @@ Bundle-Name: Z3 | |||
4 | Bundle-SymbolicName: com.microsoft.z3 | 4 | Bundle-SymbolicName: com.microsoft.z3 |
5 | Bundle-Version: 4.8.8.qualifier | 5 | Bundle-Version: 4.8.8.qualifier |
6 | Bundle-Vendor: Microsoft | 6 | Bundle-Vendor: Microsoft |
7 | Automatic-Module-Name: com.microsoft.z3 | ||
8 | Bundle-ClassPath: com.microsoft.z3.jar | 7 | Bundle-ClassPath: com.microsoft.z3.jar |
9 | Bundle-NativeCode: lib/libz3.so; | 8 | Bundle-NativeCode: lib/libz3.so; |
10 | lib/libz3java.so; | 9 | lib/libz3java.so; |
@@ -20,3 +19,4 @@ Bundle-NativeCode: lib/libz3.so; | |||
20 | processor=x86_64 | 19 | processor=x86_64 |
21 | Export-Package: com.microsoft.z3, | 20 | Export-Package: com.microsoft.z3, |
22 | com.microsoft.z3.enumerations | 21 | com.microsoft.z3.enumerations |
22 | Bundle-RequiredExecutionEnvironment: JavaSE-11 | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/META-INF/MANIFEST.MF b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/META-INF/MANIFEST.MF index b9da0f0b..f5eb5514 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/META-INF/MANIFEST.MF +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/META-INF/MANIFEST.MF | |||
@@ -8,7 +8,8 @@ Export-Package: hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra, | |||
8 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.interval, | 8 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.interval, |
9 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.interval.aggregators, | 9 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.interval.aggregators, |
10 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns, | 10 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns, |
11 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries | 11 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.queries, |
12 | hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.rules | ||
12 | Require-Bundle: hu.bme.mit.inf.dslreasoner.logic.model;bundle-version="1.0.0", | 13 | Require-Bundle: hu.bme.mit.inf.dslreasoner.logic.model;bundle-version="1.0.0", |
13 | hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage;bundle-version="1.0.0", | 14 | hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage;bundle-version="1.0.0", |
14 | hu.bme.mit.inf.dslreasoner.ecore2logic;bundle-version="1.0.0", | 15 | hu.bme.mit.inf.dslreasoner.ecore2logic;bundle-version="1.0.0", |
@@ -24,9 +25,8 @@ Require-Bundle: hu.bme.mit.inf.dslreasoner.logic.model;bundle-version="1.0.0", | |||
24 | org.eclipse.xtext;bundle-version="2.10.0", | 25 | org.eclipse.xtext;bundle-version="2.10.0", |
25 | org.eclipse.viatra.transformation.runtime.emf;bundle-version="2.0.0", | 26 | org.eclipse.viatra.transformation.runtime.emf;bundle-version="2.0.0", |
26 | org.eclipse.xtext.xbase;bundle-version="2.10.0", | 27 | org.eclipse.xtext.xbase;bundle-version="2.10.0", |
27 | com.microsoft.z3;bundle-version="4.8.5", | ||
28 | hu.bme.mit.inf.dslreasoner.ilp.cbc;bundle-version="1.0.0", | 28 | hu.bme.mit.inf.dslreasoner.ilp.cbc;bundle-version="1.0.0", |
29 | org.eclipse.viatra.query.runtime.rete;bundle-version="2.0.0" | 29 | org.eclipse.viatra.query.runtime.rete;bundle-version="2.0.0", |
30 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 | 30 | com.microsoft.z3 |
31 | Bundle-RequiredExecutionEnvironment: JavaSE-11 | ||
31 | Import-Package: org.apache.log4j | 32 | Import-Package: org.apache.log4j |
32 | Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatraquery | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationStatistics.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationStatistics.xtend new file mode 100644 index 00000000..bd5bf807 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationStatistics.xtend | |||
@@ -0,0 +1,47 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra | ||
2 | |||
3 | class ModelGenerationStatistics { | ||
4 | public var long transformationExecutionTime = 0 | ||
5 | |||
6 | synchronized def addExecutionTime(long amount) { | ||
7 | transformationExecutionTime += amount | ||
8 | } | ||
9 | |||
10 | public var long scopePropagationTime = 0 | ||
11 | |||
12 | synchronized def addScopePropagationTime(long amount) { | ||
13 | scopePropagationTime += amount | ||
14 | } | ||
15 | |||
16 | public var long mustRelationPropagationTime = 0 | ||
17 | |||
18 | synchronized def addMustRelationPropagationTime(long amount) { | ||
19 | mustRelationPropagationTime += amount | ||
20 | } | ||
21 | |||
22 | public var long preliminaryTypeAnalisisTime = 0 | ||
23 | |||
24 | public var int decisionsTried = 0 | ||
25 | |||
26 | synchronized def incrementDecisionCount() { | ||
27 | decisionsTried++ | ||
28 | } | ||
29 | |||
30 | public var int transformationInvocations | ||
31 | |||
32 | synchronized def incrementTransformationCount() { | ||
33 | transformationInvocations++ | ||
34 | } | ||
35 | |||
36 | public var int scopePropagatorInvocations | ||
37 | |||
38 | synchronized def incrementScopePropagationCount() { | ||
39 | scopePropagatorInvocations++ | ||
40 | } | ||
41 | |||
42 | public var int scopePropagatorSolverInvocations | ||
43 | |||
44 | synchronized def incrementScopePropagationSolverCount() { | ||
45 | scopePropagatorSolverInvocations++ | ||
46 | } | ||
47 | } | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/TypeInferenceMethod.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/TypeInferenceMethod.xtend new file mode 100644 index 00000000..9296a0be --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/TypeInferenceMethod.xtend | |||
@@ -0,0 +1,44 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra | ||
2 | |||
3 | import com.google.common.collect.ImmutableMap | ||
4 | import com.google.common.collect.ImmutableSet | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | ||
7 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransfomedViatraQuery | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.CachingSimplePolyhedronScopePropagatorStrategy | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.CbcPolyhedronSolver | ||
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint | ||
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.MultiplicityGoalConstraintCalculator | ||
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronScopePropagator | ||
13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationConstraintCalculator | ||
14 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagator | ||
15 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy | ||
16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.TypeHierarchyScopePropagator | ||
17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Z3PolyhedronSolver | ||
18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.GeneratedPatterns | ||
19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.ModalPatternQueries | ||
20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternProvider | ||
21 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.UnitPropagationPatternGenerator | ||
22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.rules.GoalConstraintProvider | ||
23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.rules.RefinementRuleProvider | ||
24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
25 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace | ||
26 | import java.util.Collection | ||
27 | import java.util.List | ||
28 | import java.util.Map | ||
29 | import java.util.Set | ||
30 | import org.eclipse.viatra.query.runtime.api.GenericQueryGroup | ||
31 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | ||
32 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification | ||
33 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine | ||
34 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | ||
35 | import org.eclipse.viatra.query.runtime.emf.EMFScope | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | ||
38 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRule | ||
39 | import org.eclipse.xtend.lib.annotations.Data | ||
40 | |||
41 | enum TypeInferenceMethod { | ||
42 | Generic, | ||
43 | PreliminaryAnalysis | ||
44 | } \ No newline at end of file | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ExtendedLinearExpressionBuilderFactory.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ExtendedLinearExpressionBuilderFactory.xtend new file mode 100644 index 00000000..6054affe --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ExtendedLinearExpressionBuilderFactory.xtend | |||
@@ -0,0 +1,140 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality | ||
2 | |||
3 | import com.google.common.collect.ImmutableList | ||
4 | import com.google.common.collect.ImmutableMap | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
6 | import java.util.ArrayList | ||
7 | import java.util.HashMap | ||
8 | import java.util.HashSet | ||
9 | import java.util.List | ||
10 | import java.util.Map | ||
11 | import java.util.Set | ||
12 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | ||
13 | import org.eclipse.xtend.lib.annotations.Accessors | ||
14 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor | ||
15 | |||
16 | interface BoundSaturationListener { | ||
17 | def void boundsSaturated(Integer lower, Integer upper) | ||
18 | } | ||
19 | |||
20 | interface ExtendedLinearExpressionBuilderFactory { | ||
21 | def ExtendedLinearExpressionBuilder createBuilder() | ||
22 | |||
23 | def Dimension getDimension(IPatternMatch patternMatch) | ||
24 | } | ||
25 | |||
26 | interface ExtendedLinearExpressionBuilder extends LinearTypeExpressionBuilder { | ||
27 | override ExtendedLinearExpressionBuilder add(int scale, Type type) | ||
28 | |||
29 | def ExtendedLinearExpressionBuilder add(int scale, IPatternMatch patternMatch) | ||
30 | |||
31 | def ExtendedLinearExpressionBuilder add(int scale, Dimension dimension) | ||
32 | |||
33 | def LinearBoundedExpression build(BoundSaturationListener listener) | ||
34 | } | ||
35 | |||
36 | class ExtendedPolyhedronBuilder implements ExtendedLinearExpressionBuilderFactory { | ||
37 | val Map<Type, LinearBoundedExpression> typeBounds | ||
38 | val Map<Map<Dimension, Integer>, LinearBoundedExpression> expressionsCache | ||
39 | |||
40 | val ImmutableList.Builder<Dimension> dimensions = ImmutableList.builder | ||
41 | val Set<LinearConstraint> constraints = new HashSet | ||
42 | val Set<LinearBoundedExpression> expressionsToSaturate = new HashSet | ||
43 | val Map<IPatternMatch, Dimension> patternMatchCounts = new HashMap | ||
44 | @Accessors(PUBLIC_GETTER) val List<Pair<LinearBoundedExpression, BoundSaturationListener>> saturationListeners = new ArrayList | ||
45 | |||
46 | new(Polyhedron polyhedron, Map<Type, LinearBoundedExpression> typeBounds, | ||
47 | Map<Map<Dimension, Integer>, LinearBoundedExpression> initialExpressionsCache) { | ||
48 | this.typeBounds = typeBounds | ||
49 | this.expressionsCache = new HashMap(initialExpressionsCache) | ||
50 | dimensions.addAll(polyhedron.dimensions) | ||
51 | constraints.addAll(polyhedron.constraints) | ||
52 | expressionsToSaturate.addAll(polyhedron.expressionsToSaturate) | ||
53 | } | ||
54 | |||
55 | override createBuilder() { | ||
56 | new ExtendedLinearExpressionBuilderImpl(this) | ||
57 | } | ||
58 | |||
59 | override getDimension(IPatternMatch patternMatch) { | ||
60 | patternMatchCounts.computeIfAbsent(patternMatch) [ key | | ||
61 | val dimension = new Dimension(key.toString, 0, null) | ||
62 | dimensions.add(dimension) | ||
63 | dimension | ||
64 | ] | ||
65 | } | ||
66 | |||
67 | def buildPolyhedron() { | ||
68 | new Polyhedron( | ||
69 | dimensions.build, | ||
70 | ImmutableList.copyOf(constraints), | ||
71 | ImmutableList.copyOf(expressionsToSaturate) | ||
72 | ) | ||
73 | } | ||
74 | |||
75 | @FinalFieldsConstructor | ||
76 | private static class ExtendedLinearExpressionBuilderImpl implements ExtendedLinearExpressionBuilder { | ||
77 | val ExtendedPolyhedronBuilder polyhedronBuilder | ||
78 | |||
79 | val Map<Dimension, Integer> coefficients = new HashMap | ||
80 | |||
81 | override add(int scale, Type type) { | ||
82 | val expression = polyhedronBuilder.typeBounds.get(type) | ||
83 | if (expression === null) { | ||
84 | throw new IllegalArgumentException("Unknown Type: " + type) | ||
85 | } | ||
86 | add(scale, expression) | ||
87 | } | ||
88 | |||
89 | override add(int scale, IPatternMatch patternMatch) { | ||
90 | val dimension = polyhedronBuilder.getDimension(patternMatch) | ||
91 | add(scale, dimension) | ||
92 | } | ||
93 | |||
94 | private def add(int scale, LinearBoundedExpression expression) { | ||
95 | switch (expression) { | ||
96 | Dimension: add(scale, expression) | ||
97 | LinearConstraint: add(scale, expression.coefficients) | ||
98 | default: throw new IllegalArgumentException("Unknown LinearBoundedExpression: " + expression) | ||
99 | } | ||
100 | } | ||
101 | |||
102 | private def add(int scale, Map<Dimension, Integer> coefficients) { | ||
103 | for (pair : coefficients.entrySet) { | ||
104 | add(scale * pair.value, pair.key) | ||
105 | } | ||
106 | this | ||
107 | } | ||
108 | |||
109 | override add(int scale, Dimension dimension) { | ||
110 | coefficients.merge(dimension, scale)[a, b|a + b] | ||
111 | this | ||
112 | } | ||
113 | |||
114 | override build() { | ||
115 | val filteredCoefficients = ImmutableMap.copyOf(coefficients.filter [ _, coefficient | | ||
116 | coefficient != 0 | ||
117 | ]) | ||
118 | polyhedronBuilder.expressionsCache.computeIfAbsent(filteredCoefficients) [ map | | ||
119 | if (map.size == 1) { | ||
120 | val pair = map.entrySet.head | ||
121 | if (pair.value == 1) { | ||
122 | return pair.key | ||
123 | } | ||
124 | } | ||
125 | val constraint = new LinearConstraint(map) | ||
126 | polyhedronBuilder.constraints.add(constraint) | ||
127 | constraint | ||
128 | ] | ||
129 | } | ||
130 | |||
131 | override build(BoundSaturationListener listener) { | ||
132 | val expression = build() | ||
133 | if (listener !== null) { | ||
134 | polyhedronBuilder.expressionsToSaturate.add(expression) | ||
135 | polyhedronBuilder.saturationListeners.add(expression -> listener) | ||
136 | } | ||
137 | expression | ||
138 | } | ||
139 | } | ||
140 | } | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ExtendedPolyhedronScopePropagatorStrategy.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ExtendedPolyhedronScopePropagatorStrategy.xtend new file mode 100644 index 00000000..32923396 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ExtendedPolyhedronScopePropagatorStrategy.xtend | |||
@@ -0,0 +1,63 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationStatistics | ||
5 | import java.util.Collection | ||
6 | import java.util.Map | ||
7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation | ||
8 | |||
9 | interface PolyhedronExtensionOperator { | ||
10 | def void extendPolyhedron(ExtendedLinearExpressionBuilderFactory factory) | ||
11 | } | ||
12 | |||
13 | class ExtendedPolyhedronScopePropagatorStrategy extends PolyhedronScopePropagatorStrategy { | ||
14 | val PolyhedronSolver solver | ||
15 | val Collection<PolyhedronExtensionOperator> extensionOperators | ||
16 | |||
17 | var Map<Type, LinearBoundedExpression> typeBounds | ||
18 | var Map<Map<Dimension, Integer>, LinearBoundedExpression> initialExpressionsCache | ||
19 | |||
20 | new(PolyhedronSolver solver, Collection<PolyhedronExtensionOperator> extensionOperators, | ||
21 | ModelGenerationStatistics statistics) { | ||
22 | super(statistics) | ||
23 | this.solver = solver | ||
24 | this.extensionOperators = extensionOperators | ||
25 | } | ||
26 | |||
27 | override setPolyhedron(Polyhedron polyhedron, Map<Type, LinearBoundedExpression> typeBounds, | ||
28 | Map<Map<Dimension, Integer>, LinearBoundedExpression> initialExpressionsCache) { | ||
29 | super.setPolyhedron(polyhedron, typeBounds, initialExpressionsCache) | ||
30 | this.typeBounds = typeBounds | ||
31 | this.initialExpressionsCache = initialExpressionsCache | ||
32 | } | ||
33 | |||
34 | override isRelevantRelation(Relation relation) { | ||
35 | true | ||
36 | } | ||
37 | |||
38 | override protected doSaturate() { | ||
39 | val builder = new ExtendedPolyhedronBuilder(polyhedron, typeBounds, initialExpressionsCache) | ||
40 | for (extensionOperator : extensionOperators) { | ||
41 | extensionOperator.extendPolyhedron(builder) | ||
42 | } | ||
43 | val extendedPolyhedron = builder.buildPolyhedron() | ||
44 | val saturationOperator = solver.createSaturationOperator(extendedPolyhedron) | ||
45 | val result = try { | ||
46 | saturationOperator.saturate() | ||
47 | } finally { | ||
48 | saturationOperator.close() | ||
49 | } | ||
50 | if (result == PolyhedronSaturationResult.EMPTY) { | ||
51 | // The partial model cannot be refined any more, we can't provide objective bounds. | ||
52 | for (pair : builder.saturationListeners) { | ||
53 | pair.value.boundsSaturated(null, null) | ||
54 | } | ||
55 | return false | ||
56 | } | ||
57 | for (pair : builder.saturationListeners) { | ||
58 | val expression = pair.key | ||
59 | pair.value.boundsSaturated(expression.lowerBound, expression.upperBound) | ||
60 | } | ||
61 | true | ||
62 | } | ||
63 | } | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/LinearTypeConstraintHint.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/LinearTypeConstraintHint.xtend index 8c21ca1d..31f98e36 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/LinearTypeConstraintHint.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/LinearTypeConstraintHint.xtend | |||
@@ -3,8 +3,10 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality | |||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | 3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type |
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator | 4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator |
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
6 | import java.util.Map | ||
6 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | 7 | import org.eclipse.viatra.query.runtime.api.IPatternMatch |
7 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | 8 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher |
9 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | ||
8 | 10 | ||
9 | interface LinearTypeExpressionBuilderFactory { | 11 | interface LinearTypeExpressionBuilderFactory { |
10 | def ViatraQueryMatcher<? extends IPatternMatch> createMatcher(String queryName) | 12 | def ViatraQueryMatcher<? extends IPatternMatch> createMatcher(String queryName) |
@@ -24,7 +26,7 @@ interface RelationConstraintUpdater { | |||
24 | } | 26 | } |
25 | 27 | ||
26 | interface LinearTypeConstraintHint { | 28 | interface LinearTypeConstraintHint { |
27 | def CharSequence getAdditionalPatterns(PatternGenerator patternGenerator) | 29 | def CharSequence getAdditionalPatterns(PatternGenerator patternGenerator, Map<String, PQuery> fqnToPQuery) |
28 | 30 | ||
29 | def RelationConstraintUpdater createConstraintUpdater(LinearTypeExpressionBuilderFactory builderFactory) | 31 | def RelationConstraintUpdater createConstraintUpdater(LinearTypeExpressionBuilderFactory builderFactory) |
30 | } | 32 | } |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagator.xtend index c28d4caa..ad8f94ab 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagator.xtend | |||
@@ -1,7 +1,5 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality |
2 | 2 | ||
3 | import com.google.common.cache.Cache | ||
4 | import com.google.common.cache.CacheBuilder | ||
5 | import com.google.common.collect.ImmutableList | 3 | import com.google.common.collect.ImmutableList |
6 | import com.google.common.collect.ImmutableMap | 4 | import com.google.common.collect.ImmutableMap |
7 | import com.google.common.collect.ImmutableSet | 5 | import com.google.common.collect.ImmutableSet |
@@ -23,7 +21,6 @@ import java.util.HashSet | |||
23 | import java.util.List | 21 | import java.util.List |
24 | import java.util.Map | 22 | import java.util.Map |
25 | import java.util.Set | 23 | import java.util.Set |
26 | import javax.naming.OperationNotSupportedException | ||
27 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | 24 | import org.eclipse.viatra.query.runtime.api.IPatternMatch |
28 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification | 25 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification |
29 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine | 26 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine |
@@ -32,31 +29,29 @@ import org.eclipse.viatra.query.runtime.emf.EMFScope | |||
32 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor | 29 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor |
33 | 30 | ||
34 | class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { | 31 | class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { |
35 | static val CACHE_SIZE = 10000 | ||
36 | |||
37 | val boolean updateHeuristic | 32 | val boolean updateHeuristic |
38 | val Map<Scope, LinearBoundedExpression> scopeBounds | 33 | val Map<Scope, LinearBoundedExpression> scopeBounds |
39 | val LinearBoundedExpression topLevelBounds | 34 | val LinearBoundedExpression topLevelBounds |
40 | val Polyhedron polyhedron | 35 | val Polyhedron polyhedron |
41 | val PolyhedronSaturationOperator operator | 36 | val PolyhedronScopePropagatorStrategy strategy |
42 | val Set<Relation> relevantRelations | 37 | val Set<Relation> relevantRelations |
43 | val Cache<PolyhedronSignature, PolyhedronSignature> cache = CacheBuilder.newBuilder.maximumSize(CACHE_SIZE).build | ||
44 | List<RelationConstraintUpdater> updaters = emptyList | 38 | List<RelationConstraintUpdater> updaters = emptyList |
45 | 39 | ||
46 | new(PartialInterpretation p, ModelGenerationStatistics statistics, Set<? extends Type> possibleNewDynamicTypes, | 40 | new(PartialInterpretation p, ModelGenerationStatistics statistics, Set<? extends Type> possibleNewDynamicTypes, |
47 | Map<RelationMultiplicityConstraint, UnifinishedMultiplicityQueries> unfinishedMultiplicityQueries, | 41 | Map<RelationMultiplicityConstraint, UnifinishedMultiplicityQueries> unfinishedMultiplicityQueries, |
48 | IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> hasElementInContainmentQuery, | 42 | IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> hasElementInContainmentQuery, |
49 | Map<String, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> allPatternsByName, | 43 | Map<String, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> allPatternsByName, |
50 | Collection<LinearTypeConstraintHint> hints, PolyhedronSolver solver, boolean propagateRelations, | 44 | Collection<LinearTypeConstraintHint> hints, PolyhedronScopePropagatorStrategy strategy, |
51 | boolean updateHeuristic) { | 45 | boolean propagateRelations, boolean updateHeuristic) { |
52 | super(p, statistics) | 46 | super(p, statistics) |
53 | this.updateHeuristic = updateHeuristic | 47 | this.updateHeuristic = updateHeuristic |
48 | this.strategy = strategy | ||
54 | val builder = new PolyhedronBuilder(p) | 49 | val builder = new PolyhedronBuilder(p) |
55 | builder.buildPolyhedron(possibleNewDynamicTypes) | 50 | builder.buildPolyhedron(possibleNewDynamicTypes) |
56 | scopeBounds = builder.scopeBounds | 51 | scopeBounds = builder.scopeBounds |
57 | topLevelBounds = builder.topLevelBounds | 52 | topLevelBounds = builder.topLevelBounds |
58 | polyhedron = builder.polyhedron | 53 | polyhedron = builder.polyhedron |
59 | operator = solver.createSaturationOperator(polyhedron) | 54 | strategy.setPolyhedron(polyhedron, builder.typeBounds, builder.expressionsCache) |
60 | propagateAllScopeConstraints() | 55 | propagateAllScopeConstraints() |
61 | if (propagateRelations) { | 56 | if (propagateRelations) { |
62 | val maximumNumberOfNewNodes = topLevelBounds.upperBound | 57 | val maximumNumberOfNewNodes = topLevelBounds.upperBound |
@@ -80,30 +75,10 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { | |||
80 | resetBounds() | 75 | resetBounds() |
81 | populatePolyhedronFromScope() | 76 | populatePolyhedronFromScope() |
82 | // println(polyhedron) | 77 | // println(polyhedron) |
83 | val signature = polyhedron.createSignature | 78 | if (strategy.saturate) { |
84 | val cachedSignature = cache.getIfPresent(signature) | 79 | populateScopesFromPolyhedron() |
85 | switch (cachedSignature) { | 80 | } else { |
86 | case null: { | 81 | setScopesInvalid() |
87 | statistics.incrementScopePropagationSolverCount | ||
88 | val result = operator.saturate() | ||
89 | if (result == PolyhedronSaturationResult.EMPTY) { | ||
90 | cache.put(signature, PolyhedronSignature.EMPTY) | ||
91 | // println("INVALID") | ||
92 | setScopesInvalid() | ||
93 | } else { | ||
94 | val resultSignature = polyhedron.createSignature | ||
95 | cache.put(signature, resultSignature) | ||
96 | populateScopesFromPolyhedron() | ||
97 | } | ||
98 | } | ||
99 | case PolyhedronSignature.EMPTY: | ||
100 | setScopesInvalid() | ||
101 | PolyhedronSignature.Bounds: { | ||
102 | polyhedron.applySignature(signature) | ||
103 | populateScopesFromPolyhedron() | ||
104 | } | ||
105 | default: | ||
106 | throw new IllegalStateException("Unknown polyhedron signature: " + signature) | ||
107 | } | 82 | } |
108 | // println(polyhedron) | 83 | // println(polyhedron) |
109 | if (updateHeuristic) { | 84 | if (updateHeuristic) { |
@@ -112,9 +87,9 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { | |||
112 | } | 87 | } |
113 | 88 | ||
114 | override isPropagationNeededAfterAdditionToRelation(Relation r) { | 89 | override isPropagationNeededAfterAdditionToRelation(Relation r) { |
115 | relevantRelations.contains(r) || super.isPropagationNeededAfterAdditionToRelation(r) | 90 | relevantRelations.contains(r) || strategy.isRelevantRelation(r) || super.isPropagationNeededAfterAdditionToRelation(r) |
116 | } | 91 | } |
117 | 92 | ||
118 | override isQueryEngineFlushRequiredBeforePropagation() { | 93 | override isQueryEngineFlushRequiredBeforePropagation() { |
119 | true | 94 | true |
120 | } | 95 | } |
@@ -253,7 +228,10 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { | |||
253 | } | 228 | } |
254 | buildRelevantRelations(constraints.keySet) | 229 | buildRelevantRelations(constraints.keySet) |
255 | for (hint : hints) { | 230 | for (hint : hints) { |
256 | updatersBuilder.add(hint.createConstraintUpdater(this)) | 231 | val updater = hint.createConstraintUpdater(this) |
232 | if (updater !== null) { | ||
233 | updatersBuilder.add(updater) | ||
234 | } | ||
257 | } | 235 | } |
258 | updaters = updatersBuilder.build | 236 | updaters = updatersBuilder.build |
259 | addCachedConstraintsToPolyhedron() | 237 | addCachedConstraintsToPolyhedron() |
@@ -410,7 +388,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { | |||
410 | for (scope : p.scopes) { | 388 | for (scope : p.scopes) { |
411 | switch (targetTypeInterpretation : scope.targetTypeInterpretation) { | 389 | switch (targetTypeInterpretation : scope.targetTypeInterpretation) { |
412 | PartialPrimitiveInterpretation: | 390 | PartialPrimitiveInterpretation: |
413 | throw new OperationNotSupportedException("Primitive type scopes are not yet implemented") | 391 | throw new IllegalStateException("Primitive type scopes are not yet implemented") |
414 | PartialComplexTypeInterpretation: { | 392 | PartialComplexTypeInterpretation: { |
415 | val complexType = targetTypeInterpretation.interpretationOf | 393 | val complexType = targetTypeInterpretation.interpretationOf |
416 | val typeBound = typeBounds.get(complexType) | 394 | val typeBound = typeBounds.get(complexType) |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagatorStrategy.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagatorStrategy.xtend new file mode 100644 index 00000000..f93dcd18 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagatorStrategy.xtend | |||
@@ -0,0 +1,92 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality | ||
2 | |||
3 | import com.google.common.cache.Cache | ||
4 | import com.google.common.cache.CacheBuilder | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationStatistics | ||
8 | import java.util.Map | ||
9 | import org.eclipse.xtend.lib.annotations.Accessors | ||
10 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor | ||
11 | |||
12 | @FinalFieldsConstructor | ||
13 | abstract class PolyhedronScopePropagatorStrategy { | ||
14 | val ModelGenerationStatistics statistics | ||
15 | |||
16 | @Accessors(PUBLIC_GETTER) var Polyhedron polyhedron | ||
17 | |||
18 | def void setPolyhedron(Polyhedron polyhedron, Map<Type, LinearBoundedExpression> typeBounds, | ||
19 | Map<Map<Dimension, Integer>, LinearBoundedExpression> initialExpressionsCache) { | ||
20 | if (this.polyhedron !== null) { | ||
21 | throw new IllegalStateException("polyhedron was already set") | ||
22 | } | ||
23 | this.polyhedron = polyhedron | ||
24 | initialize() | ||
25 | } | ||
26 | |||
27 | def boolean saturate() { | ||
28 | if (polyhedron === null) { | ||
29 | throw new IllegalStateException("polyhedron was not set") | ||
30 | } | ||
31 | doSaturate() | ||
32 | } | ||
33 | |||
34 | def boolean isRelevantRelation(Relation relation) { | ||
35 | false | ||
36 | } | ||
37 | |||
38 | protected def incrementScopePropagationSolverCount() { | ||
39 | statistics.incrementScopePropagationSolverCount() | ||
40 | } | ||
41 | |||
42 | protected def void initialize() { | ||
43 | } | ||
44 | |||
45 | protected def boolean doSaturate() | ||
46 | } | ||
47 | |||
48 | @FinalFieldsConstructor | ||
49 | class CachingSimplePolyhedronScopePropagatorStrategy extends PolyhedronScopePropagatorStrategy { | ||
50 | static val CACHE_SIZE = 10000 | ||
51 | |||
52 | val PolyhedronSolver solver | ||
53 | |||
54 | val Cache<PolyhedronSignature, PolyhedronSignature> cache = CacheBuilder.newBuilder.maximumSize(CACHE_SIZE).build | ||
55 | var PolyhedronSaturationOperator operator | ||
56 | |||
57 | new(PolyhedronSolver solver, ModelGenerationStatistics statistics) { | ||
58 | super(statistics) | ||
59 | this.solver = solver | ||
60 | } | ||
61 | |||
62 | override protected initialize() { | ||
63 | operator = solver.createSaturationOperator(polyhedron) | ||
64 | } | ||
65 | |||
66 | override protected doSaturate() { | ||
67 | val signature = polyhedron.createSignature | ||
68 | val cachedSignature = cache.getIfPresent(signature) | ||
69 | switch (cachedSignature) { | ||
70 | case null: { | ||
71 | incrementScopePropagationSolverCount() | ||
72 | val result = operator.saturate() | ||
73 | if (result == PolyhedronSaturationResult.EMPTY) { | ||
74 | cache.put(signature, PolyhedronSignature.EMPTY) | ||
75 | false | ||
76 | } else { | ||
77 | val resultSignature = polyhedron.createSignature | ||
78 | cache.put(signature, resultSignature) | ||
79 | true | ||
80 | } | ||
81 | } | ||
82 | case PolyhedronSignature.EMPTY: | ||
83 | false | ||
84 | PolyhedronSignature.Bounds: { | ||
85 | polyhedron.applySignature(signature) | ||
86 | true | ||
87 | } | ||
88 | default: | ||
89 | throw new IllegalStateException("Unknown polyhedron signature: " + signature) | ||
90 | } | ||
91 | } | ||
92 | } | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend index 4e046190..21bd2d9e 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend | |||
@@ -116,7 +116,7 @@ abstract class PolyhedronSignature { | |||
116 | } | 116 | } |
117 | 117 | ||
118 | @Accessors | 118 | @Accessors |
119 | abstract class LinearBoundedExpression { | 119 | class Bounds { |
120 | var Integer lowerBound | 120 | var Integer lowerBound |
121 | var Integer upperBound | 121 | var Integer upperBound |
122 | 122 | ||
@@ -132,12 +132,19 @@ abstract class LinearBoundedExpression { | |||
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||
135 | def void assertBetween(Integer tighterLowerBound, Integer tighterUpperBound) { | ||
136 | tightenLowerBound(tighterLowerBound) | ||
137 | tightenUpperBound(tighterUpperBound) | ||
138 | } | ||
139 | |||
135 | def void assertEqualsTo(int bound) { | 140 | def void assertEqualsTo(int bound) { |
136 | tightenLowerBound(bound) | 141 | assertBetween(bound, bound) |
137 | tightenUpperBound(bound) | ||
138 | } | 142 | } |
139 | } | 143 | } |
140 | 144 | ||
145 | abstract class LinearBoundedExpression extends Bounds { | ||
146 | } | ||
147 | |||
141 | @Accessors | 148 | @Accessors |
142 | class Dimension extends LinearBoundedExpression { | 149 | class Dimension extends LinearBoundedExpression { |
143 | val String name | 150 | val String name |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagator.xtend index 93b83577..cacba3c6 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagator.xtend | |||
@@ -19,6 +19,8 @@ class ScopePropagator { | |||
19 | val Map<PartialTypeInterpratation, Scope> type2Scope | 19 | val Map<PartialTypeInterpratation, Scope> type2Scope |
20 | @Accessors(PROTECTED_GETTER) val Map<Scope, Set<Scope>> superScopes | 20 | @Accessors(PROTECTED_GETTER) val Map<Scope, Set<Scope>> superScopes |
21 | @Accessors(PROTECTED_GETTER) val Map<Scope, Set<Scope>> subScopes | 21 | @Accessors(PROTECTED_GETTER) val Map<Scope, Set<Scope>> subScopes |
22 | |||
23 | @Accessors(PUBLIC_GETTER) var scopePropagationNeeded = false | ||
22 | 24 | ||
23 | new(PartialInterpretation p, ModelGenerationStatistics statistics) { | 25 | new(PartialInterpretation p, ModelGenerationStatistics statistics) { |
24 | partialInterpretation = p | 26 | partialInterpretation = p |
@@ -64,7 +66,8 @@ class ScopePropagator { | |||
64 | copyScopeBoundsToHeuristic() | 66 | copyScopeBoundsToHeuristic() |
65 | } | 67 | } |
66 | 68 | ||
67 | def propagateAllScopeConstraints() { | 69 | def void propagateAllScopeConstraints() { |
70 | scopePropagationNeeded = false | ||
68 | if (!valid) { | 71 | if (!valid) { |
69 | return | 72 | return |
70 | } | 73 | } |
@@ -93,6 +96,7 @@ class ScopePropagator { | |||
93 | if (isPrimitive) { | 96 | if (isPrimitive) { |
94 | return | 97 | return |
95 | } | 98 | } |
99 | scopePropagationNeeded = true | ||
96 | // println('''Adding to «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') | 100 | // println('''Adding to «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') |
97 | val targetScope = type2Scope.get(t) | 101 | val targetScope = type2Scope.get(t) |
98 | if (targetScope !== null) { | 102 | if (targetScope !== null) { |
@@ -117,6 +121,12 @@ class ScopePropagator { | |||
117 | // this.partialInterpretation.scopes.forEach[println(''' «(it.targetTypeInterpretation as PartialComplexTypeInterpretation).interpretationOf.name»: «it.minNewElements»-«it.maxNewElements»''')] | 121 | // this.partialInterpretation.scopes.forEach[println(''' «(it.targetTypeInterpretation as PartialComplexTypeInterpretation).interpretationOf.name»: «it.minNewElements»-«it.maxNewElements»''')] |
118 | // println('''All constraints are propagated upon increasing «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') | 122 | // println('''All constraints are propagated upon increasing «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') |
119 | } | 123 | } |
124 | |||
125 | def addedToRelation(Relation r) { | ||
126 | if (isPropagationNeededAfterAdditionToRelation(r)) { | ||
127 | scopePropagationNeeded = true | ||
128 | } | ||
129 | } | ||
120 | 130 | ||
121 | protected def setScopesInvalid() { | 131 | protected def setScopesInvalid() { |
122 | partialInterpretation.minNewElements = Integer.MAX_VALUE | 132 | partialInterpretation.minNewElements = Integer.MAX_VALUE |
@@ -127,7 +137,7 @@ class ScopePropagator { | |||
127 | } | 137 | } |
128 | } | 138 | } |
129 | 139 | ||
130 | def isPropagationNeededAfterAdditionToRelation(Relation r) { | 140 | protected def isPropagationNeededAfterAdditionToRelation(Relation r) { |
131 | false | 141 | false |
132 | } | 142 | } |
133 | 143 | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend index 80bc3844..edf92343 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend | |||
@@ -25,12 +25,13 @@ import java.util.HashMap | |||
25 | import java.util.Map | 25 | import java.util.Map |
26 | import org.eclipse.emf.ecore.EAttribute | 26 | import org.eclipse.emf.ecore.EAttribute |
27 | import org.eclipse.emf.ecore.EReference | 27 | import org.eclipse.emf.ecore.EReference |
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | 29 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery |
29 | import org.eclipse.xtend.lib.annotations.Accessors | 30 | import org.eclipse.xtend.lib.annotations.Accessors |
31 | import org.eclipse.xtend.lib.annotations.Data | ||
32 | import org.eclipse.xtend2.lib.StringConcatenationClient | ||
30 | 33 | ||
31 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 34 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
32 | import org.eclipse.xtend.lib.annotations.Data | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint | ||
34 | 35 | ||
35 | @Data class PatternGeneratorResult { | 36 | @Data class PatternGeneratorResult { |
36 | CharSequence patternText | 37 | CharSequence patternText |
@@ -38,6 +39,14 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint | |||
38 | HashMap<PConstraint,String> constraint2CurrentPreconditionName | 39 | HashMap<PConstraint,String> constraint2CurrentPreconditionName |
39 | } | 40 | } |
40 | 41 | ||
42 | interface UnitPropagationPatternGenerator { | ||
43 | def Map<Relation, String> getMustPatterns() | ||
44 | |||
45 | def Map<Relation, String> getMustNotPatterns() | ||
46 | |||
47 | def StringConcatenationClient getAdditionalPatterns(PatternGenerator generator, Map<String, PQuery> fqn2PQuery) | ||
48 | } | ||
49 | |||
41 | class PatternGenerator { | 50 | class PatternGenerator { |
42 | @Accessors(PUBLIC_GETTER) val TypeIndexer typeIndexer // = new TypeIndexer(this) | 51 | @Accessors(PUBLIC_GETTER) val TypeIndexer typeIndexer // = new TypeIndexer(this) |
43 | @Accessors(PUBLIC_GETTER) val RelationDeclarationIndexer relationDeclarationIndexer = new RelationDeclarationIndexer( | 52 | @Accessors(PUBLIC_GETTER) val RelationDeclarationIndexer relationDeclarationIndexer = new RelationDeclarationIndexer( |
@@ -157,7 +166,8 @@ class PatternGenerator { | |||
157 | Map<String, PQuery> fqn2PQuery, | 166 | Map<String, PQuery> fqn2PQuery, |
158 | TypeAnalysisResult typeAnalysisResult, | 167 | TypeAnalysisResult typeAnalysisResult, |
159 | RelationConstraints constraints, | 168 | RelationConstraints constraints, |
160 | Collection<LinearTypeConstraintHint> hints | 169 | Collection<LinearTypeConstraintHint> hints, |
170 | Collection<UnitPropagationPatternGenerator> unitPropagationPatternGenerators | ||
161 | ) { | 171 | ) { |
162 | val first = | 172 | val first = |
163 | ''' | 173 | ''' |
@@ -313,7 +323,7 @@ class PatternGenerator { | |||
313 | ////////// | 323 | ////////// |
314 | // 1.2 Relation Declaration Indexers | 324 | // 1.2 Relation Declaration Indexers |
315 | ////////// | 325 | ////////// |
316 | «relationDeclarationIndexer.generateRelationIndexers(problem,problem.relations.filter(RelationDeclaration),fqn2PQuery)» | 326 | «relationDeclarationIndexer.generateRelationIndexers(problem,problem.relations.filter(RelationDeclaration),unitPropagationPatternGenerators,fqn2PQuery)» |
317 | 327 | ||
318 | ////////// | 328 | ////////// |
319 | // 1.3 Relation Definition Indexers | 329 | // 1.3 Relation Definition Indexers |
@@ -359,13 +369,16 @@ class PatternGenerator { | |||
359 | ////////// | 369 | ////////// |
360 | // 4.3 Relation refinement | 370 | // 4.3 Relation refinement |
361 | ////////// | 371 | ////////// |
362 | «relationRefinementGenerator.generateRefineReference(problem)» | 372 | «relationRefinementGenerator.generateRefineReference(problem, unitPropagationPatternGenerators)» |
363 | 373 | ||
364 | ////////// | 374 | ////////// |
365 | // 5 Hints | 375 | // 5 Hints |
366 | ////////// | 376 | ////////// |
367 | «FOR hint : hints» | 377 | «FOR hint : hints» |
368 | «hint.getAdditionalPatterns(this)» | 378 | «hint.getAdditionalPatterns(this, fqn2PQuery)» |
379 | «ENDFOR» | ||
380 | «FOR generator : unitPropagationPatternGenerators» | ||
381 | «generator.getAdditionalPatterns(this, fqn2PQuery)» | ||
369 | «ENDFOR» | 382 | «ENDFOR» |
370 | 383 | ||
371 | ////////// | 384 | ////////// |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend index d57705ce..2e786286 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend | |||
@@ -36,9 +36,10 @@ import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | |||
36 | public Map<Relation, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> unfinishedWFQueries | 36 | public Map<Relation, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> unfinishedWFQueries |
37 | public Map<RelationMultiplicityConstraint, UnifinishedMultiplicityQueries> multiplicityConstraintQueries | 37 | public Map<RelationMultiplicityConstraint, UnifinishedMultiplicityQueries> multiplicityConstraintQueries |
38 | public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> hasElementInContainmentQuery | 38 | public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> hasElementInContainmentQuery |
39 | public Map<ObjectCreationPrecondition, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> refineObjectQueries | 39 | public Map<ObjectCreationPrecondition, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> refineObjectQueries |
40 | public Map<? extends Type, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> refineTypeQueries | 40 | public Map<? extends Type, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> refineTypeQueries |
41 | public Map<Pair<RelationDeclaration, Relation>, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> refinerelationQueries | 41 | public Map<Pair<RelationDeclaration, Relation>, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> refineRelationQueries |
42 | public Map<Pair<RelationDeclaration, Relation>, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> mustRelationPropagationQueries | ||
42 | public Map<PConstraint, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> mustUnitPropagationPreconditionPatterns | 43 | public Map<PConstraint, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> mustUnitPropagationPreconditionPatterns |
43 | public Map<PConstraint, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> currentUnitPropagationPreconditionPatterns | 44 | public Map<PConstraint, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> currentUnitPropagationPreconditionPatterns |
44 | public Map<RelationDefinition, ModalPatternQueries> modalRelationQueries | 45 | public Map<RelationDefinition, ModalPatternQueries> modalRelationQueries |
@@ -56,7 +57,7 @@ class ModalPatternQueries { | |||
56 | class UnifinishedMultiplicityQueries { | 57 | class UnifinishedMultiplicityQueries { |
57 | val IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> existingMultiplicityQuery | 58 | val IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> existingMultiplicityQuery |
58 | val IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> existingInverseMultiplicityQuery | 59 | val IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> existingInverseMultiplicityQuery |
59 | 60 | ||
60 | def Set<IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> getAllQueries() { | 61 | def Set<IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> getAllQueries() { |
61 | val builder = ImmutableSet.builder | 62 | val builder = ImmutableSet.builder |
62 | if (existingMultiplicityQuery !== null) { | 63 | if (existingMultiplicityQuery !== null) { |
@@ -70,13 +71,13 @@ class UnifinishedMultiplicityQueries { | |||
70 | } | 71 | } |
71 | 72 | ||
72 | class PatternProvider { | 73 | class PatternProvider { |
73 | |||
74 | val TypeAnalysis typeAnalysis = new TypeAnalysis | 74 | val TypeAnalysis typeAnalysis = new TypeAnalysis |
75 | 75 | ||
76 | def generateQueries(LogicProblem problem, PartialInterpretation emptySolution, ModelGenerationStatistics statistics, | 76 | def generateQueries(LogicProblem problem, PartialInterpretation emptySolution, ModelGenerationStatistics statistics, |
77 | Set<PQuery> existingQueries, ReasonerWorkspace workspace, TypeInferenceMethod typeInferenceMethod, | 77 | Set<PQuery> existingQueries, ReasonerWorkspace workspace, TypeInferenceMethod typeInferenceMethod, |
78 | ScopePropagatorStrategy scopePropagatorStrategy, RelationConstraints relationConstraints, | 78 | ScopePropagatorStrategy scopePropagatorStrategy, RelationConstraints relationConstraints, |
79 | Collection<LinearTypeConstraintHint> hints, boolean writeToFile) { | 79 | Collection<LinearTypeConstraintHint> hints, |
80 | Collection<UnitPropagationPatternGenerator> unitPropagationPatternGenerators, boolean writeToFile) { | ||
80 | val fqn2Query = existingQueries.toMap[it.fullyQualifiedName] | 81 | val fqn2Query = existingQueries.toMap[it.fullyQualifiedName] |
81 | val PatternGenerator patternGenerator = new PatternGenerator(typeInferenceMethod, scopePropagatorStrategy) | 82 | val PatternGenerator patternGenerator = new PatternGenerator(typeInferenceMethod, scopePropagatorStrategy) |
82 | val typeAnalysisResult = if (patternGenerator.requiresTypeAnalysis) { | 83 | val typeAnalysisResult = if (patternGenerator.requiresTypeAnalysis) { |
@@ -89,15 +90,16 @@ class PatternProvider { | |||
89 | null | 90 | null |
90 | } | 91 | } |
91 | val patternGeneratorResult = patternGenerator.transformBaseProperties(problem, emptySolution, fqn2Query, | 92 | val patternGeneratorResult = patternGenerator.transformBaseProperties(problem, emptySolution, fqn2Query, |
92 | typeAnalysisResult, relationConstraints, hints) | 93 | typeAnalysisResult, relationConstraints, hints, unitPropagationPatternGenerators) |
93 | if (writeToFile) { | 94 | if (writeToFile) { |
94 | workspace.writeText('''generated3valued.vql_deactivated''', patternGeneratorResult.patternText) | 95 | workspace.writeText('''generated3valued.vql_deactivated''', patternGeneratorResult.patternText) |
95 | } | 96 | } |
96 | val ParseUtil parseUtil = new ParseUtil | 97 | val ParseUtil parseUtil = new ParseUtil |
97 | val generatedQueries = parseUtil.parse(patternGeneratorResult.patternText) | 98 | val generatedQueries = parseUtil.parse(patternGeneratorResult.patternText) |
98 | val runtimeQueries = calclulateRuntimeQueries(patternGenerator, problem, emptySolution, typeAnalysisResult, | 99 | val runtimeQueries = calclulateRuntimeQueries(patternGenerator, problem, emptySolution, typeAnalysisResult, |
99 | patternGeneratorResult.constraint2MustPreconditionName, patternGeneratorResult.constraint2CurrentPreconditionName, | 100 | patternGeneratorResult.constraint2MustPreconditionName, |
100 | relationConstraints, generatedQueries) | 101 | patternGeneratorResult.constraint2CurrentPreconditionName, relationConstraints, |
102 | unitPropagationPatternGenerators, generatedQueries) | ||
101 | return runtimeQueries | 103 | return runtimeQueries |
102 | } | 104 | } |
103 | 105 | ||
@@ -109,14 +111,16 @@ class PatternProvider { | |||
109 | HashMap<PConstraint, String> mustUnitPropagationTrace, | 111 | HashMap<PConstraint, String> mustUnitPropagationTrace, |
110 | HashMap<PConstraint, String> currentUnitPropagationTrace, | 112 | HashMap<PConstraint, String> currentUnitPropagationTrace, |
111 | RelationConstraints relationConstraints, | 113 | RelationConstraints relationConstraints, |
114 | Collection<UnitPropagationPatternGenerator> unitPropagationPatternGenerators, | ||
112 | Map<String, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> queries | 115 | Map<String, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> queries |
113 | ) { | 116 | ) { |
114 | val Map<Relation, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> | 117 | val Map<Relation, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> invalidWFQueries = patternGenerator. |
115 | invalidWFQueries = patternGenerator.invalidIndexer.getInvalidateByWfQueryNames(problem).mapValues[it.lookup(queries)] | 118 | invalidIndexer.getInvalidateByWfQueryNames(problem).mapValues[it.lookup(queries)] |
116 | val Map<Relation, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> | 119 | val Map<Relation, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> unfinishedWFQueries = patternGenerator. |
117 | unfinishedWFQueries = patternGenerator.unfinishedIndexer.getUnfinishedWFQueryNames(problem).mapValues[it.lookup(queries)] | 120 | unfinishedIndexer.getUnfinishedWFQueryNames(problem).mapValues[it.lookup(queries)] |
118 | 121 | ||
119 | val unfinishedMultiplicities = patternGenerator.unfinishedIndexer.getUnfinishedMultiplicityQueries(relationConstraints.multiplicityConstraints) | 122 | val unfinishedMultiplicities = patternGenerator.unfinishedIndexer.getUnfinishedMultiplicityQueries( |
123 | relationConstraints.multiplicityConstraints) | ||
120 | val multiplicityConstraintQueries = unfinishedMultiplicities.mapValues [ | 124 | val multiplicityConstraintQueries = unfinishedMultiplicities.mapValues [ |
121 | new UnifinishedMultiplicityQueries(existingMultiplicityQueryName?.lookup(queries), | 125 | new UnifinishedMultiplicityQueries(existingMultiplicityQueryName?.lookup(queries), |
122 | existingInverseMultiplicityQueryName?.lookup(queries)) | 126 | existingInverseMultiplicityQueryName?.lookup(queries)) |
@@ -124,16 +128,22 @@ class PatternProvider { | |||
124 | val hasElementInContainmentQuery = patternGenerator.typeRefinementGenerator.hasElementInContainmentName.lookup( | 128 | val hasElementInContainmentQuery = patternGenerator.typeRefinementGenerator.hasElementInContainmentName.lookup( |
125 | queries) | 129 | queries) |
126 | 130 | ||
127 | val Map<ObjectCreationPrecondition, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> | 131 | val Map<ObjectCreationPrecondition, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> refineObjectsQueries = patternGenerator. |
128 | refineObjectsQueries = patternGenerator.typeRefinementGenerator.getRefineObjectQueryNames(problem,emptySolution,typeAnalysisResult).mapValues[it.lookup(queries)] | 132 | typeRefinementGenerator.getRefineObjectQueryNames(problem, emptySolution, typeAnalysisResult).mapValues [ |
129 | val Map<? extends Type, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> | 133 | it.lookup(queries) |
130 | refineTypeQueries = patternGenerator.typeRefinementGenerator.getRefineTypeQueryNames(problem,emptySolution,typeAnalysisResult).mapValues[it.lookup(queries)] | 134 | ] |
131 | val Map<Pair<RelationDeclaration, Relation>, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> | 135 | val Map<? extends Type, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> refineTypeQueries = patternGenerator. |
132 | refineRelationQueries = patternGenerator.relationRefinementGenerator.getRefineRelationQueries(problem).mapValues[it.lookup(queries)] | 136 | typeRefinementGenerator.getRefineTypeQueryNames(problem, emptySolution, typeAnalysisResult).mapValues [ |
133 | val Map<PConstraint, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> | 137 | it.lookup(queries) |
134 | mustUnitPropagationPreconditionPatterns = mustUnitPropagationTrace.mapValues[it.lookup(queries)] | 138 | ] |
135 | val Map<PConstraint, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> | 139 | val Map<Pair<RelationDeclaration, Relation>, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> refineRelationQueries = patternGenerator. |
136 | currentUnitPropagationPreconditionPatterns = currentUnitPropagationTrace.mapValues[it.lookup(queries)] | 140 | relationRefinementGenerator.getRefineRelationQueries(problem).mapValues[it.lookup(queries)] |
141 | val Map<Pair<RelationDeclaration, Relation>, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> mustRelationPropagationQueries = patternGenerator. | ||
142 | relationRefinementGenerator.getMustPropagationQueries(problem, unitPropagationPatternGenerators).mapValues[it.lookup(queries)] | ||
143 | val Map<PConstraint, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> mustUnitPropagationPreconditionPatterns = mustUnitPropagationTrace. | ||
144 | mapValues[it.lookup(queries)] | ||
145 | val Map<PConstraint, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> currentUnitPropagationPreconditionPatterns = currentUnitPropagationTrace. | ||
146 | mapValues[it.lookup(queries)] | ||
137 | 147 | ||
138 | val modalRelationQueries = problem.relations.filter(RelationDefinition).toMap([it], [ relationDefinition | | 148 | val modalRelationQueries = problem.relations.filter(RelationDefinition).toMap([it], [ relationDefinition | |
139 | val indexer = patternGenerator.relationDefinitionIndexer | 149 | val indexer = patternGenerator.relationDefinitionIndexer |
@@ -143,7 +153,7 @@ class PatternProvider { | |||
143 | indexer.relationDefinitionName(relationDefinition, Modality.CURRENT).lookup(queries) | 153 | indexer.relationDefinitionName(relationDefinition, Modality.CURRENT).lookup(queries) |
144 | ) | 154 | ) |
145 | ]) | 155 | ]) |
146 | 156 | ||
147 | return new GeneratedPatterns( | 157 | return new GeneratedPatterns( |
148 | invalidWFQueries, | 158 | invalidWFQueries, |
149 | unfinishedWFQueries, | 159 | unfinishedWFQueries, |
@@ -152,6 +162,7 @@ class PatternProvider { | |||
152 | refineObjectsQueries, | 162 | refineObjectsQueries, |
153 | refineTypeQueries, | 163 | refineTypeQueries, |
154 | refineRelationQueries, | 164 | refineRelationQueries, |
165 | mustRelationPropagationQueries, | ||
155 | mustUnitPropagationPreconditionPatterns, | 166 | mustUnitPropagationPreconditionPatterns, |
156 | currentUnitPropagationPreconditionPatterns, | 167 | currentUnitPropagationPreconditionPatterns, |
157 | modalRelationQueries, | 168 | modalRelationQueries, |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDeclarationIndexer.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDeclarationIndexer.xtend index b4403979..23ba3cad 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDeclarationIndexer.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDeclarationIndexer.xtend | |||
@@ -1,10 +1,13 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns |
2 | 2 | ||
3 | import com.google.common.collect.ImmutableMap | ||
4 | import com.google.common.collect.ImmutableSet | ||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.UpperMultiplicityAssertion | 5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.UpperMultiplicityAssertion |
4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration | 7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration |
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | 8 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem |
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality | 9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality |
10 | import java.util.Collection | ||
8 | import java.util.HashMap | 11 | import java.util.HashMap |
9 | import java.util.List | 12 | import java.util.List |
10 | import java.util.Map | 13 | import java.util.Map |
@@ -14,41 +17,40 @@ import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | |||
14 | 17 | ||
15 | class RelationDeclarationIndexer { | 18 | class RelationDeclarationIndexer { |
16 | val PatternGenerator base; | 19 | val PatternGenerator base; |
17 | 20 | ||
18 | new(PatternGenerator base) { | 21 | new(PatternGenerator base) { |
19 | this.base = base | 22 | this.base = base |
20 | } | 23 | } |
21 | 24 | ||
22 | def generateRelationIndexers(LogicProblem problem, Iterable<RelationDeclaration> relations, Map<String,PQuery> fqn2PQuery) { | 25 | def generateRelationIndexers(LogicProblem problem, Iterable<RelationDeclaration> relations, |
26 | Iterable<UnitPropagationPatternGenerator> unitPropagationPatternGenerators, Map<String, PQuery> fqn2PQuery) { | ||
23 | val upperMultiplicities = new HashMap | 27 | val upperMultiplicities = new HashMap |
24 | problem.annotations.filter(UpperMultiplicityAssertion).forEach[ | 28 | problem.annotations.filter(UpperMultiplicityAssertion).forEach [ |
25 | upperMultiplicities.put(it.relation,it.upper) | 29 | upperMultiplicities.put(it.relation, it.upper) |
26 | ] | 30 | ] |
27 | 31 | val mustNotRelations = ImmutableMap.copyOf(unitPropagationPatternGenerators.flatMap[mustNotPatterns.entrySet]. | |
32 | groupBy[key].mapValues[ImmutableSet.copyOf(map[value])]) | ||
33 | |||
28 | return ''' | 34 | return ''' |
29 | «FOR relation : relations» | 35 | «FOR relation : relations» |
30 | «IF base.isDerived(relation)» | 36 | «IF base.isDerived(relation)» |
31 | «generateDerivedMustRelation(problem,relation,base.getDerivedDefinition(relation).patternFullyQualifiedName.lookup(fqn2PQuery))» | 37 | «generateDerivedMustRelation(problem,relation,base.getDerivedDefinition(relation).patternFullyQualifiedName.lookup(fqn2PQuery))» |
32 | «generateDerivedMayRelation(problem,relation,base.getDerivedDefinition(relation).patternFullyQualifiedName.lookup(fqn2PQuery))» | 38 | «generateDerivedMayRelation(problem,relation,base.getDerivedDefinition(relation).patternFullyQualifiedName.lookup(fqn2PQuery))» |
33 | «ELSE» | 39 | «ELSE» |
34 | «generateMustRelation(problem,relation)» | 40 | «generateMustRelation(problem, relation)» |
35 | «generateMayRelation(problem,relation,upperMultiplicities,base.getContainments(problem),base.getInverseRelations(problem),fqn2PQuery)» | 41 | «generateMayRelation(problem, relation, upperMultiplicities, base.getContainments(problem), base.getInverseRelations(problem), mustNotRelations.get(relation) ?: emptySet, fqn2PQuery)» |
36 | «ENDIF» | 42 | «ENDIF» |
37 | «ENDFOR» | 43 | «ENDFOR» |
38 | ''' | 44 | ''' |
39 | } | 45 | } |
40 | 46 | ||
41 | def private patternName(RelationDeclaration r, Modality modality) { | 47 | def private patternName(RelationDeclaration r, Modality modality) { |
42 | '''«modality.name.toLowerCase»InRelation«base.canonizeName(r.name)»''' | 48 | '''«modality.name.toLowerCase»InRelation«base.canonizeName(r.name)»''' |
43 | } | 49 | } |
44 | 50 | ||
45 | def referRelation( | 51 | def referRelation(RelationDeclaration referred, String sourceVariable, String targetVariable, |
46 | RelationDeclaration referred, | 52 | Modality modality) '''find «referred.patternName(modality)»(problem,interpretation,«sourceVariable»,«targetVariable»);''' |
47 | String sourceVariable, | 53 | |
48 | String targetVariable, | ||
49 | Modality modality) | ||
50 | '''find «referred.patternName(modality)»(problem,interpretation,«sourceVariable»,«targetVariable»);''' | ||
51 | |||
52 | def generateMustRelation(LogicProblem problem, RelationDeclaration relation) ''' | 54 | def generateMustRelation(LogicProblem problem, RelationDeclaration relation) ''' |
53 | /** | 55 | /** |
54 | * Matcher for detecting tuples t where []«relation.name»(source,target) | 56 | * Matcher for detecting tuples t where []«relation.name»(source,target) |
@@ -65,59 +67,64 @@ class RelationDeclarationIndexer { | |||
65 | BinaryElementRelationLink.param2(link,target); | 67 | BinaryElementRelationLink.param2(link,target); |
66 | } | 68 | } |
67 | ''' | 69 | ''' |
70 | |||
68 | def generateMayRelation(LogicProblem problem, RelationDeclaration relation, | 71 | def generateMayRelation(LogicProblem problem, RelationDeclaration relation, |
69 | Map<Relation, Integer> upperMultiplicities, | 72 | Map<Relation, Integer> upperMultiplicities, List<Relation> containments, |
70 | List<Relation> containments, | 73 | HashMap<Relation, Relation> inverseRelations, Collection<String> mustNotRelations, |
71 | HashMap<Relation, Relation> inverseRelations, | 74 | Map<String, PQuery> fqn2PQuery) { |
72 | Map<String,PQuery> fqn2PQuery) | ||
73 | { | ||
74 | return ''' | 75 | return ''' |
75 | /** | 76 | /** |
76 | * Matcher for detecting tuples t where <>«relation.name»(source,target) | 77 | * Matcher for detecting tuples t where <>«relation.name»(source,target) |
77 | */ | 78 | */ |
78 | private pattern «relation.patternName(Modality.MAY)»( | 79 | private pattern «relation.patternName(Modality.MAY)»( |
79 | problem:LogicProblem, interpretation:PartialInterpretation, | 80 | problem:LogicProblem, interpretation:PartialInterpretation, |
80 | source: DefinedElement, target:DefinedElement) | 81 | source: DefinedElement, target:DefinedElement) |
81 | { | 82 | { |
82 | find interpretation(problem,interpretation); | 83 | find interpretation(problem,interpretation); |
83 | // The two endpoint of the link have to exist | 84 | // The two endpoint of the link have to exist |
84 | find mayExist(problem, interpretation, source); | 85 | find mayExist(problem, interpretation, source); |
85 | find mayExist(problem, interpretation, target); | 86 | find mayExist(problem, interpretation, target); |
86 | // Type consistency | 87 | // Type consistency |
87 | «base.typeIndexer.referInstanceOfByReference(relation.parameters.get(0),Modality.MAY,"source")» | 88 | «base.typeIndexer.referInstanceOfByReference(relation.parameters.get(0),Modality.MAY,"source")» |
88 | «base.typeIndexer.referInstanceOfByReference(relation.parameters.get(1),Modality.MAY,"target")» | 89 | «base.typeIndexer.referInstanceOfByReference(relation.parameters.get(1),Modality.MAY,"target")» |
89 | «IF upperMultiplicities.containsKey(relation)» | 90 | «IF upperMultiplicities.containsKey(relation)» |
90 | // There are "numberOfExistingReferences" currently existing instances of the reference from the source, | 91 | // There are "numberOfExistingReferences" currently existing instances of the reference from the source, |
91 | // the upper bound of the multiplicity should be considered. | 92 | // the upper bound of the multiplicity should be considered. |
92 | numberOfExistingReferences == count «referRelation(relation,"source","_",Modality.MUST)» | 93 | numberOfExistingReferences == count «referRelation(relation,"source","_",Modality.MUST)» |
93 | numberOfExistingReferences != «upperMultiplicities.get(relation)»; | 94 | numberOfExistingReferences != «upperMultiplicities.get(relation)»; |
94 | «ENDIF» | 95 | «ENDIF» |
95 | «IF inverseRelations.containsKey(relation) && upperMultiplicities.containsKey(inverseRelations.get(relation))» | 96 | «IF inverseRelations.containsKey(relation) && upperMultiplicities.containsKey(inverseRelations.get(relation))» |
96 | // There are "numberOfExistingReferences" currently existing instances of the reference to the target, | 97 | // There are "numberOfExistingReferences" currently existing instances of the reference to the target, |
97 | // the upper bound of the opposite reference multiplicity should be considered. | 98 | // the upper bound of the opposite reference multiplicity should be considered. |
98 | numberOfExistingOppositeReferences == count «base.referRelation(inverseRelations.get(relation),"target","_",Modality.MUST,fqn2PQuery)» | 99 | numberOfExistingOppositeReferences == count «base.referRelation(inverseRelations.get(relation),"target","_",Modality.MUST,fqn2PQuery)» |
99 | numberOfExistingOppositeReferences != «upperMultiplicities.get(inverseRelations.get(relation))»; | 100 | numberOfExistingOppositeReferences != «upperMultiplicities.get(inverseRelations.get(relation))»; |
100 | «ENDIF» | 101 | «ENDIF» |
101 | «IF containments.contains(relation)» | 102 | «IF containments.contains(relation)» |
102 | // The reference is containment, then a new reference cannot be create if: | 103 | // The reference is containment, then a new reference cannot be create if: |
103 | // 1. Multiple parents | 104 | // 1. Multiple parents |
104 | neg «base.containmentIndexer.referMustContaint("_","target")» | 105 | neg «base.containmentIndexer.referMustContaint("_","target")» |
105 | // 2. Circle in the containment hierarchy | 106 | // 2. Circle in the containment hierarchy |
106 | neg «base.containmentIndexer.referTransitiveMustContains("target","source")» | 107 | neg «base.containmentIndexer.referTransitiveMustContains("target","source")» |
107 | «ENDIF» | 108 | «ENDIF» |
108 | «IF inverseRelations.containsKey(relation) && containments.contains(inverseRelations.get(relation))» | 109 | «IF inverseRelations.containsKey(relation) && containments.contains(inverseRelations.get(relation))» |
109 | // The eOpposite of the reference is containment, then a referene cannot be created if | 110 | // The eOpposite of the reference is containment, then a referene cannot be created if |
110 | // 1. Multiple parents | 111 | // 1. Multiple parents |
111 | neg «base.containmentIndexer.referMustContaint("source","_")» | 112 | neg «base.containmentIndexer.referMustContaint("source","_")» |
112 | // 2. Circle in the containment hierarchy | 113 | // 2. Circle in the containment hierarchy |
113 | neg «base.containmentIndexer.referTransitiveMustContains("source","target")» | 114 | neg «base.containmentIndexer.referTransitiveMustContains("source","target")» |
114 | «ENDIF» | 115 | «ENDIF» |
115 | } or { | 116 | «IF !mustNotRelations.empty» |
116 | «relation.referRelation("source","target",Modality.MUST)» | 117 | // ![] unit propagation relations |
117 | } | 118 | «FOR mustNotRelation : mustNotRelations» |
118 | ''' | 119 | neg find «mustNotRelation»(problem, interpretation, source, target); |
120 | «ENDFOR» | ||
121 | «ENDIF» | ||
122 | } or { | ||
123 | «relation.referRelation("source","target",Modality.MUST)» | ||
124 | } | ||
125 | ''' | ||
119 | } | 126 | } |
120 | 127 | ||
121 | def generateDerivedMustRelation(LogicProblem problem, RelationDeclaration relation, PQuery definition) ''' | 128 | def generateDerivedMustRelation(LogicProblem problem, RelationDeclaration relation, PQuery definition) ''' |
122 | /** | 129 | /** |
123 | * Matcher for detecting tuples t where []«relation.name»(source,target) | 130 | * Matcher for detecting tuples t where []«relation.name»(source,target) |
@@ -129,6 +136,7 @@ class RelationDeclarationIndexer { | |||
129 | «base.relationDefinitionIndexer.referPattern(definition,#["source","target"],Modality::MUST,true,false)» | 136 | «base.relationDefinitionIndexer.referPattern(definition,#["source","target"],Modality::MUST,true,false)» |
130 | } | 137 | } |
131 | ''' | 138 | ''' |
139 | |||
132 | def generateDerivedMayRelation(LogicProblem problem, RelationDeclaration relation, PQuery definition) ''' | 140 | def generateDerivedMayRelation(LogicProblem problem, RelationDeclaration relation, PQuery definition) ''' |
133 | /** | 141 | /** |
134 | * Matcher for detecting tuples t where []«relation.name»(source,target) | 142 | * Matcher for detecting tuples t where []«relation.name»(source,target) |
@@ -140,4 +148,4 @@ class RelationDeclarationIndexer { | |||
140 | «base.relationDefinitionIndexer.referPattern(definition,#["source","target"],Modality::MAY,true,false)» | 148 | «base.relationDefinitionIndexer.referPattern(definition,#["source","target"],Modality::MAY,true,false)» |
141 | } | 149 | } |
142 | ''' | 150 | ''' |
143 | } \ No newline at end of file | 151 | } |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend index 783cd36b..6f5f2402 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend | |||
@@ -1,10 +1,17 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns |
2 | 2 | ||
3 | import com.google.common.collect.ImmutableList | ||
4 | import com.google.common.collect.ImmutableMap | ||
5 | import com.google.common.collect.ImmutableSet | ||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation |
4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration | 7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | 8 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem |
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality | 9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality |
10 | import java.util.Collection | ||
7 | import java.util.LinkedList | 11 | import java.util.LinkedList |
12 | import java.util.Map | ||
13 | import java.util.Set | ||
14 | import org.eclipse.xtend2.lib.StringConcatenationClient | ||
8 | 15 | ||
9 | class RelationRefinementGenerator { | 16 | class RelationRefinementGenerator { |
10 | PatternGenerator base; | 17 | PatternGenerator base; |
@@ -13,53 +20,61 @@ class RelationRefinementGenerator { | |||
13 | this.base = base | 20 | this.base = base |
14 | } | 21 | } |
15 | 22 | ||
16 | def CharSequence generateRefineReference(LogicProblem p) ''' | 23 | def CharSequence generateRefineReference(LogicProblem p, |
17 | «FOR relationRefinement : this.getRelationRefinements(p)» | 24 | Collection<UnitPropagationPatternGenerator> unitPropagationPatternGenerators) { |
18 | pattern «relationRefinementQueryName(relationRefinement.key,relationRefinement.value)»( | 25 | val mustRelations = getMustRelations(unitPropagationPatternGenerators) |
19 | problem:LogicProblem, interpretation:PartialInterpretation, | 26 | |
20 | relationIterpretation:PartialRelationInterpretation«IF relationRefinement.value !== null», oppositeInterpretation:PartialRelationInterpretation«ENDIF», | 27 | ''' |
21 | from: DefinedElement, to: DefinedElement) | 28 | «FOR relationRefinement : this.getRelationRefinements(p)» |
22 | { | 29 | pattern «relationRefinementQueryName(relationRefinement.key,relationRefinement.value)»( |
23 | find interpretation(problem,interpretation); | 30 | problem:LogicProblem, interpretation:PartialInterpretation, |
24 | PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation); | 31 | relationIterpretation:PartialRelationInterpretation«IF relationRefinement.value !== null», oppositeInterpretation:PartialRelationInterpretation«ENDIF», |
25 | PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"«relationRefinement.key.name»"); | 32 | from: DefinedElement, to: DefinedElement) |
26 | «IF relationRefinement.value !== null» | 33 | { |
27 | PartialInterpretation.partialrelationinterpretation(interpretation,oppositeInterpretation); | 34 | find interpretation(problem,interpretation); |
28 | PartialRelationInterpretation.interpretationOf.name(oppositeInterpretation,"«relationRefinement.value.name»"); | 35 | PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation); |
36 | PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"«relationRefinement.key.name»"); | ||
37 | «IF relationRefinement.value !== null» | ||
38 | PartialInterpretation.partialrelationinterpretation(interpretation,oppositeInterpretation); | ||
39 | PartialRelationInterpretation.interpretationOf.name(oppositeInterpretation,"«relationRefinement.value.name»"); | ||
40 | «ENDIF» | ||
41 | find mustExist(problem, interpretation, from); | ||
42 | find mustExist(problem, interpretation, to); | ||
43 | «base.typeIndexer.referInstanceOfByReference(relationRefinement.key.parameters.get(0), Modality::MUST,"from")» | ||
44 | «base.typeIndexer.referInstanceOfByReference(relationRefinement.key.parameters.get(1), Modality::MUST,"to")» | ||
45 | «base.relationDeclarationIndexer.referRelation(relationRefinement.key,"from","to",Modality.MAY)» | ||
46 | neg «base.relationDeclarationIndexer.referRelation(relationRefinement.key,"from","to",Modality.MUST)» | ||
47 | } | ||
48 | |||
49 | «IF isMustPropagationQueryNeeded(relationRefinement.key, relationRefinement.value, mustRelations)» | ||
50 | pattern «mustPropagationQueryName(relationRefinement.key)»( | ||
51 | problem:LogicProblem, interpretation:PartialInterpretation, | ||
52 | relationIterpretation:PartialRelationInterpretation«IF relationRefinement.value !== null», oppositeInterpretation:PartialRelationInterpretation«ENDIF», | ||
53 | from: DefinedElement, to: DefinedElement) | ||
54 | «FOR body : getMustPropagationBodies(relationRefinement.key, relationRefinement.value, mustRelations) SEPARATOR " or "» | ||
55 | { | ||
56 | «referRefinementQuery(relationRefinement.key, relationRefinement.value, "relationIterpretation", "oppositeInterpretation", "from", "to")» | ||
57 | «body» | ||
58 | } | ||
59 | «ENDFOR» | ||
29 | «ENDIF» | 60 | «ENDIF» |
30 | find mustExist(problem, interpretation, from); | 61 | «ENDFOR» |
31 | find mustExist(problem, interpretation, to); | 62 | ''' |
32 | «base.typeIndexer.referInstanceOfByReference(relationRefinement.key.parameters.get(0), Modality::MUST,"from")» | 63 | } |
33 | «base.typeIndexer.referInstanceOfByReference(relationRefinement.key.parameters.get(1), Modality::MUST,"to")» | ||
34 | «base.relationDeclarationIndexer.referRelation(relationRefinement.key,"from","to",Modality.MAY)» | ||
35 | neg «base.relationDeclarationIndexer.referRelation(relationRefinement.key,"from","to",Modality.MUST)» | ||
36 | } | ||
37 | «ENDFOR» | ||
38 | ''' | ||
39 | 64 | ||
40 | def String relationRefinementQueryName(RelationDeclaration relation, Relation inverseRelation) { | 65 | def String relationRefinementQueryName(RelationDeclaration relation, Relation inverseRelation) { |
41 | '''«IF inverseRelation !== null»refineRelation_«base.canonizeName(relation.name)»_and_«base.canonizeName(inverseRelation.name)»«ELSE»refineRelation_«base.canonizeName(relation.name)»«ENDIF»''' | 66 | '''«IF inverseRelation !== null»refineRelation_«base.canonizeName(relation.name)»_and_«base.canonizeName(inverseRelation.name)»«ELSE»refineRelation_«base.canonizeName(relation.name)»«ENDIF»''' |
42 | } | 67 | } |
43 | 68 | ||
69 | def String mustPropagationQueryName(RelationDeclaration relation) { | ||
70 | '''mustPropagation_«base.canonizeName(relation.name)»''' | ||
71 | } | ||
72 | |||
44 | def referRefinementQuery(RelationDeclaration relation, Relation inverseRelation, String relInterpretationName, | 73 | def referRefinementQuery(RelationDeclaration relation, Relation inverseRelation, String relInterpretationName, |
45 | String inverseInterpretationName, String sourceName, | 74 | String inverseInterpretationName, String sourceName, |
46 | String targetName) '''find «this.relationRefinementQueryName(relation,inverseRelation)»(problem, interpretation, «relInterpretationName», «IF inverseRelation !== null»«inverseInterpretationName», «ENDIF»«sourceName», «targetName»);''' | 75 | String targetName) '''find «this.relationRefinementQueryName(relation,inverseRelation)»(problem, interpretation, «relInterpretationName», «IF inverseRelation !== null»«inverseInterpretationName», «ENDIF»«sourceName», «targetName»);''' |
47 | 76 | ||
48 | def getRefineRelationQueries(LogicProblem p) { | 77 | def getRefineRelationQueries(LogicProblem p) { |
49 | // val containmentRelations = p.containmentHierarchies.map[containmentRelations].flatten.toSet | ||
50 | // p.relations.filter(RelationDeclaration).filter[!containmentRelations.contains(it)].toInvertedMap['''refineRelation_«base.canonizeName(it.name)»'''] | ||
51 | /* | ||
52 | * val res = new LinkedHashMap | ||
53 | * for(relation: getRelationRefinements(p)) { | ||
54 | * if(inverseRelations.containsKey(relation)) { | ||
55 | * val name = '''refineRelation_«base.canonizeName(relation.name)»_and_«base.canonizeName(inverseRelations.get(relation).name)»''' | ||
56 | * res.put(relation -> inverseRelations.get(relation),name) | ||
57 | * } else { | ||
58 | * val name = '''refineRelation_«base.canonizeName(relation.name)»''' | ||
59 | * res.put(relation -> null,name) | ||
60 | * } | ||
61 | * } | ||
62 | return res*/ | ||
63 | getRelationRefinements(p).toInvertedMap[relationRefinementQueryName(it.key, it.value)] | 78 | getRelationRefinements(p).toInvertedMap[relationRefinementQueryName(it.key, it.value)] |
64 | } | 79 | } |
65 | 80 | ||
@@ -83,4 +98,54 @@ class RelationRefinementGenerator { | |||
83 | } | 98 | } |
84 | return list | 99 | return list |
85 | } | 100 | } |
101 | |||
102 | def getMustPropagationQueries(LogicProblem p, | ||
103 | Collection<UnitPropagationPatternGenerator> unitPropagationPatternGenerators) { | ||
104 | val refinements = getRelationRefinements(p) | ||
105 | val mustRelations = getMustRelations(unitPropagationPatternGenerators) | ||
106 | refinements.filter[isMustPropagationQueryNeeded(key, value, mustRelations)].toInvertedMap [ | ||
107 | mustPropagationQueryName(key) | ||
108 | ] | ||
109 | } | ||
110 | |||
111 | private def getMustRelations(Collection<UnitPropagationPatternGenerator> unitPropagationPatternGenerators) { | ||
112 | ImmutableMap.copyOf(unitPropagationPatternGenerators.flatMap[mustPatterns.entrySet].groupBy[key].mapValues [ | ||
113 | ImmutableSet.copyOf(map[value]) | ||
114 | ]) | ||
115 | } | ||
116 | |||
117 | private def isMustPropagationQueryNeeded(Relation relation, Relation inverseRelation, | ||
118 | Map<Relation, ? extends Set<String>> mustRelations) { | ||
119 | val mustSet = mustRelations.get(relation) | ||
120 | if (mustSet !== null && !mustSet.empty) { | ||
121 | return true | ||
122 | } | ||
123 | if (inverseRelation !== null) { | ||
124 | val inverseMustSet = mustRelations.get(inverseRelation) | ||
125 | if (inverseMustSet !== null && !inverseMustSet.empty) { | ||
126 | return true | ||
127 | } | ||
128 | } | ||
129 | false | ||
130 | } | ||
131 | |||
132 | private def getMustPropagationBodies(Relation relation, Relation inverseRelation, | ||
133 | Map<Relation, ? extends Set<String>> mustRelations) { | ||
134 | val builder = ImmutableList.<StringConcatenationClient>builder() | ||
135 | val mustSet = mustRelations.get(relation) | ||
136 | if (mustSet !== null) { | ||
137 | for (refinementQuery : mustSet) { | ||
138 | builder.add('''find «refinementQuery»(problem, interpretation, from, to);''') | ||
139 | } | ||
140 | } | ||
141 | if (inverseRelation !== null && inverseRelation != relation) { | ||
142 | val inverseMustSet = mustRelations.get(inverseRelation) | ||
143 | if (inverseMustSet !== null) { | ||
144 | for (refinementQuery : inverseMustSet) { | ||
145 | builder.add('''find «refinementQuery»(problem, interpretation, to, from);''') | ||
146 | } | ||
147 | } | ||
148 | } | ||
149 | builder.build | ||
150 | } | ||
86 | } | 151 | } |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend index f7fe97a3..dca10baf 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend | |||
@@ -1,5 +1,6 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.rules | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.rules |
2 | 2 | ||
3 | import com.google.common.collect.ImmutableList | ||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion | 4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion |
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.LowerMultiplicityAssertion | 5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.LowerMultiplicityAssertion |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolTypeReference | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolTypeReference |
@@ -29,12 +30,14 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.par | |||
29 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationFactory | 30 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationFactory |
30 | import java.lang.reflect.Field | 31 | import java.lang.reflect.Field |
31 | import java.util.HashMap | 32 | import java.util.HashMap |
33 | import java.util.Iterator | ||
32 | import java.util.LinkedHashMap | 34 | import java.util.LinkedHashMap |
33 | import java.util.LinkedList | 35 | import java.util.LinkedList |
34 | import java.util.List | 36 | import java.util.List |
35 | import java.util.Map | 37 | import java.util.Map |
36 | import org.eclipse.viatra.query.runtime.api.AdvancedViatraQueryEngine | 38 | import org.eclipse.viatra.query.runtime.api.AdvancedViatraQueryEngine |
37 | import org.eclipse.viatra.query.runtime.api.GenericPatternMatch | 39 | import org.eclipse.viatra.query.runtime.api.GenericPatternMatch |
40 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | ||
38 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification | 41 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification |
39 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine | 42 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine |
40 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | 43 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher |
@@ -43,6 +46,7 @@ import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory | |||
43 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRule | 46 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRule |
44 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRuleFactory | 47 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRuleFactory |
45 | import org.eclipse.xtend.lib.annotations.Data | 48 | import org.eclipse.xtend.lib.annotations.Data |
49 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor | ||
46 | import org.eclipse.xtext.xbase.lib.Functions.Function0 | 50 | import org.eclipse.xtext.xbase.lib.Functions.Function0 |
47 | 51 | ||
48 | class RefinementRuleProvider { | 52 | class RefinementRuleProvider { |
@@ -50,57 +54,55 @@ class RefinementRuleProvider { | |||
50 | val extension PartialinterpretationFactory factory2 = PartialinterpretationFactory.eINSTANCE | 54 | val extension PartialinterpretationFactory factory2 = PartialinterpretationFactory.eINSTANCE |
51 | val extension LogiclanguageFactory factory3 = LogiclanguageFactory.eINSTANCE | 55 | val extension LogiclanguageFactory factory3 = LogiclanguageFactory.eINSTANCE |
52 | 56 | ||
53 | var AdvancedViatraQueryEngine queryEngine | ||
54 | var Field delayMessageDelivery | ||
55 | |||
56 | def canonizeName(String name) { | 57 | def canonizeName(String name) { |
57 | return name.replace(' ', '_') | 58 | return name.replace(' ', '_') |
58 | } | 59 | } |
59 | 60 | ||
61 | def createUnitPrulePropagator(LogicProblem p, PartialInterpretation i, GeneratedPatterns patterns, | ||
62 | ScopePropagator scopePropagator, ModelGenerationStatistics statistics) { | ||
63 | new UnitRulePropagator(p, i, this, scopePropagator, patterns.mustRelationPropagationQueries, statistics) | ||
64 | } | ||
65 | |||
60 | def LinkedHashMap<ObjectCreationPrecondition, BatchTransformationRule<GenericPatternMatch, ViatraQueryMatcher<GenericPatternMatch>>> createObjectRefinementRules( | 66 | def LinkedHashMap<ObjectCreationPrecondition, BatchTransformationRule<GenericPatternMatch, ViatraQueryMatcher<GenericPatternMatch>>> createObjectRefinementRules( |
61 | LogicProblem p, | 67 | LogicProblem p, |
62 | PartialInterpretation i, | 68 | PartialInterpretation i, |
63 | GeneratedPatterns patterns, | 69 | GeneratedPatterns patterns, |
64 | ScopePropagator scopePropagator, | 70 | UnitRulePropagator unitRulePropagator, |
65 | boolean nameNewElement, | 71 | boolean nameNewElement, |
66 | ModelGenerationStatistics statistics | 72 | ModelGenerationStatistics statistics |
67 | ) { | 73 | ) { |
68 | val res = new LinkedHashMap | 74 | val res = new LinkedHashMap |
69 | val recursiveObjectCreation = recursiveObjectCreation(p, i) | 75 | val recursiveObjectCreation = recursiveObjectCreation(p, i) |
70 | queryEngine = ViatraQueryEngine.on(new EMFScope(i)) as AdvancedViatraQueryEngine | ||
71 | delayMessageDelivery = queryEngine.class.getDeclaredField("delayMessageDelivery") | ||
72 | delayMessageDelivery.accessible = true | ||
73 | for (LHSEntry : patterns.refineObjectQueries.entrySet) { | 76 | for (LHSEntry : patterns.refineObjectQueries.entrySet) { |
74 | val containmentRelation = LHSEntry.key.containmentRelation | 77 | val containmentRelation = LHSEntry.key.containmentRelation |
75 | val inverseRelation = LHSEntry.key.inverseContainment | 78 | val inverseRelation = LHSEntry.key.inverseContainment |
76 | val type = LHSEntry.key.newType | 79 | val type = LHSEntry.key.newType |
77 | val lhs = LHSEntry.value as IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> | 80 | val lhs = LHSEntry.value as IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> |
78 | val rule = createObjectCreationRule(p, containmentRelation, inverseRelation, type, | 81 | val rule = createObjectCreationRule(p, containmentRelation, inverseRelation, type, |
79 | recursiveObjectCreation.get(type), lhs, nameNewElement, scopePropagator, statistics) | 82 | recursiveObjectCreation.get(type), lhs, nameNewElement, unitRulePropagator, statistics) |
80 | res.put(LHSEntry.key, rule) | 83 | res.put(LHSEntry.key, rule) |
81 | } | 84 | } |
82 | return res | 85 | return res |
83 | } | 86 | } |
84 | 87 | ||
85 | def private createObjectCreationRule(LogicProblem p, Relation containmentRelation, Relation inverseRelation, | 88 | def private createObjectCreationRule(LogicProblem p, Relation containmentRelation, Relation inverseRelation, |
86 | Type type, List<ObjectCreationInterpretationData> recursiceObjectCreations, | 89 | Type type, List<ObjectCreationInterpretationData> recursiveObjectCreations, |
87 | IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> lhs, boolean nameNewElement, | 90 | IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> lhs, boolean nameNewElement, |
88 | ScopePropagator scopePropagator, ModelGenerationStatistics statistics) { | 91 | UnitRulePropagator unitRulePropagator, ModelGenerationStatistics statistics) { |
89 | val name = '''addObject_«type.name.canonizeName»«IF containmentRelation!==null»_by_«containmentRelation.name.canonizeName»«ENDIF»''' | 92 | val name = '''addObject_«type.name.canonizeName»«IF containmentRelation!==null»_by_«containmentRelation.name.canonizeName»«ENDIF»''' |
90 | val ruleBuilder = factory.createRule(lhs).name(name) | 93 | val ruleBuilder = factory.createRule(lhs).name(name) |
91 | if (containmentRelation !== null) { | 94 | if (containmentRelation !== null) { |
92 | if (inverseRelation !== null) { | 95 | if (inverseRelation !== null) { |
93 | ruleBuilder.action [ match | | 96 | ruleBuilder.action [ match | |
94 | statistics.incrementTransformationCount | 97 | statistics.incrementTransformationCount |
95 | // println(name) | 98 | // println(name) |
99 | val startTime = System.nanoTime | ||
96 | // val problem = match.get(0) as LogicProblem | 100 | // val problem = match.get(0) as LogicProblem |
97 | val interpretation = match.get(1) as PartialInterpretation | 101 | val interpretation = match.get(1) as PartialInterpretation |
98 | val relationInterpretation = match.get(2) as PartialRelationInterpretation | 102 | val relationInterpretation = match.get(2) as PartialRelationInterpretation |
99 | val inverseRelationInterpretation = match.get(3) as PartialRelationInterpretation | 103 | val inverseRelationInterpretation = match.get(3) as PartialRelationInterpretation |
100 | val typeInterpretation = match.get(4) as PartialComplexTypeInterpretation | 104 | val typeInterpretation = match.get(4) as PartialComplexTypeInterpretation |
101 | val container = match.get(5) as DefinedElement | 105 | val container = match.get(5) as DefinedElement |
102 | |||
103 | val startTime = System.nanoTime | ||
104 | createObjectActionWithContainmentAndInverse( | 106 | createObjectActionWithContainmentAndInverse( |
105 | nameNewElement, | 107 | nameNewElement, |
106 | interpretation, | 108 | interpretation, |
@@ -109,29 +111,24 @@ class RefinementRuleProvider { | |||
109 | relationInterpretation, | 111 | relationInterpretation, |
110 | inverseRelationInterpretation, | 112 | inverseRelationInterpretation, |
111 | [createDefinedElement], | 113 | [createDefinedElement], |
112 | recursiceObjectCreations, | 114 | recursiveObjectCreations, |
113 | scopePropagator | 115 | unitRulePropagator |
114 | ) | 116 | ) |
115 | statistics.addExecutionTime(System.nanoTime - startTime) | 117 | statistics.addExecutionTime(System.nanoTime - startTime) |
116 | 118 | ||
117 | flushQueryEngine(scopePropagator) | 119 | unitRulePropagator.propagate |
118 | |||
119 | // Scope propagation | ||
120 | val propagatorStartTime = System.nanoTime | ||
121 | scopePropagator.propagateAllScopeConstraints() | ||
122 | statistics.addScopePropagationTime(System.nanoTime - propagatorStartTime) | ||
123 | ] | 120 | ] |
124 | } else { | 121 | } else { |
125 | ruleBuilder.action [ match | | 122 | ruleBuilder.action [ match | |
126 | statistics.incrementTransformationCount | 123 | statistics.incrementTransformationCount |
127 | // println(name) | 124 | // println(name) |
125 | val startTime = System.nanoTime | ||
128 | // val problem = match.get(0) as LogicProblem | 126 | // val problem = match.get(0) as LogicProblem |
129 | val interpretation = match.get(1) as PartialInterpretation | 127 | val interpretation = match.get(1) as PartialInterpretation |
130 | val relationInterpretation = match.get(2) as PartialRelationInterpretation | 128 | val relationInterpretation = match.get(2) as PartialRelationInterpretation |
131 | val typeInterpretation = match.get(3) as PartialComplexTypeInterpretation | 129 | val typeInterpretation = match.get(3) as PartialComplexTypeInterpretation |
132 | val container = match.get(4) as DefinedElement | 130 | val container = match.get(4) as DefinedElement |
133 | 131 | ||
134 | val startTime = System.nanoTime | ||
135 | createObjectActionWithContainment( | 132 | createObjectActionWithContainment( |
136 | nameNewElement, | 133 | nameNewElement, |
137 | interpretation, | 134 | interpretation, |
@@ -139,44 +136,34 @@ class RefinementRuleProvider { | |||
139 | container, | 136 | container, |
140 | relationInterpretation, | 137 | relationInterpretation, |
141 | [createDefinedElement], | 138 | [createDefinedElement], |
142 | recursiceObjectCreations, | 139 | recursiveObjectCreations, |
143 | scopePropagator | 140 | unitRulePropagator |
144 | ) | 141 | ) |
145 | statistics.addExecutionTime(System.nanoTime - startTime) | 142 | statistics.addExecutionTime(System.nanoTime - startTime) |
146 | 143 | ||
147 | flushQueryEngine(scopePropagator) | 144 | unitRulePropagator.propagate |
148 | |||
149 | // Scope propagation | ||
150 | val propagatorStartTime = System.nanoTime | ||
151 | scopePropagator.propagateAllScopeConstraints() | ||
152 | statistics.addScopePropagationTime(System.nanoTime - propagatorStartTime) | ||
153 | ] | 145 | ] |
154 | } | 146 | } |
155 | } else { | 147 | } else { |
156 | ruleBuilder.action [ match | | 148 | ruleBuilder.action [ match | |
157 | statistics.incrementTransformationCount | 149 | statistics.incrementTransformationCount |
158 | // println(name) | 150 | // println(name) |
151 | val startTime = System.nanoTime | ||
159 | // val problem = match.get(0) as LogicProblem | 152 | // val problem = match.get(0) as LogicProblem |
160 | val interpretation = match.get(1) as PartialInterpretation | 153 | val interpretation = match.get(1) as PartialInterpretation |
161 | val typeInterpretation = match.get(2) as PartialComplexTypeInterpretation | 154 | val typeInterpretation = match.get(2) as PartialComplexTypeInterpretation |
162 | 155 | ||
163 | val startTime = System.nanoTime | ||
164 | createObjectAction( | 156 | createObjectAction( |
165 | nameNewElement, | 157 | nameNewElement, |
166 | interpretation, | 158 | interpretation, |
167 | typeInterpretation, | 159 | typeInterpretation, |
168 | [createDefinedElement], | 160 | [createDefinedElement], |
169 | recursiceObjectCreations, | 161 | recursiveObjectCreations, |
170 | scopePropagator | 162 | unitRulePropagator |
171 | ) | 163 | ) |
172 | statistics.addExecutionTime(System.nanoTime - startTime) | 164 | statistics.addExecutionTime(System.nanoTime - startTime) |
173 | 165 | ||
174 | flushQueryEngine(scopePropagator) | 166 | unitRulePropagator.propagate |
175 | |||
176 | // Scope propagation | ||
177 | val propagatorStartTime = System.nanoTime | ||
178 | scopePropagator.propagateAllScopeConstraints() | ||
179 | statistics.addScopePropagationTime(System.nanoTime - propagatorStartTime) | ||
180 | ] | 167 | ] |
181 | } | 168 | } |
182 | return ruleBuilder.build | 169 | return ruleBuilder.build |
@@ -342,14 +329,14 @@ class RefinementRuleProvider { | |||
342 | [createStringElement] | 329 | [createStringElement] |
343 | } | 330 | } |
344 | 331 | ||
345 | def createRelationRefinementRules(GeneratedPatterns patterns, ScopePropagator scopePropagator, | 332 | def createRelationRefinementRules(GeneratedPatterns patterns, UnitRulePropagator unitRulePropagator, |
346 | ModelGenerationStatistics statistics) { | 333 | ModelGenerationStatistics statistics) { |
347 | val res = new LinkedHashMap | 334 | val res = new LinkedHashMap |
348 | for (LHSEntry : patterns.refinerelationQueries.entrySet) { | 335 | for (LHSEntry : patterns.refineRelationQueries.entrySet) { |
349 | val declaration = LHSEntry.key.key | 336 | val declaration = LHSEntry.key.key |
350 | val inverseReference = LHSEntry.key.value | 337 | val inverseReference = LHSEntry.key.value |
351 | val lhs = LHSEntry.value as IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> | 338 | val lhs = LHSEntry.value as IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> |
352 | val rule = createRelationRefinementRule(declaration, inverseReference, lhs, scopePropagator, statistics) | 339 | val rule = createRelationRefinementRule(declaration, inverseReference, lhs, unitRulePropagator, statistics) |
353 | res.put(LHSEntry.key, rule) | 340 | res.put(LHSEntry.key, rule) |
354 | } | 341 | } |
355 | return res | 342 | return res |
@@ -357,59 +344,29 @@ class RefinementRuleProvider { | |||
357 | 344 | ||
358 | def private BatchTransformationRule<GenericPatternMatch, ViatraQueryMatcher<GenericPatternMatch>> createRelationRefinementRule( | 345 | def private BatchTransformationRule<GenericPatternMatch, ViatraQueryMatcher<GenericPatternMatch>> createRelationRefinementRule( |
359 | RelationDeclaration declaration, Relation inverseRelation, | 346 | RelationDeclaration declaration, Relation inverseRelation, |
360 | IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> lhs, ScopePropagator scopePropagator, | 347 | IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> lhs, UnitRulePropagator unitRulePropagator, |
361 | ModelGenerationStatistics statistics) { | 348 | ModelGenerationStatistics statistics) { |
362 | val name = '''addRelation_«declaration.name.canonizeName»«IF inverseRelation !== null»_and_«inverseRelation.name.canonizeName»«ENDIF»''' | 349 | val name = '''addRelation_«declaration.name.canonizeName»«IF inverseRelation !== null»_and_«inverseRelation.name.canonizeName»«ENDIF»''' |
363 | val ruleBuilder = factory.createRule(lhs).name(name) | 350 | val ruleBuilder = factory.createRule(lhs).name(name) |
364 | if (inverseRelation === null) { | 351 | if (inverseRelation === null) { |
365 | ruleBuilder.action [ match | | 352 | ruleBuilder.action [ match | |
366 | statistics.incrementTransformationCount | 353 | statistics.incrementTransformationCount |
367 | |||
368 | // println(name) | 354 | // println(name) |
369 | // val problem = match.get(0) as LogicProblem | 355 | val startTime = System.nanoTime |
370 | // val interpretation = match.get(1) as PartialInterpretation | 356 | createRelationLinkAction(match, unitRulePropagator) |
371 | val relationInterpretation = match.get(2) as PartialRelationInterpretation | 357 | statistics.addExecutionTime(System.nanoTime - startTime) |
372 | val src = match.get(3) as DefinedElement | ||
373 | val trg = match.get(4) as DefinedElement | ||
374 | |||
375 | queryEngine.delayUpdatePropagation [ | ||
376 | val startTime = System.nanoTime | ||
377 | createRelationLinkAction(src, trg, relationInterpretation) | ||
378 | statistics.addExecutionTime(System.nanoTime - startTime) | ||
379 | ] | ||
380 | 358 | ||
381 | // Scope propagation | 359 | unitRulePropagator.propagate |
382 | if (scopePropagator.isPropagationNeededAfterAdditionToRelation(declaration)) { | ||
383 | queryEngine.delayUpdatePropagation [ | ||
384 | val propagatorStartTime = System.nanoTime | ||
385 | scopePropagator.propagateAllScopeConstraints() | ||
386 | statistics.addScopePropagationTime(System.nanoTime - propagatorStartTime) | ||
387 | ] | ||
388 | } | ||
389 | ] | 360 | ] |
390 | } else { | 361 | } else { |
391 | ruleBuilder.action [ match | | 362 | ruleBuilder.action [ match | |
392 | statistics.incrementTransformationCount | 363 | statistics.incrementTransformationCount |
393 | // println(name) | 364 | // println(name) |
394 | // val problem = match.get(0) as LogicProblem | ||
395 | // val interpretation = match.get(1) as PartialInterpretation | ||
396 | val relationInterpretation = match.get(2) as PartialRelationInterpretation | ||
397 | val inverseInterpretation = match.get(3) as PartialRelationInterpretation | ||
398 | val src = match.get(4) as DefinedElement | ||
399 | val trg = match.get(5) as DefinedElement | ||
400 | |||
401 | val startTime = System.nanoTime | 365 | val startTime = System.nanoTime |
402 | createRelationLinkWithInverse(src, trg, relationInterpretation, inverseInterpretation) | 366 | createRelationLinkWithInverse(match, unitRulePropagator) |
403 | statistics.addExecutionTime(System.nanoTime - startTime) | 367 | statistics.addExecutionTime(System.nanoTime - startTime) |
404 | 368 | ||
405 | // Scope propagation | 369 | unitRulePropagator.propagate |
406 | if (scopePropagator.isPropagationNeededAfterAdditionToRelation(declaration)) { | ||
407 | flushQueryEngine(scopePropagator) | ||
408 | |||
409 | val propagatorStartTime = System.nanoTime | ||
410 | scopePropagator.propagateAllScopeConstraints() | ||
411 | statistics.addScopePropagationTime(System.nanoTime - propagatorStartTime) | ||
412 | } | ||
413 | ] | 370 | ] |
414 | } | 371 | } |
415 | 372 | ||
@@ -420,7 +377,7 @@ class RefinementRuleProvider { | |||
420 | // Actions | 377 | // Actions |
421 | // /////////////////////// | 378 | // /////////////////////// |
422 | protected def void createObjectAction(boolean nameNewElement, ObjectCreationInterpretationData data, | 379 | protected def void createObjectAction(boolean nameNewElement, ObjectCreationInterpretationData data, |
423 | DefinedElement container, ScopePropagator scopePropagator) { | 380 | DefinedElement container, UnitRulePropagator unitRulePropagator) { |
424 | if (data.containerInterpretation !== null) { | 381 | if (data.containerInterpretation !== null) { |
425 | if (data.containerInverseInterpretation !== null) { | 382 | if (data.containerInverseInterpretation !== null) { |
426 | createObjectActionWithContainmentAndInverse( | 383 | createObjectActionWithContainmentAndInverse( |
@@ -432,7 +389,7 @@ class RefinementRuleProvider { | |||
432 | data.containerInverseInterpretation, | 389 | data.containerInverseInterpretation, |
433 | data.constructor, | 390 | data.constructor, |
434 | data.recursiveConstructors, | 391 | data.recursiveConstructors, |
435 | scopePropagator | 392 | unitRulePropagator |
436 | ) | 393 | ) |
437 | } else { | 394 | } else { |
438 | createObjectActionWithContainment( | 395 | createObjectActionWithContainment( |
@@ -443,7 +400,7 @@ class RefinementRuleProvider { | |||
443 | data.containerInterpretation, | 400 | data.containerInterpretation, |
444 | data.constructor, | 401 | data.constructor, |
445 | data.recursiveConstructors, | 402 | data.recursiveConstructors, |
446 | scopePropagator | 403 | unitRulePropagator |
447 | ) | 404 | ) |
448 | } | 405 | } |
449 | } else { | 406 | } else { |
@@ -453,7 +410,7 @@ class RefinementRuleProvider { | |||
453 | data.typeInterpretation, | 410 | data.typeInterpretation, |
454 | data.constructor, | 411 | data.constructor, |
455 | data.recursiveConstructors, | 412 | data.recursiveConstructors, |
456 | scopePropagator | 413 | unitRulePropagator |
457 | ) | 414 | ) |
458 | } | 415 | } |
459 | 416 | ||
@@ -468,7 +425,7 @@ class RefinementRuleProvider { | |||
468 | PartialRelationInterpretation inverseRelationInterpretation, | 425 | PartialRelationInterpretation inverseRelationInterpretation, |
469 | Function0<DefinedElement> constructor, | 426 | Function0<DefinedElement> constructor, |
470 | List<ObjectCreationInterpretationData> recursiceObjectCreations, | 427 | List<ObjectCreationInterpretationData> recursiceObjectCreations, |
471 | ScopePropagator scopePropagator | 428 | UnitRulePropagator unitRulePropagator |
472 | ) { | 429 | ) { |
473 | val newElement = constructor.apply | 430 | val newElement = constructor.apply |
474 | if (nameNewElement) { | 431 | if (nameNewElement) { |
@@ -488,14 +445,16 @@ class RefinementRuleProvider { | |||
488 | inverseRelationInterpretation.relationlinks += newLink2 | 445 | inverseRelationInterpretation.relationlinks += newLink2 |
489 | 446 | ||
490 | // Scope propagation | 447 | // Scope propagation |
491 | scopePropagator.decrementTypeScope(typeInterpretation) | 448 | unitRulePropagator.decrementTypeScope(typeInterpretation) |
449 | unitRulePropagator.addedToRelation(relationInterpretation.interpretationOf) | ||
450 | unitRulePropagator.addedToRelation(inverseRelationInterpretation.interpretationOf) | ||
492 | 451 | ||
493 | // Existence | 452 | // Existence |
494 | interpretation.newElements += newElement | 453 | interpretation.newElements += newElement |
495 | 454 | ||
496 | // Do recursive object creation | 455 | // Do recursive object creation |
497 | for (newConstructor : recursiceObjectCreations) { | 456 | for (newConstructor : recursiceObjectCreations) { |
498 | createObjectAction(nameNewElement, newConstructor, newElement, scopePropagator) | 457 | createObjectAction(nameNewElement, newConstructor, newElement, unitRulePropagator) |
499 | } | 458 | } |
500 | 459 | ||
501 | return newElement | 460 | return newElement |
@@ -509,7 +468,7 @@ class RefinementRuleProvider { | |||
509 | PartialRelationInterpretation relationInterpretation, | 468 | PartialRelationInterpretation relationInterpretation, |
510 | Function0<DefinedElement> constructor, | 469 | Function0<DefinedElement> constructor, |
511 | List<ObjectCreationInterpretationData> recursiceObjectCreations, | 470 | List<ObjectCreationInterpretationData> recursiceObjectCreations, |
512 | ScopePropagator scopePropagator | 471 | UnitRulePropagator unitRulePropagator |
513 | ) { | 472 | ) { |
514 | val newElement = constructor.apply | 473 | val newElement = constructor.apply |
515 | if (nameNewElement) { | 474 | if (nameNewElement) { |
@@ -524,16 +483,17 @@ class RefinementRuleProvider { | |||
524 | // ContainmentRelation | 483 | // ContainmentRelation |
525 | val newLink = factory2.createBinaryElementRelationLink => [it.param1 = container it.param2 = newElement] | 484 | val newLink = factory2.createBinaryElementRelationLink => [it.param1 = container it.param2 = newElement] |
526 | relationInterpretation.relationlinks += newLink | 485 | relationInterpretation.relationlinks += newLink |
486 | unitRulePropagator.addedToRelation(relationInterpretation.interpretationOf) | ||
527 | 487 | ||
528 | // Scope propagation | 488 | // Scope propagation |
529 | scopePropagator.decrementTypeScope(typeInterpretation) | 489 | unitRulePropagator.decrementTypeScope(typeInterpretation) |
530 | 490 | ||
531 | // Existence | 491 | // Existence |
532 | interpretation.newElements += newElement | 492 | interpretation.newElements += newElement |
533 | 493 | ||
534 | // Do recursive object creation | 494 | // Do recursive object creation |
535 | for (newConstructor : recursiceObjectCreations) { | 495 | for (newConstructor : recursiceObjectCreations) { |
536 | createObjectAction(nameNewElement, newConstructor, newElement, scopePropagator) | 496 | createObjectAction(nameNewElement, newConstructor, newElement, unitRulePropagator) |
537 | } | 497 | } |
538 | 498 | ||
539 | return newElement | 499 | return newElement |
@@ -541,7 +501,7 @@ class RefinementRuleProvider { | |||
541 | 501 | ||
542 | protected def createObjectAction(boolean nameNewElement, PartialInterpretation interpretation, | 502 | protected def createObjectAction(boolean nameNewElement, PartialInterpretation interpretation, |
543 | PartialTypeInterpratation typeInterpretation, Function0<DefinedElement> constructor, | 503 | PartialTypeInterpratation typeInterpretation, Function0<DefinedElement> constructor, |
544 | List<ObjectCreationInterpretationData> recursiceObjectCreations, ScopePropagator scopePropagator) { | 504 | List<ObjectCreationInterpretationData> recursiceObjectCreations, UnitRulePropagator unitRulePropagator) { |
545 | val newElement = constructor.apply | 505 | val newElement = constructor.apply |
546 | if (nameNewElement) { | 506 | if (nameNewElement) { |
547 | newElement.name = '''new «interpretation.newElements.size»''' | 507 | newElement.name = '''new «interpretation.newElements.size»''' |
@@ -554,38 +514,220 @@ class RefinementRuleProvider { | |||
554 | } | 514 | } |
555 | 515 | ||
556 | // Scope propagation | 516 | // Scope propagation |
557 | scopePropagator.decrementTypeScope(typeInterpretation) | 517 | unitRulePropagator.decrementTypeScope(typeInterpretation) |
558 | 518 | ||
559 | // Existence | 519 | // Existence |
560 | interpretation.newElements += newElement | 520 | interpretation.newElements += newElement |
561 | 521 | ||
562 | // Do recursive object creation | 522 | // Do recursive object creation |
563 | for (newConstructor : recursiceObjectCreations) { | 523 | for (newConstructor : recursiceObjectCreations) { |
564 | createObjectAction(nameNewElement, newConstructor, newElement, scopePropagator) | 524 | createObjectAction(nameNewElement, newConstructor, newElement, unitRulePropagator) |
565 | } | 525 | } |
566 | 526 | ||
567 | return newElement | 527 | return newElement |
568 | } | 528 | } |
569 | 529 | ||
570 | protected def boolean createRelationLinkAction(DefinedElement src, DefinedElement trg, | 530 | protected def createRelationLinkAction(IPatternMatch match, UnitRulePropagator unitRulePropagator) { |
571 | PartialRelationInterpretation relationInterpretation) { | 531 | // val problem = match.get(0) as LogicProblem |
532 | // val interpretation = match.get(1) as PartialInterpretation | ||
533 | val relationInterpretation = match.get(2) as PartialRelationInterpretation | ||
534 | val src = match.get(3) as DefinedElement | ||
535 | val trg = match.get(4) as DefinedElement | ||
536 | createRelationLinkAction(src, trg, relationInterpretation, unitRulePropagator) | ||
537 | } | ||
538 | |||
539 | protected def void createRelationLinkAction(DefinedElement src, DefinedElement trg, | ||
540 | PartialRelationInterpretation relationInterpretation, UnitRulePropagator unitRulePropagator) { | ||
572 | val link = createBinaryElementRelationLink => [it.param1 = src it.param2 = trg] | 541 | val link = createBinaryElementRelationLink => [it.param1 = src it.param2 = trg] |
573 | relationInterpretation.relationlinks += link | 542 | relationInterpretation.relationlinks += link |
543 | unitRulePropagator.addedToRelation(relationInterpretation.interpretationOf) | ||
574 | } | 544 | } |
575 | 545 | ||
576 | protected def boolean createRelationLinkWithInverse(DefinedElement src, DefinedElement trg, | 546 | protected def void createRelationLinkWithInverse(IPatternMatch match, UnitRulePropagator unitRulePropagator) { |
577 | PartialRelationInterpretation relationInterpretation, PartialRelationInterpretation inverseInterpretation) { | 547 | // val problem = match.get(0) as LogicProblem |
548 | // val interpretation = match.get(1) as PartialInterpretation | ||
549 | val relationInterpretation = match.get(2) as PartialRelationInterpretation | ||
550 | val inverseInterpretation = match.get(3) as PartialRelationInterpretation | ||
551 | val src = match.get(4) as DefinedElement | ||
552 | val trg = match.get(5) as DefinedElement | ||
553 | createRelationLinkWithInverse(src, trg, relationInterpretation, inverseInterpretation, unitRulePropagator) | ||
554 | } | ||
555 | |||
556 | protected def void createRelationLinkWithInverse(DefinedElement src, DefinedElement trg, | ||
557 | PartialRelationInterpretation relationInterpretation, PartialRelationInterpretation inverseInterpretation, | ||
558 | UnitRulePropagator unitRulePropagator) { | ||
578 | val link = createBinaryElementRelationLink => [it.param1 = src it.param2 = trg] | 559 | val link = createBinaryElementRelationLink => [it.param1 = src it.param2 = trg] |
579 | relationInterpretation.relationlinks += link | 560 | relationInterpretation.relationlinks += link |
580 | val inverseLink = createBinaryElementRelationLink => [it.param1 = trg it.param2 = src] | 561 | val inverseLink = createBinaryElementRelationLink => [it.param1 = trg it.param2 = src] |
581 | inverseInterpretation.relationlinks += inverseLink | 562 | inverseInterpretation.relationlinks += inverseLink |
563 | unitRulePropagator.addedToRelation(relationInterpretation.interpretationOf) | ||
564 | unitRulePropagator.addedToRelation(inverseInterpretation.interpretationOf) | ||
582 | } | 565 | } |
583 | 566 | ||
584 | protected def flushQueryEngine(ScopePropagator scopePropagator) { | 567 | static class UnitRulePropagator { |
585 | if (scopePropagator.queryEngineFlushRequiredBeforePropagation && queryEngine.updatePropagationDelayed) { | 568 | val LogicProblem p |
586 | delayMessageDelivery.setBoolean(queryEngine, false) | 569 | val PartialInterpretation i |
587 | queryEngine.getQueryBackend(ReteBackendFactory.INSTANCE).flushUpdates | 570 | val RefinementRuleProvider refinementRuleProvider |
588 | delayMessageDelivery.setBoolean(queryEngine, true) | 571 | var AdvancedViatraQueryEngine queryEngine |
572 | var Field delayMessageDelivery | ||
573 | val ScopePropagator scopePropagator | ||
574 | val List<AbstractMustRelationPropagator<? extends IPatternMatch>> propagators | ||
575 | val ModelGenerationStatistics statistics | ||
576 | |||
577 | new(LogicProblem p, PartialInterpretation i, RefinementRuleProvider refinementRuleProvider, | ||
578 | ScopePropagator scopePropagator, | ||
579 | Map<Pair<RelationDeclaration, Relation>, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> mustRelationPropagationQueries, | ||
580 | ModelGenerationStatistics statistics) { | ||
581 | this.p = p | ||
582 | this.i = i | ||
583 | this.refinementRuleProvider = refinementRuleProvider | ||
584 | queryEngine = ViatraQueryEngine.on(new EMFScope(i)) as AdvancedViatraQueryEngine | ||
585 | delayMessageDelivery = queryEngine.class.getDeclaredField("delayMessageDelivery") | ||
586 | delayMessageDelivery.accessible = true | ||
587 | this.scopePropagator = scopePropagator | ||
588 | propagators = ImmutableList.copyOf(mustRelationPropagationQueries.entrySet.map [ entry | | ||
589 | val matcher = queryEngine.getMatcher(entry.value) | ||
590 | getPropagator(entry.key.key, entry.key.value, matcher) | ||
591 | ]) | ||
592 | this.statistics = statistics | ||
593 | } | ||
594 | |||
595 | def decrementTypeScope(PartialTypeInterpratation partialTypeInterpratation) { | ||
596 | scopePropagator.decrementTypeScope(partialTypeInterpratation) | ||
597 | } | ||
598 | |||
599 | def addedToRelation(Relation r) { | ||
600 | scopePropagator.addedToRelation(r) | ||
601 | } | ||
602 | |||
603 | def propagate() { | ||
604 | var boolean changed | ||
605 | do { | ||
606 | val scopeChanged = propagateScope() | ||
607 | val mustChanged = propagateMustRelations() | ||
608 | changed = scopeChanged || mustChanged | ||
609 | } while (changed) | ||
610 | } | ||
611 | |||
612 | protected def flushQueryEngine() { | ||
613 | if (queryEngine.updatePropagationDelayed) { | ||
614 | delayMessageDelivery.setBoolean(queryEngine, false) | ||
615 | queryEngine.getQueryBackend(ReteBackendFactory.INSTANCE).flushUpdates | ||
616 | delayMessageDelivery.setBoolean(queryEngine, true) | ||
617 | } | ||
618 | } | ||
619 | |||
620 | protected def propagateScope() { | ||
621 | if (scopePropagator.scopePropagationNeeded) { | ||
622 | if (scopePropagator.queryEngineFlushRequiredBeforePropagation) { | ||
623 | flushQueryEngine() | ||
624 | } | ||
625 | val propagatorStartTime = System.nanoTime | ||
626 | scopePropagator.propagateAllScopeConstraints() | ||
627 | statistics.addScopePropagationTime(System.nanoTime - propagatorStartTime) | ||
628 | true | ||
629 | } else { | ||
630 | false | ||
631 | } | ||
632 | } | ||
633 | |||
634 | protected def propagateMustRelations() { | ||
635 | if (propagators.empty) { | ||
636 | return false | ||
637 | } | ||
638 | flushQueryEngine() | ||
639 | val propagatorStartTime = System.nanoTime | ||
640 | var changed = false | ||
641 | for (propagator : propagators) { | ||
642 | changed = propagator.propagate(p, i, refinementRuleProvider, this) || changed | ||
643 | } | ||
644 | statistics.addMustRelationPropagationTime(System.nanoTime - propagatorStartTime) | ||
645 | changed | ||
646 | } | ||
647 | |||
648 | private static def <T extends IPatternMatch> getPropagator(Relation relation, Relation inverseRelation, | ||
649 | ViatraQueryMatcher<T> matcher) { | ||
650 | if (inverseRelation === null) { | ||
651 | new MustRelationPropagator(matcher) | ||
652 | } else if (relation == inverseRelation) { | ||
653 | new MustRelationPropagatorWithSelfInverse(matcher) | ||
654 | } else { | ||
655 | new MustRelationPropagatorWithInverse(matcher) | ||
656 | } | ||
657 | } | ||
658 | |||
659 | @FinalFieldsConstructor | ||
660 | private static abstract class AbstractMustRelationPropagator<T extends IPatternMatch> { | ||
661 | val ViatraQueryMatcher<T> matcher | ||
662 | |||
663 | def propagate(LogicProblem p, PartialInterpretation i, RefinementRuleProvider refinementRuleProvider, | ||
664 | UnitRulePropagator unitRulePropagator) { | ||
665 | val iterator = getIterator(p, i) | ||
666 | if (!iterator.hasNext) { | ||
667 | return false | ||
668 | } | ||
669 | iterate(iterator, refinementRuleProvider, unitRulePropagator) | ||
670 | true | ||
671 | } | ||
672 | |||
673 | def iterate(Iterator<T> iterator, RefinementRuleProvider refinementRuleProvider, | ||
674 | UnitRulePropagator unitRulePropagator) { | ||
675 | while (iterator.hasNext) { | ||
676 | doPropagate(iterator.next, refinementRuleProvider, unitRulePropagator) | ||
677 | } | ||
678 | } | ||
679 | |||
680 | protected def getIterator(LogicProblem p, PartialInterpretation i) { | ||
681 | val partialMatch = matcher.newEmptyMatch | ||
682 | partialMatch.set(0, p) | ||
683 | partialMatch.set(1, i) | ||
684 | matcher.streamAllMatches(partialMatch).iterator | ||
685 | } | ||
686 | |||
687 | protected def void doPropagate(T match, RefinementRuleProvider refinementRuleProvider, | ||
688 | UnitRulePropagator unitRulePropagator) | ||
689 | } | ||
690 | |||
691 | private static class MustRelationPropagator<T extends IPatternMatch> extends AbstractMustRelationPropagator<T> { | ||
692 | new(ViatraQueryMatcher<T> matcher) { | ||
693 | super(matcher) | ||
694 | } | ||
695 | |||
696 | override protected doPropagate(T match, RefinementRuleProvider refinementRuleProvider, | ||
697 | UnitRulePropagator unitRulePropagator) { | ||
698 | refinementRuleProvider.createRelationLinkAction(match, unitRulePropagator) | ||
699 | } | ||
700 | } | ||
701 | |||
702 | private static class MustRelationPropagatorWithInverse<T extends IPatternMatch> extends AbstractMustRelationPropagator<T> { | ||
703 | new(ViatraQueryMatcher<T> matcher) { | ||
704 | super(matcher) | ||
705 | } | ||
706 | |||
707 | override protected doPropagate(T match, RefinementRuleProvider refinementRuleProvider, | ||
708 | UnitRulePropagator unitRulePropagator) { | ||
709 | refinementRuleProvider.createRelationLinkWithInverse(match, unitRulePropagator) | ||
710 | } | ||
711 | } | ||
712 | |||
713 | private static class MustRelationPropagatorWithSelfInverse<T extends IPatternMatch> extends MustRelationPropagatorWithInverse<T> { | ||
714 | new(ViatraQueryMatcher<T> matcher) { | ||
715 | super(matcher) | ||
716 | } | ||
717 | |||
718 | override iterate(Iterator<T> iterator, RefinementRuleProvider refinementRuleProvider, | ||
719 | UnitRulePropagator unitRulePropagator) { | ||
720 | val pairs = newHashSet | ||
721 | while (iterator.hasNext) { | ||
722 | val match = iterator.next | ||
723 | val src = match.get(4) as DefinedElement | ||
724 | val trg = match.get(5) as DefinedElement | ||
725 | if (!pairs.contains(trg -> src)) { | ||
726 | pairs.add(src -> trg) | ||
727 | doPropagate(match, refinementRuleProvider, unitRulePropagator) | ||
728 | } | ||
729 | } | ||
730 | } | ||
589 | } | 731 | } |
590 | } | 732 | } |
591 | } | 733 | } |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/util/ParseUtil.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/util/ParseUtil.xtend index 26ec7091..69b54b8a 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/util/ParseUtil.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/util/ParseUtil.xtend | |||
@@ -6,7 +6,6 @@ import com.google.inject.Inject | |||
6 | import com.google.inject.Injector | 6 | import com.google.inject.Injector |
7 | import com.google.inject.multibindings.Multibinder | 7 | import com.google.inject.multibindings.Multibinder |
8 | import com.google.inject.name.Names | 8 | import com.google.inject.name.Names |
9 | import com.google.inject.util.Modules | ||
10 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage | 9 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguagePackage |
11 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage | 10 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage |
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage | 11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage |
@@ -46,7 +45,6 @@ import org.eclipse.xtext.scoping.IScope | |||
46 | import org.eclipse.xtext.scoping.IScopeProvider | 45 | import org.eclipse.xtext.scoping.IScopeProvider |
47 | import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider | 46 | import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider |
48 | import org.eclipse.xtext.scoping.impl.SimpleScope | 47 | import org.eclipse.xtext.scoping.impl.SimpleScope |
49 | import org.eclipse.xtext.service.AbstractGenericModule | ||
50 | import org.eclipse.xtext.service.SingletonBinding | 48 | import org.eclipse.xtext.service.SingletonBinding |
51 | import org.eclipse.xtext.workspace.IProjectConfigProvider | 49 | import org.eclipse.xtext.workspace.IProjectConfigProvider |
52 | 50 | ||
@@ -65,35 +63,32 @@ package class StandaloneParserWithFixedMetamodelProviderModule extends Standalon | |||
65 | Multibinder::newSetBinder(binder, IMetamodelProviderInstance); | 63 | Multibinder::newSetBinder(binder, IMetamodelProviderInstance); |
66 | } | 64 | } |
67 | 65 | ||
68 | } | 66 | @SingletonBinding |
69 | 67 | override IResourceServiceProvider.Registry bindIResourceServiceProvider$Registry() { | |
70 | package class StandaloneParserOverridesModule extends AbstractGenericModule { | 68 | new VqlDeactivatedServiceProviderRegistry |
71 | 69 | } | |
72 | def Class<? extends IMetamodelProvider> bindIMetamodelProvider() { | 70 | |
71 | override Class<? extends IMetamodelProvider> bindIMetamodelProvider() { | ||
73 | FixedMetamodelProvider | 72 | FixedMetamodelProvider |
74 | } | 73 | } |
75 | 74 | ||
76 | def Class<? extends IProjectConfigProvider> bindProjectConfigProvider() { | 75 | override Class<? extends IProjectConfigProvider> bindProjectConfigProvider() { |
77 | NullProjectConfigProvider | 76 | NullProjectConfigProvider |
78 | } | 77 | } |
79 | 78 | ||
80 | @SingletonBinding | 79 | @SingletonBinding |
81 | def Class<? extends IResourceServiceProvider.Registry> bindIResourceServiceProvider$Registry() { | 80 | override EValidator.Registry bindEValidatorRegistry() { |
82 | VqlDeactivatedServiceProviderRegistry | ||
83 | } | ||
84 | |||
85 | def EValidator.Registry bindEValidator$Registry() { | ||
86 | // org.eclipse.xtext.validation.EValidatorRegistrar modifies EValidators already in the registry, | 81 | // org.eclipse.xtext.validation.EValidatorRegistrar modifies EValidators already in the registry, |
87 | // so it is not safe to populate the registry from the EValidator.Registry.INSTANCE singleton. | 82 | // so it is not safe to populate the registry from the EValidator.Registry.INSTANCE singleton. |
88 | // There is no need to execute any EValiator other than EMFPatternLanguageValidator, | 83 | // There is no need to execute any EValiator other than EMFPatternLanguageValidator, |
89 | // so we can start with a blank registry instead. | 84 | // so we can start with a blank registry instead. |
90 | new EValidatorRegistryImpl() | 85 | new EValidatorRegistryImpl |
91 | } | 86 | } |
92 | 87 | ||
93 | def EPackage.Registry bindEPackage$Registry() { | 88 | @SingletonBinding |
89 | override EPackage.Registry bindEPackageRegistry() { | ||
94 | new EPackageRegistryImpl(EPackage.Registry.INSTANCE) | 90 | new EPackageRegistryImpl(EPackage.Registry.INSTANCE) |
95 | } | 91 | } |
96 | |||
97 | } | 92 | } |
98 | 93 | ||
99 | package class NullProjectConfigProvider implements IProjectConfigProvider { | 94 | package class NullProjectConfigProvider implements IProjectConfigProvider { |
@@ -136,10 +131,8 @@ class ParseUtil { | |||
136 | 131 | ||
137 | def protected Injector internalCreateInjector() { | 132 | def protected Injector internalCreateInjector() { |
138 | ensureViatraInitialized(); | 133 | ensureViatraInitialized(); |
139 | val runtimeModulemodule = new StandaloneParserWithFixedMetamodelProviderModule | 134 | val runtimeModule = new StandaloneParserWithFixedMetamodelProviderModule |
140 | val overridesModule = new StandaloneParserOverridesModule | 135 | val newInjector = Guice.createInjector(runtimeModule) |
141 | val module = Modules.override(runtimeModulemodule).with(overridesModule) | ||
142 | val newInjector = Guice.createInjector(module) | ||
143 | return newInjector | 136 | return newInjector |
144 | } | 137 | } |
145 | 138 | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/META-INF/MANIFEST.MF b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/META-INF/MANIFEST.MF index 4ad61ccb..402a0b7d 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/META-INF/MANIFEST.MF +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/META-INF/MANIFEST.MF | |||
@@ -4,6 +4,7 @@ Bundle-Name: Reasoner | |||
4 | Bundle-SymbolicName: hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner | 4 | Bundle-SymbolicName: hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner |
5 | Bundle-Version: 1.0.0.qualifier | 5 | Bundle-Version: 1.0.0.qualifier |
6 | Export-Package: hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner, | 6 | Export-Package: hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner, |
7 | hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse, | ||
7 | hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization | 8 | hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization |
8 | Require-Bundle: hu.bme.mit.inf.dslreasoner.ecore2logic;bundle-version="1.0.0", | 9 | Require-Bundle: hu.bme.mit.inf.dslreasoner.ecore2logic;bundle-version="1.0.0", |
9 | hu.bme.mit.inf.dslreasoner.logic.model;bundle-version="1.0.0", | 10 | hu.bme.mit.inf.dslreasoner.logic.model;bundle-version="1.0.0", |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ModelGenerationMethodBasedGlobalConstraint.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ModelGenerationMethodBasedGlobalConstraint.xtend index 9ef5e091..691e0645 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ModelGenerationMethodBasedGlobalConstraint.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ModelGenerationMethodBasedGlobalConstraint.xtend | |||
@@ -1,7 +1,6 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner |
2 | 2 | ||
3 | import org.eclipse.viatra.dse.objectives.IGlobalConstraint | 3 | import org.eclipse.viatra.dse.objectives.IGlobalConstraint |
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethod | ||
5 | 4 | ||
6 | abstract class ModelGenerationMethodBasedGlobalConstraint implements IGlobalConstraint { | 5 | abstract class ModelGenerationMethodBasedGlobalConstraint implements IGlobalConstraint { |
7 | val protected ModelGenerationMethod method | 6 | val protected ModelGenerationMethod method |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ModelGenerationMethodProvider.xtend index 56beacfa..25137eba 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ModelGenerationMethodProvider.xtend | |||
@@ -1,215 +1,201 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner |
2 | 2 | ||
3 | import com.google.common.collect.ImmutableMap | 3 | import com.google.common.collect.ImmutableMap |
4 | import com.google.common.collect.ImmutableSet | 4 | import com.google.common.collect.ImmutableSet |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel | 5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel |
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem |
7 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransfomedViatraQuery | 7 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransfomedViatraQuery |
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.CbcPolyhedronSolver | 8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationStatistics |
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint | 9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.CachingSimplePolyhedronScopePropagatorStrategy |
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.MultiplicityGoalConstraintCalculator | 10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.CbcPolyhedronSolver |
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronScopePropagator | 11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint |
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationConstraintCalculator | 12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.MultiplicityGoalConstraintCalculator |
13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagator | 13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator |
14 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy | 14 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronScopePropagator |
15 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.TypeHierarchyScopePropagator | 15 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationConstraintCalculator |
16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Z3PolyhedronSolver | 16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagator |
17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.GeneratedPatterns | 17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy |
18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.ModalPatternQueries | 18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.TypeHierarchyScopePropagator |
19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternProvider | 19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Z3PolyhedronSolver |
20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.rules.GoalConstraintProvider | 20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.GeneratedPatterns |
21 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.rules.RefinementRuleProvider | 21 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.ModalPatternQueries |
22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternProvider |
23 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace | 23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.rules.GoalConstraintProvider |
24 | import java.util.Collection | 24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.rules.RefinementRuleProvider |
25 | import java.util.List | 25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
26 | import java.util.Map | 26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.DiversityChecker |
27 | import java.util.Set | 27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.ViatraReasonerSolutionSaver |
28 | import org.eclipse.viatra.query.runtime.api.GenericQueryGroup | 28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ThreeValuedCostObjectiveProvider |
29 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | 29 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace |
30 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification | 30 | import java.util.Collection |
31 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine | 31 | import java.util.List |
32 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | 32 | import java.util.Map |
33 | import org.eclipse.viatra.query.runtime.emf.EMFScope | 33 | import java.util.Set |
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint | 34 | import org.eclipse.viatra.dse.objectives.IObjective |
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | 35 | import org.eclipse.viatra.query.runtime.api.GenericQueryGroup |
36 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRule | 36 | import org.eclipse.viatra.query.runtime.api.IPatternMatch |
37 | import org.eclipse.xtend.lib.annotations.Data | 37 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification |
38 | 38 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine | |
39 | class ModelGenerationStatistics { | 39 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher |
40 | public var long transformationExecutionTime = 0 | 40 | import org.eclipse.viatra.query.runtime.emf.EMFScope |
41 | 41 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint | |
42 | synchronized def addExecutionTime(long amount) { | 42 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery |
43 | transformationExecutionTime += amount | 43 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRule |
44 | } | 44 | import org.eclipse.xtend.lib.annotations.Data |
45 | 45 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedPolyhedronScopePropagatorStrategy | |
46 | public var long scopePropagationTime = 0 | 46 | |
47 | 47 | @Data class ModelGenerationMethod { | |
48 | synchronized def addScopePropagationTime(long amount) { | 48 | ModelGenerationStatistics statistics |
49 | scopePropagationTime += amount | 49 | |
50 | } | 50 | Collection<? extends BatchTransformationRule<?, ?>> objectRefinementRules |
51 | 51 | Collection<? extends BatchTransformationRule<?, ?>> relationRefinementRules | |
52 | public var long preliminaryTypeAnalisisTime = 0 | 52 | |
53 | 53 | List<MultiplicityGoalConstraintCalculator> unfinishedMultiplicities | |
54 | public var int decisionsTried = 0 | 54 | |
55 | 55 | Collection<? extends IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> unfinishedWF | |
56 | synchronized def incrementDecisionCount() { | 56 | |
57 | decisionsTried++ | 57 | Collection<? extends IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> invalidWF |
58 | } | 58 | |
59 | 59 | Map<PConstraint, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> mustUnitPropagationPreconditions | |
60 | public var int transformationInvocations | 60 | Map<PConstraint, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> currentUnitPropagationPreconditions |
61 | 61 | ||
62 | synchronized def incrementTransformationCount() { | 62 | Map<String, ModalPatternQueries> modalRelationQueries |
63 | transformationInvocations++ | 63 | |
64 | } | 64 | Collection<? extends IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> allPatterns |
65 | 65 | ||
66 | public var int scopePropagatorInvocations | 66 | Collection<IObjective> costObjectives |
67 | 67 | boolean optimizationProblem | |
68 | synchronized def incrementScopePropagationCount() { | 68 | ViatraReasonerSolutionSaver solutionSaver |
69 | scopePropagatorInvocations++ | 69 | } |
70 | } | 70 | |
71 | 71 | class ModelGenerationMethodProvider { | |
72 | public var int scopePropagatorSolverInvocations | 72 | val PatternProvider patternProvider = new PatternProvider |
73 | 73 | val RefinementRuleProvider refinementRuleProvider = new RefinementRuleProvider | |
74 | synchronized def incrementScopePropagationSolverCount() { | 74 | val GoalConstraintProvider goalConstraintProvider = new GoalConstraintProvider |
75 | scopePropagatorSolverInvocations++ | 75 | val relationConstraintCalculator = new RelationConstraintCalculator |
76 | } | 76 | |
77 | } | 77 | def ModelGenerationMethod createModelGenerationMethod( |
78 | 78 | LogicProblem logicProblem, | |
79 | @Data class ModelGenerationMethod { | 79 | PartialInterpretation emptySolution, |
80 | ModelGenerationStatistics statistics | 80 | ReasonerWorkspace workspace, |
81 | 81 | ViatraReasonerConfiguration config | |
82 | Collection<? extends BatchTransformationRule<?, ?>> objectRefinementRules | 82 | ) { |
83 | Collection<? extends BatchTransformationRule<?, ?>> relationRefinementRules | 83 | val statistics = new ModelGenerationStatistics |
84 | 84 | val debugLevel = config.documentationLevel | |
85 | List<MultiplicityGoalConstraintCalculator> unfinishedMultiplicities | 85 | val writeFiles = (debugLevel === DocumentationLevel.NORMAL || debugLevel === DocumentationLevel.FULL) |
86 | 86 | ||
87 | Collection<? extends IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> unfinishedWF | 87 | val Set<PQuery> existingQueries = logicProblem.relations.map[annotations].flatten.filter(TransfomedViatraQuery). |
88 | 88 | map[it.patternPQuery as PQuery].toSet | |
89 | Collection<? extends IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> invalidWF | 89 | |
90 | 90 | val relationConstraints = relationConstraintCalculator.calculateRelationConstraints(logicProblem) | |
91 | Map<PConstraint, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> mustUnitPropagationPreconditions | 91 | val queries = patternProvider.generateQueries(logicProblem, emptySolution, statistics, existingQueries, |
92 | Map<PConstraint, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> currentUnitPropagationPreconditions | 92 | workspace, config.typeInferenceMethod, config.scopePropagatorStrategy, relationConstraints, config.hints, |
93 | 93 | config.unitPropagationPatternGenerators, writeFiles) | |
94 | Map<String, ModalPatternQueries> modalRelationQueries | 94 | |
95 | 95 | val unfinishedMultiplicities = goalConstraintProvider.getUnfinishedMultiplicityQueries(logicProblem, queries, | |
96 | Collection<? extends IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> allPatterns | 96 | config.calculateObjectCreationCosts) |
97 | } | 97 | val unfinishedWF = queries.getUnfinishedWFQueries.values |
98 | 98 | val modalRelationQueriesBuilder = ImmutableMap.builder | |
99 | enum TypeInferenceMethod { | 99 | for (entry : queries.modalRelationQueries.entrySet) { |
100 | Generic, | 100 | val annotation = entry.key.annotations.filter(TransfomedViatraQuery).head |
101 | PreliminaryAnalysis | 101 | if (annotation !== null) { |
102 | } | 102 | modalRelationQueriesBuilder.put(annotation.patternFullyQualifiedName, entry.value) |
103 | 103 | } | |
104 | class ModelGenerationMethodProvider { | 104 | } |
105 | val PatternProvider patternProvider = new PatternProvider | 105 | val modalRelationQueries = modalRelationQueriesBuilder.build |
106 | val RefinementRuleProvider refinementRuleProvider = new RefinementRuleProvider | 106 | val invalidWF = queries.getInvalidWFQueries.values |
107 | val GoalConstraintProvider goalConstraintProvider = new GoalConstraintProvider | 107 | val mustUnitPropagationPreconditions = queries.getMustUnitPropagationPreconditionPatterns |
108 | val relationConstraintCalculator = new RelationConstraintCalculator | 108 | val currentUnitPropagationPreconditions = queries.getCurrentUnitPropagationPreconditionPatterns |
109 | 109 | val queriesToPrepare = ImmutableSet.builder.addAll(queries.refineObjectQueries.values).addAll( | |
110 | def ModelGenerationMethod createModelGenerationMethod( | 110 | queries.refineTypeQueries.values).addAll(queries.refineRelationQueries.values).addAll( |
111 | LogicProblem logicProblem, | 111 | queries.mustRelationPropagationQueries.values).addAll(queries.multiplicityConstraintQueries.values.flatMap [ |
112 | PartialInterpretation emptySolution, | 112 | allQueries |
113 | ReasonerWorkspace workspace, | 113 | ]).addAll(queries.unfinishedWFQueries.values).addAll(queries.invalidWFQueries.values).addAll( |
114 | boolean nameNewElements, | 114 | queries.mustUnitPropagationPreconditionPatterns.values).addAll( |
115 | TypeInferenceMethod typeInferenceMethod, | 115 | queries.currentUnitPropagationPreconditionPatterns.values).add(queries.hasElementInContainmentQuery).build |
116 | boolean calculateObjectCreationCosts, | 116 | val queryEngine = ViatraQueryEngine.on(new EMFScope(emptySolution)) |
117 | ScopePropagatorStrategy scopePropagatorStrategy, | 117 | GenericQueryGroup.of(queriesToPrepare).prepare(queryEngine) |
118 | Collection<LinearTypeConstraintHint> hints, | 118 | |
119 | DocumentationLevel debugLevel | 119 | val objectiveProvider = new ThreeValuedCostObjectiveProvider(queryEngine, emptySolution, modalRelationQueries) |
120 | ) { | 120 | val transformedObjectives = objectiveProvider.getCostObjectives(config.costObjectives) |
121 | val statistics = new ModelGenerationStatistics | 121 | |
122 | val writeFiles = (debugLevel === DocumentationLevel.NORMAL || debugLevel === DocumentationLevel.FULL) | 122 | val solutionSaver = new ViatraReasonerSolutionSaver(transformedObjectives.leveledExtremalObjectives, |
123 | 123 | config.solutionScope.numberOfRequiredSolutions, DiversityChecker.of(config.diversityRequirement)) | |
124 | val Set<PQuery> existingQueries = logicProblem.relations.map[annotations].flatten.filter(TransfomedViatraQuery). | 124 | |
125 | map[it.patternPQuery as PQuery].toSet | 125 | val allHints = ImmutableSet.builder |
126 | 126 | allHints.addAll(config.hints) | |
127 | val relationConstraints = relationConstraintCalculator.calculateRelationConstraints(logicProblem) | 127 | for (hint : transformedObjectives.hints) { |
128 | val queries = patternProvider.generateQueries(logicProblem, emptySolution, statistics, existingQueries, | 128 | hint.boundsProvider = solutionSaver |
129 | workspace, typeInferenceMethod, scopePropagatorStrategy, relationConstraints, hints, writeFiles) | 129 | allHints.add(hint) |
130 | 130 | } | |
131 | val scopePropagator = createScopePropagator(scopePropagatorStrategy, emptySolution, hints, queries, statistics) | 131 | |
132 | scopePropagator.propagateAllScopeConstraints | 132 | val scopePropagator = createScopePropagator(config.scopePropagatorStrategy, emptySolution, allHints.build, |
133 | val objectRefinementRules = refinementRuleProvider.createObjectRefinementRules(logicProblem, emptySolution, | 133 | transformedObjectives.extensionOperators, queries, statistics) |
134 | queries, scopePropagator, nameNewElements, statistics) | 134 | scopePropagator.propagateAllScopeConstraints |
135 | val relationRefinementRules = refinementRuleProvider.createRelationRefinementRules(queries, scopePropagator, | 135 | val unitRulePropagator = refinementRuleProvider.createUnitPrulePropagator(logicProblem, emptySolution, queries, |
136 | statistics) | 136 | scopePropagator, statistics) |
137 | 137 | val objectRefinementRules = refinementRuleProvider.createObjectRefinementRules(logicProblem, emptySolution, | |
138 | val unfinishedMultiplicities = goalConstraintProvider.getUnfinishedMultiplicityQueries(logicProblem, queries, | 138 | queries, unitRulePropagator, config.nameNewElements, statistics) |
139 | calculateObjectCreationCosts) | 139 | val relationRefinementRules = refinementRuleProvider.createRelationRefinementRules(queries, unitRulePropagator, |
140 | 140 | statistics) | |
141 | val unfinishedWF = queries.getUnfinishedWFQueries.values | 141 | |
142 | 142 | return new ModelGenerationMethod( | |
143 | val modalRelationQueriesBuilder = ImmutableMap.builder | 143 | statistics, |
144 | for (entry : queries.modalRelationQueries.entrySet) { | 144 | objectRefinementRules.values, |
145 | val annotation = entry.key.annotations.filter(TransfomedViatraQuery).head | 145 | relationRefinementRules.values, |
146 | if (annotation !== null) { | 146 | unfinishedMultiplicities, |
147 | modalRelationQueriesBuilder.put(annotation.patternFullyQualifiedName, entry.value) | 147 | unfinishedWF, |
148 | } | 148 | invalidWF, |
149 | } | 149 | mustUnitPropagationPreconditions, |
150 | val modalRelationQueries = modalRelationQueriesBuilder.build | 150 | currentUnitPropagationPreconditions, |
151 | 151 | modalRelationQueries, | |
152 | val invalidWF = queries.getInvalidWFQueries.values | 152 | queries.allQueries, |
153 | 153 | transformedObjectives.objectives, | |
154 | val mustUnitPropagationPreconditions = queries.getMustUnitPropagationPreconditionPatterns | 154 | transformedObjectives.optimizationProblem, |
155 | val currentUnitPropagationPreconditions = queries.getCurrentUnitPropagationPreconditionPatterns | 155 | solutionSaver |
156 | 156 | ) | |
157 | val queriesToPrepare = ImmutableSet.builder.addAll(queries.refineObjectQueries.values).addAll( | 157 | } |
158 | queries.refineTypeQueries.values).addAll(queries.refinerelationQueries.values).addAll(queries. | 158 | |
159 | multiplicityConstraintQueries.values.flatMap[allQueries]).addAll(queries.unfinishedWFQueries.values).addAll( | 159 | private def createScopePropagator(ScopePropagatorStrategy scopePropagatorStrategy, |
160 | queries.invalidWFQueries.values).addAll(queries.mustUnitPropagationPreconditionPatterns.values).addAll( | 160 | PartialInterpretation emptySolution, Collection<LinearTypeConstraintHint> hints, |
161 | queries.currentUnitPropagationPreconditionPatterns.values).add(queries.hasElementInContainmentQuery).build | 161 | Collection<PolyhedronExtensionOperator> extensionOperators, GeneratedPatterns queries, |
162 | val queryEngine = ViatraQueryEngine.on(new EMFScope(emptySolution)) | 162 | ModelGenerationStatistics statistics) { |
163 | GenericQueryGroup.of(queriesToPrepare).prepare(queryEngine) | 163 | if (!hints.empty && !(scopePropagatorStrategy instanceof ScopePropagatorStrategy.Polyhedral)) { |
164 | 164 | throw new IllegalArgumentException("Only the Polyhedral scope propagator strategy can use hints.") | |
165 | return new ModelGenerationMethod( | 165 | } |
166 | statistics, | 166 | switch (scopePropagatorStrategy) { |
167 | objectRefinementRules.values, | 167 | case ScopePropagatorStrategy.None, |
168 | relationRefinementRules.values, | 168 | case ScopePropagatorStrategy.Basic: |
169 | unfinishedMultiplicities, | 169 | new ScopePropagator(emptySolution, statistics) |
170 | unfinishedWF, | 170 | case ScopePropagatorStrategy.BasicTypeHierarchy: |
171 | invalidWF, | 171 | new TypeHierarchyScopePropagator(emptySolution, statistics) |
172 | mustUnitPropagationPreconditions, | 172 | ScopePropagatorStrategy.Polyhedral: { |
173 | currentUnitPropagationPreconditions, | 173 | val types = queries.refineObjectQueries.keySet.map[newType].toSet |
174 | modalRelationQueries, | 174 | val allPatternsByName = queries.allQueries.toMap[fullyQualifiedName] |
175 | queries.allQueries | 175 | val solver = switch (scopePropagatorStrategy.solver) { |
176 | ) | 176 | case Z3Integer: |
177 | } | 177 | new Z3PolyhedronSolver(false, scopePropagatorStrategy.timeoutSeconds) |
178 | 178 | case Z3Real: | |
179 | private def createScopePropagator(ScopePropagatorStrategy scopePropagatorStrategy, | 179 | new Z3PolyhedronSolver(true, scopePropagatorStrategy.timeoutSeconds) |
180 | PartialInterpretation emptySolution, Collection<LinearTypeConstraintHint> hints, GeneratedPatterns queries, | 180 | case Cbc: |
181 | ModelGenerationStatistics statistics) { | 181 | new CbcPolyhedronSolver(false, scopePropagatorStrategy.timeoutSeconds, true) |
182 | if (!hints.empty && !(scopePropagatorStrategy instanceof ScopePropagatorStrategy.Polyhedral)) { | 182 | case Clp: |
183 | throw new IllegalArgumentException("Only the Polyhedral scope propagator strategy can use hints.") | 183 | new CbcPolyhedronSolver(true, scopePropagatorStrategy.timeoutSeconds, true) |
184 | } | 184 | default: |
185 | switch (scopePropagatorStrategy) { | 185 | throw new IllegalArgumentException("Unknown polyhedron solver: " + |
186 | case ScopePropagatorStrategy.None, | 186 | scopePropagatorStrategy.solver) |
187 | case ScopePropagatorStrategy.Basic: | 187 | } |
188 | new ScopePropagator(emptySolution, statistics) | 188 | val strategy = if (extensionOperators.empty) { |
189 | case ScopePropagatorStrategy.BasicTypeHierarchy: | 189 | new CachingSimplePolyhedronScopePropagatorStrategy(solver, statistics) |
190 | new TypeHierarchyScopePropagator(emptySolution, statistics) | 190 | } else { |
191 | ScopePropagatorStrategy.Polyhedral: { | 191 | new ExtendedPolyhedronScopePropagatorStrategy(solver, extensionOperators, statistics) |
192 | val types = queries.refineObjectQueries.keySet.map[newType].toSet | 192 | } |
193 | val allPatternsByName = queries.allQueries.toMap[fullyQualifiedName] | 193 | new PolyhedronScopePropagator(emptySolution, statistics, types, queries.multiplicityConstraintQueries, |
194 | val solver = switch (scopePropagatorStrategy.solver) { | 194 | queries.hasElementInContainmentQuery, allPatternsByName, hints, strategy, |
195 | case Z3Integer: | 195 | scopePropagatorStrategy.requiresUpperBoundIndexing, scopePropagatorStrategy.updateHeuristic) |
196 | new Z3PolyhedronSolver(false, scopePropagatorStrategy.timeoutSeconds) | 196 | } |
197 | case Z3Real: | 197 | default: |
198 | new Z3PolyhedronSolver(true, scopePropagatorStrategy.timeoutSeconds) | 198 | throw new IllegalArgumentException("Unknown scope propagator strategy: " + scopePropagatorStrategy) |
199 | case Cbc: | 199 | } |
200 | new CbcPolyhedronSolver(false, scopePropagatorStrategy.timeoutSeconds, true) | 200 | } |
201 | case Clp: | 201 | } |
202 | new CbcPolyhedronSolver(true, scopePropagatorStrategy.timeoutSeconds, true) | ||
203 | default: | ||
204 | throw new IllegalArgumentException("Unknown polyhedron solver: " + | ||
205 | scopePropagatorStrategy.solver) | ||
206 | } | ||
207 | new PolyhedronScopePropagator(emptySolution, statistics, types, queries.multiplicityConstraintQueries, | ||
208 | queries.hasElementInContainmentQuery, allPatternsByName, hints, solver, | ||
209 | scopePropagatorStrategy.requiresUpperBoundIndexing, scopePropagatorStrategy.updateHeuristic) | ||
210 | } | ||
211 | default: | ||
212 | throw new IllegalArgumentException("Unknown scope propagator strategy: " + scopePropagatorStrategy) | ||
213 | } | ||
214 | } | ||
215 | } | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend index c333feca..8e992741 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend | |||
@@ -1,7 +1,5 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner |
2 | 2 | ||
3 | import com.google.common.collect.ImmutableList | ||
4 | import com.google.common.collect.Lists | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel | 3 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel |
6 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner | 4 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner |
7 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasonerException | 5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasonerException |
@@ -11,7 +9,6 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | |||
11 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage | 9 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage |
12 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicresultFactory | 10 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicresultFactory |
13 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult | 11 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult |
14 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethodProvider | ||
15 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy | 12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy |
16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.PartialInterpretationInitialiser | 13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.PartialInterpretationInitialiser |
17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 14 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
@@ -22,7 +19,6 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.sta | |||
22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.PairwiseNeighbourhoodBasedStateCoderFactory | 19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.PairwiseNeighbourhoodBasedStateCoderFactory |
23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.BasicScopeGlobalConstraint | 20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.BasicScopeGlobalConstraint |
24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.BestFirstStrategyForModelGeneration | 21 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.BestFirstStrategyForModelGeneration |
25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.DiversityChecker | ||
26 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.InconsistentScopeGlobalConstraint | 22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.InconsistentScopeGlobalConstraint |
27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.LoggerSolutionFoundHandler | 23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.LoggerSolutionFoundHandler |
28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.ModelGenerationCompositeObjective | 24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.ModelGenerationCompositeObjective |
@@ -32,11 +28,8 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.PunishSizeObjective | |||
32 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.ScopeObjective | 28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.ScopeObjective |
33 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.SurelyViolatedObjectiveGlobalConstraint | 29 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.SurelyViolatedObjectiveGlobalConstraint |
34 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.UnfinishedMultiplicityObjective | 30 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.UnfinishedMultiplicityObjective |
35 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.ViatraReasonerSolutionSaver | ||
36 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.WF2ObjectiveConverter | 31 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.WF2ObjectiveConverter |
37 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind | 32 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind |
38 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ThreeValuedCostElement | ||
39 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ThreeValuedCostObjective | ||
40 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace | 33 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace |
41 | import java.util.List | 34 | import java.util.List |
42 | import java.util.Map | 35 | import java.util.Map |
@@ -86,12 +79,7 @@ class ViatraReasoner extends LogicReasoner { | |||
86 | problem, | 79 | problem, |
87 | emptySolution, | 80 | emptySolution, |
88 | workspace, | 81 | workspace, |
89 | viatraConfig.nameNewElements, | 82 | viatraConfig |
90 | viatraConfig.typeInferenceMethod, | ||
91 | viatraConfig.calculateObjectCreationCosts, | ||
92 | viatraConfig.scopePropagatorStrategy, | ||
93 | viatraConfig.hints, | ||
94 | viatraConfig.documentationLevel | ||
95 | ) | 83 | ) |
96 | 84 | ||
97 | val compositeObjective = new ModelGenerationCompositeObjective( | 85 | val compositeObjective = new ModelGenerationCompositeObjective( |
@@ -111,45 +99,21 @@ class ViatraReasoner extends LogicReasoner { | |||
111 | dse.addObjective(punishObjective) | 99 | dse.addObjective(punishObjective) |
112 | } | 100 | } |
113 | 101 | ||
114 | val extremalObjectives = Lists.newArrayListWithExpectedSize(viatraConfig.costObjectives.size) | 102 | for (costObjective : method.costObjectives) { |
115 | for (entry : viatraConfig.costObjectives.indexed) { | ||
116 | val objectiveName = '''costObjective«entry.key»''' | ||
117 | val objectiveConfig = entry.value | ||
118 | val elementsBuilder = ImmutableList.builder | ||
119 | for (elementConfig : objectiveConfig.elements) { | ||
120 | val relationName = elementConfig.patternQualifiedName | ||
121 | val modalQueries = method.modalRelationQueries.get(relationName) | ||
122 | if (modalQueries === null) { | ||
123 | throw new IllegalArgumentException("Unknown relation: " + relationName) | ||
124 | } | ||
125 | elementsBuilder.add(new ThreeValuedCostElement( | ||
126 | modalQueries.currentQuery, | ||
127 | modalQueries.mayQuery, | ||
128 | modalQueries.mustQuery, | ||
129 | elementConfig.weight | ||
130 | )) | ||
131 | } | ||
132 | val costElements = elementsBuilder.build | ||
133 | val costObjective = new ThreeValuedCostObjective(objectiveName, costElements, objectiveConfig.kind, | ||
134 | objectiveConfig.threshold, 3) | ||
135 | dse.addObjective(costObjective) | 103 | dse.addObjective(costObjective) |
136 | if (objectiveConfig.findExtremum) { | ||
137 | extremalObjectives += costObjective | ||
138 | } | ||
139 | } | 104 | } |
140 | |||
141 | val numberOfRequiredSolutions = configuration.solutionScope.numberOfRequiredSolutions | 105 | val numberOfRequiredSolutions = configuration.solutionScope.numberOfRequiredSolutions |
142 | val solutionStore = if (extremalObjectives.empty) { | 106 | val solutionStore = if (method.optimizationProblem) { |
143 | new SolutionStore(numberOfRequiredSolutions) | ||
144 | } else { | ||
145 | new SolutionStore() | 107 | new SolutionStore() |
108 | } else { | ||
109 | new SolutionStore(numberOfRequiredSolutions) | ||
146 | } | 110 | } |
147 | solutionStore.registerSolutionFoundHandler(new LoggerSolutionFoundHandler(viatraConfig)) | 111 | solutionStore.registerSolutionFoundHandler(new LoggerSolutionFoundHandler(viatraConfig)) |
148 | val diversityChecker = DiversityChecker.of(viatraConfig.diversityRequirement) | ||
149 | val numericSolver = new NumericSolver(method, viatraConfig.runIntermediateNumericalConsistencyChecks, false) | 112 | val numericSolver = new NumericSolver(method, viatraConfig.runIntermediateNumericalConsistencyChecks, false) |
150 | val solutionSaver = new ViatraReasonerSolutionSaver(newArrayList(extremalObjectives), numberOfRequiredSolutions, | 113 | val solutionSaver = method.solutionSaver |
151 | diversityChecker, numericSolver) | 114 | solutionSaver.numericSolver = numericSolver |
152 | val solutionCopier = solutionSaver.solutionCopier | 115 | val solutionCopier = solutionSaver.solutionCopier |
116 | val diversityChecker = solutionSaver.diversityChecker | ||
153 | solutionStore.withSolutionSaver(solutionSaver) | 117 | solutionStore.withSolutionSaver(solutionSaver) |
154 | dse.solutionStore = solutionStore | 118 | dse.solutionStore = solutionStore |
155 | 119 | ||
@@ -184,7 +148,8 @@ class ViatraReasoner extends LogicReasoner { | |||
184 | dse.addTransformationRule(rule) | 148 | dse.addTransformationRule(rule) |
185 | } | 149 | } |
186 | 150 | ||
187 | val strategy = new BestFirstStrategyForModelGeneration(workspace, viatraConfig, method, solutionSaver, numericSolver) | 151 | val strategy = new BestFirstStrategyForModelGeneration(workspace, viatraConfig, method, solutionSaver, |
152 | numericSolver) | ||
188 | viatraConfig.progressMonitor.workedForwardTransformation | 153 | viatraConfig.progressMonitor.workedForwardTransformation |
189 | val transformationFinished = System.nanoTime | 154 | val transformationFinished = System.nanoTime |
190 | val transformationTime = transformationFinished - transformationStartTime | 155 | val transformationTime = transformationFinished - transformationStartTime |
@@ -210,14 +175,15 @@ class ViatraReasoner extends LogicReasoner { | |||
210 | it.value = (pair.value / 1000000) as int | 175 | it.value = (pair.value / 1000000) as int |
211 | ] | 176 | ] |
212 | } | 177 | } |
213 | for(x: 0..<strategy.times.size) { | 178 | for (x : 0 ..< strategy.times.size) { |
214 | it.entries += createStringStatisticEntry => [ | 179 | it.entries += createStringStatisticEntry => [ |
215 | it.name = '''Solution«x+1»DetailedStatistics''' | 180 | it.name = '''Solution«x+1»DetailedStatistics''' |
216 | it.value = strategy.times.get(x) | 181 | it.value = strategy.times.get(x) |
217 | ] | 182 | ] |
218 | } | 183 | } |
219 | it.entries += createIntStatisticEntry => [ | 184 | it.entries += createIntStatisticEntry => [ |
220 | it.name = "ExplorationInitializationTime" it.value = ((strategy.explorationStarted-transformationFinished)/1000000) as int | 185 | it.name = "ExplorationInitializationTime" |
186 | it.value = ((strategy.explorationStarted - transformationFinished) / 1000000) as int | ||
221 | ] | 187 | ] |
222 | it.entries += createIntStatisticEntry => [ | 188 | it.entries += createIntStatisticEntry => [ |
223 | it.name = "TransformationExecutionTime" | 189 | it.name = "TransformationExecutionTime" |
@@ -228,6 +194,10 @@ class ViatraReasoner extends LogicReasoner { | |||
228 | it.value = (method.statistics.scopePropagationTime / 1000000) as int | 194 | it.value = (method.statistics.scopePropagationTime / 1000000) as int |
229 | ] | 195 | ] |
230 | it.entries += createIntStatisticEntry => [ | 196 | it.entries += createIntStatisticEntry => [ |
197 | it.name = "MustRelationPropagationTime" | ||
198 | it.value = (method.statistics.mustRelationPropagationTime / 1000000) as int | ||
199 | ] | ||
200 | it.entries += createIntStatisticEntry => [ | ||
231 | it.name = "TypeAnalysisTime" | 201 | it.name = "TypeAnalysisTime" |
232 | it.value = (method.statistics.preliminaryTypeAnalisisTime / 1000000) as int | 202 | it.value = (method.statistics.preliminaryTypeAnalisisTime / 1000000) as int |
233 | ] | 203 | ] |
@@ -248,22 +218,28 @@ class ViatraReasoner extends LogicReasoner { | |||
248 | it.value = dse.numberOfStates as int | 218 | it.value = dse.numberOfStates as int |
249 | ] | 219 | ] |
250 | it.entries += createIntStatisticEntry => [ | 220 | it.entries += createIntStatisticEntry => [ |
251 | it.name = "ForwardTime" it.value = (strategy.forwardTime/1000000) as int | 221 | it.name = "ForwardTime" |
222 | it.value = (strategy.forwardTime / 1000000) as int | ||
252 | ] | 223 | ] |
253 | it.entries += createIntStatisticEntry => [ | 224 | it.entries += createIntStatisticEntry => [ |
254 | it.name = "BacktrackingTime" it.value = (strategy.backtrackingTime/1000000) as int | 225 | it.name = "BacktrackingTime" |
226 | it.value = (strategy.backtrackingTime / 1000000) as int | ||
255 | ] | 227 | ] |
256 | it.entries += createIntStatisticEntry => [ | 228 | it.entries += createIntStatisticEntry => [ |
257 | it.name = "GlobalConstraintEvaluationTime" it.value = (strategy.globalConstraintEvaluationTime/1000000) as int | 229 | it.name = "GlobalConstraintEvaluationTime" |
230 | it.value = (strategy.globalConstraintEvaluationTime / 1000000) as int | ||
258 | ] | 231 | ] |
259 | it.entries += createIntStatisticEntry => [ | 232 | it.entries += createIntStatisticEntry => [ |
260 | it.name = "FitnessCalculationTime" it.value = (strategy.fitnessCalculationTime/1000000) as int | 233 | it.name = "FitnessCalculationTime" |
234 | it.value = (strategy.fitnessCalculationTime / 1000000) as int | ||
261 | ] | 235 | ] |
262 | it.entries += createIntStatisticEntry => [ | 236 | it.entries += createIntStatisticEntry => [ |
263 | it.name = "SolutionCopyTime" it.value = (solutionSaver.totalCopierRuntime/1000000) as int | 237 | it.name = "SolutionCopyTime" |
238 | it.value = (solutionSaver.totalCopierRuntime / 1000000) as int | ||
264 | ] | 239 | ] |
265 | it.entries += createIntStatisticEntry => [ | 240 | it.entries += createIntStatisticEntry => [ |
266 | it.name = "ActivationSelectionTime" it.value = (strategy.activationSelector.runtime/1000000) as int | 241 | it.name = "ActivationSelectionTime" |
242 | it.value = (strategy.activationSelector.runtime / 1000000) as int | ||
267 | ] | 243 | ] |
268 | it.entries += createIntStatisticEntry => [ | 244 | it.entries += createIntStatisticEntry => [ |
269 | it.name = "Decisions" | 245 | it.name = "Decisions" |
@@ -282,27 +258,34 @@ class ViatraReasoner extends LogicReasoner { | |||
282 | it.value = method.statistics.scopePropagatorSolverInvocations | 258 | it.value = method.statistics.scopePropagatorSolverInvocations |
283 | ] | 259 | ] |
284 | it.entries += createIntStatisticEntry => [ | 260 | it.entries += createIntStatisticEntry => [ |
285 | it.name = "NumericalSolverSumTime" it.value = (strategy.numericSolver.runtime/1000000) as int | 261 | it.name = "NumericalSolverSumTime" |
262 | it.value = (strategy.numericSolver.runtime / 1000000) as int | ||
286 | ] | 263 | ] |
287 | it.entries += createIntStatisticEntry => [ | 264 | it.entries += createIntStatisticEntry => [ |
288 | it.name = "NumericalSolverProblemFormingTime" it.value = (strategy.numericSolver.solverFormingProblem/1000000) as int | 265 | it.name = "NumericalSolverProblemFormingTime" |
266 | it.value = (strategy.numericSolver.solverFormingProblem / 1000000) as int | ||
289 | ] | 267 | ] |
290 | it.entries += createIntStatisticEntry => [ | 268 | it.entries += createIntStatisticEntry => [ |
291 | it.name = "NumericalSolverSolvingTime" it.value = (strategy.numericSolver.solverSolvingProblem/1000000) as int | 269 | it.name = "NumericalSolverSolvingTime" |
270 | it.value = (strategy.numericSolver.solverSolvingProblem / 1000000) as int | ||
292 | ] | 271 | ] |
293 | it.entries += createIntStatisticEntry => [ | 272 | it.entries += createIntStatisticEntry => [ |
294 | it.name = "NumericalSolverInterpretingSolution" it.value = (strategy.numericSolver.solverSolution/1000000) as int | 273 | it.name = "NumericalSolverInterpretingSolution" |
274 | it.value = (strategy.numericSolver.solverSolution / 1000000) as int | ||
295 | ] | 275 | ] |
296 | it.entries += createIntStatisticEntry => [ | 276 | it.entries += createIntStatisticEntry => [ |
297 | it.name = "NumericalSolverCachingTime" it.value = (strategy.numericSolver.cachingTime/1000000) as int | 277 | it.name = "NumericalSolverCachingTime" |
278 | it.value = (strategy.numericSolver.cachingTime / 1000000) as int | ||
298 | ] | 279 | ] |
299 | it.entries += createIntStatisticEntry => [ | 280 | it.entries += createIntStatisticEntry => [ |
300 | it.name = "NumericalSolverCallNumber" it.value = strategy.numericSolver.numberOfSolverCalls | 281 | it.name = "NumericalSolverCallNumber" |
282 | it.value = strategy.numericSolver.numberOfSolverCalls | ||
301 | ] | 283 | ] |
302 | it.entries += createIntStatisticEntry => [ | 284 | it.entries += createIntStatisticEntry => [ |
303 | it.name = "NumericalSolverCachedAnswerNumber" it.value = strategy.numericSolver.numberOfCachedSolverCalls | 285 | it.name = "NumericalSolverCachedAnswerNumber" |
286 | it.value = strategy.numericSolver.numberOfCachedSolverCalls | ||
304 | ] | 287 | ] |
305 | if(diversityChecker.active) { | 288 | if (diversityChecker.active) { |
306 | it.entries += createIntStatisticEntry => [ | 289 | it.entries += createIntStatisticEntry => [ |
307 | it.name = "SolutionDiversityCheckTime" | 290 | it.name = "SolutionDiversityCheckTime" |
308 | it.value = (diversityChecker.totalRuntime / 1000000) as int | 291 | it.value = (diversityChecker.totalRuntime / 1000000) as int |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend index 0173124c..fbe6da9d 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend | |||
@@ -4,19 +4,20 @@ import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner | |||
4 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicSolverConfiguration | 4 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicSolverConfiguration |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration | 5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration |
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration |
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethod | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod | 7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod |
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorConstraints | 9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorConstraints |
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorSolver | 10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorSolver |
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy | 11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy |
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.UnitPropagationPatternGenerator | ||
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualiser | 13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualiser |
14 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.CostObjectiveHint | ||
13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind | 15 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveKind |
14 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold | 16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold |
15 | import java.util.LinkedList | 17 | import java.util.LinkedList |
16 | import java.util.List | 18 | import java.util.List |
17 | import java.util.Set | 19 | import java.util.Set |
18 | import org.eclipse.xtext.xbase.lib.Functions.Function1 | 20 | import org.eclipse.xtext.xbase.lib.Functions.Function1 |
19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint | ||
20 | 21 | ||
21 | enum StateCoderStrategy { | 22 | enum StateCoderStrategy { |
22 | Neighbourhood, | 23 | Neighbourhood, |
@@ -77,6 +78,8 @@ class ViatraReasonerConfiguration extends LogicSolverConfiguration { | |||
77 | public var List<LinearTypeConstraintHint> hints = newArrayList | 78 | public var List<LinearTypeConstraintHint> hints = newArrayList |
78 | 79 | ||
79 | public var List<CostObjectiveConfiguration> costObjectives = newArrayList | 80 | public var List<CostObjectiveConfiguration> costObjectives = newArrayList |
81 | |||
82 | public var List<UnitPropagationPatternGenerator> unitPropagationPatternGenerators = newArrayList | ||
80 | } | 83 | } |
81 | 84 | ||
82 | class DiversityDescriptor { | 85 | class DiversityDescriptor { |
@@ -111,9 +114,11 @@ class CostObjectiveConfiguration { | |||
111 | public var ObjectiveKind kind | 114 | public var ObjectiveKind kind |
112 | public var ObjectiveThreshold threshold | 115 | public var ObjectiveThreshold threshold |
113 | public var boolean findExtremum | 116 | public var boolean findExtremum |
117 | public var CostObjectiveHint hint | ||
114 | } | 118 | } |
115 | 119 | ||
116 | class CostObjectiveElementConfiguration { | 120 | class CostObjectiveElementConfiguration { |
117 | public var String patternQualifiedName | 121 | public var String patternQualifiedName |
118 | public var int weight | 122 | public var int weight |
119 | } | 123 | } |
124 | |||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java index a2de1abc..4b7cead1 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java | |||
@@ -28,8 +28,6 @@ import org.eclipse.viatra.dse.objectives.Fitness; | |||
28 | import org.eclipse.viatra.dse.objectives.ObjectiveComparatorHelper; | 28 | import org.eclipse.viatra.dse.objectives.ObjectiveComparatorHelper; |
29 | import org.eclipse.viatra.dse.solutionstore.ISolutionFoundHandler; | 29 | import org.eclipse.viatra.dse.solutionstore.ISolutionFoundHandler; |
30 | import org.eclipse.viatra.dse.solutionstore.SolutionStore; | 30 | import org.eclipse.viatra.dse.solutionstore.SolutionStore; |
31 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
32 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher; | ||
33 | 31 | ||
34 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; | 32 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel; |
35 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner; | 33 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner; |
@@ -37,12 +35,11 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; | |||
37 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.InconsistencyResult; | 35 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.InconsistencyResult; |
38 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; | 36 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult; |
39 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult; | 37 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult; |
40 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethod; | ||
41 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.PartialInterpretation2Logic; | 38 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.PartialInterpretation2Logic; |
42 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; | 39 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; |
43 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.NeighbourhoodBasedPartialInterpretationStateCoder; | ||
44 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; | 40 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualisation; |
45 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualiser; | 41 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretationVisualiser; |
42 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethod; | ||
46 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; | 43 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration; |
47 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace; | 44 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace; |
48 | 45 | ||
@@ -301,13 +298,12 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
301 | return activationIds; | 298 | return activationIds; |
302 | } | 299 | } |
303 | 300 | ||
304 | private void checkForSolution(final Fitness fittness) { | 301 | private void checkForSolution(final Fitness fitness) { |
305 | solutionStore.newSolution(context); | 302 | solutionStore.newSolution(context); |
306 | } | 303 | } |
307 | 304 | ||
308 | public List<String> times = new LinkedList<String>(); | 305 | public List<String> times = new LinkedList<String>(); |
309 | private void saveTimes() { | 306 | private void saveTimes() { |
310 | long statecoderTime = ((NeighbourhoodBasedPartialInterpretationStateCoder<?, ?>)this.context.getStateCoder()).getStatecoderRuntime()/1000000; | ||
311 | long forwardTime = context.getDesignSpaceManager().getForwardTime()/1000000; | 307 | long forwardTime = context.getDesignSpaceManager().getForwardTime()/1000000; |
312 | long backtrackingTime = context.getDesignSpaceManager().getBacktrackingTime()/1000000; | 308 | long backtrackingTime = context.getDesignSpaceManager().getBacktrackingTime()/1000000; |
313 | long activationSelection = this.activationSelector.getRuntime()/1000000; | 309 | long activationSelection = this.activationSelector.getRuntime()/1000000; |
@@ -317,8 +313,7 @@ public class BestFirstStrategyForModelGeneration implements IStrategy { | |||
317 | long numericalSolverSolving = this.numericSolver.getSolverSolvingProblem()/1000000; | 313 | long numericalSolverSolving = this.numericSolver.getSolverSolvingProblem()/1000000; |
318 | long numericalSolverInterpreting = this.numericSolver.getSolverSolution()/1000000; | 314 | long numericalSolverInterpreting = this.numericSolver.getSolverSolution()/1000000; |
319 | this.times.add( | 315 | this.times.add( |
320 | "(TransformationExecutionTime"+method.getStatistics().transformationExecutionTime/1000000+ | 316 | "(TransformationExecutionTime"+method.getStatistics().transformationExecutionTime/1000000+ |
321 | "|StateCoderTime:"+statecoderTime+ | ||
322 | "|ForwardTime:"+forwardTime+ | 317 | "|ForwardTime:"+forwardTime+ |
323 | "|Backtrackingtime:"+backtrackingTime+ | 318 | "|Backtrackingtime:"+backtrackingTime+ |
324 | "|GlobalConstraintEvaluationTime:"+(globalConstraintEvaluationTime/1000000)+ | 319 | "|GlobalConstraintEvaluationTime:"+(globalConstraintEvaluationTime/1000000)+ |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/NumericSolver.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/NumericSolver.xtend index 066040a0..70e8e9c2 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/NumericSolver.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/NumericSolver.xtend | |||
@@ -1,13 +1,13 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse |
2 | 2 | ||
3 | import hu.bme.mit.inf.dslreasoner.viatra2logic.NumericTranslator | 3 | import hu.bme.mit.inf.dslreasoner.viatra2logic.NumericTranslator |
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethod | ||
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BooleanElement | 4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BooleanElement |
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.IntegerElement | 5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.IntegerElement |
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PrimitiveElement | 7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PrimitiveElement |
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.RealElement | 8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.RealElement |
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.StringElement | 9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.StringElement |
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethod | ||
11 | import java.math.BigDecimal | 11 | import java.math.BigDecimal |
12 | import java.util.HashMap | 12 | import java.util.HashMap |
13 | import java.util.LinkedHashMap | 13 | import java.util.LinkedHashMap |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/PartialModelAsLogicInterpretation.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/PartialModelAsLogicInterpretation.xtend index cfd11816..b48d0831 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/PartialModelAsLogicInterpretation.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/PartialModelAsLogicInterpretation.xtend | |||
@@ -22,12 +22,13 @@ import java.util.List | |||
22 | import java.util.Map | 22 | import java.util.Map |
23 | import java.util.TreeSet | 23 | import java.util.TreeSet |
24 | import org.eclipse.emf.ecore.EObject | 24 | import org.eclipse.emf.ecore.EObject |
25 | import org.eclipse.xtend.lib.annotations.Accessors | ||
25 | import org.eclipse.xtext.xbase.lib.Functions.Function1 | 26 | import org.eclipse.xtext.xbase.lib.Functions.Function1 |
26 | 27 | ||
27 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 28 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
28 | 29 | ||
29 | class PartialModelAsLogicInterpretation implements LogicModelInterpretation{ | 30 | class PartialModelAsLogicInterpretation implements LogicModelInterpretation{ |
30 | val PartialInterpretation partialInterpretation | 31 | @Accessors val PartialInterpretation partialInterpretation |
31 | val Map<EObject, EObject> trace; | 32 | val Map<EObject, EObject> trace; |
32 | val Map<TypeDeclaration,PartialComplexTypeInterpretation> type2Interpretation | 33 | val Map<TypeDeclaration,PartialComplexTypeInterpretation> type2Interpretation |
33 | val Map<RelationDeclaration,PartialRelationInterpretation> relation2Interpretation | 34 | val Map<RelationDeclaration,PartialRelationInterpretation> relation2Interpretation |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/SolutionCopier.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/SolutionCopier.xtend index 38c8f5a1..33b69436 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/SolutionCopier.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/SolutionCopier.xtend | |||
@@ -26,16 +26,12 @@ class CopiedSolution { | |||
26 | * using the supplied {@link NumericSolver}. | 26 | * using the supplied {@link NumericSolver}. |
27 | */ | 27 | */ |
28 | class SolutionCopier { | 28 | class SolutionCopier { |
29 | val NumericSolver numericSolver | ||
30 | val copiedSolutions = new LinkedHashMap<Object, CopiedSolution> | 29 | val copiedSolutions = new LinkedHashMap<Object, CopiedSolution> |
31 | 30 | ||
31 | @Accessors NumericSolver numericSolver | ||
32 | long startTime = System.nanoTime | 32 | long startTime = System.nanoTime |
33 | @Accessors(PUBLIC_GETTER) long totalCopierRuntime = 0 | 33 | @Accessors(PUBLIC_GETTER) long totalCopierRuntime = 0 |
34 | 34 | ||
35 | new(NumericSolver numericSolver) { | ||
36 | this.numericSolver = numericSolver | ||
37 | } | ||
38 | |||
39 | def void copySolution(ThreadContext context, Object solutionId) { | 35 | def void copySolution(ThreadContext context, Object solutionId) { |
40 | val existingCopy = copiedSolutions.get(solutionId) | 36 | val existingCopy = copiedSolutions.get(solutionId) |
41 | if (existingCopy === null) { | 37 | if (existingCopy === null) { |
@@ -47,7 +43,7 @@ class SolutionCopier { | |||
47 | totalCopierRuntime += System.nanoTime - copyStart | 43 | totalCopierRuntime += System.nanoTime - copyStart |
48 | val copierRuntime = System.nanoTime - startTime | 44 | val copierRuntime = System.nanoTime - startTime |
49 | val copiedSolution = new CopiedSolution(copiedPartialInterpretation, copier, copierRuntime) | 45 | val copiedSolution = new CopiedSolution(copiedPartialInterpretation, copier, copierRuntime) |
50 | numericSolver.fillSolutionCopy(copiedSolution.trace) | 46 | numericSolver?.fillSolutionCopy(copiedSolution.trace) |
51 | copiedSolutions.put(solutionId, copiedSolution) | 47 | copiedSolutions.put(solutionId, copiedSolution) |
52 | } else { | 48 | } else { |
53 | existingCopy.current = true | 49 | existingCopy.current = true |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ViatraReasonerSolutionSaver.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ViatraReasonerSolutionSaver.xtend index c0b5008c..e00f76ff 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ViatraReasonerSolutionSaver.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ViatraReasonerSolutionSaver.xtend | |||
@@ -1,5 +1,9 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse |
2 | 2 | ||
3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Bounds | ||
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.DirectionalThresholdObjective | ||
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.IObjectiveBoundsProvider | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization.ObjectiveThreshold | ||
3 | import java.util.HashMap | 7 | import java.util.HashMap |
4 | import java.util.Map | 8 | import java.util.Map |
5 | import org.eclipse.viatra.dse.api.DSEException | 9 | import org.eclipse.viatra.dse.api.DSEException |
@@ -18,24 +22,32 @@ import org.eclipse.xtend.lib.annotations.Accessors | |||
18 | * Will also automatically fill any missing numerical values in the saved solutions | 22 | * Will also automatically fill any missing numerical values in the saved solutions |
19 | * using the supplied {@link NumericSolver}. | 23 | * using the supplied {@link NumericSolver}. |
20 | */ | 24 | */ |
21 | class ViatraReasonerSolutionSaver implements ISolutionSaver { | 25 | class ViatraReasonerSolutionSaver implements ISolutionSaver, IObjectiveBoundsProvider { |
26 | static val TOLERANCE = 1e-10 | ||
27 | |||
22 | @Accessors val SolutionCopier solutionCopier | 28 | @Accessors val SolutionCopier solutionCopier |
23 | val NumericSolver numericSolver | ||
24 | @Accessors val DiversityChecker diversityChecker | 29 | @Accessors val DiversityChecker diversityChecker |
30 | val IObjective[][] leveledExtremalObjectives | ||
25 | val boolean hasExtremalObjectives | 31 | val boolean hasExtremalObjectives |
26 | val int numberOfRequiredSolutions | 32 | val int numberOfRequiredSolutions |
27 | val ObjectiveComparatorHelper comparatorHelper | 33 | val ObjectiveComparatorHelper comparatorHelper |
28 | val Map<SolutionTrajectory, Fitness> trajectories = new HashMap | 34 | val Map<SolutionTrajectory, Fitness> trajectories = new HashMap |
29 | 35 | ||
30 | @Accessors(PUBLIC_SETTER) var Map<Object, Solution> solutionsCollection | 36 | @Accessors var NumericSolver numericSolver |
37 | @Accessors var Map<Object, Solution> solutionsCollection | ||
31 | 38 | ||
32 | new(IObjective[][] leveledExtremalObjectives, int numberOfRequiredSolutions, DiversityChecker diversityChecker, NumericSolver numericSolver) { | 39 | new(IObjective[][] leveledExtremalObjectives, int numberOfRequiredSolutions, DiversityChecker diversityChecker) { |
33 | this.diversityChecker = diversityChecker | 40 | this.diversityChecker = diversityChecker |
34 | comparatorHelper = new ObjectiveComparatorHelper(leveledExtremalObjectives) | 41 | comparatorHelper = new ObjectiveComparatorHelper(leveledExtremalObjectives) |
42 | this.leveledExtremalObjectives = leveledExtremalObjectives | ||
35 | hasExtremalObjectives = leveledExtremalObjectives.exists[!empty] | 43 | hasExtremalObjectives = leveledExtremalObjectives.exists[!empty] |
36 | this.numberOfRequiredSolutions = numberOfRequiredSolutions | 44 | this.numberOfRequiredSolutions = numberOfRequiredSolutions |
37 | this.solutionCopier = new SolutionCopier(numericSolver) | 45 | this.solutionCopier = new SolutionCopier |
46 | } | ||
47 | |||
48 | def setNumericSolver(NumericSolver numericSolver) { | ||
38 | this.numericSolver = numericSolver | 49 | this.numericSolver = numericSolver |
50 | solutionCopier.numericSolver = numericSolver | ||
39 | } | 51 | } |
40 | 52 | ||
41 | override saveSolution(ThreadContext context, Object id, SolutionTrajectory solutionTrajectory) { | 53 | override saveSolution(ThreadContext context, Object id, SolutionTrajectory solutionTrajectory) { |
@@ -51,6 +63,7 @@ class ViatraReasonerSolutionSaver implements ISolutionSaver { | |||
51 | if (!shouldSaveSolution(fitness, context)) { | 63 | if (!shouldSaveSolution(fitness, context)) { |
52 | return false | 64 | return false |
53 | } | 65 | } |
66 | println("Found: " + fitness) | ||
54 | val dominatedTrajectories = newArrayList | 67 | val dominatedTrajectories = newArrayList |
55 | for (entry : trajectories.entrySet) { | 68 | for (entry : trajectories.entrySet) { |
56 | val isLastFitnessBetter = comparatorHelper.compare(fitness, entry.value) | 69 | val isLastFitnessBetter = comparatorHelper.compare(fitness, entry.value) |
@@ -99,7 +112,7 @@ class ViatraReasonerSolutionSaver implements ISolutionSaver { | |||
99 | } | 112 | } |
100 | 113 | ||
101 | private def shouldSaveSolution(Fitness fitness, ThreadContext context) { | 114 | private def shouldSaveSolution(Fitness fitness, ThreadContext context) { |
102 | return fitness.satisifiesHardObjectives && numericSolver.currentSatisfiable | 115 | fitness.satisifiesHardObjectives && (numericSolver === null || numericSolver.currentSatisfiable) |
103 | } | 116 | } |
104 | 117 | ||
105 | private def basicSaveSolution(ThreadContext context, Object id, SolutionTrajectory solutionTrajectory, | 118 | private def basicSaveSolution(ThreadContext context, Object id, SolutionTrajectory solutionTrajectory, |
@@ -145,8 +158,93 @@ class ViatraReasonerSolutionSaver implements ISolutionSaver { | |||
145 | } | 158 | } |
146 | solutionsCollection.size < numberOfRequiredSolutions | 159 | solutionsCollection.size < numberOfRequiredSolutions |
147 | } | 160 | } |
148 | 161 | ||
149 | def getTotalCopierRuntime() { | 162 | def getTotalCopierRuntime() { |
150 | solutionCopier.totalCopierRuntime | 163 | solutionCopier.totalCopierRuntime |
151 | } | 164 | } |
165 | |||
166 | override computeRequiredBounds(IObjective objective, Bounds bounds) { | ||
167 | if (!hasExtremalObjectives) { | ||
168 | return | ||
169 | } | ||
170 | if (objective instanceof DirectionalThresholdObjective) { | ||
171 | switch (threshold : objective.threshold) { | ||
172 | case ObjectiveThreshold.NO_THRESHOLD: { | ||
173 | // No threshold to set. | ||
174 | } | ||
175 | ObjectiveThreshold.Exclusive: { | ||
176 | switch (kind : objective.kind) { | ||
177 | case HIGHER_IS_BETTER: | ||
178 | bounds.tightenLowerBound(Math.floor(threshold.threshold + 1) as int) | ||
179 | case LOWER_IS_BETTER: | ||
180 | bounds.tightenUpperBound(Math.ceil(threshold.threshold - 1) as int) | ||
181 | default: | ||
182 | throw new IllegalArgumentException("Unknown objective kind" + kind) | ||
183 | } | ||
184 | if (threshold.clampToThreshold) { | ||
185 | return | ||
186 | } | ||
187 | } | ||
188 | ObjectiveThreshold.Inclusive: { | ||
189 | switch (kind : objective.kind) { | ||
190 | case HIGHER_IS_BETTER: | ||
191 | bounds.tightenLowerBound(Math.ceil(threshold.threshold) as int) | ||
192 | case LOWER_IS_BETTER: | ||
193 | bounds.tightenUpperBound(Math.floor(threshold.threshold) as int) | ||
194 | default: | ||
195 | throw new IllegalArgumentException("Unknown objective kind" + kind) | ||
196 | } | ||
197 | if (threshold.clampToThreshold) { | ||
198 | return | ||
199 | } | ||
200 | } | ||
201 | default: | ||
202 | throw new IllegalArgumentException("Unknown threshold: " + threshold) | ||
203 | } | ||
204 | for (level : leveledExtremalObjectives) { | ||
205 | switch (level.size) { | ||
206 | case 0: { | ||
207 | // Nothing to do, wait for the next level. | ||
208 | } | ||
209 | case 1: { | ||
210 | val primaryObjective = level.get(0) | ||
211 | if (primaryObjective != objective) { | ||
212 | // There are no worst-case bounds for secondary objectives. | ||
213 | return | ||
214 | } | ||
215 | } | ||
216 | default: | ||
217 | // There are no worst-case bounds for Pareto front calculation. | ||
218 | return | ||
219 | } | ||
220 | } | ||
221 | val fitnessIterator = trajectories.values.iterator | ||
222 | if (!fitnessIterator.hasNext) { | ||
223 | return | ||
224 | } | ||
225 | val fitness = fitnessIterator.next.get(objective.name) | ||
226 | while (fitnessIterator.hasNext) { | ||
227 | val otherFitness = fitnessIterator.next.get(objective.name) | ||
228 | if (Math.abs(fitness - otherFitness) > TOLERANCE) { | ||
229 | throw new IllegalStateException("Inconsistent fitness: " + objective.name) | ||
230 | } | ||
231 | } | ||
232 | switch (kind : objective.kind) { | ||
233 | case HIGHER_IS_BETTER: | ||
234 | if (needsMoreSolutionsWithSameFitness) { | ||
235 | bounds.tightenLowerBound(Math.floor(fitness) as int) | ||
236 | } else { | ||
237 | bounds.tightenLowerBound(Math.floor(fitness + 1) as int) | ||
238 | } | ||
239 | case LOWER_IS_BETTER: | ||
240 | if (needsMoreSolutionsWithSameFitness) { | ||
241 | bounds.tightenUpperBound(Math.ceil(fitness) as int) | ||
242 | } else { | ||
243 | bounds.tightenUpperBound(Math.ceil(fitness - 1) as int) | ||
244 | } | ||
245 | default: | ||
246 | throw new IllegalArgumentException("Unknown objective kind" + kind) | ||
247 | } | ||
248 | } | ||
249 | } | ||
152 | } | 250 | } |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/CostElementMatchers.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/CostElementMatchers.xtend new file mode 100644 index 00000000..885b14e8 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/CostElementMatchers.xtend | |||
@@ -0,0 +1,137 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization | ||
2 | |||
3 | import com.google.common.collect.ImmutableList | ||
4 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage | ||
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage | ||
6 | import java.util.List | ||
7 | import org.eclipse.emf.ecore.EObject | ||
8 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | ||
9 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | ||
10 | import org.eclipse.xtend.lib.annotations.Data | ||
11 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | ||
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
13 | |||
14 | @FunctionalInterface | ||
15 | interface ParameterScopeBound { | ||
16 | def double getUpperBound() | ||
17 | } | ||
18 | |||
19 | @Data | ||
20 | class CostElementMatch { | ||
21 | val IPatternMatch match | ||
22 | val boolean must | ||
23 | |||
24 | def isMulti() { | ||
25 | CostElementMatchers.isMultiMatch(match) | ||
26 | } | ||
27 | } | ||
28 | |||
29 | @Data | ||
30 | class CostElementMatchers { | ||
31 | val ViatraQueryMatcher<? extends IPatternMatch> currentMatcher | ||
32 | val ViatraQueryMatcher<? extends IPatternMatch> mayMatcher | ||
33 | val ViatraQueryMatcher<? extends IPatternMatch> mustMatcher | ||
34 | val List<ParameterScopeBound> parameterScopeBounds | ||
35 | val int weight | ||
36 | |||
37 | def getCurrentNumberOfMatches() { | ||
38 | currentMatcher.countMatches | ||
39 | } | ||
40 | |||
41 | def getMinimumNumberOfMatches() { | ||
42 | mustMatcher.countMatches | ||
43 | } | ||
44 | |||
45 | def getMaximumNumberOfMatches() { | ||
46 | var double sum = 0 | ||
47 | val iterator = mayMatcher.streamAllMatches.iterator | ||
48 | while (iterator.hasNext) { | ||
49 | val match = iterator.next | ||
50 | var double product = 1 | ||
51 | val numberOfParameters = parameterScopeBounds.size | ||
52 | for (var int i = 0; i < numberOfParameters; i++) { | ||
53 | if (isMulti(match.get(i + 2))) { | ||
54 | val scopeBound = parameterScopeBounds.get(i) | ||
55 | product *= scopeBound.upperBound | ||
56 | } | ||
57 | |||
58 | } | ||
59 | sum += product | ||
60 | } | ||
61 | sum | ||
62 | } | ||
63 | |||
64 | def getMatches() { | ||
65 | ImmutableList.copyOf(mayMatcher.streamAllMatches.iterator.map [ match | | ||
66 | new CostElementMatch(match, mustMatcher.isMatch(match)) | ||
67 | ]) | ||
68 | } | ||
69 | |||
70 | def projectMayMatch(IPatternMatch match, int... indices) { | ||
71 | mayMatcher.projectMatch(match, indices) | ||
72 | } | ||
73 | |||
74 | private static def <T extends IPatternMatch> projectMatch(ViatraQueryMatcher<T> matcher, IPatternMatch match, int... indices) { | ||
75 | checkMatch(match) | ||
76 | val n = matcher.specification.parameters.length - 2 | ||
77 | if (indices.length != n) { | ||
78 | throw new IllegalArgumentException("Invalid number of projection indices") | ||
79 | } | ||
80 | val newMatch = matcher.newEmptyMatch | ||
81 | newMatch.set(0, match.get(0)) | ||
82 | newMatch.set(1, match.get(1)) | ||
83 | for (var int i = 0; i < n; i++) { | ||
84 | newMatch.set(i + 2, match.get(indices.get(i))) | ||
85 | } | ||
86 | if (!matcher.hasMatch(newMatch)) { | ||
87 | throw new IllegalArgumentException("Projected match does not exist") | ||
88 | } | ||
89 | return newMatch | ||
90 | } | ||
91 | |||
92 | private static def <T extends IPatternMatch> isMatch(ViatraQueryMatcher<T> matcher, IPatternMatch match) { | ||
93 | val n = matcher.specification.parameters.length | ||
94 | if (n != match.specification.parameters.length) { | ||
95 | throw new IllegalArgumentException("Invalid number of match arguments") | ||
96 | } | ||
97 | val newMatch = matcher.newEmptyMatch | ||
98 | for (var int i = 0; i < n; i++) { | ||
99 | newMatch.set(i, match.get(i)) | ||
100 | } | ||
101 | return matcher.hasMatch(newMatch) | ||
102 | } | ||
103 | |||
104 | static def isMulti(Object o) { | ||
105 | if (o instanceof EObject) { | ||
106 | switch (feature : o.eContainmentFeature) { | ||
107 | case LogicproblemPackage.eINSTANCE.logicProblem_Elements, | ||
108 | case PartialinterpretationPackage.eINSTANCE.partialInterpretation_NewElements: | ||
109 | false | ||
110 | case PartialinterpretationPackage.eINSTANCE.partialInterpretation_OpenWorldElements: | ||
111 | true | ||
112 | default: | ||
113 | throw new IllegalStateException("Unknown containment feature for element: " + feature) | ||
114 | } | ||
115 | } else { | ||
116 | false | ||
117 | } | ||
118 | } | ||
119 | |||
120 | static def isMultiMatch(IPatternMatch match) { | ||
121 | checkMatch(match) | ||
122 | val n = match.specification.parameters.length | ||
123 | for (var int i = 2; i < n; i++) { | ||
124 | if (isMulti(match.get(i))) { | ||
125 | return true | ||
126 | } | ||
127 | } | ||
128 | false | ||
129 | } | ||
130 | |||
131 | private static def checkMatch(IPatternMatch match) { | ||
132 | val n = match.specification.parameters.length | ||
133 | if (n < 2 || !(match.get(0) instanceof LogicProblem) || !(match.get(1) instanceof PartialInterpretation)) { | ||
134 | throw new IllegalArgumentException("Match is not from the partial interpretation") | ||
135 | } | ||
136 | } | ||
137 | } | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/CostObjectiveHint.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/CostObjectiveHint.xtend new file mode 100644 index 00000000..2434073d --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/CostObjectiveHint.xtend | |||
@@ -0,0 +1,68 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.BoundSaturationListener | ||
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ExtendedLinearExpressionBuilder | ||
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator | ||
9 | import java.util.Map | ||
10 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | ||
11 | import org.eclipse.xtend.lib.annotations.Accessors | ||
12 | |||
13 | abstract class CostObjectiveHint implements LinearTypeConstraintHint, BoundSaturationListener { | ||
14 | @Accessors ThreeValuedCostObjective objective | ||
15 | @Accessors IObjectiveBoundsProvider boundsProvider | ||
16 | |||
17 | Integer bestUpper = null | ||
18 | |||
19 | override getAdditionalPatterns(PatternGenerator patternGenerator, Map<String, PQuery> fqnToPQuery) { | ||
20 | '''''' | ||
21 | } | ||
22 | |||
23 | override createConstraintUpdater(LinearTypeExpressionBuilderFactory builderFactory) { | ||
24 | null | ||
25 | } | ||
26 | |||
27 | def isExact() { | ||
28 | false | ||
29 | } | ||
30 | |||
31 | def PolyhedronExtensionOperator createPolyhedronExtensionOperator( | ||
32 | Map<String, CostElementMatchers> costElementMatchers) { | ||
33 | null | ||
34 | } | ||
35 | |||
36 | def setObjective(ThreeValuedCostObjective objective) { | ||
37 | if (this.objective !== null) { | ||
38 | throw new IllegalStateException("Objective was already set") | ||
39 | } | ||
40 | this.objective = objective | ||
41 | } | ||
42 | |||
43 | def setBoundsProvider(IObjectiveBoundsProvider boundsProvider) { | ||
44 | if (this.boundsProvider !== null) { | ||
45 | throw new IllegalStateException("Objective bounds provider was already set") | ||
46 | } | ||
47 | this.boundsProvider = boundsProvider | ||
48 | } | ||
49 | |||
50 | protected def buildWithBounds(ExtendedLinearExpressionBuilder builder) { | ||
51 | val bounds = builder.build(this) | ||
52 | if (objective !== null && boundsProvider !== null) { | ||
53 | boundsProvider.computeRequiredBounds(objective, bounds) | ||
54 | } | ||
55 | if (exact && bestUpper !== null) { | ||
56 | bounds.tightenLowerBound(bestUpper) | ||
57 | } | ||
58 | bounds | ||
59 | } | ||
60 | |||
61 | override boundsSaturated(Integer lower, Integer upper) { | ||
62 | if (upper !== null && (bestUpper === null || bestUpper < upper)) { | ||
63 | bestUpper = upper | ||
64 | } | ||
65 | objective?.boundsSaturated(lower, upper) | ||
66 | } | ||
67 | |||
68 | } | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/IObjectiveBoundsProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/IObjectiveBoundsProvider.xtend new file mode 100644 index 00000000..3c4d36a5 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/IObjectiveBoundsProvider.xtend | |||
@@ -0,0 +1,8 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Bounds | ||
4 | import org.eclipse.viatra.dse.objectives.IObjective | ||
5 | |||
6 | interface IObjectiveBoundsProvider { | ||
7 | def void computeRequiredBounds(IObjective objective, Bounds bounds) | ||
8 | } | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/ThreeValuedCostObjective.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/ThreeValuedCostObjective.xtend index 0a6fd55b..9b1a7e9f 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/ThreeValuedCostObjective.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/ThreeValuedCostObjective.xtend | |||
@@ -1,85 +1,80 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization |
2 | 2 | ||
3 | import com.google.common.collect.ImmutableList | 3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.BoundSaturationListener |
4 | import java.util.Collection | 4 | import java.util.Map |
5 | import org.eclipse.viatra.dse.base.ThreadContext | 5 | import org.eclipse.viatra.dse.base.ThreadContext |
6 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | 6 | import org.eclipse.xtend.lib.annotations.Accessors |
7 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification | ||
8 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | ||
9 | import org.eclipse.xtend.lib.annotations.Data | ||
10 | 7 | ||
11 | @Data | 8 | class ThreeValuedCostObjective extends AbstractThreeValuedObjective implements BoundSaturationListener { |
12 | class ThreeValuedCostElement { | 9 | @Accessors val Map<String, CostElementMatchers> matchers |
13 | val IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> currentMatchQuery | 10 | double lowerBoundHint = Double.NEGATIVE_INFINITY |
14 | val IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> mayMatchQuery | 11 | double upperBoundHint = Double.POSITIVE_INFINITY |
15 | val IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> mustMatchQuery | ||
16 | val int weight | ||
17 | } | ||
18 | |||
19 | class ThreeValuedCostObjective extends AbstractThreeValuedObjective { | ||
20 | val Collection<ThreeValuedCostElement> costElements | ||
21 | Collection<CostElementMatchers> matchers | ||
22 | 12 | ||
23 | new(String name, Collection<ThreeValuedCostElement> costElements, ObjectiveKind kind, ObjectiveThreshold threshold, | 13 | new(String name, Map<String, CostElementMatchers> matchers, ObjectiveKind kind, ObjectiveThreshold threshold, |
24 | int level) { | 14 | int level) { |
25 | super(name, kind, threshold, level) | 15 | super(name, kind, threshold, level) |
26 | this.costElements = costElements | 16 | this.matchers = matchers |
27 | } | 17 | } |
28 | 18 | ||
29 | override createNew() { | 19 | override createNew() { |
30 | new ThreeValuedCostObjective(name, costElements, kind, threshold, level) | 20 | // new ThreeValuedCostObjective(name, matchers, kind, threshold, level) |
21 | throw new UnsupportedOperationException("ThreeValuedCostObjective can only be used from a single thread") | ||
31 | } | 22 | } |
32 | 23 | ||
33 | override init(ThreadContext context) { | 24 | override init(ThreadContext context) { |
34 | val queryEngine = context.queryEngine | ||
35 | matchers = ImmutableList.copyOf(costElements.map [ element | | ||
36 | new CostElementMatchers( | ||
37 | queryEngine.getMatcher(element.currentMatchQuery), | ||
38 | queryEngine.getMatcher(element.mayMatchQuery), | ||
39 | queryEngine.getMatcher(element.mustMatchQuery), | ||
40 | element.weight | ||
41 | ) | ||
42 | ]) | ||
43 | } | 25 | } |
44 | 26 | ||
45 | override getRawFitness(ThreadContext context) { | 27 | override getRawFitness(ThreadContext context) { |
46 | var int cost = 0 | 28 | var double cost = 0 |
47 | for (matcher : matchers) { | 29 | for (matcher : matchers.values) { |
48 | cost += matcher.weight * matcher.currentMatcher.countMatches | 30 | cost += matcher.weight * matcher.currentNumberOfMatches |
49 | } | 31 | } |
50 | cost as double | 32 | cost |
51 | } | 33 | } |
52 | 34 | ||
53 | override getLowestPossibleFitness(ThreadContext threadContext) { | 35 | override getLowestPossibleFitness(ThreadContext threadContext) { |
54 | var int cost = 0 | 36 | var double cost = 0 |
55 | for (matcher : matchers) { | 37 | for (matcher : matchers.values) { |
56 | if (matcher.weight >= 0) { | 38 | if (matcher.weight >= 0) { |
57 | cost += matcher.weight * matcher.mustMatcher.countMatches | 39 | cost += matcher.weight * matcher.minimumNumberOfMatches |
58 | } else if (matcher.mayMatcher.countMatches > 0) { | 40 | } else { |
59 | // TODO Count may matches. | 41 | cost += matcher.weight * matcher.maximumNumberOfMatches |
60 | return Double.NEGATIVE_INFINITY | ||
61 | } | 42 | } |
62 | } | 43 | } |
63 | cost as double | 44 | val boundWithHint = Math.max(lowerBoundHint, cost) |
45 | if (boundWithHint > upperBoundHint) { | ||
46 | throw new IllegalStateException("Inconsistent cost bounds") | ||
47 | } | ||
48 | boundWithHint | ||
64 | } | 49 | } |
65 | 50 | ||
66 | override getHighestPossibleFitness(ThreadContext threadContext) { | 51 | override getHighestPossibleFitness(ThreadContext threadContext) { |
67 | var int cost = 0 | 52 | var double cost = 0 |
68 | for (matcher : matchers) { | 53 | for (matcher : matchers.values) { |
69 | if (matcher.weight <= 0) { | 54 | if (matcher.weight <= 0) { |
70 | cost += matcher.weight * matcher.mustMatcher.countMatches | 55 | cost += matcher.weight * matcher.minimumNumberOfMatches |
71 | } else if (matcher.mayMatcher.countMatches > 0) { | 56 | } else { |
72 | return Double.POSITIVE_INFINITY | 57 | cost += matcher.weight * matcher.maximumNumberOfMatches |
73 | } | 58 | } |
74 | } | 59 | } |
75 | cost as double | 60 | val boundWithHint = Math.min(upperBoundHint, cost) |
61 | if (boundWithHint < lowerBoundHint) { | ||
62 | throw new IllegalStateException("Inconsistent cost bounds") | ||
63 | } | ||
64 | boundWithHint | ||
76 | } | 65 | } |
77 | 66 | ||
78 | @Data | 67 | override boundsSaturated(Integer lower, Integer upper) { |
79 | private static class CostElementMatchers { | 68 | lowerBoundHint = if (lower === null) { |
80 | val ViatraQueryMatcher<? extends IPatternMatch> currentMatcher | 69 | Double.NEGATIVE_INFINITY |
81 | val ViatraQueryMatcher<? extends IPatternMatch> mayMatcher | 70 | } else { |
82 | val ViatraQueryMatcher<? extends IPatternMatch> mustMatcher | 71 | lower |
83 | val int weight | 72 | } |
73 | upperBoundHint = if (upper === null) { | ||
74 | Double.POSITIVE_INFINITY | ||
75 | } else { | ||
76 | upper | ||
77 | } | ||
78 | println('''Bounds saturated: «lower»..«upper»''') | ||
84 | } | 79 | } |
85 | } | 80 | } |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/ThreeValuedCostObjectiveProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/ThreeValuedCostObjectiveProvider.xtend new file mode 100644 index 00000000..c2750acd --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/optimization/ThreeValuedCostObjectiveProvider.xtend | |||
@@ -0,0 +1,205 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.optimization | ||
2 | |||
3 | import com.google.common.collect.ImmutableList | ||
4 | import com.google.common.collect.ImmutableMap | ||
5 | import com.google.common.collect.Lists | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolTypeReference | ||
7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference | ||
8 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntTypeReference | ||
9 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealTypeReference | ||
10 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation | ||
11 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.StringTypeReference | ||
12 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration | ||
13 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeReference | ||
14 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransfomedViatraQuery | ||
15 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronExtensionOperator | ||
16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.ModalPatternQueries | ||
17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialBooleanInterpretation | ||
18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation | ||
19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialIntegerInterpretation | ||
20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
21 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRealInterpretation | ||
22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialStringInterpretation | ||
23 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope | ||
24 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.CostObjectiveConfiguration | ||
25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.CostObjectiveElementConfiguration | ||
26 | import java.util.Collection | ||
27 | import java.util.Map | ||
28 | import org.eclipse.viatra.dse.objectives.IObjective | ||
29 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine | ||
30 | import org.eclipse.xtend.lib.annotations.Data | ||
31 | |||
32 | @Data | ||
33 | class ThreeValuedCostObjectiveProviderResult { | ||
34 | val Collection<IObjective> objectives | ||
35 | val Collection<CostObjectiveHint> hints | ||
36 | val Collection<PolyhedronExtensionOperator> extensionOperators | ||
37 | val IObjective[][] leveledExtremalObjectives | ||
38 | val boolean optimizationProblem | ||
39 | } | ||
40 | |||
41 | class ThreeValuedCostObjectiveProvider { | ||
42 | static val COST_OBJECTIVE_LEVEL = 3 | ||
43 | |||
44 | val ViatraQueryEngine queryEngine | ||
45 | val Map<String, ModalPatternQueries> modalRelationQueries | ||
46 | val Map<String, Relation> qualifiedNameToRelationMap | ||
47 | val ParameterScopeBound defaultBounds | ||
48 | val ParameterScopeBound booleanBounds | ||
49 | val ParameterScopeBound integerBounds | ||
50 | val ParameterScopeBound realBounds | ||
51 | val ParameterScopeBound stringBounds | ||
52 | val Map<TypeDeclaration, ParameterScopeBound> typeDeclarationToBoundsMap | ||
53 | |||
54 | new(ViatraQueryEngine queryEngine, PartialInterpretation interpretation, | ||
55 | Map<String, ModalPatternQueries> modalRelationQueries) { | ||
56 | this.queryEngine = queryEngine | ||
57 | this.modalRelationQueries = modalRelationQueries | ||
58 | qualifiedNameToRelationMap = ImmutableMap.copyOf( | ||
59 | interpretation.problem.annotations.filter(TransfomedViatraQuery). | ||
60 | toMap([patternFullyQualifiedName], [target])) | ||
61 | defaultBounds = new PartialInterpretationBasedParameterScopeBound(interpretation) | ||
62 | var ParameterScopeBound booleanBounds = null | ||
63 | var ParameterScopeBound integerBounds = null | ||
64 | var ParameterScopeBound realBounds = null | ||
65 | var ParameterScopeBound stringBounds = null | ||
66 | val typeDeclarationToBoundsMapBuilder = ImmutableMap.builder | ||
67 | for (scope : interpretation.scopes) { | ||
68 | val bounds = new ScopeBasedParameterScopeBound(scope) | ||
69 | switch (typeInterpretation : scope.targetTypeInterpretation) { | ||
70 | PartialBooleanInterpretation: | ||
71 | if (booleanBounds === null) { | ||
72 | booleanBounds = bounds | ||
73 | } else { | ||
74 | throw new IllegalStateException("Duplicate partial boolean interpretation") | ||
75 | } | ||
76 | PartialIntegerInterpretation: | ||
77 | if (integerBounds === null) { | ||
78 | integerBounds = bounds | ||
79 | } else { | ||
80 | throw new IllegalStateException("Duplicate partial integer interpretation") | ||
81 | } | ||
82 | PartialRealInterpretation: | ||
83 | if (realBounds === null) { | ||
84 | realBounds = bounds | ||
85 | } else { | ||
86 | throw new IllegalStateException("Duplicate partial real interpretation") | ||
87 | } | ||
88 | PartialStringInterpretation: | ||
89 | if (stringBounds === null) { | ||
90 | stringBounds = bounds | ||
91 | } else { | ||
92 | throw new IllegalStateException("Duplicate partial string interpretation") | ||
93 | } | ||
94 | PartialComplexTypeInterpretation: | ||
95 | typeDeclarationToBoundsMapBuilder.put(typeInterpretation.interpretationOf, bounds) | ||
96 | } | ||
97 | } | ||
98 | this.booleanBounds = booleanBounds ?: defaultBounds | ||
99 | this.integerBounds = integerBounds ?: defaultBounds | ||
100 | this.realBounds = realBounds ?: defaultBounds | ||
101 | this.stringBounds = stringBounds ?: defaultBounds | ||
102 | typeDeclarationToBoundsMap = typeDeclarationToBoundsMapBuilder.build | ||
103 | } | ||
104 | |||
105 | def getCostObjectives(Collection<CostObjectiveConfiguration> costObjectives) { | ||
106 | val objectives = ImmutableList.<IObjective>builder | ||
107 | val hints = ImmutableList.<CostObjectiveHint>builder | ||
108 | val extensionOperators = ImmutableList.<PolyhedronExtensionOperator>builder | ||
109 | val extremalObjectives = Lists.newArrayListWithExpectedSize(costObjectives.size) | ||
110 | for (entry : costObjectives.indexed) { | ||
111 | val objectiveName = '''costObjective«entry.key»''' | ||
112 | val objectiveConfig = entry.value | ||
113 | val costObjective = transformCostObjective(objectiveConfig, objectiveName) | ||
114 | objectives.add(costObjective) | ||
115 | if (objectiveConfig.findExtremum) { | ||
116 | extremalObjectives += costObjective | ||
117 | } | ||
118 | val hint = objectiveConfig.hint | ||
119 | if (hint !== null) { | ||
120 | hints.add(hint) | ||
121 | hint.objective = costObjective | ||
122 | val extensionOperator = hint.createPolyhedronExtensionOperator(costObjective.matchers) | ||
123 | if (extensionOperator !== null) { | ||
124 | extensionOperators.add(extensionOperator) | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | new ThreeValuedCostObjectiveProviderResult( | ||
129 | objectives.build, | ||
130 | hints.build, | ||
131 | extensionOperators.build, | ||
132 | newArrayList(extremalObjectives), | ||
133 | !extremalObjectives.empty | ||
134 | ) | ||
135 | } | ||
136 | |||
137 | private def transformCostObjective(CostObjectiveConfiguration configuration, String name) { | ||
138 | val costElements = ImmutableMap.copyOf(configuration.elements.toMap([patternQualifiedName], [ | ||
139 | transformCostElement | ||
140 | ])) | ||
141 | new ThreeValuedCostObjective(name, costElements, configuration.kind, configuration.threshold, | ||
142 | COST_OBJECTIVE_LEVEL) | ||
143 | } | ||
144 | |||
145 | private def transformCostElement(CostObjectiveElementConfiguration elementConfig) { | ||
146 | val relationName = elementConfig.patternQualifiedName | ||
147 | val modalQueries = modalRelationQueries.get(relationName) | ||
148 | if (modalQueries === null) { | ||
149 | throw new IllegalArgumentException("Unknown relation queries: " + relationName) | ||
150 | } | ||
151 | val relation = qualifiedNameToRelationMap.get(relationName) | ||
152 | if (relation === null) { | ||
153 | throw new IllegalArgumentException("Unknown transformed relation: " + relationName) | ||
154 | } | ||
155 | val parameterBounds = ImmutableList.copyOf(relation.parameters.map[parameterBound]) | ||
156 | new CostElementMatchers( | ||
157 | queryEngine.getMatcher(modalQueries.currentQuery), | ||
158 | queryEngine.getMatcher(modalQueries.mayQuery), | ||
159 | queryEngine.getMatcher(modalQueries.mustQuery), | ||
160 | parameterBounds, | ||
161 | elementConfig.weight | ||
162 | ) | ||
163 | } | ||
164 | |||
165 | private def getParameterBound(TypeReference typeReference) { | ||
166 | switch (typeReference) { | ||
167 | BoolTypeReference: booleanBounds | ||
168 | IntTypeReference: integerBounds | ||
169 | RealTypeReference: realBounds | ||
170 | StringTypeReference: stringBounds | ||
171 | ComplexTypeReference: typeDeclarationToBoundsMap.getOrDefault(typeReference.referred, defaultBounds) | ||
172 | } | ||
173 | } | ||
174 | |||
175 | private static abstract class AbstractParameterScopeBound implements ParameterScopeBound { | ||
176 | override getUpperBound() { | ||
177 | val rawValue = rawUpperBound | ||
178 | if (rawValue < 0) { | ||
179 | Double.POSITIVE_INFINITY | ||
180 | } else { | ||
181 | rawValue | ||
182 | } | ||
183 | } | ||
184 | |||
185 | protected def int getRawUpperBound() | ||
186 | } | ||
187 | |||
188 | @Data | ||
189 | private static class ScopeBasedParameterScopeBound extends AbstractParameterScopeBound { | ||
190 | val Scope scope | ||
191 | |||
192 | override protected getRawUpperBound() { | ||
193 | scope.maxNewElements | ||
194 | } | ||
195 | } | ||
196 | |||
197 | @Data | ||
198 | private static class PartialInterpretationBasedParameterScopeBound extends AbstractParameterScopeBound { | ||
199 | val PartialInterpretation interpretation | ||
200 | |||
201 | override protected getRawUpperBound() { | ||
202 | interpretation.maxNewElements | ||
203 | } | ||
204 | } | ||
205 | } | ||
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/base/DesignSpaceManager.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/base/DesignSpaceManager.java index 7e7a6e51..133ef948 100644 --- a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/base/DesignSpaceManager.java +++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/base/DesignSpaceManager.java | |||
@@ -369,6 +369,7 @@ public class DesignSpaceManager implements IBacktrackListener { | |||
369 | } catch (InvocationTargetException e) { | 369 | } catch (InvocationTargetException e) { |
370 | throw new RuntimeException(e); | 370 | throw new RuntimeException(e); |
371 | } | 371 | } |
372 | backtrackingTime += System.nanoTime() - start; | ||
372 | updateActivationCodes(); | 373 | updateActivationCodes(); |
373 | 374 | ||
374 | Object lastActivationId = trajectory.getLastActivationId(); | 375 | Object lastActivationId = trajectory.getLastActivationId(); |
@@ -382,7 +383,6 @@ public class DesignSpaceManager implements IBacktrackListener { | |||
382 | } | 383 | } |
383 | 384 | ||
384 | logger.debug("Backtrack."); | 385 | logger.debug("Backtrack."); |
385 | backtrackingTime += System.nanoTime() - start; | ||
386 | 386 | ||
387 | return true; | 387 | return true; |
388 | } | 388 | } |
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/xtend-gen/converter/.UML2TGF.xtendbin b/Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/xtend-gen/converter/.UML2TGF.xtendbin deleted file mode 100644 index 4a93782b..00000000 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.originalFiles/xtend-gen/converter/.UML2TGF.xtendbin +++ /dev/null | |||
Binary files differ | |||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/config/genericFamilyTreeSMTQual.vsconfig b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/config/genericFamilyTreeSMTQual.vsconfig index 80ab2906..fa9cd6e2 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/config/genericFamilyTreeSMTQual.vsconfig +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/config/genericFamilyTreeSMTQual.vsconfig | |||
@@ -36,6 +36,9 @@ generate { | |||
36 | log-level = normal, | 36 | log-level = normal, |
37 | "fitness-punishSize" = "false", | 37 | "fitness-punishSize" = "false", |
38 | "fitness-scope" = "3", | 38 | "fitness-scope" = "3", |
39 | "fitness-objectCreationCosts" = "true", | ||
40 | "scopePropagator" = "typeHierarchy", | ||
41 | "fitness-missing-containment" = "2", | ||
39 | "numeric-solver-at-end" = "true" | 42 | "numeric-solver-at-end" = "true" |
40 | } | 43 | } |
41 | 44 | ||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/queries/SatelliteQueries.vql b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/queries/SatelliteQueries.vql index 57b5933a..da889032 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/queries/SatelliteQueries.vql +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/queries/SatelliteQueries.vql | |||
@@ -245,146 +245,4 @@ pattern tooLowPathLengthForGroundStation(s:CommSubsystem) { | |||
245 | GroundStationNetwork.commSubsystem(_,ts); | 245 | GroundStationNetwork.commSubsystem(_,ts); |
246 | check(l!=385000);//385.000km | 246 | check(l!=385000);//385.000km |
247 | } | 247 | } |
248 | //// | 248 | |
249 | //// Metrics | ||
250 | //// | ||
251 | // | ||
252 | //// Coverage | ||
253 | // | ||
254 | //pattern coverageMetric(Coverage : java Double) { | ||
255 | // Coverage == sum find missionCoverage(_, #_); | ||
256 | //} | ||
257 | // | ||
258 | //private pattern missionCoverage(Mission : InterferometryMission, Coverage : java Double) { | ||
259 | // InterferometryMission.observationTime(Mission, ObservationTime); | ||
260 | // ObserverCount == count find spacecraftWithInterferometryPayload(Mission, _); | ||
261 | // Coverage == eval(Math.pow(1 - 2.0 / ObserverCount, 1 + 9 * (1.0 / ObservationTime)) + 0.05 * ObservationTime / 3); | ||
262 | //} | ||
263 | // | ||
264 | //// Time | ||
265 | // | ||
266 | //pattern timeMetric(Time : java Double) { | ||
267 | // Time == sum find missionTime(_, #_); | ||
268 | //} | ||
269 | // | ||
270 | //private pattern missionTime(Mission : InterferometryMission, Time : java Double) { | ||
271 | // InterferometryMission.observationTime(Mission, ObservationTime); | ||
272 | // TrasmitTime == sum find transmitTime(Mission, _, #_); | ||
273 | // Time == eval(TrasmitTime + 60.0 * ObservationTime); | ||
274 | //} | ||
275 | // | ||
276 | //private pattern transmitTime(Mission : InterferometryMission, Spacecraft : Spacecraft, TransmitTime : java Double) { | ||
277 | // ConstellationMission.spacecraft(Mission, Spacecraft); | ||
278 | // find scienceData(Spacecraft, ScienceData); | ||
279 | // IncomingData == sum find incomingData(Spacecraft, _, #_); | ||
280 | // find transmitRate(Spacecraft, TransmitRate); | ||
281 | // TransmitTime == eval((ScienceData + IncomingData) / (7.5 * TransmitRate)); | ||
282 | //} | ||
283 | // | ||
284 | //private pattern incomingData(Spacecraft : Spacecraft, Source : Spacecraft, Data : java Double) { | ||
285 | // find indirectCommunicationLink(Source, Spacecraft); | ||
286 | // find scienceData(Source, Data); | ||
287 | //} | ||
288 | // | ||
289 | //private pattern scienceData(Spacecraft : Spacecraft, Data : java Double) { | ||
290 | // ConstellationMission.spacecraft(Mission, Spacecraft); | ||
291 | // InterferometryMission.observationTime(Mission, ObservationTime); | ||
292 | // Data == eval(12.0 * ObservationTime); | ||
293 | //} | ||
294 | // | ||
295 | //private pattern transmitRate(Spacecraft : Spacecraft, TransmitRate : java Double) { | ||
296 | // find spacecraftUplink(Spacecraft, Comm, Target); | ||
297 | // UHFCommSubsystem(Comm); | ||
298 | // Spacecraft(Target); | ||
299 | // TransmitRate == 5.0; | ||
300 | //} or { | ||
301 | // find spacecraftUplink(Spacecraft, Comm, Target); | ||
302 | // XCommSubsystem(Comm); | ||
303 | // Spacecraft(Target); | ||
304 | // TransmitRate == 1.6; | ||
305 | //} or { | ||
306 | // find spacecraftUplink(Spacecraft, Comm, Target); | ||
307 | // XCommSubsystem(Comm); | ||
308 | // GroundStationNetwork(Target); | ||
309 | // TransmitRate == 0.7; | ||
310 | //} or { | ||
311 | // find spacecraftUplink(Spacecraft, Comm, Target); | ||
312 | // KaCommSubsystem(Comm); | ||
313 | // Spacecraft(Target); | ||
314 | // TransmitRate == 220.0; | ||
315 | //} or { | ||
316 | // find spacecraftUplink(Spacecraft, Comm, Target); | ||
317 | // KaCommSubsystem(Comm); | ||
318 | // GroundStationNetwork(Target); | ||
319 | // TransmitRate == 80.0; | ||
320 | //} | ||
321 | // | ||
322 | //private pattern spacecraftUplink(Spacecraft : Spacecraft, TargetSubsystem : CommSubsystem, Target : CommunicatingElement) { | ||
323 | // CommunicatingElement.commSubsystem.target(Spacecraft, TargetSubsystem); | ||
324 | // CommunicatingElement.commSubsystem(Target, TargetSubsystem); | ||
325 | //} | ||
326 | // | ||
327 | //// Cost | ||
328 | // | ||
329 | //pattern costMetric(Cost : java Double) { | ||
330 | // Cost == sum find missionCost(_, #_); | ||
331 | //} | ||
332 | // | ||
333 | //private pattern missionCost(Mission : InterferometryMission, Cost : java Double) { | ||
334 | // InterferometryMission.observationTime(Mission, ObservationTime); | ||
335 | // SpacecraftCost == sum find spacecraftCost(Mission, _, #_); | ||
336 | // Cost == eval(SpacecraftCost + 100000.0 * ObservationTime); | ||
337 | //} | ||
338 | // | ||
339 | //private pattern spacecraftCost(Mission : InterferometryMission, Spacecraft : Spacecraft, Cost : java Double) { | ||
340 | // ConstellationMission.spacecraft(Mission, Spacecraft); | ||
341 | // find spacecraftOfKindCount(Spacecraft, KindCount); | ||
342 | // find basePrice(Spacecraft, BasePrice); | ||
343 | // find interferometryPayloadCost(Spacecraft, InterferometryPayloadCost); | ||
344 | // find additionalCommSubsystemCost(Spacecraft, AdditionalCommSubsystemCost); | ||
345 | // Cost == eval(BasePrice * Math.pow(KindCount, -0.25) + InterferometryPayloadCost + AdditionalCommSubsystemCost); | ||
346 | //} | ||
347 | // | ||
348 | //private pattern spacecraftOfKindCount(Sat : Spacecraft, Count : java Integer) { | ||
349 | // CubeSat3U(Sat); | ||
350 | // Count == count find cubeSat3U(_); | ||
351 | //} or { | ||
352 | // CubeSat6U(Sat); | ||
353 | // Count == count find cubeSat6U(_); | ||
354 | //} or { | ||
355 | // SmallSat(Sat); | ||
356 | // Count == count find smallSat(_); | ||
357 | //} | ||
358 | // | ||
359 | //private pattern basePrice(Spacecraft : Spacecraft, BasePrice : java Double) { | ||
360 | // CubeSat3U(Spacecraft); | ||
361 | // BasePrice == 250000.0; | ||
362 | //} or { | ||
363 | // CubeSat6U(Spacecraft); | ||
364 | // BasePrice == 750000.0; | ||
365 | //} or { | ||
366 | // SmallSat(Spacecraft); | ||
367 | // BasePrice == 3000000.0; | ||
368 | //} | ||
369 | // | ||
370 | //private pattern interferometryPayloadCost(Spacecraft : Spacecraft, Cost : java Double) { | ||
371 | // find spacecraftWithInterferometryPayload(_, Spacecraft); | ||
372 | // Cost == 50000.0; | ||
373 | //} or { | ||
374 | // neg find spacecraftWithInterferometryPayload(_, Spacecraft); | ||
375 | // Cost == 0.0; | ||
376 | //} | ||
377 | // | ||
378 | //private pattern additionalCommSubsystemCost(Spacecraft : Spacecraft, Cost : java Double) { | ||
379 | // find spacecraftWithTwoCommSubsystems(Spacecraft); | ||
380 | // Cost == 100000.0; | ||
381 | //} or { | ||
382 | // neg find spacecraftWithTwoCommSubsystems(Spacecraft); | ||
383 | // Cost == 0.0; | ||
384 | //} | ||
385 | // | ||
386 | //private pattern spacecraftWithTwoCommSubsystems(Spacecraft : Spacecraft) { | ||
387 | // Spacecraft.commSubsystem(Spacecraft, Subsystem1); | ||
388 | // Spacecraft.commSubsystem(Spacecraft, Subsystem2); | ||
389 | // Subsystem1 != Subsystem2; | ||
390 | //} | ||
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemHint.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemHint.xtend index 8d6523b1..300f8b51 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemHint.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemHint.xtend | |||
@@ -4,6 +4,8 @@ import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | |||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | 4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace |
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory | 5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory |
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator | 6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator |
7 | import java.util.Map | ||
8 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | ||
7 | 9 | ||
8 | class FileSystemHint extends Ecore2LogicTraceBasedHint { | 10 | class FileSystemHint extends Ecore2LogicTraceBasedHint { |
9 | static val REMAINING_CONTENTS_ROOT = "hint_root" | 11 | static val REMAINING_CONTENTS_ROOT = "hint_root" |
@@ -12,7 +14,7 @@ class FileSystemHint extends Ecore2LogicTraceBasedHint { | |||
12 | super(ecore2Logic, trace) | 14 | super(ecore2Logic, trace) |
13 | } | 15 | } |
14 | 16 | ||
15 | override getAdditionalPatterns(PatternGenerator it) ''' | 17 | override getAdditionalPatterns(PatternGenerator it, Map<String, PQuery> fqnToPQuery) ''' |
16 | pattern «REMAINING_CONTENTS_ROOT»(problem:LogicProblem, interpretation:PartialInterpretation, remainingContents:java Integer) { | 18 | pattern «REMAINING_CONTENTS_ROOT»(problem:LogicProblem, interpretation:PartialInterpretation, remainingContents:java Integer) { |
17 | find interpretation(problem, interpretation); | 19 | find interpretation(problem, interpretation); |
18 | remainingContents == sum find remainingContents_root_reference_Dir_helper(problem, interpretation, _, #_) | 20 | remainingContents == sum find remainingContents_root_reference_Dir_helper(problem, interpretation, _, #_) |
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemInconsistencyDetector.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemInconsistencyDetector.xtend index f4f36951..9cc6e415 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemInconsistencyDetector.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/FileSystemInconsistencyDetector.xtend | |||
@@ -1,10 +1,10 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.run | 1 | package hu.bme.mit.inf.dslreasoner.run |
2 | 2 | ||
3 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | ||
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethod | ||
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethodBasedGlobalConstraint | 5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethodBasedGlobalConstraint |
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethod | ||
7 | import org.eclipse.viatra.dse.base.ThreadContext | 6 | import org.eclipse.viatra.dse.base.ThreadContext |
7 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | ||
8 | 8 | ||
9 | class FileSystemInconsistencyDetector extends ModelGenerationMethodBasedGlobalConstraint { | 9 | class FileSystemInconsistencyDetector extends ModelGenerationMethodBasedGlobalConstraint { |
10 | var PartialInterpretation partialInterpretation | 10 | var PartialInterpretation partialInterpretation |
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend index bf9ca274..cbc692b3 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend | |||
@@ -12,8 +12,8 @@ import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | |||
12 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor | 12 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor |
13 | import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns | 13 | import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns |
14 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor | 14 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor |
15 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethod | ||
16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint | 15 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint |
16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethod | ||
17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethodBasedGlobalConstraint | 17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethodBasedGlobalConstraint |
18 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace | 18 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace |
19 | import java.util.Collection | 19 | import java.util.Collection |
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphHint.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphHint.xtend index 97ce4ee6..9a84f777 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphHint.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphHint.xtend | |||
@@ -4,13 +4,15 @@ import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | |||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | 4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace |
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory | 5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory |
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator | 6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator |
7 | import java.util.Map | ||
8 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | ||
7 | 9 | ||
8 | class SGraphHint extends Ecore2LogicTraceBasedHint { | 10 | class SGraphHint extends Ecore2LogicTraceBasedHint { |
9 | new(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) { | 11 | new(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) { |
10 | super(ecore2Logic, trace) | 12 | super(ecore2Logic, trace) |
11 | } | 13 | } |
12 | 14 | ||
13 | override getAdditionalPatterns(extension PatternGenerator patternGenerator) { | 15 | override getAdditionalPatterns(extension PatternGenerator patternGenerator, Map<String, PQuery> fqnToPQuery) { |
14 | "" | 16 | "" |
15 | } | 17 | } |
16 | 18 | ||
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphInconsistencyDetector.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphInconsistencyDetector.xtend index 22addd3d..b8167566 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphInconsistencyDetector.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphInconsistencyDetector.xtend | |||
@@ -1,7 +1,7 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.run | 1 | package hu.bme.mit.inf.dslreasoner.run |
2 | 2 | ||
3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethod | ||
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethod | ||
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethodBasedGlobalConstraint | 5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethodBasedGlobalConstraint |
6 | import org.eclipse.viatra.dse.base.ThreadContext | 6 | import org.eclipse.viatra.dse.base.ThreadContext |
7 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | 7 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher |
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend index ef5b779e..28954d60 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend | |||
@@ -5,6 +5,8 @@ import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace | |||
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality | 5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality |
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory | 6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory |
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator | 7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator |
8 | import java.util.Map | ||
9 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | ||
8 | 10 | ||
9 | class SatelliteHint extends Ecore2LogicTraceBasedHint { | 11 | class SatelliteHint extends Ecore2LogicTraceBasedHint { |
10 | static val INTERFEROMETY_PAYLOAD = "hint_interferometryPayload" | 12 | static val INTERFEROMETY_PAYLOAD = "hint_interferometryPayload" |
@@ -14,7 +16,7 @@ class SatelliteHint extends Ecore2LogicTraceBasedHint { | |||
14 | super(ecore2Logic, trace) | 16 | super(ecore2Logic, trace) |
15 | } | 17 | } |
16 | 18 | ||
17 | override getAdditionalPatterns(PatternGenerator it) ''' | 19 | override getAdditionalPatterns(PatternGenerator it, Map<String, PQuery> fqnToPQuery) ''' |
18 | pattern «INTERFEROMETY_PAYLOAD»(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement) { | 20 | pattern «INTERFEROMETY_PAYLOAD»(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement) { |
19 | find interpretation(problem, interpretation); | 21 | find interpretation(problem, interpretation); |
20 | find mustExist(problem, interpretation, object); | 22 | find mustExist(problem, interpretation, object); |
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SimpleRun.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SimpleRun.xtend index b65826ad..5e2d0920 100644 --- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SimpleRun.xtend +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SimpleRun.xtend | |||
@@ -1,9 +1,8 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.run | 1 | package hu.bme.mit.inf.dslreasoner.run |
2 | 2 | ||
3 | import functionalarchitecture.FunctionalarchitecturePackage | 3 | import functionalarchitecture.FunctionalarchitecturePackage |
4 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Model | ||
4 | import hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns | 5 | import hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns |
5 | import hu.bme.mit.inf.dslreasoner.domains.transima.fam.Model | ||
6 | import hu.bme.mit.inf.dslreasoner.domains.transima.fam.Type | ||
7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | 6 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic |
8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration | 7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration |
9 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor | 8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor |
@@ -15,7 +14,6 @@ import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore | |||
15 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic | 14 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic |
16 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration | 15 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration |
17 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor | 16 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor |
18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy | ||
19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic | 17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic |
20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
21 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml | 19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml |
@@ -121,8 +119,6 @@ class SimpleRun { | |||
121 | val patterns = i.specifications.toList | 119 | val patterns = i.specifications.toList |
122 | val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name== "Constraint"]].toSet | 120 | val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name== "Constraint"]].toSet |
123 | val derivedFeatures = new LinkedHashMap | 121 | val derivedFeatures = new LinkedHashMap |
124 | derivedFeatures.put(Type.instance,metamodel.attributes.filter[it.name == "type"].head) | ||
125 | derivedFeatures.put(Model.instance,metamodel.references.filter[it.name == "model"].head) | ||
126 | val res = new ViatraQuerySetDescriptor( | 122 | val res = new ViatraQuerySetDescriptor( |
127 | patterns, | 123 | patterns, |
128 | wfPatterns, | 124 | wfPatterns, |