Example usage for org.apache.commons.configuration CompositeConfiguration getInt

List of usage examples for org.apache.commons.configuration CompositeConfiguration getInt

Introduction

In this page you can find the example usage for org.apache.commons.configuration CompositeConfiguration getInt.

Prototype

public int getInt(String key, int defaultValue) 

Source Link

Usage

From source file:mpaf.Main.java

public static void main(String[] args) {
    // Apache commons configuration
    CompositeConfiguration config = new CompositeConfiguration();
    try {// w ww.j  a v  a 2 s  . c  om

        XMLConfiguration user = new XMLConfiguration("mpaf.properties.user.xml");
        XMLConfiguration defaults = new XMLConfiguration("mpaf.properties.default.xml");

        // careful configuration is read from top to bottom if you want a
        // config to overwrite the user config, add it as first element
        // also make it optional to load, check if the file exists and THEN
        // load it!
        if (user != null)
            config.addConfiguration(user);
        config.addConfiguration(defaults);
    } catch (ConfigurationException e1) {
        e1.printStackTrace();
    }

    SqlHandler sqlH = null;
    sqlH = new SqlHandler();
    sqlH.setDbtype(config.getString("db.type", "sqlite"));
    sqlH.setDbhost(config.getString("db.host", "127.0.0.1"));
    sqlH.setDbport(config.getString("db.port", "3306"));
    sqlH.setDbname(config.getString("db.name", "mpaf.db"));
    sqlH.setDbuser(config.getString("db.user"));
    sqlH.setDbpass(config.getString("db.password"));

    IceModel iceM = new IceModel(config);
    IceController iceC;
    try {
        iceC = new IceController(iceM, sqlH.getConnection());
    } catch (ClassNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        return;
    } catch (SQLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        return;
    }

    Server server = new Server();

    ConsoleParser parser = new ConsoleParser(iceC, iceM, server);
    new Thread(parser).start();

    // will be called once a shutdown event is thrown(like ctrl+c or sigkill
    // etc.)
    ShutdownThread shutdown = new ShutdownThread(iceC);
    Runtime.getRuntime().addShutdownHook(new Thread(shutdown));

    if (config.getBoolean("jetty.enabled")) {
        SocketConnector connector = new SocketConnector();
        connector.setPort(config.getInt("jetty.ports.http", 10001));
        server.setConnectors(new Connector[] { connector });

        ServletContextHandler servletC = new ServletContextHandler(ServletContextHandler.SESSIONS);
        servletC.setContextPath("/");
        servletC.setAttribute("sqlhandler", sqlH);
        servletC.setAttribute("iceController", iceC);
        servletC.setAttribute("iceModel", iceM);
        // To add a servlet:
        ServletHolder holder = new ServletHolder(new DefaultCacheServlet());
        holder.setInitParameter("cacheControl", "max-age=3600,public");
        holder.setInitParameter("resourceBase", "web");
        servletC.addServlet(holder, "/");
        servletC.addServlet(new ServletHolder(new ServerList()), "/serverlist");
        servletC.addServlet(new ServletHolder(new ChannelList()), "/channellist");
        servletC.addServlet(new ServletHolder(new HandlerList()), "/handlerlist");
        servletC.addServlet(new ServletHolder(new ServerManage()), "/servermanage");
        servletC.addServlet(new ServletHolder(new Login()), "/login");
        servletC.addServlet(new ServletHolder(new Logout()), "/logout");
        servletC.addServlet(new ServletHolder(new UserCreate()), "/usercreate");
        servletC.addServlet(new ServletHolder(new UserInfo()), "/userinfo");
        servletC.addServlet(new ServletHolder(new UserList()), "/userlist");

        server.setHandler(servletC);
        try {
            server.start();
            server.join();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

From source file:ffx.crystal.ReflectionList.java

private void setResolutionBins(CompositeConfiguration properties) {
    if (properties != null) {
        nbins = properties.getInt("nbins", 10);
    }//from   w w  w . j  a  v a2 s  .co  m
    double nbinsd = (double) nbins;
    for (HKL ih : hkllist) {
        int bin = (int) (nbinsd * ordinal(Crystal.invressq(this.crystal, ih)));
        ih.bin = min(bin, nbins - 1);
    }
}

From source file:ffx.xray.DiffractionRefinementData.java

/**
 * allocate data given a {@link ReflectionList}
 *
 * @param properties configuration properties
 * @param reflectionlist {@link ReflectionList} to use to allocate data
 *//*from   ww w  .  java 2  s  .  c o m*/
public DiffractionRefinementData(CompositeConfiguration properties, ReflectionList reflectionlist) {

    int rflag = -1;
    if (properties != null) {
        rflag = properties.getInt("rfreeflag", -1);
        fsigfcutoff = properties.getDouble("fsigfcutoff", -1.0);
    } else {
        fsigfcutoff = -1.0;
    }

    this.n = reflectionlist.hkllist.size();
    this.scale_n = reflectionlist.crystal.scale_n;
    this.rfreeflag = rflag;
    this.nbins = reflectionlist.nbins;
    fsigf = new double[n][2];
    freer = new int[n];
    fc = new double[n][2];
    fs = new double[n][2];
    fctot = new double[n][2];
    fomphi = new double[n][2];
    fofc2 = new double[n][2];
    fofc1 = new double[n][2];
    dfc = new double[n][2];
    dfs = new double[n][2];

    for (int i = 0; i < n; i++) {
        fsigf[i][0] = fsigf[i][1] = Double.NaN;
        fctot[i][0] = fctot[i][1] = Double.NaN;
    }

    spline = new double[nbins * 2];
    sigmaa = new double[nbins];
    sigmaw = new double[nbins];
    fcesq = new double[nbins];
    foesq = new double[nbins];
    for (int i = 0; i < nbins; i++) {
        spline[i] = spline[i + nbins] = sigmaa[i] = fcesq[i] = foesq[i] = 1.0;
        sigmaw[i] = 0.05;
    }

    // initial guess for scaling/bulk solvent correction
    solvent_k = 0.33;
    solvent_ueq = 50.0 / (8.0 * PI * PI);
    model_k = 0.0;
}

From source file:ffx.xray.DiffractionData.java

/**
 * construct a diffraction data assembly
 *
 * @param assembly/*w  ww. ja  v  a 2  s .c o m*/
 * {@link ffx.potential.MolecularAssembly molecular assembly} object array
 * (typically containing alternate conformer assemblies), used as the atomic
 * model for comparison against the data
 * @param properties system properties file
 * @param solventmodel the type of solvent model desired - see
 * {@link CrystalReciprocalSpace.SolventModel bulk solvent model} selections
 * @param datafile one or more {@link DiffractionFile} to be refined against
 */
public DiffractionData(MolecularAssembly assembly[], CompositeConfiguration properties,
        SolventModel solventmodel, DiffractionFile... datafile) {

    this.assembly = assembly;
    this.solventModel = solventmodel;
    this.modelName = assembly[0].getFile().getName();
    this.dataFiles = datafile;
    this.n = datafile.length;

    int rflag = properties.getInt("rfreeflag", -1);
    fsigfCutoff = properties.getDouble("fsigfcutoff", -1.0);
    gridSearch = properties.getBoolean("gridsearch", false);
    splineFit = properties.getBoolean("splinefit", true);
    use_3g = properties.getBoolean("use_3g", true);
    aRadBuff = properties.getDouble("aradbuff", 0.75);
    double sampling = properties.getDouble("sampling", 0.6);
    xrayScaleTol = properties.getDouble("xrayscaletol", 1e-4);
    sigmaATol = properties.getDouble("sigmaatol", 0.05);
    xWeight = properties.getDouble("xweight", 1.0);
    bSimWeight = properties.getDouble("bsimweight", 1.0);
    bNonZeroWeight = properties.getDouble("bnonzeroweight", 1.0);
    bMass = properties.getDouble("bmass", 5.0);
    residueBFactor = properties.getBoolean("residuebfactor", false);
    nResidueBFactor = properties.getInt("nresiduebfactor", 1);
    addAnisou = properties.getBoolean("addanisou", false);
    refineMolOcc = properties.getBoolean("refinemolocc", false);
    occMass = properties.getDouble("occmass", 10.0);

    crystal = new Crystal[n];
    resolution = new Resolution[n];
    reflectionList = new ReflectionList[n];
    refinementData = new DiffractionRefinementData[n];
    scaleBulkMinimize = new ScaleBulkMinimize[n];
    sigmaAMinimize = new SigmaAMinimize[n];
    splineMinimize = new SplineMinimize[n];
    crystalStats = new CrystalStats[n];

    // read in Fo/sigFo/FreeR
    File tmp;
    Crystal crystalinit = Crystal.checkProperties(properties);
    Resolution resolutioninit = Resolution.checkProperties(properties);
    if (crystalinit == null || resolutioninit == null) {
        for (int i = 0; i < n; i++) {
            tmp = new File(datafile[i].getFilename());
            reflectionList[i] = datafile[i].getDiffractionfilter().getReflectionList(tmp, properties);

            if (reflectionList[i] == null) {
                logger.info(" Crystal information from the PDB or property file will be used.");
                crystalinit = assembly[i].getCrystal().getUnitCell();
                double res = datafile[i].getDiffractionfilter().getResolution(tmp, crystalinit);
                if (res < 0.0) {
                    logger.severe("MTZ/CIF/CNS file does not contain full crystal information!");
                } else {
                    resolutioninit = new Resolution(res, sampling);
                    reflectionList[i] = new ReflectionList(crystalinit, resolutioninit, properties);
                }
            }
        }
    } else {
        for (int i = 0; i < n; i++) {
            reflectionList[i] = new ReflectionList(crystalinit, resolutioninit, properties);
        }
    }

    for (int i = 0; i < n; i++) {
        crystal[i] = reflectionList[i].crystal;
        resolution[i] = reflectionList[i].resolution;
        refinementData[i] = new DiffractionRefinementData(properties, reflectionList[i]);
        tmp = new File(datafile[i].getFilename());
        datafile[i].getDiffractionfilter().readFile(tmp, reflectionList[i], refinementData[i], properties);
    }

    if (!crystal[0].equals(assembly[0].getCrystal().getUnitCell())) {
        logger.severe("PDB and reflection file crystal information do not match! (check CRYST1 record?)");
    }

    if (logger.isLoggable(Level.INFO)) {
        StringBuilder sb = new StringBuilder();
        sb.append(" X-ray Refinement Settings\n\n");
        sb.append("  Target Function\n");
        sb.append("  X-ray refinement weight (xweight): ").append(xWeight).append("\n");
        sb.append("  Use cctbx 3 Gaussians (use_3g): ").append(use_3g).append("\n");
        sb.append("  Atomic form factor radius buffer (aradbuff): ").append(aRadBuff).append("\n");
        sb.append("  Reciprocal space sampling rate (sampling): ").append(sampling).append("\n");
        sb.append("  Resolution dependent spline scale (splinefit): ").append(splineFit).append("\n");
        sb.append("  Solvent grid search (gridsearch): ").append(gridSearch).append("\n");
        sb.append("  X-ray scale fit tolerance (xrayscaletol): ").append(xrayScaleTol).append("\n");
        sb.append("  Sigma A fit tolerance (sigmaatol): ").append(sigmaATol).append("\n\n");
        sb.append("  Reflections\n");
        sb.append("  F/sigF cutoff (fsigfcutoff): ").append(fsigfCutoff).append("\n");
        sb.append("  R Free flag (rfreeflag) (if -1, value will be updated when data is read in): ")
                .append(rflag).append("\n");
        sb.append("  Number of bins (nbins): ").append(reflectionList[0].nbins).append("\n\n");
        sb.append("  B-Factors\n");
        sb.append("  Similarity weight (bsimweight): ").append(bSimWeight).append("\n");
        sb.append("  Non-zero weight (bnonzeroweight): ").append(bNonZeroWeight).append("\n");
        sb.append("  Lagrangian mass (bmass): ").append(bMass).append("\n");
        sb.append("  Refined by residue (residuebfactor): ").append(residueBFactor).append("\n");
        sb.append("    (if true, num. residues per B (nresiduebfactor): ").append(nResidueBFactor)
                .append(")\n");
        sb.append("  Add ANISOU for refinement (addanisou): ").append(addAnisou).append("\n\n");
        sb.append("  Occupancies\n");
        sb.append("  Refine on molecules (HETATMs - refinemolocc): ").append(refineMolOcc).append("\n");
        sb.append("  Lagrangian mass (occmass): ").append(occMass).append("\n");

        logger.info(sb.toString());
    }

    // now set up the refinement model
    refinementModel = new RefinementModel(assembly, refineMolOcc);

    // initialize atomic form factors
    for (Atom a : refinementModel.getTotalAtomArray()) {
        a.setFormFactorIndex(-1);
        XRayFormFactor atomff = new XRayFormFactor(a, use_3g, 2.0);
        a.setFormFactorIndex(atomff.ffIndex);

        if (a.getOccupancy() == 0.0) {
            a.setFormFactorWidth(1.0);
            continue;
        }

        double arad = a.getVDWType().radius * 0.5;
        double xyz[] = new double[3];
        xyz[0] = a.getX() + arad;
        xyz[1] = a.getY();
        xyz[2] = a.getZ();
        double rho = atomff.rho(0.0, 1.0, xyz);
        while (rho > 0.001) {
            arad += 0.1;
            xyz[0] = a.getX() + arad;
            rho = atomff.rho(0.0, 1.0, xyz);
        }
        arad += aRadBuff;
        a.setFormFactorWidth(arad);
    }

    // set up FFT and run it
    crs_fc = new CrystalReciprocalSpace[n];
    crs_fs = new CrystalReciprocalSpace[n];

    parallelTeam = assembly[0].getParallelTeam();

    parallelTeam = new ParallelTeam();
    for (int i = 0; i < n; i++) {
        crs_fc[i] = new CrystalReciprocalSpace(reflectionList[i], refinementModel.getTotalAtomArray(),
                parallelTeam, parallelTeam, false, dataFiles[i].isNeutron());
        refinementData[i].setCrystalReciprocalSpace_fc(crs_fc[i]);
        crs_fc[i].setUse3G(use_3g);
        crs_fc[i].setWeight(dataFiles[i].getWeight());
        crs_fc[i].lambdaTerm = false;
        crs_fs[i] = new CrystalReciprocalSpace(reflectionList[i], refinementModel.getTotalAtomArray(),
                parallelTeam, parallelTeam, true, dataFiles[i].isNeutron(), solventmodel);
        refinementData[i].setCrystalReciprocalSpace_fs(crs_fs[i]);
        crs_fs[i].setUse3G(use_3g);
        crs_fs[i].setWeight(dataFiles[i].getWeight());
        crs_fs[i].lambdaTerm = false;

        crystalStats[i] = new CrystalStats(reflectionList[i], refinementData[i]);
    }

    scaled = new boolean[n];
    fill(scaled, false);
}

From source file:ffx.algorithms.AbstractOSRW.java

/**
 * OSRW Asynchronous MultiWalker Constructor.
 *
 * @param lambdaInterface defines Lambda and dU/dL.
 * @param potential defines the Potential energy.
 * @param lambdaFile contains the current Lambda particle position and
 * velocity.//  ww  w.ja v a  2  s  .  com
 * @param histogramFile contains the Lambda and dU/dL histogram.
 * @param properties defines System properties.
 * @param temperature the simulation temperature.
 * @param dt the time step.
 * @param printInterval number of steps between logging updates.
 * @param saveInterval number of steps between restart file updates.
 * @param asynchronous set to true if walkers run asynchronously.
 * @param resetNumSteps whether to reset energy counts to 0
 * @param algorithmListener the AlgorithmListener to be notified of
 * progress.
 */
public AbstractOSRW(LambdaInterface lambdaInterface, Potential potential, File lambdaFile, File histogramFile,
        CompositeConfiguration properties, double temperature, double dt, double printInterval,
        double saveInterval, boolean asynchronous, boolean resetNumSteps, AlgorithmListener algorithmListener) {
    this.lambdaInterface = lambdaInterface;
    this.potential = potential;
    this.lambdaFile = lambdaFile;
    this.histogramFile = histogramFile;
    this.temperature = temperature;
    this.asynchronous = asynchronous;
    this.algorithmListener = algorithmListener;

    nVariables = potential.getNumberOfVariables();
    lowEnergyCoordsZero = new double[nVariables];
    lowEnergyCoordsOne = new double[nVariables];

    /**
     * Convert the time step to picoseconds.
     */
    this.dt = dt * 0.001;

    /**
     * Convert the print interval to a print frequency.
     */
    printFrequency = 100;
    if (printInterval >= this.dt) {
        printFrequency = (int) (printInterval / this.dt);
    }

    /**
     * Convert the save interval to a save frequency.
     */
    saveFrequency = 1000;
    if (saveInterval >= this.dt) {
        saveFrequency = (int) (saveInterval / this.dt);
    }

    biasCutoff = properties.getInt("lambda-bias-cutoff", 5);
    biasMag = properties.getDouble("bias-gaussian-mag", 0.002);
    dL = properties.getDouble("lambda-bin-width", 0.005);
    dFL = properties.getDouble("flambda-bin-width", 2.0);

    /**
     * Require modest sampling of the lambda path.
     */
    if (dL > 0.1) {
        dL = 0.1;
    }

    /**
     * Many lambda bin widths do not evenly divide into 1.0; here we correct
     * for this by computing an integer number of bins, then re-setting the
     * lambda variable appropriately. Note that we also choose to have an
     * odd number of lambda bins, so that the centers of the first and last
     * bin are at 0 and 1.
     */
    lambdaBins = (int) (1.0 / dL);
    if (lambdaBins % 2 == 0) {
        lambdaBins++;
    }

    /**
     * The initial number of FLambda bins does not really matter, since a
     * larger number is automatically allocated as needed. The center of the
     * central bin is at 0.
     */
    FLambdaBins = 401;
    minFLambda = -(dFL * FLambdaBins) / 2.0;

    energyCount = -1;

    dL = 1.0 / (lambdaBins - 1);
    dL_2 = dL / 2.0;
    minLambda = -dL_2;
    dFL_2 = dFL / 2.0;
    maxFLambda = minFLambda + FLambdaBins * dFL;
    FLambda = new double[lambdaBins];
    dUdXdL = new double[nVariables];
    stochasticRandom = new Random(0);

    /**
     * Set up the multi-walker communication variables for Parallel Java
     * communication between nodes.
     */
    world = Comm.world();
    numProc = world.size();
    rank = world.rank();
    jobBackend = JobBackend.getJobBackend();

    /**
     * Log OSRW parameters.
     */
    logger.info(" Orthogonal Space Random Walk Parameters");
    logger.info(String.format(" Gaussian Bias Magnitude:        %6.5f (kcal/mole)", biasMag));
    logger.info(String.format(" Gaussian Bias Cutoff:           %6d bins", biasCutoff));
}

From source file:ffx.algorithms.MolecularDynamics.java

/**
 * <p>//from ww  w  . j  a  v  a  2s.  c o  m
 * Constructor for MolecularDynamics.</p>
 *
 * @param assembly a {@link ffx.potential.MolecularAssembly} object.
 * @param potentialEnergy a {@link ffx.numerics.Potential} object.
 * @param properties a
 * {@link org.apache.commons.configuration.CompositeConfiguration} object.
 * @param listener a {@link ffx.algorithms.AlgorithmListener} object.
 * @param requestedThermostat a
 * {@link ffx.algorithms.Thermostat.Thermostats} object.
 * @param requestedIntegrator a
 * {@link ffx.algorithms.Integrator.Integrators} object.
 */
public MolecularDynamics(MolecularAssembly assembly, Potential potentialEnergy,
        CompositeConfiguration properties, AlgorithmListener listener, Thermostats requestedThermostat,
        Integrators requestedIntegrator) {
    this.molecularAssembly = assembly;
    assemblies = new ArrayList<>();
    assemblies.add(new AssemblyInfo(assembly));
    this.algorithmListener = listener;
    this.potential = potentialEnergy;

    assemblies.get(0).props = properties;
    mass = potentialEnergy.getMass();
    numberOfVariables = potentialEnergy.getNumberOfVariables();
    x = new double[numberOfVariables];
    v = new double[numberOfVariables];
    a = new double[numberOfVariables];
    aPrevious = new double[numberOfVariables];
    grad = new double[numberOfVariables];

    /**
     * If an Integrator wasn't passed to the MD constructor, check for one
     * specified as a property.
     */
    if (requestedIntegrator == null) {
        String integrate = properties.getString("integrate", "beeman").trim();
        try {
            requestedIntegrator = Integrators.valueOf(integrate);
        } catch (Exception e) {
            requestedIntegrator = Integrators.BEEMAN;
        }
    }
    switch (requestedIntegrator) {
    case RESPA:
        integrator = new Respa(numberOfVariables, x, v, a, aPrevious, mass);
        break;
    case STOCHASTIC:
        double friction = properties.getDouble("friction", 91.0);
        Stochastic stochastic = new Stochastic(friction, numberOfVariables, x, v, a, mass);
        if (properties.containsKey("randomseed")) {
            stochastic.setRandomSeed(properties.getInt("randomseed", 0));
        }
        integrator = stochastic;
        /**
         * The stochastic dynamics integration procedure will thermostat
         * the system. The ADIABTIC thermostat just serves to report the
         * temperature and initialize velocities if necessary.
         */
        requestedThermostat = Thermostats.ADIABATIC;
        break;
    case VELOCITYVERLET:
        integrator = new VelocityVerlet(numberOfVariables, x, v, a, mass);
        break;
    case BEEMAN:
    default:
        integrator = new BetterBeeman(numberOfVariables, x, v, a, aPrevious, mass);
    }

    /**
     * If a Thermostat wasn't passed to the MD constructor, check for one
     * specified as a property.
     */
    if (requestedThermostat == null) {
        String thermo = properties.getString("thermostat", "Berendsen").trim();
        try {
            requestedThermostat = Thermostats.valueOf(thermo);
        } catch (Exception e) {
            requestedThermostat = Thermostats.BERENDSEN;
        }
    }

    switch (requestedThermostat) {
    case BERENDSEN:
        double tau = properties.getDouble("tau-temperature", 0.2);
        thermostat = new Berendsen(numberOfVariables, x, v, mass, potentialEnergy.getVariableTypes(), 300.0,
                tau);
        break;
    case BUSSI:
        tau = properties.getDouble("tau-temperature", 0.2);
        thermostat = new Bussi(numberOfVariables, x, v, mass, potentialEnergy.getVariableTypes(), 300.0, tau);
        break;
    case ADIABATIC:
    default:
        thermostat = new Adiabatic(numberOfVariables, x, v, mass, potentialEnergy.getVariableTypes());
    }

    if (properties.containsKey("randomseed")) {
        thermostat.setRandomSeed(properties.getInt("randomseed", 0));
    }

    /**
     * For StochasticDynamics, center of mass motion will not be removed.
     */
    if (integrator instanceof Stochastic) {
        thermostat.setRemoveCenterOfMassMotion(false);
    }

    done = true;
}

From source file:ffx.xray.Looptimizer.java

/**
 * OSRW Asynchronous MultiWalker Constructor.
 *
 * @param lambdaInterface defines Lambda and dU/dL.
 * @param potential defines the Potential energy.
 * @param lambdaFile contains the current Lambda particle position and
 * velocity./* ww  w.j  ava2s .c  om*/
 * @param histogramFile contains the Lambda and dU/dL histogram.
 * @param properties defines System properties.
 * @param temperature the simulation temperature.
 * @param dt the time step.
 * @param printInterval number of steps between logging updates.
 * @param saveInterval number of steps between restart file updates.
 * @param asynchronous set to true if walkers run asynchronously.
 * @param algorithmListener the AlgorithmListener to be notified of
 * progress.
 */
public Looptimizer(LambdaInterface lambdaInterface, Potential potential, File lambdaFile, File histogramFile,
        CompositeConfiguration properties, double temperature, double dt, double printInterval,
        double saveInterval, boolean asynchronous, AlgorithmListener algorithmListener) {
    this.lambdaInterface = lambdaInterface;
    this.potential = potential;
    this.lambdaFile = lambdaFile;
    this.histogramFile = histogramFile;
    this.temperature = temperature;
    this.asynchronous = asynchronous;
    this.algorithmListener = algorithmListener;

    nVariables = potential.getNumberOfVariables();
    lowEnergyCoordsZero = new double[nVariables];
    lowEnergyCoordsOne = new double[nVariables];

    /**
     * Convert the time step to picoseconds.
     */
    this.dt = dt * 0.001;

    /**
     * Convert the print interval to a print frequency.
     */
    printFrequency = 100;
    if (printInterval >= this.dt) {
        printFrequency = (int) (printInterval / this.dt);
    }

    /**
     * Convert the save interval to a save frequency.
     */
    saveFrequency = 1000;
    if (saveInterval >= this.dt) {
        saveFrequency = (int) (saveInterval / this.dt);
    }

    biasCutoff = properties.getInt("lambda-bias-cutoff", 5);
    biasMag = properties.getDouble("bias-gaussian-mag", 0.002);
    dL = properties.getDouble("lambda-bin-width", 0.005);
    dFL = properties.getDouble("flambda-bin-width", 2.0);

    /**
     * Require modest sampling of the lambda path.
     */
    if (dL > 0.1) {
        dL = 0.1;
    }

    /**
     * Many lambda bin widths do not evenly divide into 1.0; here we correct
     * for this by computing an integer number of bins, then re-setting the
     * lambda variable appropriately. Note that we also choose to have an
     * odd number of lambda bins, so that the centers of the first and last
     * bin are at 0 and 1.
     */
    lambdaBins = (int) (1.0 / dL);
    if (lambdaBins % 2 == 0) {
        lambdaBins++;
    }

    /**
     * The initial number of FLambda bins does not really matter, since a
     * larger number is automatically allocated as needed. The center of the
     * central bin is at 0.
     */
    FLambdaBins = 401;
    minFLambda = -(dFL * FLambdaBins) / 2.0;

    /**
     * Allocate space for the recursion kernel that stores counts.
     */
    recursionKernel = new int[lambdaBins][FLambdaBins];

    /**
     * Load the OSRW histogram restart file if it exists.
     */
    boolean readHistogramRestart = false;
    if (histogramFile != null && histogramFile.exists()) {
        try {
            OSRWHistogramReader osrwHistogramReader = new OSRWHistogramReader(new FileReader(histogramFile));
            osrwHistogramReader.readHistogramFile();
            logger.info(String.format("\n Continuing OSRW histogram from %s.", histogramFile.getName()));
            readHistogramRestart = true;
        } catch (FileNotFoundException ex) {
            logger.info(" Histogram restart file could not be found and will be ignored.");
        }
    }

    /**
     * Load the OSRW lambda restart file if it exists.
     */
    if (lambdaFile != null && lambdaFile.exists()) {
        try {
            OSRWLambdaReader osrwLambdaReader = new OSRWLambdaReader(new FileReader(lambdaFile));
            osrwLambdaReader.readLambdaFile();
            logger.info(String.format("\n Continuing OSRW lambda from %s.", lambdaFile.getName()));
        } catch (FileNotFoundException ex) {
            logger.info(" Lambda restart file could not be found and will be ignored.");
        }
    }

    dL = 1.0 / (lambdaBins - 1);
    dL_2 = dL / 2.0;
    minLambda = -dL_2;
    dFL_2 = dFL / 2.0;
    maxFLambda = minFLambda + FLambdaBins * dFL;
    FLambda = new double[lambdaBins];
    dUdXdL = new double[nVariables];
    energyCount = -1;
    stochasticRandom = new Random(0);

    /**
     * Set up the multi-walker communication variables for Parallel Java
     * communication between nodes.
     */
    world = Comm.world();
    numProc = world.size();
    rank = world.rank();
    jobBackend = JobBackend.getJobBackend();

    if (asynchronous) {
        /**
         * Use asynchronous communication.
         */
        myRecursionCount = new double[2];
        myRecursionCountBuf = DoubleBuf.buffer(myRecursionCount);
        receiveThread = new ReceiveThread();
        receiveThread.start();
        recursionCounts = null;
        recursionCountsBuf = null;
    } else {
        /**
         * Use synchronous communication.
         */
        recursionCounts = new double[numProc][2];
        recursionCountsBuf = new DoubleBuf[numProc];
        for (int i = 0; i < numProc; i++) {
            recursionCountsBuf[i] = DoubleBuf.buffer(recursionCounts[i]);
        }
        myRecursionCount = recursionCounts[rank];
        myRecursionCountBuf = recursionCountsBuf[rank];
        receiveThread = null;
    }

    /**
     * Log OSRW parameters.
     */
    logger.info(" Orthogonal Space Random Walk Parameters");
    logger.info(String.format(" Gaussian Bias Magnitude:        %6.5f (kcal/mole)", biasMag));
    logger.info(String.format(" Gaussian Bias Cutoff:           %6d bins", biasCutoff));

    /**
     * Update and print out the recursion slave.
     */
    if (readHistogramRestart) {
        updateFLambda(true);
    }

}