private void initPopulation() {
   population =
       new int[GeneticRobotProperties.getProps().getBreederPopulationSize()]
           [Scenarios.getNumberOfScenes()];
   for (int i = 0; i < GeneticRobotProperties.getProps().getBreederPopulationSize(); i++) {
     for (int j = 0; j < Scenarios.getNumberOfScenes(); j++) {
       population[i][j] = RND.nextInt(ParamActions.getNumberOfActions());
     }
   }
 }
Esempio n. 2
0
 private com.relteq.sirius.jaxb.Settings restoreSettings(Scenarios db_scenario)
     throws TorqueException {
   com.relteq.sirius.jaxb.Settings settings = factory.createSettings();
   settings.setUnits("US");
   settings.setVehicleTypes(restoreVehicleTypes(db_scenario.getVehicleTypeSets()));
   return settings;
 }
Esempio n. 3
0
 private com.relteq.sirius.jaxb.Routes restoreRoutes(Scenarios db_scenario)
     throws TorqueException {
   @SuppressWarnings("unchecked")
   List<RouteSets> db_rset_l = db_scenario.getRouteSetss();
   if (db_rset_l.isEmpty()) return null;
   com.relteq.sirius.jaxb.Routes routes = factory.createRoutes();
   for (RouteSets db_rset : db_rset_l) routes.getRoute().add(restoreRoute(db_rset.getRoutes()));
   return routes;
 }
Esempio n. 4
0
 private com.relteq.sirius.jaxb.NetworkList restoreNetworkList(Scenarios db_scenario)
     throws TorqueException {
   @SuppressWarnings("unchecked")
   List<NetworkSets> db_nets_l = db_scenario.getNetworkSetss();
   if (db_nets_l.isEmpty()) return null;
   com.relteq.sirius.jaxb.NetworkList nets = factory.createNetworkList();
   for (NetworkSets db_nets : db_nets_l)
     nets.getNetwork().add(restoreNetwork(db_nets.getNetworks()));
   return nets;
 }
Esempio n. 5
0
  @Override
  public void open(int run_id) throws SiriusException {
    success = false;
    if (1 != scenario.numEnsemble) logger.warn("scenario.numEnsembles != 1");
    if (null == db_scenario) throw new SiriusException("Scenario was not loaded from the database");

    logger.info("Initializing simulation run");
    Connection conn = null;
    try {
      conn = Transaction.begin();

      DataSources db_ds = new DataSources();
      db_ds.setId(DataSourcesPeer.nextId(DataSourcesPeer.ID, conn));
      db_ds.save(conn);

      Criteria crit = new Criteria();
      crit.add(ScenariosPeer.ID, db_scenario.getId());
      com.workingdogs.village.Value max_runnum =
          SimulationRunsPeer.maxColumnValue(SimulationRunsPeer.RUN_NUMBER, crit, conn);
      final long run_number = null == max_runnum ? 1 : max_runnum.asLong() + 1;
      logger.info("Run number: " + run_number);

      db_simulation_run = new com.relteq.sirius.om.SimulationRuns();
      db_simulation_run.setDataSources(db_ds);
      db_simulation_run.setScenarios(db_scenario);
      db_simulation_run.setRunNumber(run_number);
      db_simulation_run.setVersion(com.relteq.sirius.Version.get().getEngineVersion());
      db_simulation_run.setBuild("");
      db_simulation_run.setSimulationStartTime(BigDecimal.valueOf(scenario.getTimeStart()));
      db_simulation_run.setSimulationDuration(
          BigDecimal.valueOf(scenario.getTimeEnd() - scenario.getTimeStart()));
      db_simulation_run.setSimulationDt(BigDecimal.valueOf(scenario.getSimDtInSeconds()));
      db_simulation_run.setOutputDt(BigDecimal.valueOf(scenario.getOutputDt()));
      db_simulation_run.setExecutionStartTime(Calendar.getInstance().getTime());
      db_simulation_run.setStatus(-1);
      db_simulation_run.save(conn);

      Transaction.commit(conn);
      conn = null;
      success = true;
    } catch (TorqueException exc) {
      throw new SiriusException(exc);
    } catch (DataSetException exc) {
      throw new SiriusException(exc);
    } finally {
      if (null != conn) {
        Transaction.safeRollback(conn);
        db_simulation_run = null;
      }
    }
    ts = Calendar.getInstance();
    ts.set(Calendar.MILLISECOND, 0);
  }
Esempio n. 6
0
 private com.relteq.sirius.jaxb.DestinationNetworks restoreDestinationNetworks(
     Scenarios db_scenario) throws TorqueException {
   @SuppressWarnings("unchecked")
   List<DestinationNetworkSets> db_dns_l = db_scenario.getDestinationNetworkSetss();
   if (db_dns_l.isEmpty()) return null;
   com.relteq.sirius.jaxb.DestinationNetworks destnets = factory.createDestinationNetworks();
   for (DestinationNetworkSets db_dns : db_dns_l)
     destnets
         .getDestinationNetwork()
         .add(restoreDestinationNetwork(db_dns.getDestinationNetworks()));
   return destnets;
 }
Esempio n. 7
0
 private com.relteq.sirius.jaxb.Scenario restoreScenario(Scenarios db_scenario)
     throws SiriusException {
   if (null == db_scenario) return null;
   com.relteq.sirius.jaxb.Scenario scenario = factory.createScenario();
   scenario.setId(id2str(db_scenario.getId()));
   scenario.setName(db_scenario.getName());
   scenario.setDescription(db_scenario.getDescription());
   try {
     scenario.setSettings(restoreSettings(db_scenario));
     scenario.setNetworkList(restoreNetworkList(db_scenario));
     scenario.setSignalList(restoreSignalList(db_scenario.getSignalSets()));
     scenario.setSensorList(restoreSensorList(db_scenario.getSensorSets()));
     scenario.setInitialDensitySet(restoreInitialDensitySet(db_scenario.getInitialDensitySets()));
     scenario.setWeavingFactorSet(restoreWeavingFactorSet(db_scenario.getWeavingFactorSets()));
     scenario.setSplitRatioProfileSet(
         restoreSplitRatioProfileSet(db_scenario.getSplitRatioProfileSets()));
     scenario.setDownstreamBoundaryCapacityProfileSet(
         restoreDownstreamBoundaryCapacity(
             db_scenario.getDownstreamBoundaryCapacityProfileSets()));
     scenario.setEventSet(restoreEventSet(db_scenario.getEventSets()));
     scenario.setDemandProfileSet(restoreDemandProfileSet(db_scenario.getDemandProfileSets()));
     scenario.setControllerSet(restoreControllerSet(db_scenario.getControllerSets()));
     scenario.setFundamentalDiagramProfileSet(
         restoreFundamentalDiagramProfileSet(db_scenario.getFundamentalDiagramProfileSets()));
     scenario.setNetworkConnections(
         restoreNetworkConnections(db_scenario.getNetworkConnectionSets()));
     scenario.setDestinationNetworks(restoreDestinationNetworks(db_scenario));
     scenario.setRoutes(restoreRoutes(db_scenario));
   } catch (TorqueException exc) {
     throw new SiriusException(exc);
   }
   return scenario;
 }