Пример #1
0
  static ScenarioForEvalData createPlanfall(ScenarioForEvalData nullfall) {
    // (construct the policy case.  The base case can be used to simplify things ...)

    // The policy case is initialized as a complete copy of the base case:
    ScenarioForEvalData planfall = nullfall.createDeepCopy();

    // we are now looking at one specific OD relation (for this scenario, there is only one!)
    Values planfallForOD = planfall.getByODRelation("AB");
    {
      // modify the travel times for the rail mode:
      ValuesForAMode railValues = planfallForOD.getByMode(Mode.rail);
      railValues
          .getByDemandSegment(DemandSegment.PV_NON_COMMERCIAL)
          .incByEntry(Attribute.hrs, -0.1);
      railValues.getByDemandSegment(DemandSegment.GV).incByEntry(Attribute.hrs, -0.1);

      // modify some demand (presumably as a result):
      double delta = 100.;
      //			double delta = 0. ;
      railValues.getByDemandSegment(DemandSegment.GV).incByEntry(Attribute.XX, delta);
      planfall
          .getByODRelation("AB")
          .getByMode(Mode.road)
          .getByDemandSegment(DemandSegment.GV)
          .incByEntry(Attribute.XX, -delta);
    }
    return planfall;
  }
 /** This method tests the {@code areEqual} method for another type of value and {@code Float}s. */
 @Test
 public void test_are_equal_for_float_and_string() {
   assertThat(Values.areEqual(1F, "1")).isTrue();
   assertThat(Values.areEqual(2F, "1")).isFalse();
   assertThat(Values.areEqual(1.5F, "1.5")).isTrue();
   assertThat(Values.areEqual(2.5F, "1.5")).isFalse();
 }
 /**
  * This method tests the {@code areEqual} method for another type of value and {@code Double}s.
  */
 @Test
 public void test_are_equal_for_double_and_string() {
   assertThat(Values.areEqual(1D, "1")).isTrue();
   assertThat(Values.areEqual(2D, "1")).isFalse();
   assertThat(Values.areEqual(1.5D, "1.5")).isTrue();
   assertThat(Values.areEqual(2.5D, "1.5")).isFalse();
 }
 /**
  * This method tests the {@code areEqual} method for another type of value and {@code
  * BigDecimal}s.
  */
 @Test
 public void test_are_equal_for_bigdecimal_and_string() {
   assertThat(Values.areEqual(new BigDecimal("1"), "1")).isTrue();
   assertThat(Values.areEqual(new BigDecimal("2"), "1")).isFalse();
   assertThat(Values.areEqual(new BigDecimal("1.5"), "1.5")).isTrue();
   assertThat(Values.areEqual(new BigDecimal("2.5"), "1.5")).isFalse();
 }
Пример #5
0
  static ScenarioForEvalData createNullfall() {
    // set up the base case:
    ScenarioForEvalData nullfall = new ScenarioForEvalData();

    // construct values for one OD relation:
    Values nullfallForOD = new Values();
    nullfall.setValuesForODRelation("AB", nullfallForOD);
    {
      // construct values for the road mode for this OD relation:
      ValuesForAMode roadValues = nullfallForOD.getByMode(Mode.road);
      {
        //				// passenger traffic:
        //				ValuesForAUserType pvValues = roadValues.getByType(Type.PV) ;
        //				pvValues.setByEntry( Entry.amount, 1000. ) ; // number of persons
        //				pvValues.setByEntry( Entry.km, 10. ) ;
        //				pvValues.setByEntry( Entry.hrs, 1. ) ;
      }
      {
        // freight traffic:
        Attributes gvValues = roadValues.getByDemandSegment(DemandSegment.GV);
        gvValues.setByEntry(Attribute.XX, 1000.); // tons
        gvValues.setByEntry(Attribute.km, 10.);
        gvValues.setByEntry(Attribute.hrs, 1.);
      }

      // rail values are just a copy of the road values:
      ValuesForAMode railValues = roadValues.createDeepCopy();
      nullfallForOD.setValuesForMode(Mode.rail, railValues);
    }

    // return the base case:
    return nullfall;
  }
 ScannerFilter(String[] inclusionsx, String[] exclusionsx, File dirName) {
   project = new Project();
   project.setBaseDir(dirName);
   fileSet = new FileSet();
   fileSet.setProject(project);
   fileSet.setDir(dirName);
   fileSet.appendIncludes(Values.trimCopy(inclusionsx));
   fileSet.appendExcludes(Values.trimCopy(exclusionsx));
   fileSet.appendExcludes(DEFAULT_EXCLUDES);
 }
Пример #7
0
  public static void main(String args[]) throws IOException {
    Values object = new Values();
    try {
      object.fetchmessages();
    } catch (IOException e) {
      e.printStackTrace();
    }

    object.dispaly(4);
  }
 /**
  * Save the descriptor configuration.
  *
  * <p>{@inheritDoc}
  */
 @Override
 public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
   // Get the values and check them.
   String deploy =
       Values.textOrElse(req.getParameter("dimensionsbuildnotifier.deployState"), null);
   String action =
       Values.textOrElse(req.getParameter("dimensionsbuildnotifier.actionState"), null);
   this.save();
   return super.configure(req, formData);
 }
Пример #9
0
 // new row added at runtime, so no starting values
 public VariableRow(int scope) {
   startValues = new Values(); // just to avoid NPEs
   endValues = new Values();
   endValues.name = "";
   endValues.dataType = "string";
   endValues.scope = scope;
   endValues.value = "";
   endValues.attributes = new YAttributeMap();
   initialiseValidity();
 }
Пример #10
0
 private static int effectiveIndex(Array array, Procedure proc, Object[] args, int[] work)
     throws Throwable {
   Object mapval = proc.applyN(args);
   if (mapval instanceof Values) {
     Values mapvals = (Values) mapval;
     for (int i = 0, j = 0; (i = mapvals.nextPos(i)) != 0; j++) {
       work[j] = ((Number) mapvals.getPosPrevious(i)).intValue();
     }
   } else work[0] = ((Number) mapval).intValue();
   if (array instanceof GeneralArray) return ((GeneralArray) array).resolve(work);
   else return work[0];
 }
Пример #11
0
  /** get all the unique values for the filters */
  public static Object values(Request req, Response res) {
    Values ret = new Values();
    ret.commit = StatsMain.store.commit.stream().map(c -> c.a).collect(Collectors.toSet());

    ret.instanceType =
        StatsMain.store.instanceType.stream().map(c -> c.a).collect(Collectors.toSet());

    ret.graphId = StatsMain.store.graphId.stream().map(c -> c.a).collect(Collectors.toSet());

    ret.jobId = StatsMain.store.jobId.stream().map(c -> c.a).collect(Collectors.toSet());

    return ret;
  }
Пример #12
0
 public Values copy() {
   Values copy = new Values();
   copy.name = name;
   copy.dataType = dataType;
   copy.scope = scope;
   copy.index = index;
   copy.value = value;
   copy.inputBinding = inputBinding;
   copy.outputBinding = outputBinding;
   copy.attributes = new YAttributeMap(attributes);
   copy.logPredicate = cloneLogPredicate();
   return copy;
 }
Пример #13
0
  @Override
  public void onReceive(Context appContext, Intent intent) {
    context = appContext;
    loc = Localizator.geoLocate(context);
    if (loc != null) {
      URLForecast = Conversor.getUrlForecast(loc);

      /*
       * Toast.makeText(context,
       * "¡Vibration Mode On porque el tiempo se ha terminado!",
       * Toast.LENGTH_LONG).show();
       */

      // Define la vibracion del telefono

      /*
       * Vibrator vibrator = (Vibrator) context
       * .getSystemService(Context.VIBRATOR_SERVICE);
       * vibrator.vibrate(1000);
       */
      prefs = context.getSharedPreferences(Values.getPrefs(), Context.MODE_PRIVATE);
      prefs.edit().putBoolean("active", true).commit();
      check_server();
    } else {
      Log.e(LogDavid, "LOC NULL");
      if (!Localizator.isProviderEnabled(appContext)) {
        Notifications notif = new Notifications(appContext);
        notif.providerDisabled();
      } else {

      }
    }
  }
Пример #14
0
  public static UpdateLogFrameJS toJavaScript(UpdateLogFrame updateLogFrame) {
    final UpdateLogFrameJS updateLogFrameJS = Values.createJavaScriptObject(UpdateLogFrameJS.class);

    updateLogFrameJS.setProjectId(updateLogFrame.getProjectId());
    updateLogFrameJS.setLogFrame(updateLogFrame.getLogFrame());

    return updateLogFrameJS;
  }
  /** This method tests the {@code areEqual} method for {@code TimeValue}s. */
  @Test
  public void test_are_equal_for_times() throws Exception {
    assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:06")), "09:01:06")).isTrue();
    assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:00")), "09:01:00")).isTrue();
    assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:00")), "09:01")).isTrue();
    assertThat(Values.areEqual(getValue(null, null), (String) null)).isTrue();

    assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:06")), "09:01:05")).isFalse();
    assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:06")), "09:02:06")).isFalse();
    assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:06")), "10:01:06")).isFalse();
    assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:06")), "09:01:06.000000003"))
        .isFalse();
    assertThat(Values.areEqual(getValue(null, Time.valueOf("09:01:06")), (String) null)).isFalse();
  }
Пример #16
0
 private boolean necesaryUpdate() {
   prefs = context.getSharedPreferences(Values.getPrefs(), Context.MODE_PRIVATE);
   long date_last_update = prefs.getLong("date_update", 0) * 1000;
   if ((System.currentTimeMillis() - date_last_update) < Values.elapsed_time / 2) {
     return false;
   }
   Log.d(LogDavid, "UPDATE_NECESARY");
   return true;
 }
Пример #17
0
 public static UpdateProjectTeamMembersJs toJavascript(
     UpdateProjectTeamMembers updateProjectTeamMembers) {
   UpdateProjectTeamMembersJs updateProjectTeamMembersJs =
       Values.createJavaScriptObject(UpdateProjectTeamMembersJs.class);
   updateProjectTeamMembersJs.setProjectId(updateProjectTeamMembers.getProjectId());
   updateProjectTeamMembersJs.setTeamMembers(updateProjectTeamMembers.getTeamMembers());
   updateProjectTeamMembersJs.setTeamMemberProfiles(
       updateProjectTeamMembers.getTeamMemberProfiles());
   return updateProjectTeamMembersJs;
 }
Пример #18
0
  /** Create population */
  public Population(Map map) {
    this.individuals = new ArrayList<>();
    this.size = Values.getPopulationSize();
    this.map = map;

    // create all individual
    for (int i = 0; i < this.size; i++) {
      // create an individual
      this.individuals.add(new Individual(map.getCountries()));
    }
  }
Пример #19
0
  void executeInsert(Table table) {
    table.buildInsert(sqlBuilder);
    SqlStatement stmt =
        generatedList.isEmpty() ? trx.prepare(sqlBuilder) : trx.prepareAndGenerateKeys(sqlBuilder);

    for (Values values : valuesList) {
      ValuesBinder binder = stmt.valuesBinder();
      values.bind(binder);
      stmt.addBatch();
    }

    stmt.executeBatch();

    if (!generatedList.isEmpty()) {
      Result generatedKeys = stmt.generatedKeys();
      for (Generated lazy : generatedList) {
        if (generatedKeys.next()) {
          lazy.extract(generatedKeys);
        }
      }
    }
  }
Пример #20
0
  /** Constructor. */
  public PTAModelChecker(Prism prism, ModulesFile modulesFile, PropertiesFile propertiesFile)
      throws PrismException {
    this.prism = prism;
    mainLog = prism.getMainLog();
    this.modulesFile = modulesFile;
    this.propertiesFile = propertiesFile;

    // Get combined constant values from model/properties
    constantValues = new Values();
    constantValues.addValues(modulesFile.getConstantValues());
    if (propertiesFile != null) constantValues.addValues(propertiesFile.getConstantValues());

    // Build a combined label list and expand any constants
    // (note labels in model are ignored (removed) during PTA translation so need to store here)
    labelList = new LabelList();
    for (int i = 0; i < modulesFile.getLabelList().size(); i++) {
      labelList.addLabel(
          modulesFile.getLabelList().getLabelNameIdent(i),
          modulesFile.getLabelList().getLabel(i).deepCopy());
    }
    for (int i = 0; i < propertiesFile.getLabelList().size(); i++) {
      labelList.addLabel(
          propertiesFile.getLabelList().getLabelNameIdent(i),
          propertiesFile.getLabelList().getLabel(i).deepCopy());
    }
    labelList = (LabelList) labelList.replaceConstants(constantValues);

    // Build mapping from all (original model) variables to non-clocks only
    int numVars = modulesFile.getNumVars();
    nonClockVarMap = new int[numVars];
    int count = 0;
    for (int i = 0; i < numVars; i++) {
      if (modulesFile.getVarType(i) instanceof TypeClock) {
        nonClockVarMap[i] = -1;
      } else {
        nonClockVarMap[i] = count++;
      }
    }
  }
Пример #21
0
 public final Values values() throws ParseException {
   Values values;
   Value value;
   value = value();
   values = new Values(value.units, value.value);
   label_4:
   while (true) {
     switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
       case COMA:;
         break;
       default:
         jj_la1[12] = jj_gen;
         break label_4;
     }
     jj_consume_token(COMA);
     value = value();
     values.addValues(value.value);
   }
   {
     if (true) return values;
   }
   throw new Error("Missing return statement in function");
 }
Пример #22
0
 public void writeObject(Object value) {
   if (value instanceof Values) {
     Values.writeValues(value, this);
     return;
   }
   if (value instanceof KNode) {
     KNode node = (KNode) value;
     writeObject(((NodeTree) node.sequence).typedValue(node.ipos));
     return;
   }
   Object old = table.get(value, null);
   if (old != null) return;
   table.put(value, value);
   base.writeObject(value);
 }
 @Override
 public PCollection<T> apply(PCollection<T> in) {
   WithKeys<IdT, T> withKeys = WithKeys.of(fn);
   if (representativeType != null) {
     withKeys = withKeys.withKeyType(representativeType);
   }
   return in.apply(withKeys)
       .apply(
           Combine.<IdT, T, T>perKey(
               new Combine.BinaryCombineFn<T>() {
                 @Override
                 public T apply(T left, T right) {
                   return left;
                 }
               }))
       .apply(Values.<T>create());
 }
Пример #24
0
  public static OrgUnitJS toJavaScript(OrgUnitDTO orgUnitDTO) {
    final OrgUnitJS orgUnitJS = Values.createJavaScriptObject(OrgUnitJS.class);

    orgUnitJS.setId(orgUnitDTO.getId());
    orgUnitJS.setName(orgUnitDTO.getName());
    orgUnitJS.setFullName(orgUnitDTO.getFullName());
    orgUnitJS.setOrgUnitModel(orgUnitDTO.getOrgUnitModel());
    orgUnitJS.setPlannedBudget(orgUnitDTO.getPlannedBudget());
    orgUnitJS.setSpendBudget(orgUnitDTO.getSpendBudget());
    orgUnitJS.setReceivedBudget(orgUnitDTO.getReceivedBudget());
    orgUnitJS.setParent(orgUnitDTO.getParentOrgUnit());
    orgUnitJS.setChildren(toArray(orgUnitDTO.getChildrenOrgUnits()));
    orgUnitJS.setCalendarId(orgUnitDTO.getCalendarId());
    orgUnitJS.setDeleted(orgUnitDTO.getDeleted());
    orgUnitJS.setOfficeLocationCountry(orgUnitDTO.getOfficeLocationCountry());

    return orgUnitJS;
  }
Пример #25
0
  private void check_server() {
    JsonParser jsonParser = new JsonParser(URLForecast);
    WeatherAsyncTask weatherAsyncTask = new WeatherAsyncTask();
    Editor edit;
    try {
      if (necesaryUpdate()) {
        Log.d(LogDavid, "NECESITO ACTUALIZAR");
        Weather weathers[] = weatherAsyncTask.execute(jsonParser).get();
        int n = Conversor.getNextWeather(weathers);
        Weather weather = weathers[n];
        if (n > 0) save_weather(weathers[n - 1]);
        else save_weather(weathers[0]);

        /*
         * Toast toast2 = Toast.makeText(context, R.string.success,
         * Toast.LENGTH_SHORT); toast2.show();
         */

        // if (weather.getRain_threehours() > 0 || weather.getSnow_threehours() > 0) {
        if (notificationNeeded(weather)) {
          Log.d(LogDavid, "NECESITO AVISAR");
          if (Conversor.ifNotificationAllowed(prefs)) {
            Log.d(LogDavid, "PUEDO AVISAR");
            Notifications notif = new Notifications(context);
            notif.notify(weather);
          } else {
            Log.d(LogDavid, "NO PUEDO AVISAR");
          }
        } else {
          Log.d(LogDavid, "NO NECESITO AVISAR - PREVIOUS FALSE");
          edit = prefs.edit();
          edit.putBoolean(Values.getPrevNotif(), false);
          edit.commit();
        }
      } else {
        Log.d(LogDavid, "NO ACTUALIZO");
      }
    } catch (Exception e) {
      Log.e(LogDavid, "Error Refresh: " + e.toString());
      e.printStackTrace();
    }
  }
Пример #26
0
 /**
  * Returns an iterator for the values in the map. Remove is supported. Note that the same iterator
  * instance is returned each time this method is called. Use the {@link OrderedMapValues}
  * constructor for nested or multithreaded iteration.
  */
 public Values<V> values() {
   if (values1 == null) {
     values1 = new OrderedMapValues(this);
     values2 = new OrderedMapValues(this);
   }
   if (!values1.valid) {
     values1.reset();
     values1.valid = true;
     values2.valid = false;
     return values1;
   }
   values2.reset();
   values2.valid = true;
   values1.valid = false;
   return values2;
 }
Пример #27
0
 /**
  * Returns an iterator for the values in the map. Remove is supported. Note that the same iterator
  * instance is returned each time this method is called. Use the {@link Entries} constructor for
  * nested or multithreaded iteration.
  */
 public Values<V> values() {
   if (valuesIter1 == null) {
     valuesIter1 = new Values(this);
     valuesIter2 = new Values(this);
   }
   if (!valuesIter1.valid) {
     valuesIter1.index = 0;
     valuesIter1.valid = true;
     valuesIter2.valid = false;
     return valuesIter1;
   }
   valuesIter2.index = 0;
   valuesIter2.valid = true;
   valuesIter1.valid = false;
   return valuesIter2;
 }
 /** This method tests the {@code areEqual} method for another type of value and {@code Long}s. */
 @Test
 public void test_are_equal_for_long_and_string() {
   assertThat(Values.areEqual((long) 1, "1")).isTrue();
   assertThat(Values.areEqual((long) 2, "1")).isFalse();
 }
 /**
  * This method tests the {@code areEqual} method for another type of value and {@code
  * BigInteger}s.
  */
 @Test
 public void test_are_equal_for_biginteger_and_string() {
   assertThat(Values.areEqual(new BigInteger("1"), "1")).isTrue();
   assertThat(Values.areEqual(new BigInteger("2"), "1")).isFalse();
 }
 /** This method should fail because the expected value is null. */
 @Test
 public void should_fail_because_string_is_null_with_bigdecimal() {
   assertThat(Values.areEqual(new BigDecimal("1"), (String) null)).isFalse();
 }