4.1. Commandline interface¶
This topic describes how to call the CLI of MindOpt to solve optimization problems. Before using the CLI, you need to set environment variables. For more information, see Installation instructions.
4.1.1. Brief description¶
Use the following statement to call the CLI of MindOpt:
mindopt <filename> [options]
<filename>
: an optimization problem file in the MPS/LP or .dat-s format.options
: parameter settings. For more information about the parameters, see Optional input parameters.
Other CLI options:
MindOpt [options] |
Description |
---|---|
-h (or - -help) |
list options |
-v (or - -version) |
print release version |
-d (or - -disable_file_output) |
disable solution (.bas and .sol files) output |
-r (or - -relax) |
relax all integrality requirements |
-c (or - -check_license) |
run license diagnostic tool |
- -desensitize |
desensitize the optimization model files |
- -sensitize |
recover the model which has been desensitized |
4.1.2. Example¶
The following part is an example of solving a linear programming problem:
cd <MDOHOME>/examples/data
mindopt afiro.mps
Output:
MindOpt Version 0.19.0 (Built: 20220410)
Copyright (c) 2020-2021 Alibaba Cloud.
Reader started. File : ../data/afiro.mps
Reader terminated. Time : 0.001s
Checking license : /home/mindopt/mindopt/mindopt.lic
Your license will expire in 51 days.
Concurrent optimization started.
- Num. threads : 12
- Num. optimizers : 2
- Registered optimizers.
+ : Simplex method (1 thread, enabled output)
+ : Interior point method (11 threads, disabled output)
Model summary.
- Num. variables : 32
- Num. constraints : 27
- Num. nonzeros : 83
- Bound range : [4.4e+01,5.0e+02]
- Objective range : [3.2e-01,1.0e+01]
- Matrix range : [1.1e-01,2.4e+00]
Presolver started.
Presolver terminated. Time : 0.000s
Simplex method started.
Iteration Objective Dual Inf. Primal Inf. Time
0 -5.21810e+02 0.0000e+00 4.1717e+02 0.00s
4 -4.64753e+02 0.0000e+00 0.0000e+00 0.00s
Postsolver started.
Simplex method terminated. Time : 0.002s
Concurrent optimization terminated.
Optimizer summary.
- Optimizer used : Simplex method
- Optimizer status : OPTIMAL
- Total time : 0.006s
Solution summary. Primal solution Dual solution
- Objective : -4.6475314286e+02 -4.6475314286e+02
- Norm : 5.00e+02 2.29e+00
- Var. viol. : 1.42e-14 0.00e+00
- Cons. viol. : 0.00e+00 5.55e-17
4.1.3. Input file format: mps/lp/dat-s¶
MindOpt supports the following storage formats for optimization models:
.dat-s
file, used in SDP..nl
file. You can usemindoptampl filename.nl
to solve it, more details Verify mindoptampl.
These formats were originally designed for (mixed-integer) linear programming problems and are now applicable to second-order cone programming. Before using these formats, read the specifications of MPS format and LP format.
Warning
- Strict naming specifications must be followed when you use the
LP
andMPS
formats. Otherwise, errors occur easily and are not easy to identify. Naming specifications of the LP format . For example, a name must not begin with a number, period (.), or letter
e
orE
. Pay attention to the specifications when you call an API (see API Reference) to input variable names or constraint names.When you use the modeling feature of MindOpt to generate an
MPS
orLP
file, if the name does not follow the naming specifications, MindOpt will output the file with the default name.A variable or constraint name cannot exceed 160
characters
.A variable or constraint name cannot contain operators such as
+
and-
. Otherwise, the solver may consider these symbols as operators rather than variable names, thereby causing parsing errors.A variable or constraint name can contain Chinese characters. However, we recommend that you do not use Chinese characters to ensure stability.
4.1.4. Input parameters¶
You can execute the following command to modify parameter values:
<param>=<value>
: modifies the value of<param>
to<value>
.
For example, the following command enables MindOpt to solve afiro.mps
, changes the optimization method (see “Method”) to primal simplex method, and limits the number of iterations (see “SPX/MaxIterations”) to 10000.
mindopt afiro.mps Method=0 SPX/MaxIterations=10000
For more information about the parameters, see Optional input parameters.
4.1.5. Sanitize Model Files¶
--sanitize
and --undo_sanitize
interfaces are used to sanitize and restore data. You can refer to article for how it works.
Supported model files are
MPS: File extension name must be
.mps
,.mps.gz
, or.mps.bz2
.LP: File extension name must be
.lp
,.lp.gz
, orlp.bz2
.
Let’s take 80bau3b.mps
in the examples/data
folder of the installation directory as an example.
Run the following command line to do data sanitization:
mindopt ./data/80bau3b.mps --sanitize
After data sanitization, two files are generated:
–
80bau3b_sanitized.mps
, the desensitized files. Names of variables and constraints are converted into Rxx and Cxx sequential encoding forms, to clear business-related information and retain only numerical data. –80bau3b_mapping.json
file saves the correspondence between the names in the sanitized file and the origin file.
After data sanitization, the original file can be restored through the 80bau3b_mapping.json
file. Placing the two files in the same directory, and then run the command line instruction as follows:
mindopt ./data/80bau3b_mapping.json --undo_sanitize
Then, the file 80bau3b_sanitized_undo_sanitized.mps
will be generated. Compared with the original file 80bau3b.mps
, you can see that it has been restored.