Exemplo n.º 1
0
 def test(self):
     if not self.lock.locked():
         self.lock.acquire()
         self.__clear_map()
         simulation = Simulation(self.scenarios[self.scenario],
                                 self.test_iteration_finished, 1)
         if self.last_model:
             simulation.model = self.last_model
         simulation.start(self)
         self.lock.release()
     else:
         print("Cannot run tests - Test results are showing now")
Exemplo n.º 2
0
    def run(self):
        self._init()

        # Run simulation: for each service to evaluate, create a simulation and delegate to the loader objects
        # the decision about the environment to load based on the alternatives
        services = self._parser.get_services()

        for service in services:
            # For each alternative of this service, create a simulation
            for alternative in service.get_alternatives():
                '''
                Creating overlay and adding it to the topology object.
                '''
                self._log.info(self.__class__.__name__, 'Creating overlay for alternative %s.', alternative.get_name())
                # Creating the overlay for current alternative
                overlay = alternative.create_overlay(self._topology.get_topology_from_graphml())
                self._log.info(self.__class__.__name__, 'Adding overlay %s for alternative %s to the topology.',
                               overlay.get_name(), alternative.get_name())
                self._topology.add_overlay(overlay)

                '''
                Loading environment, creating the simulation and running it.
                '''
                self._log.info(self.__class__.__name__, 'Loading the environment for the alternative %s.', alternative)
                # Load an environment for the current alternative of this service
                environment = self._loader.load(alternative.get_environment())
                # Create the simulation
                simulation = Simulation(self._topology, service, environment, alternative)
                self._log.info(
                    self.__class__.__name__,
                    'A new simulation has been created for service %s and alternative %s.',
                    service.get_name(), alternative)
                # Run the simulation
                simulation.start()
                simulation.join()

            self._log.info(self.__class__.__name__, 'All alternatives for service %s have been successfully tested.',
                           service.get_name())

        self._log.info(self.__class__.__name__, 'All services have been successfully tested; framework will stop.')
Exemplo n.º 3
0
import time

from model.simulation import Simulation
from examples.Scenario2 import Scenario2

start = time.clock()
class App:
    def iteration_finished(self,a,b):
        pass

print(time.clock() - start)


app = App()
sim = Simulation(Scenario2)
sim.start(app)
Exemplo n.º 4
0
 def train(self):
     simulation = Simulation(self.scenarios[self.scenario],
                             self.training_iteration_finished,
                             self.iterations)
     simulation.start(self)
     self.last_model = simulation.model