From 60adf1f30285fd7cea5f5edde8e844bc83d34f2f Mon Sep 17 00:00:00 2001 From: Ralf Sieger Date: Fri, 10 Jan 2025 13:37:21 +0100 Subject: [PATCH] added basic EA SimulationExecutor --- .../META-INF/MANIFEST.MF | 11 +++++- .../ea/launch/EAOptimizerLaunchFactory.java | 15 +++++--- .../launch/EAOptimizerSimulationExecutor.java | 38 +++++++++++++++++++ 3 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 bundles/org.palladiosimulator.simexp.dsl.ea.launch/src/main/java/org/palladiosimulator/simexp/dsl/ea/launch/EAOptimizerSimulationExecutor.java diff --git a/bundles/org.palladiosimulator.simexp.dsl.ea.launch/META-INF/MANIFEST.MF b/bundles/org.palladiosimulator.simexp.dsl.ea.launch/META-INF/MANIFEST.MF index dc2ad44b..54a82200 100644 --- a/bundles/org.palladiosimulator.simexp.dsl.ea.launch/META-INF/MANIFEST.MF +++ b/bundles/org.palladiosimulator.simexp.dsl.ea.launch/META-INF/MANIFEST.MF @@ -4,11 +4,18 @@ Bundle-ManifestVersion: 2 Bundle-Name: org.palladiosimulator.simexp.dsl.ea.launch Bundle-Vendor: My Company Bundle-Version: 0.1.0.qualifier -Require-Bundle: org.palladiosimulator.simexp.workflow;bundle-version="1.0.0", +Require-Bundle: org.apache.log4j;bundle-version="1.2.19", + org.palladiosimulator.simexp.workflow;bundle-version="1.0.0", tools.mdsd.probdist.api;bundle-version="1.0.0", org.palladiosimulator.simexp.pcm;bundle-version="1.0.0", org.palladiosimulator.simexp.commons.constants;bundle-version="1.0.0", - org.palladiosimulator.simexp.pcm.examples;bundle-version="1.0.0" + org.palladiosimulator.simexp.pcm.examples;bundle-version="1.0.0", + org.palladiosimulator.simexp.markovian;bundle-version="1.0.0", + org.palladiosimulator.simexp.core;bundle-version="1.0.0", + org.palladiosimulator.simexp.markovian.model;bundle-version="0.1.0", + org.palladiosimulator.simulizar.reconfiguration.qvto;bundle-version="5.2.1", + org.palladiosimulator.simexp.dsl.smodel;bundle-version="0.1.0", + org.palladiosimulator.simexp.pcm.modelled;bundle-version="1.0.0" Bundle-SymbolicName: org.palladiosimulator.simexp.dsl.ea.launch;singleton:=true Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/bundles/org.palladiosimulator.simexp.dsl.ea.launch/src/main/java/org/palladiosimulator/simexp/dsl/ea/launch/EAOptimizerLaunchFactory.java b/bundles/org.palladiosimulator.simexp.dsl.ea.launch/src/main/java/org/palladiosimulator/simexp/dsl/ea/launch/EAOptimizerLaunchFactory.java index 6a0ec0be..666054eb 100644 --- a/bundles/org.palladiosimulator.simexp.dsl.ea.launch/src/main/java/org/palladiosimulator/simexp/dsl/ea/launch/EAOptimizerLaunchFactory.java +++ b/bundles/org.palladiosimulator.simexp.dsl.ea.launch/src/main/java/org/palladiosimulator/simexp/dsl/ea/launch/EAOptimizerLaunchFactory.java @@ -2,12 +2,15 @@ import java.util.Optional; +import org.eclipse.emf.common.util.URI; import org.palladiosimulator.core.simulation.SimulationExecutor; import org.palladiosimulator.simexp.commons.constants.model.ModelledOptimizationType; import org.palladiosimulator.simexp.commons.constants.model.SimulatorType; +import org.palladiosimulator.simexp.dsl.smodel.smodel.Smodel; import org.palladiosimulator.simexp.pcm.config.IModelledWorkflowConfiguration; import org.palladiosimulator.simexp.pcm.config.IWorkflowConfiguration; import org.palladiosimulator.simexp.pcm.examples.executor.ModelLoader; +import org.palladiosimulator.simexp.pcm.modelled.ModelledModelLoader; import org.palladiosimulator.simexp.workflow.api.ILaunchFactory; import org.palladiosimulator.simexp.workflow.api.LaunchDescriptionProvider; @@ -26,17 +29,19 @@ public int canHandle(IWorkflowConfiguration config) { return 0; } - // TODO: - - return 0; + return 10; } @Override public SimulationExecutor createSimulationExecutor(IWorkflowConfiguration config, LaunchDescriptionProvider launchDescriptionProvider, Optional seedProvider, ModelLoader.Factory modelLoaderFactory) { - // TODO Auto-generated method stub - return null; + ModelLoader modelLoader = modelLoaderFactory.create(); + ModelledModelLoader modelledModelLoader = (ModelledModelLoader) modelLoader; + IModelledWorkflowConfiguration modelledWorkflowConfiguration = (IModelledWorkflowConfiguration) config; + URI smodelURI = modelledWorkflowConfiguration.getSmodelURI(); + Smodel smodel = modelledModelLoader.loadSModel(smodelURI); + return new EAOptimizerSimulationExecutor(smodel); } } diff --git a/bundles/org.palladiosimulator.simexp.dsl.ea.launch/src/main/java/org/palladiosimulator/simexp/dsl/ea/launch/EAOptimizerSimulationExecutor.java b/bundles/org.palladiosimulator.simexp.dsl.ea.launch/src/main/java/org/palladiosimulator/simexp/dsl/ea/launch/EAOptimizerSimulationExecutor.java new file mode 100644 index 00000000..312ee80c --- /dev/null +++ b/bundles/org.palladiosimulator.simexp.dsl.ea.launch/src/main/java/org/palladiosimulator/simexp/dsl/ea/launch/EAOptimizerSimulationExecutor.java @@ -0,0 +1,38 @@ +package org.palladiosimulator.simexp.dsl.ea.launch; + +import org.apache.log4j.Logger; +import org.palladiosimulator.core.simulation.SimulationExecutor; +import org.palladiosimulator.simexp.dsl.smodel.smodel.Smodel; + +public class EAOptimizerSimulationExecutor implements SimulationExecutor { + protected static final Logger LOGGER = Logger.getLogger(EAOptimizerSimulationExecutor.class); + + private final Smodel smodel; + + public EAOptimizerSimulationExecutor(Smodel smodel) { + this.smodel = smodel; + } + + @Override + public String getPolicyId() { + return String.format("EA-%s", smodel.getModelName()); + } + + @Override + public void evaluate() { + // TODO: + double totalReward = 0.0; + LOGGER.info("***********************************************************************"); + LOGGER.info( + String.format("The fittest individual of policy %1s has an reward of %2s", getPolicyId(), totalReward)); + // TODO: dump optimization values + LOGGER.info("***********************************************************************"); + } + + @Override + public void execute() { + // TODO Auto-generated method stub + + } + +}