## milk.experiment
Class MIRemoteExperiment

    java.lang.Object
      |
      +--milk.experiment.MIExperiment
            |
            +--milk.experiment.MIRemoteExperiment

All Implemented Interfaces:
  weka.core.OptionHandler, java.io.Serializable

public class MIRemoteExperiment
extends MIExperiment

Holds all the necessary configuration information for a distributed experiment. This object is able to be serialized for storage on disk.

This class is experimental at present. Has been tested using CSVResultListener (sending results to standard out) and DatabaseResultListener (InstantDB + RmiJdbc bridge).

Getting started:

Start InstantDB (with the RMI bridge) on some machine. If using java2 then specify -Djava.security.policy=db.policy to the virtual machine. Where db.policy is as follows:

     grant {
       permission java.security.AllPermission;
     };

Start RemoteEngine servers on x machines as per the instructons in the README_Experiment_Gui file. There must be a DatabaseUtils.props in either the HOME or current directory of each machine, listing all necessary jdbc drivers.

The machine where a MIRemoteExperiment is started must also have a copy of DatabaseUtils.props listing the URL to the machine where the database server is running (RmiJdbc + InstantDB).

Here is an example of starting a MIRemoteExperiment:

     java -Djava.rmi.server.codebase=file:/path to weka classes/ \
     weka.experiment.MIRemoteExperiment -L 1 -U 10 \
     -T /home/ml/datasets/UCI/iris.arff \
     -D "weka.experiment.DatabaseResultListener" \
     -P "weka.experiment.RandomSplitResultProducer" \
     -h rosebud.cs.waikato.ac.nz -h blackbird.cs.waikato.ac.nz -r -- \
     -W weka.experiment.ClassifierSplitEvaluator -- \
     -W weka.classifiers.bayes.NaiveBayes

The "codebase" property tells rmi where to serve up weka classes from. This can either be a file url (as long as a shared file system is being used that is accessable by the remoteEngine servers), or http url (which of course supposes that a web server is running and you have put your weka classes somewhere that is web accessable). If using a file url the trailing "/" is *most* important unless the weka classes are in a jar file.

See Also:
  Serialized Form

Field Summary
`protected static int` `AVAILABLE`
`protected static int` `CONNECTION_FAILED`
`protected static int` `IN_USE`
`protected javax.swing.DefaultListModel` `m_remoteHosts` Holds the names of machines with remoteEngine servers running
`protected boolean` `m_splitByDataSet` If true, then sub experiments are created on the basis of data sets rather than run number.
`protected int[]` `m_subExpComplete` The status of each of the sub-experiments
`protected MIExperiment[]` `m_subExperiments` The sub experiments
`protected static int` `MAX_FAILURES` allow at most 3 failures on a host before it is removed from the list of usable hosts
`protected static int` `SOME_OTHER_FAILURE`

Fields inherited from class milk.experiment.MIExperiment
`FILE_EXTENSION, m_AdditionalMeasures, m_AdvanceDataSetFirst, m_ClassFirst, m_CurrentInstances, m_CurrentProperty, m_DatasetNumber, m_Datasets, m_Finished, m_Notes, m_PropertyArray, m_PropertyNumber, m_PropertyPath, m_ResultListener, m_ResultProducer, m_RunLower, m_RunNumber, m_RunUpper, m_UsePropertyIterator`

Constructor Summary
`MIRemoteExperiment(MIExperiment base)` Construct a new MIRemoteExperiment using a base Experiment

Method Summary
`void` `abortExperiment()` Set the abort flag
`void` `addRemoteExperimentListener(weka.experiment.RemoteExperimentListener r)` Add an object to the list of those interested in recieving update information from the MIRemoteExperiment
`void` `addRemoteHost(java.lang.String hostname)` Add a host name to the list of remote hosts
`void` `advanceCounters()` overides the one in Experiment
`protected void` `availableHost(int hostNum)` Pushes a host back onto the queue of available hosts and attempts to launch a waiting experiment (if any).
`MIExperiment` `getBaseExperiment()` Get the base experiment used by this remote experiment
`javax.swing.DefaultListModel` `getRemoteHosts()` Get the list of remote host names
`boolean` `getSplitByDataSet()` Returns true if sub experiments are to be created on the basis of data set..
`protected void` `incrementFailed(int hostNum)` Increment the overall number of failures and the number of failures for a particular host
`protected void` `incrementFinished()` Increment the number of successfully completed sub experiments
`void` `initialize()` Prepares a remote experiment for running, creates sub experiments
`void` `launchNext(int wexp, int ah)` Launch a sub experiment on a remote host
`static void` `main(java.lang.String[] args)` Configures/Runs the Experiment from the command line.
`void` `nextIteration()` Overides the one in Experiment
`void` `postProcess()` overides the one in Experiment
`void` `runExperiment()` Overides runExperiment in Experiment
`void` `setBaseExperiment(MIExperiment base)` Set the base experiment.
`void` `setDatasets(javax.swing.DefaultListModel ds)` Set the datasets to use in the experiment
`void` `setNotes(java.lang.String newNotes)` Set the user notes.
`void` `setPropertyArray(java.lang.Object newPropArray)` Sets the array of values to set the custom property to.
`void` `setPropertyPath(weka.experiment.PropertyNode[] newPropertyPath)` Sets the path of properties taken to get to the custom property to iterate over.
`void` `setResultListener(MIResultListener newResultListener)` Sets the result listener where results will be sent.
`void` `setResultProducer(MIResultProducer newResultProducer)` Set the result producer used for the current experiment.
`void` `setRunLower(int newRunLower)` Set the lower run number for the experiment.
`void` `setRunUpper(int newRunUpper)` Set the upper run number for the experiment.
`void` `setSplitByDataSet(boolean sd)` Set whether sub experiments are to be created on the basis of data set.
`void` `setUsePropertyIterator(boolean newUsePropertyIterator)` Sets whether the custom property iterator should be used.
`java.lang.String` `toString()` Overides toString in Experiment
`protected void` `waitingExperiment(int expNum)` Push an experiment back on the queue of waiting experiments

Methods inherited from class milk.experiment.MIExperiment
`classFirst, getAdvanceDataSetFirst, getCurrentDatasetNumber, getCurrentPropertyNumber, getCurrentRunNumber, getDatasets, getNotes, getOptions, getPropertyArray, getPropertyArrayLength, getPropertyArrayValue, getPropertyPath, getResultListener, getResultProducer, getRunLower, getRunUpper, getUsePropertyIterator, hasMoreIterations, listOptions, setAdvanceDataSetFirst, setOptions, setProperty`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### m_remoteHosts

    protected javax.swing.DefaultListModel m_remoteHosts

  Holds the names of machines with remoteEngine servers running

### AVAILABLE

    protected static final int AVAILABLE

See Also:
  Constant Field Values

### IN_USE

    protected static final int IN_USE

See Also:
  Constant Field Values

### CONNECTION_FAILED

    protected static final int CONNECTION_FAILED

See Also:
  Constant Field Values

### SOME_OTHER_FAILURE

    protected static final int SOME_OTHER_FAILURE

See Also:
  Constant Field Values

### MAX_FAILURES

    protected static final int MAX_FAILURES

  allow at most 3 failures on a host before it is removed from the list of usable hosts

  See Also:
    Constant Field Values

### m_subExperiments

    protected MIExperiment[] m_subExperiments

  The sub experiments

### m_subExpComplete

    protected int[] m_subExpComplete

  The status of each of the sub-experiments

### m_splitByDataSet

    protected boolean m_splitByDataSet

  If true, then sub experiments are created on the basis of data sets rather than run number.

Constructor Detail

### MIRemoteExperiment

    public MIRemoteExperiment(MIExperiment base)
                       throws java.lang.Exception

  Construct a new MIRemoteExperiment using a base Experiment

Parameters:
  `base` - the base experiment to use
Throws:
  `java.lang.Exception` - if the base experiment is null

Method Detail

### getSplitByDataSet

    public boolean getSplitByDataSet()

  Returns true if sub experiments are to be created on the basis of data set..

  Returns:
    a `boolean` value indicating whether sub experiments are to be created on the basis of data set (true) or run number (false).

### setSplitByDataSet

    public void setSplitByDataSet(boolean sd)

  Set whether sub experiments are to be created on the basis of data set.

  Parameters:
    `sd` - true if sub experiments are to be created on the basis of data set. Otherwise sub experiments are created on the basis of run number.

### addRemoteExperimentListener

    public void addRemoteExperimentListener(weka.experiment.RemoteExperimentListener r)

  Add an object to the list of those interested in recieving update information from the MIRemoteExperiment

  Parameters:
    `r` - a listener

### getBaseExperiment

    public MIExperiment getBaseExperiment()

  Get the base experiment used by this remote experiment

  Returns:
    the base experiment

### setBaseExperiment

    public void setBaseExperiment(MIExperiment base)
                           throws java.lang.Exception

  Set the base experiment. A sub experiment will be created for each run in the base experiment.

  Parameters:
    `base` - the base experiment to use.
  Throws:
    `java.lang.Exception` - if supplied base experiment is null

### setNotes

    public void setNotes(java.lang.String newNotes)

  Set the user notes.

  Overrides:
    `setNotes` in class `MIExperiment`
  Parameters:
    `newNotes` - New user notes.

### setRunLower

    public void setRunLower(int newRunLower)

  Set the lower run number for the experiment.

  Overrides:
    `setRunLower` in class `MIExperiment`
  Parameters:
    `newRunLower` - the lower run number for the experiment.

### setRunUpper

    public void setRunUpper(int newRunUpper)

  Set the upper run number for the experiment.

  Overrides:
    `setRunUpper` in class `MIExperiment`
  Parameters:
    `newRunUpper` - the upper run number for the experiment.

### setResultListener

    public void setResultListener(MIResultListener newResultListener)

  Sets the result listener where results will be sent.

  Overrides:
    `setResultListener` in class `MIExperiment`
  Parameters:
    `newResultListener` - the result listener where results will be sent.

### setResultProducer

    public void setResultProducer(MIResultProducer newResultProducer)

  Set the result producer used for the current experiment.

  Overrides:
    `setResultProducer` in class `MIExperiment`
  Parameters:
    `newResultProducer` - result producer to use for the current experiment.

### setDatasets

    public void setDatasets(javax.swing.DefaultListModel ds)

  Set the datasets to use in the experiment

  Overrides:
    `setDatasets` in class `MIExperiment`
  Parameters:
    `ds` - the list of datasets to use

### setUsePropertyIterator

    public void setUsePropertyIterator(boolean newUsePropertyIterator)

  Sets whether the custom property iterator should be used.

  Overrides:
    `setUsePropertyIterator` in class `MIExperiment`
  Parameters:
    `newUsePropertyIterator` - true if so

### setPropertyPath

    public void setPropertyPath(weka.experiment.PropertyNode[] newPropertyPath)

  Sets the path of properties taken to get to the custom property to iterate over.

  Overrides:
    `setPropertyPath` in class `MIExperiment`
  Parameters:
    `newPropertyPath` - an array of PropertyNodes

### setPropertyArray

    public void setPropertyArray(java.lang.Object newPropArray)

  Sets the array of values to set the custom property to.

  Overrides:
    `setPropertyArray` in class `MIExperiment`
  Parameters:
    `newPropArray` - a value of type Object which should be an array of the appropriate values.

### initialize

    public void initialize()
                    throws java.lang.Exception

  Prepares a remote experiment for running, creates sub experiments

  Overrides:
    `initialize` in class `MIExperiment`
  Throws:
    `java.lang.Exception` - if an error occurs

### abortExperiment

    public void abortExperiment()

  Set the abort flag

### incrementFinished

    protected void incrementFinished()

  Increment the number of successfully completed sub experiments

### incrementFailed

    protected void incrementFailed(int hostNum)

  Increment the overall number of failures and the number of failures for a particular host

  Parameters:
    `hostNum` - the index of the host to increment failure count

### waitingExperiment

    protected void waitingExperiment(int expNum)

  Push an experiment back on the queue of waiting experiments

  Parameters:
    `expNum` - the index of the experiment to push onto the queue

### availableHost

    protected void availableHost(int hostNum)

  Pushes a host back onto the queue of available hosts and attempts to launch a waiting experiment (if any).

  Parameters:
    `hostNum` - the index of the host to push back onto the queue of available hosts

### launchNext

    public void launchNext(int wexp,
                           int ah)

  Launch a sub experiment on a remote host

  Parameters:
    `wexp` - the index of the sub experiment to launch
    `ah` - the index of the available host to launch on

### nextIteration

    public void nextIteration()
                       throws java.lang.Exception

  Overides the one in Experiment

  Overrides:
    `nextIteration` in class `MIExperiment`
  Throws:
    `java.lang.Exception`

### advanceCounters

    public void advanceCounters()

  overides the one in Experiment

  Overrides:
    `advanceCounters` in class `MIExperiment`

### postProcess

    public void postProcess()

  overides the one in Experiment

  Overrides:
    `postProcess` in class `MIExperiment`

### addRemoteHost

    public void addRemoteHost(java.lang.String hostname)

  Add a host name to the list of remote hosts

  Parameters:
    `hostname` - the host name to add to the list

### getRemoteHosts

    public javax.swing.DefaultListModel getRemoteHosts()

  Get the list of remote host names

  Returns:
    the list of remote host names

### toString

    public java.lang.String toString()

  Overides toString in Experiment

  Overrides:
    `toString` in class `MIExperiment`
  Returns:
    a description of this remote experiment

### runExperiment

    public void runExperiment()

  Overides runExperiment in Experiment

  Overrides:
    `runExperiment` in class `MIExperiment`

### main

    public static void main(java.lang.String[] args)

  Configures/Runs the Experiment from the command line.

  Parameters:
    `args` - command line arguments to the Experiment.