Gurobi——GRBEnv

Article directory

GRBEnv

  Gurobi environment object. Gurobi models are always related to the environment. You must create an environment before you can create and populate a model. You usually only need one environment object in your program.

  The methods on the environment object are mainly used to manage Gurobi parameters (for example, get, getParamInfo, set).

GRBEnv()

  Constructor for GRBEnv objects. You can choose to build a local environment, which will solve the Gurobi model on the local machine, a client environment of the Gurobi Compute Server, which will solve the Gurobi model on the server machine, or an instant cloud environment, which will launch a Gurobi cloud server and Solve the model on this server. Choose the appropriate signature for the type of environment you want to launch.

GRBEnv GRBEnv()

  Create a Gurobi environment (disable logging). This method will also populate any parameters specified in the gurobi.lic file (ComputeServer, TokenServer, ServerPassword, etc.). This method will also check if a file named gurobi.env exists in the current working directory, and if the file exists, it will try to read the parameter settings from the file. The file should be in PRM format (in short, each line should contain a parameter name followed by the desired value for that parameter).

  In general, you should aim to create a single Gurobi environment in your program, even if you plan to use multiple models. Reusing one environment is much more efficient than creating and destroying multiple environments. An exception is if you are writing a multi-threaded program, as the environment is not thread-safe. In this case, each thread requires a separate environment.

Return value: An environment object (no associated log file).

GRBEnv GRBEnv(bool empty)

  Create an empty Gurobi environment. Use GRBEnv::start to start the environment.

  If the environment is not empty, this method will also populate any parameters specified in the gurobi.lic file (ComputeServer, TokenServer, ServerPassword, etc.). This method will also check if a file named gurobi.env exists in the current working directory, and if the file exists, it will try to read the parameter settings from the file. The file should be in PRM format (in short, each line should contain a parameter name followed by the desired value for that parameter).

  In general, you should aim to create a single Gurobi environment in your program, even if you plan to use multiple models. Reusing one environment is much more efficient than creating and destroying multiple environments. An exception is if you are writing a multi-threaded program, as the environment is not thread-safe. In this case, each thread requires a separate environment.

parameter Detailed explanation
empty Indicates whether the environment should be empty. If you want to set parameters before actually starting the environment, you should use empty=true. This is useful if you want to connect to a compute server, token server, Gurobi Instant Cloud, or cluster manager. See the Environment section for details.
return value An environment object.
GRBEnv GRBEnv(const string& logFileName)

  Create a Gurobi environment (enable logging). This method will also populate any parameters specified in the gurobi.lic file (ComputeServer, TokenServer, ServerPassword, etc.). This method will also check if a file named gurobi.env exists in the current working directory, and if the file exists, it will try to read the parameter settings from the file. The file should be in PRM format (in short, each line should contain a parameter name followed by the desired value for that parameter).

  In general, you should aim to create a single Gurobi environment in your program, even if you plan to use multiple models. Reusing one environment is much more efficient than creating and destroying multiple environments. An exception is if you are writing a multi-threaded program, as the environment is not thread-safe. In this case, each thread requires a separate environment.

parameter Detailed explanation
logFileName The desired log file name.
return value An environment object.
GRBEnv GRBEnv(const string& 	logFileName,
	  	  	  const string& 	computeServer,
	  	  	  const string& 	router,
	  	  	  const string& 	password,
	  	  	  const string& 	group,
	  	  	  int 	CStlsInsecure,
	  	  	  int 	priority,
	  	  	  double 	timeout )

  Create a client Gurobi environment on the compute server. This method will also check if a file named gurobi.env exists in the current working directory, and if the file exists, it will try to read the parameter settings from the file. The file should be in PRM format (in short, each line should contain a parameter name followed by the desired value for that parameter).

  In general, you should aim to create a single Gurobi environment in your program, even if you plan to use multiple models. Reusing one environment is much more efficient than creating and destroying multiple environments. An exception is if you are writing a multi-threaded program, as the environment is not thread-safe. In this case, each thread requires a separate environment.

parameter Detailed explanation
logFileName The name of the log file for this environment. Pass an empty string for no log file.
computeServer Compute server. You can refer to a server by its name or IP address. If you are using a non-default port, the server name should be followed by the port number (e.g. server1:61000)
router Routers for compute server clusters. Routers can be used to increase the robustness of compute server deployments. You should refer to the router by its name or IP address. If no router is used (which is the typical case), pass an empty string.
password Obtain the password for access to the specified Compute Server cluster. If no password is required, pass an empty string.
group Compute the name of the server group.
CStlsInsecure Indicates whether to use unsafe mode in TLS (Transport Layer Security). Set this to 0 unless your server administrator tells you otherwise.
priority The priority of the job. The priority must be between -100 and 100, and the default value is 0 (by convention). Select higher priority jobs from the server job queue before lower priority jobs. Depending on the server's configuration, jobs with priority 100 run immediately, bypassing the job queue and ignoring job limits on the server. You should be careful with priority 100 jobs as they can severely overload the server, causing the job to fail and, in extreme cases, cause the server to crash. This behavior is managed by HARDJOBLIMIT and is disabled by default. For more information on options for starting a compute server, see the Gurobi Remote Services Reference Manual.
timeout Queue timeout in seconds. If the job does not reach the front of the queue before the specified timeout, the call will exit with a JOB_REJECTED error. Use -1 to indicate that the call should not timeout.
return value An environment object.
GRBEnv 	GRBEnv(const string& 	logFileName,
	  	  	const string& 	accessID,
	  	  	const string& 	secretKey,
	  	  	const string& 	pool,
	  	  	int 	priority )

  Create a Gurobi Instant Cloud environment. This method will also check if a file named gurobi.env exists in the current working directory, and if the file exists, it will try to read the parameter settings from the file. The file should be in PRM format (in short, each line should contain a parameter name followed by the desired value for that parameter).

  In general, you should aim to create a single Gurobi environment in your program, even if you plan to use multiple models. Reusing one environment is much more efficient than creating and destroying multiple environments. An exception is if you are writing a multi-threaded program, as the environment is not thread-safe. In this case, each thread requires a separate environment.

parameter Detailed explanation
logfilename The name of the log file for this environment. May be NULL (or empty string), in which case no log file will be created.
accessID The access ID for your Gurobi Instant Cloud license. This can be retrieved from the Gurobi Instant Cloud website. When combined with your secretKey, this allows you to launch Instant Cloud instances and submit jobs to them.
secretKey The key to your Gurobi Instant Cloud license. This can be retrieved from the Gurobi Instant Cloud website. When combined with your accessID, this allows you to launch Instant Cloud instances and submit jobs to them. Please note that you should keep your key secret.
pool Machine pool. Machine pools allow you to create fixed configurations on your Instant Cloud website (capturing machine types, geographic regions, etc.) and then launch and share machines from client programs without restarting the configuration information each time the machine is started. May be NULL (or empty string), in which case your job will be launched in the default pool associated with your cloud license.
priority The priority of the job. The priority must be between -100 and 100, and the default value is 0 (by convention). Select higher priority jobs from the server job queue before lower priority jobs.
return value An environment object.

Guess you like

Origin blog.csdn.net/qq_16775293/article/details/122714610