weka.clusterers.assigners
Class LPAssigner

java.lang.Object
  extended byweka.clusterers.assigners.MPCKMeansAssigner
      extended byweka.clusterers.assigners.LPAssigner
All Implemented Interfaces:
java.lang.Cloneable, OptionHandler, java.io.Serializable

public class LPAssigner
extends MPCKMeansAssigner

See Also:
Serialized Form

Field Summary
static int ENGINE_JMATLINK
          Different engines that can be used to solve the LP
static int ENGINE_MATLAB
           
static int ENGINE_OCTAVE
           
static int ENGINE_TOMLAB
           
protected  Instances m_centroids
           
protected  java.util.HashMap m_constraintHash
           
protected  java.lang.String m_dataFilename
           
protected  java.lang.String m_dataFilenameBase
           
protected  jmatlink.JMatLink m_engine
          The matlab engine
protected  int m_engineType
          The engine
protected  Instances m_instances
          fields to be initialized from m_clusterer
protected  double[] m_maxCLDistances
           
protected  Metric m_metric
           
protected  LearnableMetric[] m_metrics
           
protected  int m_numCLConstraints
           
protected  int m_numClusters
           
protected  int m_numConstraints
           
protected  int m_numConstraintVars
           
protected  int m_numInstances
           
protected  int m_numLabelVars
           
protected  int m_numMLConstraints
           
protected  int m_numVars
           
protected  java.lang.String m_outFilename
           
protected  java.lang.String m_outFilenameBase
           
protected  java.lang.String m_progFilename
           
protected  java.io.File m_tempDirFile
           
protected  java.lang.String m_tempDirPath
          Path to the directory where temporary files will be stored
protected  boolean m_useMultipleMetrics
           
static Tag[] TAGS_ENGINE_TYPE
           
 
Fields inherited from class weka.clusterers.assigners.MPCKMeansAssigner
m_clusterer
 
Constructor Summary
LPAssigner()
           
 
Method Summary
protected  void accumulateConstraintCoeffs(double[] objCoeffs)
          Accumulate contribution from constraints
protected  void accumulateDistortionCoeffs(double[] objCoeffs)
          go through all instances and all clusters and accumulate the distortion contributions
protected  void addPairPenalties(InstancePair pair, int idx, double[] objCoeffs)
          accumulate penalties associated with a given constraint
 int assign()
          The main method
protected  double[] calculateMaxDistances(Instance[][] maxCLPoints)
           
protected  void dumpData(double[] objCoeffs, double[][] A_eq, double[] b_eq, double[][] A, double[] b)
          Dump data matrix into a file
protected  void dumpDataTomLab(double[] objCoeffs, double[][] A_eq, double[] b_eq, double[][] A, double[] b)
          Dump data matrix into a file
 SelectedTag getEngineType()
          Get the engine type
 java.lang.String[] getOptions()
          Gets the current option settings for the OptionHandler.
protected  double[][] getSolution()
          Read the solution from the output file of Octave
protected  void initialize()
          Initialize fields from the current clustererer
 boolean isSequential()
          This is a sequential assignment method
 java.util.Enumeration listOptions()
          Returns an enumeration of all the available options..
 void prepareEngine()
          Create octave m-file
 int runEngine()
          Run octave in command line with a given argument
 void setEngineType(SelectedTag engineType)
          Set the engine type
 void setOptions(java.lang.String[] options)
          Sets the OptionHandler's options using the given list.
 
Methods inherited from class weka.clusterers.assigners.MPCKMeansAssigner
setClusterer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_instances

protected Instances m_instances
fields to be initialized from m_clusterer


m_constraintHash

protected java.util.HashMap m_constraintHash

m_numInstances

protected int m_numInstances

m_numClusters

protected int m_numClusters

m_numConstraints

protected int m_numConstraints

m_numCLConstraints

protected int m_numCLConstraints

m_numMLConstraints

protected int m_numMLConstraints

m_numLabelVars

protected int m_numLabelVars

m_numConstraintVars

protected int m_numConstraintVars

m_numVars

protected int m_numVars

m_useMultipleMetrics

protected boolean m_useMultipleMetrics

m_metric

protected Metric m_metric

m_metrics

protected LearnableMetric[] m_metrics

m_maxCLDistances

protected double[] m_maxCLDistances

m_centroids

protected Instances m_centroids

ENGINE_JMATLINK

public static final int ENGINE_JMATLINK
Different engines that can be used to solve the LP

See Also:
Constant Field Values

ENGINE_OCTAVE

public static final int ENGINE_OCTAVE
See Also:
Constant Field Values

ENGINE_MATLAB

public static final int ENGINE_MATLAB
See Also:
Constant Field Values

ENGINE_TOMLAB

public static final int ENGINE_TOMLAB
See Also:
Constant Field Values

TAGS_ENGINE_TYPE

public static final Tag[] TAGS_ENGINE_TYPE

m_engineType

protected int m_engineType
The engine


m_engine

protected jmatlink.JMatLink m_engine
The matlab engine


m_tempDirPath

protected java.lang.String m_tempDirPath
Path to the directory where temporary files will be stored


m_tempDirFile

protected java.io.File m_tempDirFile

m_progFilename

protected java.lang.String m_progFilename

m_dataFilenameBase

protected java.lang.String m_dataFilenameBase

m_dataFilename

protected java.lang.String m_dataFilename

m_outFilenameBase

protected java.lang.String m_outFilenameBase

m_outFilename

protected java.lang.String m_outFilename
Constructor Detail

LPAssigner

public LPAssigner()
Method Detail

isSequential

public boolean isSequential()
This is a sequential assignment method

Specified by:
isSequential in class MPCKMeansAssigner

initialize

protected void initialize()
                   throws java.lang.Exception
Initialize fields from the current clustererer

Throws:
java.lang.Exception

assign

public int assign()
           throws java.lang.Exception
The main method

Specified by:
assign in class MPCKMeansAssigner
Returns:
the number of points that changed assignment
Throws:
java.lang.Exception

accumulateDistortionCoeffs

protected void accumulateDistortionCoeffs(double[] objCoeffs)
                                   throws java.lang.Exception
go through all instances and all clusters and accumulate the distortion contributions

Throws:
java.lang.Exception

accumulateConstraintCoeffs

protected void accumulateConstraintCoeffs(double[] objCoeffs)
                                   throws java.lang.Exception
Accumulate contribution from constraints

Throws:
java.lang.Exception

addPairPenalties

protected void addPairPenalties(InstancePair pair,
                                int idx,
                                double[] objCoeffs)
                         throws java.lang.Exception
accumulate penalties associated with a given constraint

Throws:
java.lang.Exception

dumpData

protected void dumpData(double[] objCoeffs,
                        double[][] A_eq,
                        double[] b_eq,
                        double[][] A,
                        double[] b)
Dump data matrix into a file


dumpDataTomLab

protected void dumpDataTomLab(double[] objCoeffs,
                              double[][] A_eq,
                              double[] b_eq,
                              double[][] A,
                              double[] b)
Dump data matrix into a file


getSolution

protected double[][] getSolution()
Read the solution from the output file of Octave


prepareEngine

public void prepareEngine()
Create octave m-file


runEngine

public int runEngine()
Run octave in command line with a given argument


calculateMaxDistances

protected double[] calculateMaxDistances(Instance[][] maxCLPoints)
                                  throws java.lang.Exception
Throws:
java.lang.Exception

setEngineType

public void setEngineType(SelectedTag engineType)
Set the engine type


getEngineType

public SelectedTag getEngineType()
Get the engine type

Returns:
engine type

setOptions

public void setOptions(java.lang.String[] options)
                throws java.lang.Exception
Description copied from interface: OptionHandler
Sets the OptionHandler's options using the given list. All options will be set (or reset) during this call (i.e. incremental setting of options is not possible).

Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported

listOptions

public java.util.Enumeration listOptions()
Description copied from interface: OptionHandler
Returns an enumeration of all the available options..

Returns:
an enumeration of all available options.

getOptions

public java.lang.String[] getOptions()
Description copied from interface: OptionHandler
Gets the current option settings for the OptionHandler.

Returns:
the list of current option settings as an array of strings