gurobi
Class GRBEnv

java.lang.Object
  extended by gurobi.GRBEnv

public class GRBEnv
extends java.lang.Object

Gurobi environment object. Gurobi models are always associated with an environment. You must create an environment before can you create and populate a model. You will generally only need a single environment object in your program.

The methods on environment objects are mainly used to manage Gurobi parameters (e.g., get, getParamInfo, set).

While the Java garbage collector will eventually collect an unused GRBEnv object, an environment will hold onto resources (Gurobi licenses, file descriptors, etc.) until that collection occurs. If your program creates multiple GRBEnv objects, we recommend that you call GRBEnv.dispose when you are done using one.


Constructor Summary
GRBEnv()
          Create a Gurobi environment (with logging disabled).
GRBEnv(boolean empty)
           
GRBEnv(java.lang.String logFileName)
          Create a Gurobi environment (with logging enabled).
GRBEnv(java.lang.String s0, java.lang.String s1, java.lang.String s2, int i1, java.lang.String s3)
           
GRBEnv(java.lang.String logfilename, java.lang.String accessID, java.lang.String secretKey, java.lang.String pool, int priority)
          Create a Gurobi environment on Gurobi Instant Cloud.
GRBEnv(java.lang.String logFileName, java.lang.String computeServer, java.lang.String router, java.lang.String password, java.lang.String group, int tlsInsecure, int priority, double timeout)
          Create a client Gurobi environment on a compute server.
 
Method Summary
 void dispose()
          Release the resources associated with a GRBEnv object.
protected  void finalize()
           
 double get(GRB.DoubleParam param)
          Query the value of a double-valued parameter.
 int get(GRB.IntParam param)
          Query the value of an int-valued parameter.
 java.lang.String get(GRB.StringParam param)
          Query the value of a string-valued parameter.
 java.lang.String getErrorMsg()
          Query the error message for the most recent exception associated with this environment.
 void getParamInfo(GRB.DoubleParam param, double[] info)
          Obtain detailed information about a double parameter.
 void getParamInfo(GRB.IntParam param, int[] info)
          Obtain detailed information about an integer parameter.
 void getParamInfo(GRB.StringParam param, java.lang.String[] info)
          Obtain detailed information about a string parameter.
 void message(java.lang.String message)
          Write a message to the console and the log file.
protected  void modelCntDecrease()
           
protected  void modelCntIncrease()
           
protected  boolean modelCntZero()
           
 void readParams(java.lang.String paramFile)
          Read new parameter settings from a file.
 void release()
          Release the license associated with this environment.
 void resetParams()
          Reset all parameters to their default values.
 void set(GRB.DoubleParam param, double newval)
          Set the value of a double-valued parameter.
 void set(GRB.IntParam param, int newval)
          Set the value of an int-valued parameter.
 void set(GRB.StringParam param, java.lang.String newval)
          Set the value of a string-valued parameter.
 void set(java.lang.String param, java.lang.String newval)
          Set the value of any parameter using strings alone.
 void start()
          Start an empty environment.
 void writeParams(java.lang.String paramFile)
          Write all non-default parameter settings to a file.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GRBEnv

public GRBEnv()
       throws GRBException
Create a Gurobi environment (with logging disabled). \EnvCreationDesc{method}

Throws:
GRBException

GRBEnv

public GRBEnv(java.lang.String logFileName)
       throws GRBException
Create a Gurobi environment (with logging enabled). \EnvCreationDesc{method}

Parameters:
logFileName - The desired log file name.
Throws:
GRBException

GRBEnv

public GRBEnv(boolean empty)
       throws GRBException
Throws:
GRBException

GRBEnv

public GRBEnv(java.lang.String logFileName,
              java.lang.String computeServer,
              java.lang.String router,
              java.lang.String password,
              java.lang.String group,
              int tlsInsecure,
              int priority,
              double timeout)
       throws GRBException
Create a client Gurobi environment on a compute server. \EnvCreationDescNolic{method}

Parameters:
logFileName - The name of the log file for this environment. Pass an empty string for no log file.
computeServer - \EnvargComputeServer
router - \EnvargRouter
password - \EnvargPassword
group - \EnvargGroup
tlsInsecure - \EnvargTlsInsecure
priority - \EnvargPriorityCS
timeout - \EnvargTimeout
Throws:
GRBException

GRBEnv

public GRBEnv(java.lang.String logfilename,
              java.lang.String accessID,
              java.lang.String secretKey,
              java.lang.String pool,
              int priority)
       throws GRBException
Create a Gurobi environment on Gurobi Instant Cloud. \EnvCreationDescNolic{method}

Parameters:
logfilename - The name of the log file for this environment. May be NULL (or an empty string), in which case no log file is created.
accessID - \EnvargAccessID
secretKey - \EnvargSecretKey
pool - \EnvargPool
priority - \EnvargPriorityCloud
Throws:
GRBException

GRBEnv

public GRBEnv(java.lang.String s0,
              java.lang.String s1,
              java.lang.String s2,
              int i1,
              java.lang.String s3)
       throws GRBException
Throws:
GRBException
Method Detail

start

public void start()
           throws GRBException
Start an empty environment.

Throws:
GRBException

release

public void release()
Release the license associated with this environment. You will no longer be able to call optimize on models created with this environment after the license has been released.


dispose

public void dispose()
             throws GRBException
Release the resources associated with a GRBEnv object. While the Java garbage collector will eventually reclaim these resources, we recommend that you call the dispose method when you are done using an environment if your program creates more than one.

The dispose method on a GRBEnv should be called only after you have called dispose on all of the models that were created within that environment. You should not attempt to use a GRBEnv object after calling dispose.

Throws:
GRBException

finalize

protected void finalize()
                 throws GRBException
Overrides:
finalize in class java.lang.Object
Throws:
GRBException

message

public void message(java.lang.String message)
             throws GRBException
Write a message to the console and the log file.

Parameters:
message - Print a message to the console and to the log file. Note that this call has no effect unless the OutputFlag parameter is set.
Throws:
GRBException

get

public int get(GRB.IntParam param)
        throws GRBException
Query the value of an int-valued parameter.

Parameters:
param - The parameter being queried.
Returns:
The current value of the requested parameter.
Throws:
GRBException

get

public double get(GRB.DoubleParam param)
           throws GRBException
Query the value of a double-valued parameter.

Parameters:
param - The parameter being queried.
Returns:
The current value of the requested parameter.
Throws:
GRBException

get

public java.lang.String get(GRB.StringParam param)
                     throws GRBException
Query the value of a string-valued parameter.

Parameters:
param - The parameter being queried.
Returns:
The current value of the requested parameter.
Throws:
GRBException

set

public void set(GRB.IntParam param,
                int newval)
         throws GRBException
Set the value of an int-valued parameter.

Parameters:
param - The parameter being modified.
newval - The desired new value of the parameter.
Throws:
GRBException

set

public void set(GRB.DoubleParam param,
                double newval)
         throws GRBException
Set the value of a double-valued parameter.

Parameters:
param - The parameter being modified.
newval - The desired new value of the parameter.
Throws:
GRBException

set

public void set(GRB.StringParam param,
                java.lang.String newval)
         throws GRBException
Set the value of a string-valued parameter.

Parameters:
param - The parameter being modified.
newval - The desired new value of the parameter.
Throws:
GRBException

set

public void set(java.lang.String param,
                java.lang.String newval)
         throws GRBException
Set the value of any parameter using strings alone.

Parameters:
param - The name of the parameter being modified.
newval - The desired new value of the parameter.
Throws:
GRBException

getParamInfo

public void getParamInfo(GRB.IntParam param,
                         int[] info)
                  throws GRBException
Obtain detailed information about an integer parameter.

Parameters:
param - The parameter of interest.
info - The returned information. The result will contain four entries: the current value of the parameter, the minimum allowed value, the maximum allowed value, and the default value.
Throws:
GRBException

getParamInfo

public void getParamInfo(GRB.DoubleParam param,
                         double[] info)
                  throws GRBException
Obtain detailed information about a double parameter.

Parameters:
param - The parameter of interest.
info - The returned information. The result will contain four entries: the current value of the parameter, the minimum allowed value, the maximum allowed value, and the default value.
Throws:
GRBException

getParamInfo

public void getParamInfo(GRB.StringParam param,
                         java.lang.String[] info)
                  throws GRBException
Obtain detailed information about a string parameter.

Parameters:
param - The parameter of interest.
info - The returned information. The result will contain two entries: the current value of the parameter and the default value.
Throws:
GRBException

resetParams

public void resetParams()
                 throws GRBException
Reset all parameters to their default values.

Throws:
GRBException

writeParams

public void writeParams(java.lang.String paramFile)
                 throws GRBException
Write all non-default parameter settings to a file.

Parameters:
paramFile - Name of the file to which non-default parameter settings should be written. The previous contents are overwritten.
Throws:
GRBException

readParams

public void readParams(java.lang.String paramFile)
                throws GRBException
Read new parameter settings from a file.

Parameters:
paramFile - Name of the file containing parameter settings. Parameters should be listed one per line, with the parameter name first and the desired value second. For example:

Blank lines and lines that begin with the hash symbol are ignored.

Throws:
GRBException

getErrorMsg

public java.lang.String getErrorMsg()
Query the error message for the most recent exception associated with this environment.

Returns:
The error string.

modelCntIncrease

protected void modelCntIncrease()

modelCntDecrease

protected void modelCntDecrease()

modelCntZero

protected boolean modelCntZero()