Commit 5759588d authored by Alexander Diewald's avatar Alexander Diewald
Browse files

DSE: Use the SolverSetting Class for Storage, not the Instance...

Issue-Ref: 4064
Issue-Url: https://af3-developer.fortiss.org/issues/4064

Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent ff3dfa8f
......@@ -3,5 +3,5 @@ SolverSettingsDialog.java 25b3541fc6eab090500321fa32a3f68992fff0a0 GREEN
SolverSettingsTreeTableViewer.java 0f0be7ff52d2c48fbff9d37c7e23bd7a99eb1948 YELLOW
SynthesisCategoryExplorationTargetContentProvider.java 410f00e07b5f4208b762b80baf563b2b73a93a71 GREEN
SynthesisCategoryRuleSetContentProvider.java 039913dba18b0248d10a77275258bc9acf9526cf GREEN
SynthesisFXContentController.java b5b981a42ae8bd551253ba347b48bbdca936ce96 YELLOW
SynthesisFXContentController.java 2adf53db3d39714cefde496926563d0e77c7b378 YELLOW
SynthesisFXViewPart.java e40c2bd501d87b41c6324ab80fd34e64410db644 GREEN
......@@ -189,7 +189,7 @@ public class SynthesisFXContentController extends CompositeFXControllerBase<Anch
* Caches the {@link IDSEBackend}-specific settings (defaults from the backends, saved settings
* for {@link ExplorationStep}s).
*/
protected Map<IDSEBackend, SolverSettings> solverSettings = new HashMap<>();
protected Map<Class<? extends IDSEBackend>, SolverSettings> solverSettings = new HashMap<>();
/** State variable that indicates whether a solution from the backend can be visualized. */
protected boolean useResults = false;
......@@ -268,6 +268,10 @@ public class SynthesisFXContentController extends CompositeFXControllerBase<Anch
}
}
/**
* Creates a {@link StringConverter} for the mapping between {@link IDSEBackend}s and their
* representation in {@link ComboBox}es.
*/
protected StringConverter<IDSEBackend> createExpTgtComboConverter(ComboBox<IDSEBackend> combo) {
return new StringConverter<IDSEBackend>() {
@Override
......@@ -285,17 +289,17 @@ public class SynthesisFXContentController extends CompositeFXControllerBase<Anch
/** Returns the {@link SolverSettings} of the currently selected feasibility checker. */
protected SolverSettings getSolverSettings(IDSEBackend selectedBackend) {
SolverSettings settings = solverSettings.get(selectedBackend);
SolverSettings settings = solverSettings.get(selectedBackend.getClass());
if(settings == null) {
settings = selectedBackend.getSolverSettings();
solverSettings.put(selectedBackend, settings);
solverSettings.put(selectedBackend.getClass(), settings);
}
return settings;
}
/** Sets the {@link SolverSettings} of the given {@link IDSEBackend}. */
protected void setSolverSettings(IDSEBackend selectedBackend, SolverSettings settings) {
solverSettings.put(selectedBackend, settings);
solverSettings.put(selectedBackend.getClass(), settings);
}
/** Loads existing {@link SolverSettings} from an {@link ExplorationStep}. */
......
dseml.ecore df66fd1e1e45789fc18bcb2d5992eb839188e849 GREEN
exploration.ecore e65a609db5c6650bbab5144ccef266a19d407385 GREEN
exploration.ecore a37edcd2c57a5e45e307345cc6988ad6633f2f2b YELLOW
......@@ -891,7 +891,13 @@
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Map entries of the {@link IDSEBackend}-specific settings."/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="key" lowerBound="1" eType="#//project/IDSEBackend"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="key" lowerBound="1">
<eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaClass">
<eTypeArguments>
<eUpperBound eClassifier="#//project/IDSEBackend"/>
</eTypeArguments>
</eGenericType>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="value" lowerBound="1"
eType="#//SolverSettings" containment="true"/>
</eClassifiers>
......
ExecuteDSECommandLineHandler.java 4bdedc9265f4e058b9a44935f30820f0a58c1ab1 GREEN
ExecuteDSECommandLineHandler.java 4d80dee08bbf5f66d460bcdd158aaf3c96b654ab YELLOW
TestCaseGenerationCommandLineHandler.java ccd942515f5490ff9ed6ece891f3ade206333a08 GREEN
ValidateDSESolutionCommandLineInterface.java 47d7ffc80526e670ac149a2c18100ca6cc8ee19b GREEN
......@@ -103,8 +103,8 @@ public final class ExecuteDSECommandLineHandler implements ICommandLineSwitchHan
return;
}
Map<IDSEBackend, SolverSettings> settings = new HashMap<>();
settings.put(z3Backend.get(), z3Backend.get().getSolverSettings());
Map<Class<? extends IDSEBackend>, SolverSettings> settings = new HashMap<>();
settings.put(z3Backend.get().getClass(), z3Backend.get().getSolverSettings());
ExplorationSpecification expSpec = constructExplorationSpecification(matchingDSE);
expSpec.getSynthTypes().addAll(solutionType);
......@@ -158,11 +158,11 @@ public final class ExecuteDSECommandLineHandler implements ICommandLineSwitchHan
private final DSE dse;
/** References the settings of the solvers used for the exploration. */
private final Map<IDSEBackend, SolverSettings> settings;
private final Map<Class<? extends IDSEBackend>, SolverSettings> settings;
/** Constructor. */
/* package */ DseCLISolutionAdapter(DSE selectedDSE, ExplorationSpecification expSpec,
Map<IDSEBackend, SolverSettings> settings) {
Map<Class<? extends IDSEBackend>, SolverSettings> settings) {
super(expSpec);
this.dse = selectedDSE;
this.settings = settings;
......
DSEProjectModelElementFactory.java e00a2ea157d571992a7d9a7ed4f842b78b4141d4 GREEN
DSEProjectModelElementFactory.java 49c1d88c2260764ffeda419b8d3ca5002d387481 YELLOW
DSESolutionConversionUtils.java a6ccbba92864c653d1518a92455e87c17f7cc72b GREEN
DSMLModelElementFactory.java fa4a735ff40ab8f7d9898cecc0b04cfd8997572f GREEN
DSMLUtils.java 1113377031374cef7e29afcef458c4aeecad2b21 GREEN
......
......@@ -15,13 +15,13 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.exploration.util;
import static java.util.stream.Collectors.toMap;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.stream.Collectors;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.fortiss.af3.exploration.model.IExplorationConstraint;
......@@ -153,12 +153,12 @@ public class DSEProjectModelElementFactory {
/** Creates a {@link ExplorationStep}. */
public static ExplorationStep createExplorationStep(String name, Collection<RuleSet> ruleSets,
Map<IDSEBackend, SolverSettings> settings) {
Map<Class<? extends IDSEBackend>, SolverSettings> settings) {
ExplorationStep explorationStep = ProjectFactory.eINSTANCE.createExplorationStep();
explorationStep.setName(name);
explorationStep.getUsedRuleSets().addAll(ruleSets);
Map<IDSEBackend, SolverSettings> settingsCopy = settings.entrySet().parallelStream()
.collect(Collectors.toMap(e -> e.getKey(), e -> copy(e.getValue())));
Map<Class<? extends IDSEBackend>, SolverSettings> settingsCopy = settings.entrySet()
.parallelStream().collect(toMap(e -> e.getKey(), e -> copy(e.getValue())));
explorationStep.getSolverSettings().putAll(settingsCopy);
return explorationStep;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment