Example usage for org.apache.commons.configuration Configuration getDouble

List of usage examples for org.apache.commons.configuration Configuration getDouble

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration getDouble.

Prototype

Double getDouble(String key, Double defaultValue);

Source Link

Document

Get a Double associated with the given configuration key.

Usage

From source file:keel.Algorithms.Neural_Networks.NNEP_Common.mutators.structural.StructuralMutator.java

/**
 * <p>/*from  ww w.j a v a 2  s .c  o m*/
 * Configuration parameters for StructuralMutator are:
 * </p>
 * @params settings Settings to configure
 * <ul>
 * <li>
 * <code>temperature-exponent[@value] double (default=1)</code></p>
 * Temperature exponent to be used for obtaining temperature
 * of each indivual mutated.
 * </li>
 * <li>
 * <code>significative-weigth[@value] double (default=0.0000001)</code></p>
 * Minimum value of new weigths.
 * </li>
 * <li>
 * <code>neurons-ranges: complex</code></p> 
 * Ranges of neurons added or deleted.
 * <ul>
 *       <li>
 *       <code>neurons-ranges.added: complex</code>
 *       Ranges of neurons added.
 *       <ul>
 *          <li>
 *          <code>neurons-ranges.added[@min] int (default=1)</code>
 *          Minimum number of added neurons.
 *          </li>
 *          <li>
 *          <code>neurons-ranges.added[@max] int (default=2)</code>
 *          Maximum number of added neurons.
 *          </li>
 *       </ul> 
 *       </li>
 *       <li>
 *       <code>neurons-ranges.deleted: complex</code>
 *       Ranges of neurons deleted.
 *       <ul>
 *          <li>
 *          <code>neurons-ranges.deleted[@min] int (default=1)</code>
 *          Minimum number of deleted neurons.
 *          </li>
 *          <li>
 *          <code>neurons-ranges.deleted[@max] int (default=2)</code>
 *          Maximum number of deleted neurons.
 *          </li>
 *       </ul> 
 *       </li>
 * </ul> 
 * </li>
 * <li>
 * <code>links-ranges: complex</code></p> 
 * Ranges of links added or deleted.
 * <ul>
 *       <li>
 *       <code>links-ranges[@relative] boolean (default=false)</code>
 *      If we use a relative number of links, then we have to specify
 *      a percentage of links added or deleted, dependind of the layer
 *      operated
 *       </li>
 *       <li>
 *       <code>links-ranges.added: complex</code>
 *       Ranges of absolute number of links added 
 *      (when <code>links-ranges.relative = false </code>).
 *       <ul>
 *          <li>
 *          <code>links-ranges.added[@min] int (default=1)</code>
 *          Minimum number of added links.
 *          </li>
 *          <li>
 *          <code>links-ranges.added[@max] int (default=6)</code>
 *          Maximum number of added links.
 *          </li>
 *       </ul> 
 *       </li>
 *       <li>
 *       <code>links-ranges.deleted: complex</code>
 *       Ranges of absolute number of links deleted 
 *      (when <code>links-ranges.relative = false </code>).
 *       <ul>
 *          <li>
 *          <code>links-ranges.deleted[@min] int (default=1)</code>
 *          Minimum number of deleted links.
 *          </li>
 *          <li>
 *          <code>links-ranges.deleted[@max] int (default=6)</code>
 *          Maximum number of deleted links.
 *          </li>
 *       </ul> 
 *       </li>
 *       <li> 
 *          <code>links-ranges.percentages: complex</code>
 *          Percentages of links added and deleted
 *         (when <code>links-ranges.relative = true </code>).
 *          <ul>
 *             <li>
 *             <code>links-ranges.percentages[@hidden] int (default=30)</code>
 *             Percentage of links added/deleted of each neuron of a hidden layer.
 *             </li>
 *             <li>
 *             <code>links-ranges.percentages[@output] int (default=5)</code>
 *             Percentage of links added/deleted of each neuron of an output layer.
 *             </li>
 *          </ul> 
 *       </li>
 * </ul> 
 * </li>
 * </ul>
 */

public void configure(Configuration settings) {

    // Setup pr
    temperExponent = settings.getDouble("temperature-exponent[@value]", 1);

    // Setup significativeWeigth
    significativeWeigth = settings.getDouble("significative-weigth[@value]", 0.0000001);

    // Setup neurons mutation parameters
    minNeuronsAdd = settings.getInt("neurons-ranges.added[@min]", 1);
    maxNeuronsAdd = settings.getInt("neurons-ranges.added[@max]", 2);
    minNeuronsDel = settings.getInt("neurons-ranges.deleted[@min]", 1);
    maxNeuronsDel = settings.getInt("neurons-ranges.deleted[@max]", 2);

    // Setup links mutation parameters
    nOfLinksRelative = settings.getBoolean("links-ranges[@relative]", false);
    if (!nOfLinksRelative) {
        minLinksAdd = settings.getInt("links-ranges.added[@min]", 1);
        maxLinksAdd = settings.getInt("links-ranges.added[@max]", 6);
        minLinksDel = settings.getInt("links-ranges.deleted[@min]", 1);
        maxLinksDel = settings.getInt("links-ranges.deleted[@max]", 6);
    } else {
        hiddenLinksPercentage = settings.getInt("links-ranges.percentages[@hidden]", 30);
        outputLinksPercentage = settings.getInt("links-ranges.percentages[@output]", 5);
    }
}

From source file:ch.epfl.eagle.daemon.scheduler.Scheduler.java

public void initialize(Configuration conf, InetSocketAddress socket) throws IOException {
    address = Network.socketAddressToThrift(socket);
    String mode = conf.getString(EagleConf.DEPLOYMENT_MODE, "unspecified");
    this.conf = conf;
    if (mode.equals("standalone")) {
        state = new StandaloneSchedulerState();
    } else if (mode.equals("configbased")) {
        state = new ConfigSchedulerState();
    } else {//from  www.  j  a v a 2s .  c  o  m
        throw new RuntimeException("Unsupported deployment mode: " + mode);
    }

    state.initialize(conf);

    defaultProbeRatioUnconstrained = conf.getDouble(EagleConf.SAMPLE_RATIO, EagleConf.DEFAULT_SAMPLE_RATIO);
    defaultProbeRatioConstrained = conf.getDouble(EagleConf.SAMPLE_RATIO_CONSTRAINED,
            EagleConf.DEFAULT_SAMPLE_RATIO_CONSTRAINED);

    requestTaskPlacers = Maps.newConcurrentMap();

    useCancellation = conf.getBoolean(EagleConf.CANCELLATION, EagleConf.DEFAULT_CANCELLATION);

    // [[FLORIN
    this.hostnameCentralizedScheduler = conf.getString("scheduler.centralized", "none");
    this.smallPartition = conf.getInt(EagleConf.SMALL_PARTITION, EagleConf.DEFAULT_SMALL_PARTITION);
    this.bigPartition = conf.getInt(EagleConf.BIG_PARTITION, EagleConf.DEFAULT_BIG_PARTITION);

    // if(address.getHost().contains(this.hostnameCentralizedScheduler)){
    if (address.getHost().matches(this.hostnameCentralizedScheduler)) {
        amIMaster = true;
        LOG.info("I am master: " + this.hostnameCentralizedScheduler + "--" + address.getHost() + "--");
    }
    // LOG.info("I am NOT master: "+this.hostnameCentralizedScheduler+"--"+address.getHost()+"--");

    // EAGLE
    this.piggybacking = conf.getBoolean(EagleConf.PIGGYBACKING, EagleConf.DEFAULT_PIGGYBACKING);
    LOG.info("Piggybacking: " + this.piggybacking);
    distributedLongStatusTimestamp = -1;
    distributedNotExecutingLong = new ArrayList<String>();
    this.retry_rounds = conf.getInt(EagleConf.RETRY_ROUNDS, EagleConf.DEFAULT_RETRY_ROUNDS);
    LOG.info("retry_rounds: " + this.retry_rounds);
    this.last_round_short_partition = conf.getBoolean(EagleConf.LAST_ROUND_SHORT_PARTITION,
            EagleConf.DEFAULT_LAST_ROUND_SHORT_PARTITION);

    if (useCancellation) {
        LOG.debug("Initializing cancellation service");
        cancellationService = new CancellationService(nodeMonitorClientPool);
        new Thread(cancellationService).start();
    } else {
        LOG.debug("Not using cancellation");
    }

    spreadEvenlyTaskSetSize = conf.getInt(EagleConf.SPREAD_EVENLY_TASK_SET_SIZE,
            EagleConf.DEFAULT_SPREAD_EVENLY_TASK_SET_SIZE);
}

From source file:org.apache.bookkeeper.common.conf.ConfigKey.java

/**
 * Retrieve the setting from the configuration <tt>conf</tt> as a {@link Double} value.
 *
 * @param conf configuration to retrieve the setting
 * @return the value as a double number//www.j  a v a 2s  . c  o m
 */
public double getDouble(Configuration conf) {
    checkArgument(type() == Type.DOUBLE, "'" + name() + "' is NOT a DOUBLE numeric setting");
    return conf.getDouble(name(), (Double) defaultValue());
}

From source file:org.apache.james.backends.cassandra.init.configuration.QueryLoggerConfiguration.java

private static Optional<Double> getOptionalDoubleFromConf(Configuration configuration, String key) {
    return Optional.ofNullable(configuration.getDouble(key, null));
}

From source file:org.apache.james.smtpserver.fastfail.SpamAssassinHandler.java

@Override
public void init(Configuration config) throws ConfigurationException {
    setSpamdHost(config.getString("spamdHost", "localhost"));
    setSpamdPort(config.getInt("spamdPort", 783));
    setSpamdRejectionHits(config.getDouble("spamdRejectionHits", 0.0));
}

From source file:org.apache.tinkerpop.gremlin.process.computer.ranking.pagerank.PageRankVertexProgram.java

@Override
public void loadState(final Graph graph, final Configuration configuration) {
    if (configuration.containsKey(INITIAL_RANK_TRAVERSAL))
        this.initialRankTraversal = PureTraversal.loadState(configuration, INITIAL_RANK_TRAVERSAL, graph);
    if (configuration.containsKey(EDGE_TRAVERSAL)) {
        this.edgeTraversal = PureTraversal.loadState(configuration, EDGE_TRAVERSAL, graph);
        this.incidentMessageScope = MessageScope.Local.of(() -> this.edgeTraversal.get().clone());
        this.countMessageScope = MessageScope.Local
                .of(new MessageScope.Local.ReverseTraversalSupplier(this.incidentMessageScope));
    }/*from www  .j a  v a  2 s  .com*/
    this.vertexCountAsDouble = configuration.getDouble(VERTEX_COUNT, 1.0d);
    this.alpha = configuration.getDouble(ALPHA, 0.85d);
    this.totalIterations = configuration.getInt(TOTAL_ITERATIONS, 30);
    this.property = configuration.getString(PROPERTY, PAGE_RANK);
    this.vertexComputeKeys = new HashSet<>(
            Arrays.asList(VertexComputeKey.of(this.property, false), VertexComputeKey.of(EDGE_COUNT, true)));
}

From source file:org.janusgraph.olap.PageRankVertexProgram.java

@Override
public void loadState(final Graph graph, final Configuration configuration) {
    dampingFactor = configuration.getDouble(DAMPING_FACTOR, 0.85D);
    maxIterations = configuration.getInt(MAX_ITERATIONS, 10);
    vertexCount = configuration.getLong(VERTEX_COUNT, 1L);
}

From source file:org.matsim.contrib.taxi.optimizer.assignment.AssignmentTaxiOptimizerParams.java

public AssignmentTaxiOptimizerParams(Configuration optimizerConfig) {
    super(optimizerConfig, true, true);

    mode = Mode.valueOf(optimizerConfig.getString(MODE));

    // when the cost is measured in time units (seconds),
    // 48 * 36000 s (2 days) seem big enough to prevent such assignments
    nullPathCost = optimizerConfig.getDouble(NULL_PATH_COST, 48 * 3600);

    vehPlanningHorizonOversupply = optimizerConfig.getInt(VEH_PLANNING_HORIZON_OVERSUPPLY);
    vehPlanningHorizonUndersupply = optimizerConfig.getInt(VEH_PLANNING_HORIZON_UNDERSUPPLY);

    nearestRequestsLimit = optimizerConfig.getInt(NEAREST_REQUESTS_LIMIT);
    nearestVehiclesLimit = optimizerConfig.getInt(NEAREST_VEHICLES_LIMIT);
}

From source file:org.mot.core.scheduler.BackTestSimulator.java

private void init() {

    PropertiesFactory pf = PropertiesFactory.getInstance();

    Configuration simulationProperties;
    try {//from ww  w.  j  a v  a  2s.c o  m
        simulationProperties = new PropertiesConfiguration(pf.getConfigDir() + "/simulation.properties");

        frequency = simulationProperties.getString("simulation.default.frequency", "TICK");
        quantity = simulationProperties.getInt("simulation.default.quantity", 10);
        minProfit = simulationProperties.getDouble("simulation.default.minProfit", 2.0);
        className = simulationProperties.getString("simulation.default.class",
                "org.mot.client.sg.mvgAvg.SimpleMvgAvgComparison");
        txnpct = simulationProperties.getDouble("simulation.order.txncost.pct", 0.0024);

    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    Map<Integer, String> instruments = new Hashtable<Integer, String>();

    WatchListDAO wld = new WatchListDAO();
    instruments = wld.getWatchlistAsTable("STK");

    Iterator<Entry<Integer, String>> it = instruments.entrySet().iterator();

    while (it.hasNext()) {
        final Map.Entry<Integer, String> entry = it.next();
        String symbol = entry.getValue();

        this.triggerYesterdaysReplay(symbol);
        this.triggerLastWeekReplay(symbol);
        //this.triggerLastMonthReplay(symbol);

    }
}

From source file:org.mot.core.simulation.listener.SimulationMessageListener.java

@SuppressWarnings("unchecked")
@Override//w ww  .  j ava 2  s.  c  o  m
public void onMessage(Message msg) {
    // TODO Auto-generated method stub

    BytesMessage message = (BytesMessage) msg;

    // Read in properties from file
    Configuration simulationProperties;

    byte[] bytes;
    try {
        PropertiesFactory pf = PropertiesFactory.getInstance();
        simulationProperties = new PropertiesConfiguration(pf.getConfigDir() + "/simulation.properties");
        final Double minProfit = simulationProperties.getDouble("simulation.default.db.requireMinProfit", 2.0);
        final Double txnpct = simulationProperties.getDouble("simulation.order.txncost.pct", 0.0024);

        bytes = new byte[(int) message.getBodyLength()];
        message.readBytes(bytes);

        SimulationRequest sr = SimulationRequest.deserialize(bytes);
        sr.setMinProfit(minProfit);
        sr.setTxnPct(txnpct);

        String className = sr.getClassName();

        Class<?> c;
        try {
            c = Class.forName(className);
            Object inst = c.newInstance();

            // Make sure the startup method is called for initialization...
            //Method m1= c.getDeclaredMethod("startup", String.class, String.class, LoadValue[].class, Boolean.class, Integer.class );
            //m1.invoke(inst, sr.getClassName(), sr.getSymbol(), lvc.convertStringToValues(sr.getLoadValues()), true, sr.getQuantity());

            // Call the backtest Processing class...
            Method m = c.getDeclaredMethod("processSimulationRequests", SimulationRequest.class);
            Object ret = m.invoke(inst, sr);
            ArrayList<SimulationResponse> simulationResponses = (ArrayList<SimulationResponse>) ret;

            // Iterate over the expressions
            Iterator<SimulationResponse> it = simulationResponses.iterator();
            while (it.hasNext()) {
                SimulationResponse u = it.next();
                this.writeToDB(u);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

        msg.acknowledge();

    } catch (JMSException | ClassNotFoundException | IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {

    }

}