|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgurobi.GRBEnv
public class GRBEnv
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., @link GRBEnv#get get, @link GRBEnv#getParamInfo getParamInfo, @link GRBEnv#set set).
While the Java garbage collector will eventually collect an unused
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 CStlsInsecure,
int priority,
double timeout)
Create a client Gurobi environment on a compute server. |
Method Summary | |
---|---|
void |
dispose()
Release the resources associated with a @code 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 |
---|
public GRBEnv() throws GRBException
In general, you should aim to create a single Gurobi environment in your program, even if you plan to work with multiple models. Reusing one environment is much more efficient than creating and destroying multiple environments. The one exception is if you are writing a multi-threaded program, since environments are not thread safe. In this case, you will need a separate environment for each of your threads.
GRBException
public GRBEnv(java.lang.String logFileName) throws GRBException
In general, you should aim to create a single Gurobi environment in your program, even if you plan to work with multiple models. Reusing one environment is much more efficient than creating and destroying multiple environments. The one exception is if you are writing a multi-threaded program, since environments are not thread safe. In this case, you will need a separate environment for each of your threads.
logFileName
- The desired log file name.
GRBException
public GRBEnv(boolean empty) throws GRBException
GRBException
public GRBEnv(java.lang.String logFileName, java.lang.String computeServer, java.lang.String router, java.lang.String password, java.lang.String group, int CStlsInsecure, int priority, double timeout) throws GRBException
In general, you should aim to create a single Gurobi environment in your program, even if you plan to work with multiple models. Reusing one environment is much more efficient than creating and destroying multiple environments. The one exception is if you are writing a multi-threaded program, since environments are not thread safe. In this case, you will need a separate environment for each of your threads.
logFileName
- The name of the log file for this environment. Pass an empty string
for no log file.computeServer
- A Compute Server. You can refer to the server using its name or its IP
address. If you are using a non-default port, the server name should
be followed by the port number (e.g., @literal server1:61000)router
- The router for a Compute Server cluster. A router can be used to
improve the robustness of a Compute Server deployment. You should
refer to the router using either its name or its IP address. If no
router is used (which is the typical case), pass an empty string.password
- The password for gaining access to the specified Compute Server
cluster. Pass an empty string if no password is required.group
- The name of the Compute Server group.CStlsInsecure
- Indicates whether to use insecure mode in the TLS (Transport Layer
Security). Set this to 0 unless your server administrator tells you
otherwise.priority
- The priority of the job. Priorities must be between -100 and 100, with
a default value of 0 (by convention). Higher priority jobs are chosen
from the server job queue before lower priority jobs. Depending on the
configuration of the server, a job with priority 100 runs immediately,
bypassing the job queue and ignoring the job limit on the server. You
should exercise caution with priority 100 jobs, since they can
severely overload a server, which can cause jobs to fail, and in
extreme cases can cause the server to crash. This behavior is managed
by the HARDJOBLIMIT, and is disabled by default. Refer to the
Gurobi Remote Services
Reference Manual for more information on starting Compute Server
options.timeout
- Queue timeout (in seconds). If the job doesn't reach the front of the
queue before the specified timeout, the call will exit with a @literal
JOB_REJECTED error. Use -1 to indicate that the call should never
timeout.
GRBException
public GRBEnv(java.lang.String logfilename, java.lang.String accessID, java.lang.String secretKey, java.lang.String pool, int priority) throws GRBException
In general, you should aim to create a single Gurobi environment in your program, even if you plan to work with multiple models. Reusing one environment is much more efficient than creating and destroying multiple environments. The one exception is if you are writing a multi-threaded program, since environments are not thread safe. In this case, you will need a separate environment for each of your threads.
logfilename
- The name of the log file for this environment. May be @literal NULL
(or an empty string), in which case no log file is created.accessID
- The access ID for your Gurobi Instant Cloud license. This can be
retrieved from the Gurobi Instant Cloud website. When used in
combination with your @literal secretKey, this allows you to launch
Instant Cloud instances and submit jobs to them.secretKey
- The secret key for your Gurobi Instant Cloud license. This can be
retrieved from the Gurobi Instant Cloud website. When used in
combination with your @literal accessID, this allows you to launch
Instant Cloud instances and submit jobs to them. Note that you should
keep your secret key private.pool
- The machine pool. Machine pools allow you to create fixed
configurations on the Instant Cloud website (capturing things like
type of machine, geographic region, etc.), and then launch and share
machines from client programs without having to restart the
configuration information each time you launch a machine. May bepriority
- The priority of the job. Priorities must be between -100 and 100, with
a default value of 0 (by convention). Higher priority jobs are chosen
from the server job queue before lower priority jobs.
GRBException
public GRBEnv(java.lang.String s0, java.lang.String s1, java.lang.String s2, int i1, java.lang.String s3) throws GRBException
GRBException
Method Detail |
---|
public void start() throws GRBException
This method will also populate any parameter (ComputeServer, TokenServer, ServerPassword, etc.) specified in your gurobi.lic file. This method will also check the current working directory for a file named gurobi.env, and it will attempt to read parameter settings from this file if it exists. The file should be in @literal PRM format (briefly, each line should contain a parameter name, followed by the desired value for that parameter). After that, it will apply all parameter changes specified by the user prior to this call. Note that this might overwrite parameters set in the license file, or in the gurobi.env file, if present.
After all these changes are performed, the code will actually activate the environment, and make it ready to work with models.
In general, you should aim to create a single Gurobi environment in your program, even if you plan to work with multiple models. Reusing one environment is much more efficient than creating and destroying multiple environments. The one exception is if you are writing a multi-threaded program, since environments are not thread safe. In this case, you will need a separate environment for each of your threads.
Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.
GRBException
public void release()
public void dispose() throws GRBException
The @code dispose method on a @code GRBEnv should be called only after you have called @code dispose on all of the models that were created within that environment. You should not attempt to use a @code GRBEnv object after calling @code dispose.
GRBException
protected void finalize() throws GRBException
finalize
in class java.lang.Object
GRBException
public void message(java.lang.String message) throws GRBException
message
- Print a message to the console and to the log file. Note that this
call has no effect unless the @literal OutputFlag parameter is set.
GRBException
public int get(GRB.IntParam param) throws GRBException
param
- The parameter being queried. Please consult the parameter section for
a complete list of Gurobi parameters, including descriptions of their
purposes and their minimum, maximum, and default values.
GRBException
public double get(GRB.DoubleParam param) throws GRBException
param
- The parameter being queried. Please consult the parameter section for
a complete list of Gurobi parameters, including descriptions of their
purposes and their minimum, maximum, and default values.
GRBException
public java.lang.String get(GRB.StringParam param) throws GRBException
param
- The parameter being queried. Please consult the parameter section for
a complete list of Gurobi parameters, including descriptions of their
purposes and their minimum, maximum, and default values.
GRBException
public void set(GRB.IntParam param, int newval) throws GRBException
param
- The parameter being modified. Please consult the parameter section for
a complete list of Gurobi parameters, including descriptions of their
purposes and their minimum, maximum, and default values.newval
- The desired new value of the parameter.
GRBException
public void set(GRB.DoubleParam param, double newval) throws GRBException
param
- The parameter being modified. Please consult the parameter section for
a complete list of Gurobi parameters, including descriptions of their
purposes and their minimum, maximum, and default values.newval
- The desired new value of the parameter.
GRBException
public void set(GRB.StringParam param, java.lang.String newval) throws GRBException
param
- The parameter being modified. Please consult the parameter section for
a complete list of Gurobi parameters, including descriptions of their
purposes and their minimum, maximum, and default values.newval
- The desired new value of the parameter.
GRBException
public void set(java.lang.String param, java.lang.String newval) throws GRBException
param
- The name of the parameter being modified. Please consult the parameter
section for a complete list of Gurobi parameters, including
descriptions of their purposes and their minimum, maximum, and default
values.newval
- The desired new value of the parameter.
GRBException
public void getParamInfo(GRB.IntParam param, int[] info) throws GRBException
param
- The parameter of interest. Please consult the parameter section for a
complete list of Gurobi parameters, including descriptions of their
purposes and their minimum, maximum, and default values.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.
GRBException
public void getParamInfo(GRB.DoubleParam param, double[] info) throws GRBException
param
- The parameter of interest. Please consult the parameter section for a
complete list of Gurobi parameters, including descriptions of their
purposes and their minimum, maximum, and default values.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.
GRBException
public void getParamInfo(GRB.StringParam param, java.lang.String[] info) throws GRBException
param
- The parameter of interest. Please consult the parameter section for a
complete list of Gurobi parameters, including descriptions of their
purposes and their minimum, maximum, and default values.info
- The returned information. The result will contain two entries: the
current value of the parameter and the default value.
GRBException
public void resetParams() throws GRBException
Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.
GRBException
public void writeParams(java.lang.String paramFile) throws GRBException
Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.
paramFile
- Name of the file to which non-default parameter settings should be
written. The previous contents are overwritten.
GRBException
public void readParams(java.lang.String paramFile) throws GRBException
Please consult the parameter section for a complete list of Gurobi parameters, including descriptions of their purposes and their minimum, maximum, and default values.
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.
GRBException
public java.lang.String getErrorMsg()
protected void modelCntIncrease()
protected void modelCntDecrease()
protected boolean modelCntZero()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |