jCMPL
Class Cmpl

java.lang.Object
  extended by java.lang.Thread
      extended by jCMPL.Cmpl
All Implemented Interfaces:
java.lang.Runnable

public class Cmpl
extends java.lang.Thread

Cmpl

Version:
1.0.0 beta 1 license LGPLv3
Author:
Mike Steglich, Bernhard Knie

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static int ASYNCHRONOUSLY
           
static int CMPL_FAILED
           
static int CMPL_OK
           
static int CMPL_UNKNOWN
           
static int CMPL_WARNINGS
           
static int CMPLSERVER_CLEANED
           
static int CMPLSERVER_ERROR
           
static int CMPLSERVER_OK
           
static int PROBLEM_CANCELED
           
static int PROBLEM_FINISHED
           
static int PROBLEM_NOTRUNNING
           
static int PROBLEM_RUNNING
           
static int SOLVER_FAILED
           
static int SOLVER_OK
           
static int SYNCHRONOUSLY
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Cmpl(java.lang.String model)
          constructor
 
Method Summary
 java.lang.String asciiSolFile()
          Returns the name of the Ascii solution file - controlled by the command line arg -solutionAscii
 void cancel()
          Cancels the Cmpl solving process on the connected CMPLServer The status of the model can be obtained by the methods cmplStatus and cmplStatusText
 java.util.ArrayList<CmplMsg> cmplMessages()
          Returns the CmplMessages
 java.lang.String cmplSolFile()
          Returns the name of the CmplSolution file - controlled by the command line arg -solution
 int cmplStatus()
          Returns the CMPL related status of the Cmpl object CMPL_UNKNOWN = 0 CMPL_OK = 1 CMPL_WARNINGS = 2 CMPL_FAILED = 3 CMPLSERVER_OK = 6 CMPLSERVER_ERROR = 7 CMPLSERVER_CLEANED = 8 PROBLEM_RUNNING = 9 PROBLEM_FINISHED = 10 PROBLEM_CANCELED = 11 PROBLEM_NOTRUNNING = 12
 java.lang.String cmplStatusText()
          Returns the CMPL related status text of the Cmpl object CMPL_UNKNOWN CMPL_OK CMPL_WARNINGS CMPL_FAILED SOLVER_OK SOLVER_FAILED CMPLSERVER_OK CMPLSERVER_ERROR CMPLSERVER_CLEANED PROBLEM_RUNNING PROBLEM_FINISHED PROBLEM_CANCELED PROBLEM_NOTRUNNING
 java.lang.String conDisplayOptions()
          Returns the a string with the display options for the constraints of the generated and solved CMPL model
 void connect(java.lang.String cmplUrl)
          Connects a CMPLServer under cmplUrl - first step of solving a model on a CMPLServer remotely
 java.lang.String csvSolFile()
          Returns the name of the Csv solution file - controlled by the command line arg -solutionCsv
 void debug(boolean x)
          Very simple debug mode
 void delOption(java.lang.Integer pos)
          Deletes an option
 void delOptions()
          Deletes all options
 void disconnect()
          Disconnects the connected CMPLServer
protected  void finalize()
          destructor
 java.lang.Object getConByName(java.lang.String name)
          Enables the direct access to a single constraint or constraint array of the optimal solution
 java.lang.Object getConByName(java.lang.String name, int solNr)
          Enables the direct access to a single constraint or constraint array of the solution with solNr
 java.lang.Object getVarByName(java.lang.String name)
          Enables the direct access to a single variable or variable array of the optimal solution
 java.lang.Object getVarByName(java.lang.String name, int solNr)
          Enables the direct access to a single variable or variable array of solution with solNr
 void interrupt()
          Used for stopping a Cmpl thread
 java.lang.String jobId()
          Returns the jobId of the Cmpl problem at the connected CMPLServer
 void knock()
          Knocks on the door of the connected CMPLServer and asks whether the model is finished - second step of solving a model on a CMPLServer asynchronously The status of the model can be obtained by the methods cmplStatus and cmplStatusText
 java.lang.String model()
          Returns the name of the model
 long nrOfConstraints()
          Returns the number of constraints of the generated and solved CMPL model
 long nrOfSolutions()
          Returns the number of solutions of the generated and solved CMPL model
 long nrOfVariables()
          Returns the number of variables of the generated and solved CMPL model
 java.lang.String objectiveName()
          Returns the name of the objective function of the generated and solved CMPL model
 java.lang.String objectiveSense()
          Returns the objective sense of the generated and solved CMPL model
 java.lang.String output()
          Returns the stdOut and stdErr of Cmpl and the invoked solver
 long refreshTime()
          Returns the refreshtime of the model
 void retrieve()
          Retrieves the Cmpl solution(s) if possible from the connected CMPLServer last step of solving a model on a CMPLServer asynchronously
 void run()
          Used for model.start() if the model is executed in parallel
 void saveSolution()
          Saves the solution(s) as CmplSolutions file with filename modelname.csol
 void saveSolution(java.lang.String solFileName)
          Saves the solution(s) as CmplSolutions file given filename
 void saveSolutionAscii()
          Saves the solution(s) as ASCII file with filename modelname.csol
 void saveSolutionAscii(java.lang.String solFileName)
          Saves the solution(s) as ASCII file with given file name
 void saveSolutionCsv()
          Saves the solution(s) as CSV file with file name modelname.csv
 void saveSolutionCsv(java.lang.String solFileName)
          Saves the solution(s) as CSV file with given file name
 java.lang.String send()
          Sends the Cmpl model instance to the connected CMPLServer first step of solving a model on a CMPLServer asynchronously (after connect()) The status of the model can be obtained by the methods cmplStatus and cmplStatusText
 java.lang.Integer setOption(java.lang.String option)
          Sets a CMPL, display or solver option
 void setOutput(java.lang.Boolean ok)
          Turns the output of CMPL and the invoked solver on or off
 void setOutput(java.lang.Boolean ok, java.lang.String lStr)
          Turns the output of CMPL and the invoked solver on or off
 void setParameters(CmplParameter... params)
          Committing CmplParameter objects to the Cmpl model
 void setRefreshTime(long rTime)
          Refresh time for getting the output of CMPL and the invoked solver from a CMPLServer if the model is solved synchronously.
 void setSets(CmplSet... sets)
          Committing CmplSet objects to the Cmpl model
 CmplSolution solution()
          Returns the first (optimal) CmplSolutions object
 java.util.ArrayList<CmplSolution> solutionPool()
          Returns a list of CmplSolutions objects
 void solutionReport()
          Writes a standard solution report to stdOut
 void solutionReport(java.lang.String fileName)
          Writes a standard solution report to a file Used by saveSolutionAscii
 void solve()
          Solves a Cmpl model either with a local installed CMPL or if the model is connected with a CMPLServer remotely.
 java.lang.String solver()
          Returns the name of the invoked solver of the generated and solved CMPL model
 java.lang.String solverMessage()
          Returns the message of the invoked solver of the generated and solved CMPL model
 int solverStatus()
          Returns the solver related status of the Cmpl object SOLVER_OK = 4 SOLVER_FAILED = 5
 java.lang.String solverStatusText()
          Returns the solver related status text of the Cmpl object SOLVER_OK SOLVER_FAILED
 java.lang.String varDisplayOptions()
          Returns the a string with the display options for the variables of the generated and solved CMPL model
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CMPL_UNKNOWN

public static final int CMPL_UNKNOWN
See Also:
Constant Field Values

CMPL_OK

public static final int CMPL_OK
See Also:
Constant Field Values

CMPL_WARNINGS

public static final int CMPL_WARNINGS
See Also:
Constant Field Values

CMPL_FAILED

public static final int CMPL_FAILED
See Also:
Constant Field Values

SOLVER_OK

public static final int SOLVER_OK
See Also:
Constant Field Values

SOLVER_FAILED

public static final int SOLVER_FAILED
See Also:
Constant Field Values

CMPLSERVER_OK

public static final int CMPLSERVER_OK
See Also:
Constant Field Values

CMPLSERVER_ERROR

public static final int CMPLSERVER_ERROR
See Also:
Constant Field Values

CMPLSERVER_CLEANED

public static final int CMPLSERVER_CLEANED
See Also:
Constant Field Values

PROBLEM_RUNNING

public static final int PROBLEM_RUNNING
See Also:
Constant Field Values

PROBLEM_FINISHED

public static final int PROBLEM_FINISHED
See Also:
Constant Field Values

PROBLEM_CANCELED

public static final int PROBLEM_CANCELED
See Also:
Constant Field Values

PROBLEM_NOTRUNNING

public static final int PROBLEM_NOTRUNNING
See Also:
Constant Field Values

SYNCHRONOUSLY

public static final int SYNCHRONOUSLY
See Also:
Constant Field Values

ASYNCHRONOUSLY

public static final int ASYNCHRONOUSLY
See Also:
Constant Field Values
Constructor Detail

Cmpl

public Cmpl(java.lang.String model)
     throws CmplException
constructor

Throws:
CmplException
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
destructor

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

model

public java.lang.String model()
Returns the name of the model

Returns:
The name of the mode

refreshTime

public long refreshTime()
Returns the refreshtime of the model

Returns:
Refreshtime of the model

output

public java.lang.String output()
Returns the stdOut and stdErr of Cmpl and the invoked solver

Returns:
The stdOut and stdErr of Cmpl and the invoked solver

cmplMessages

public java.util.ArrayList<CmplMsg> cmplMessages()
Returns the CmplMessages

Returns:
ArrayList of the CmplMessages

solutionPool

public java.util.ArrayList<CmplSolution> solutionPool()
                                               throws CmplException
Returns a list of CmplSolutions objects

Returns:
ArrayList of CmplSolutions objects
Throws:
CmplException

solution

public CmplSolution solution()
                      throws CmplException
Returns the first (optimal) CmplSolutions object

Returns:
first (optimal) solution
Throws:
CmplException

nrOfVariables

public long nrOfVariables()
                   throws CmplException
Returns the number of variables of the generated and solved CMPL model

Returns:
Number of variables
Throws:
CmplException

nrOfConstraints

public long nrOfConstraints()
                     throws CmplException
Returns the number of constraints of the generated and solved CMPL model

Returns:
Number of constraints
Throws:
CmplException

objectiveName

public java.lang.String objectiveName()
                               throws CmplException
Returns the name of the objective function of the generated and solved CMPL model

Returns:
objective name
Throws:
CmplException

objectiveSense

public java.lang.String objectiveSense()
                                throws CmplException
Returns the objective sense of the generated and solved CMPL model

Returns:
objective sense
Throws:
CmplException

nrOfSolutions

public long nrOfSolutions()
                   throws CmplException
Returns the number of solutions of the generated and solved CMPL model

Returns:
Number of solutions
Throws:
CmplException

solver

public java.lang.String solver()
                        throws CmplException
Returns the name of the invoked solver of the generated and solved CMPL model

Returns:
Invoked solver
Throws:
CmplException

solverMessage

public java.lang.String solverMessage()
                               throws CmplException
Returns the message of the invoked solver of the generated and solved CMPL model

Returns:
Message of the invoked solver
Throws:
CmplException

varDisplayOptions

public java.lang.String varDisplayOptions()
                                   throws CmplException
Returns the a string with the display options for the variables of the generated and solved CMPL model

Returns:
Display options for the variables
Throws:
CmplException

conDisplayOptions

public java.lang.String conDisplayOptions()
                                   throws CmplException
Returns the a string with the display options for the constraints of the generated and solved CMPL model

Returns:
Display options for the constraints
Throws:
CmplException

cmplStatus

public int cmplStatus()
Returns the CMPL related status of the Cmpl object CMPL_UNKNOWN = 0 CMPL_OK = 1 CMPL_WARNINGS = 2 CMPL_FAILED = 3 CMPLSERVER_OK = 6 CMPLSERVER_ERROR = 7 CMPLSERVER_CLEANED = 8 PROBLEM_RUNNING = 9 PROBLEM_FINISHED = 10 PROBLEM_CANCELED = 11 PROBLEM_NOTRUNNING = 12

Returns:
Status of the Cmpl object

cmplStatusText

public java.lang.String cmplStatusText()
Returns the CMPL related status text of the Cmpl object CMPL_UNKNOWN CMPL_OK CMPL_WARNINGS CMPL_FAILED SOLVER_OK SOLVER_FAILED CMPLSERVER_OK CMPLSERVER_ERROR CMPLSERVER_CLEANED PROBLEM_RUNNING PROBLEM_FINISHED PROBLEM_CANCELED PROBLEM_NOTRUNNING

Returns:
Cmpl status text

solverStatus

public int solverStatus()
Returns the solver related status of the Cmpl object SOLVER_OK = 4 SOLVER_FAILED = 5

Returns:
solver status

solverStatusText

public java.lang.String solverStatusText()
Returns the solver related status text of the Cmpl object SOLVER_OK SOLVER_FAILED

Returns:
solver status text

cmplSolFile

public java.lang.String cmplSolFile()
Returns the name of the CmplSolution file - controlled by the command line arg -solution

Returns:
name of the CmplSolution file

csvSolFile

public java.lang.String csvSolFile()
Returns the name of the Csv solution file - controlled by the command line arg -solutionCsv

Returns:
name of the Csv solution file

asciiSolFile

public java.lang.String asciiSolFile()
Returns the name of the Ascii solution file - controlled by the command line arg -solutionAscii

Returns:
name of the Ascii solution file

jobId

public java.lang.String jobId()
Returns the jobId of the Cmpl problem at the connected CMPLServer

Returns:
String of the jobId

setOutput

public void setOutput(java.lang.Boolean ok,
                      java.lang.String lStr)
Turns the output of CMPL and the invoked solver on or off

Parameters:
ok - Switch for on or off
lStr - Leading string for the output (default - model name)

setOutput

public void setOutput(java.lang.Boolean ok)
Turns the output of CMPL and the invoked solver on or off

Parameters:
ok - Switch for on or off

setRefreshTime

public void setRefreshTime(long rTime)
Refresh time for getting the output of CMPL and the invoked solver from a CMPLServer if the model is solved synchronously.

Parameters:
rTime - refresh time in milliseconds (default 400)

setSets

public void setSets(CmplSet... sets)
             throws CmplException
Committing CmplSet objects to the Cmpl model

Parameters:
sets - CmplSet object(s)
Throws:
CmplException

setParameters

public void setParameters(CmplParameter... params)
                   throws CmplException
Committing CmplParameter objects to the Cmpl model

Parameters:
params - CmplParameter object(s)
Throws:
CmplException

setOption

public java.lang.Integer setOption(java.lang.String option)
Sets a CMPL, display or solver option

Parameters:
option - option in CmplHeader syntax
Returns:
option id

delOption

public void delOption(java.lang.Integer pos)
               throws CmplException
Deletes an option

Parameters:
pos - option id
Throws:
CmplException

delOptions

public void delOptions()
Deletes all options


debug

public void debug(boolean x)
Very simple debug mode

Parameters:
x - switchfor on or off

getVarByName

public java.lang.Object getVarByName(java.lang.String name)
                              throws CmplException
Enables the direct access to a single variable or variable array of the optimal solution

Parameters:
name - Name of the variable (w/o index)
Returns:
either a CmplSolElement or CmplSolArray
Throws:
CmplException

getVarByName

public java.lang.Object getVarByName(java.lang.String name,
                                     int solNr)
                              throws CmplException
Enables the direct access to a single variable or variable array of solution with solNr

Parameters:
name - Name of the variable (w/o index)
solNr - Index of the solution
Returns:
either a CmplSolElement or CmplSolArray
Throws:
CmplException

getConByName

public java.lang.Object getConByName(java.lang.String name)
                              throws CmplException
Enables the direct access to a single constraint or constraint array of the optimal solution

Parameters:
name - Name of the constraint (w/o index)
Returns:
either a CmplSolElement or CmplSolArray
Throws:
CmplException

getConByName

public java.lang.Object getConByName(java.lang.String name,
                                     int solNr)
                              throws CmplException
Enables the direct access to a single constraint or constraint array of the solution with solNr

Parameters:
name - Name of the constraint (w/o index)
solNr - Index of the solution
Returns:
either a CmplSolElement or CmplSolArray
Throws:
CmplException

solve

public void solve()
           throws CmplException
Solves a Cmpl model either with a local installed CMPL or if the model is connected with a CMPLServer remotely. The status of the model and the solver can be obtained by the methods cmplStatus, cmplStatusText,solverStatus and solverStatusText

Throws:
CmplException

connect

public void connect(java.lang.String cmplUrl)
             throws CmplException
Connects a CMPLServer under cmplUrl - first step of solving a model on a CMPLServer remotely

Parameters:
cmplUrl - URL of the CMPLServer
Throws:
CmplException

disconnect

public void disconnect()
                throws CmplException
Disconnects the connected CMPLServer

Throws:
CmplException

send

public java.lang.String send()
                      throws CmplException
Sends the Cmpl model instance to the connected CMPLServer first step of solving a model on a CMPLServer asynchronously (after connect()) The status of the model can be obtained by the methods cmplStatus and cmplStatusText

Throws:
CmplException

knock

public void knock()
           throws CmplException
Knocks on the door of the connected CMPLServer and asks whether the model is finished - second step of solving a model on a CMPLServer asynchronously The status of the model can be obtained by the methods cmplStatus and cmplStatusText

Throws:
CmplException

cancel

public void cancel()
            throws CmplException
Cancels the Cmpl solving process on the connected CMPLServer The status of the model can be obtained by the methods cmplStatus and cmplStatusText

Throws:
CmplException

retrieve

public void retrieve()
              throws CmplException
Retrieves the Cmpl solution(s) if possible from the connected CMPLServer last step of solving a model on a CMPLServer asynchronously

Throws:
CmplException - The status of the model and the solver can be obtained by the methods cmplStatus, cmplStatusText,solverStatus and solverStatusText
CmplException

saveSolution

public void saveSolution()
                  throws CmplException
Saves the solution(s) as CmplSolutions file with filename modelname.csol

Throws:
CmplException

saveSolution

public void saveSolution(java.lang.String solFileName)
                  throws CmplException
Saves the solution(s) as CmplSolutions file given filename

Parameters:
solFileName - File name
Throws:
CmplException

saveSolutionAscii

public void saveSolutionAscii()
                       throws CmplException
Saves the solution(s) as ASCII file with filename modelname.csol

Throws:
CmplException

saveSolutionAscii

public void saveSolutionAscii(java.lang.String solFileName)
                       throws CmplException
Saves the solution(s) as ASCII file with given file name

Parameters:
solFileName - File name
Throws:
CmplException

solutionReport

public void solutionReport()
                    throws CmplException
Writes a standard solution report to stdOut

Throws:
CmplException

solutionReport

public void solutionReport(java.lang.String fileName)
                    throws CmplException
Writes a standard solution report to a file Used by saveSolutionAscii

Parameters:
fileName - File name
Throws:
CmplException

saveSolutionCsv

public void saveSolutionCsv()
                     throws CmplException
Saves the solution(s) as CSV file with file name modelname.csv

Throws:
CmplException

saveSolutionCsv

public void saveSolutionCsv(java.lang.String solFileName)
                     throws CmplException
Saves the solution(s) as CSV file with given file name

Parameters:
solFileName - File name
Throws:
CmplException

run

public void run()
Used for model.start() if the model is executed in parallel

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

interrupt

public void interrupt()
Used for stopping a Cmpl thread

Overrides:
interrupt in class java.lang.Thread