Skip to content

Commit

Permalink
basic in-process simulation working
Browse files Browse the repository at this point in the history
  • Loading branch information
rsfzi committed Jan 11, 2025
1 parent f257ce0 commit bf46d9a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Bundle-ManifestVersion: 2
Bundle-Name: org.palladiosimulator.simexp.dsl.ea.launch
Bundle-Vendor: My Company
Bundle-Version: 0.1.0.qualifier
Require-Bundle: org.apache.log4j;bundle-version="1.2.19",
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.26.100",
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",
Expand All @@ -16,7 +17,9 @@ Require-Bundle: org.apache.log4j;bundle-version="1.2.19",
org.palladiosimulator.simexp.dsl.ea.api;bundle-version="0.1.0",
org.palladiosimulator.simexp.dsl.ea.optimizer;bundle-version="0.1.0",
org.palladiosimulator.simexp.dsl.smodel.api;bundle-version="0.1.0",
org.palladiosimulator.simexp.dsl.smodel.interpreter;bundle-version="0.1.0"
org.palladiosimulator.simexp.dsl.smodel.interpreter;bundle-version="0.1.0",
org.palladiosimulator.simexp.pcm.modelled.simulator;bundle-version="1.0.0",
org.palladiosimulator.simexp.pcm.simulator;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 @@ -12,6 +12,7 @@
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.examples.executor.ModelLoader.Factory;
import org.palladiosimulator.simexp.pcm.modelled.ModelledModelLoader;
import org.palladiosimulator.simexp.workflow.api.ILaunchFactory;
import org.palladiosimulator.simexp.workflow.api.LaunchDescriptionProvider;
Expand Down Expand Up @@ -43,12 +44,15 @@ public SimulationExecutor createSimulationExecutor(IWorkflowConfiguration config
IModelledWorkflowConfiguration modelledWorkflowConfiguration = (IModelledWorkflowConfiguration) config;
URI smodelURI = modelledWorkflowConfiguration.getSmodelURI();
Smodel smodel = modelledModelLoader.loadSModel(smodelURI);
IDisposeableEAFitnessEvaluator fitnessEvaluator = createFitnessEvaluator(modelledWorkflowConfiguration);
IDisposeableEAFitnessEvaluator fitnessEvaluator = createFitnessEvaluator(modelledWorkflowConfiguration,
launchDescriptionProvider, seedProvider, modelLoaderFactory);
return new EAOptimizerSimulationExecutor(smodel, fitnessEvaluator);
}

private IDisposeableEAFitnessEvaluator createFitnessEvaluator(IModelledWorkflowConfiguration config) {
return new LocalEAFitnessEvaluator();
private IDisposeableEAFitnessEvaluator createFitnessEvaluator(IModelledWorkflowConfiguration config,
LaunchDescriptionProvider launchDescriptionProvider, Optional<ISeedProvider> seedProvider,
Factory modelLoaderFactory) {
return new LocalEAFitnessEvaluator(config, launchDescriptionProvider, seedProvider, modelLoaderFactory);
}

}
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
package org.palladiosimulator.simexp.dsl.ea.launch.evaluate.local;

import java.util.List;
import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

import org.apache.log4j.Logger;
import org.eclipse.core.runtime.CoreException;
import org.palladiosimulator.core.simulation.SimulationExecutor;
import org.palladiosimulator.simexp.dsl.ea.launch.evaluate.IDisposeableEAFitnessEvaluator;
import org.palladiosimulator.simexp.pcm.config.IModelledWorkflowConfiguration;
import org.palladiosimulator.simexp.pcm.examples.executor.ModelLoader.Factory;
import org.palladiosimulator.simexp.workflow.api.ISimExpWorkflowConfiguration;
import org.palladiosimulator.simexp.workflow.api.LaunchDescriptionProvider;
import org.palladiosimulator.simexp.workflow.launcher.SimulationExecutorLookup;

import tools.mdsd.probdist.api.random.ISeedProvider;

public class LocalEAFitnessEvaluator implements IDisposeableEAFitnessEvaluator {
protected static final Logger LOGGER = Logger.getLogger(LocalEAFitnessEvaluator.class);

private final IModelledWorkflowConfiguration config;
private final LaunchDescriptionProvider launchDescriptionProvider;
private final Optional<ISeedProvider> seedProvider;
private final Factory modelLoaderFactory;
private final ExecutorService executor;

public LocalEAFitnessEvaluator() {
public LocalEAFitnessEvaluator(IModelledWorkflowConfiguration config,
LaunchDescriptionProvider launchDescriptionProvider, Optional<ISeedProvider> seedProvider,
Factory modelLoaderFactory) {
this.config = config;
this.launchDescriptionProvider = launchDescriptionProvider;
this.seedProvider = seedProvider;
this.modelLoaderFactory = modelLoaderFactory;
this.executor = Executors.newFixedThreadPool(1);
}

Expand All @@ -41,8 +61,21 @@ public Double call() throws Exception {
return future;
}

private Double doCalcFitness(List<OptimizableValue<?>> optimizableValues) {
private Double doCalcFitness(List<OptimizableValue<?>> optimizableValues) throws CoreException {
SimulationExecutorLookup simulationExecutorLookup = new SimulationExecutorLookup();
SimulationExecutor effectiveSimulationExecutor = simulationExecutorLookup
.lookupSimulationExecutor((ISimExpWorkflowConfiguration) config, launchDescriptionProvider, seedProvider);

LOGGER.info("effective simulation start");
try {
effectiveSimulationExecutor.execute();
effectiveSimulationExecutor.evaluate();
} finally {
effectiveSimulationExecutor.dispose();
}
LOGGER.info("effective simulation finish");

// TODO:
return null;
return 0.0;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.palladiosimulator.simexp.workflow.config;
package org.palladiosimulator.simexp.workflow.api;

import org.palladiosimulator.simexp.pcm.config.IModelledPrismWorkflowConfiguration;
import org.palladiosimulator.simexp.pcm.config.IModelledWorkflowConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.palladiosimulator.simexp.commons.constants.model.SimulationEngine;
import org.palladiosimulator.simexp.commons.constants.model.SimulatorType;
import org.palladiosimulator.simexp.pcm.config.SimulationParameters;
import org.palladiosimulator.simexp.workflow.api.ISimExpWorkflowConfiguration;

import tools.mdsd.probdist.api.random.ISeedProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import org.eclipse.core.runtime.Platform;
import org.palladiosimulator.core.simulation.SimulationExecutor;
import org.palladiosimulator.simexp.workflow.api.ILaunchFactory;
import org.palladiosimulator.simexp.workflow.api.ISimExpWorkflowConfiguration;
import org.palladiosimulator.simexp.workflow.api.LaunchDescriptionProvider;
import org.palladiosimulator.simexp.workflow.config.ISimExpWorkflowConfiguration;

import tools.mdsd.probdist.api.random.ISeedProvider;

Expand Down

0 comments on commit bf46d9a

Please sign in to comment.