Skip to content

Commit

Permalink
added basic EA SimulationExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
rsfzi committed Jan 10, 2025
1 parent c283cda commit 60adf1f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<ISeedProvider> 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);
}

}
Original file line number Diff line number Diff line change
@@ -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

}

}

0 comments on commit 60adf1f

Please sign in to comment.