This is the accompanying code for the article "A cautionary note on the use of Gurobi for cryptanalysis". It consists of the code of the four examples mentioned in the report.
Gurobi 9.0.2 build v9.0.2rc0 (linux64)
Each example mainly consists of the MILP model in LP format model.lp
and the python script SolveModel.py
to test the model.
To run the test, simply execute the following command:
- For Example I, II, III:
$ gurobi.sh SolveModel.py model.lp
- For Example IV:
$ gurobi.sh SolveModel.py model.lp model_reoredered.lp
It will generate three files:
- Gurobi log file for the n-threads run:
Log*_cores.log
- Gurobi log file for the single-thread run:
Log1_cores.log
- The feasible solution from the single-thread run:
solution_1_cores.sol
And the output will be like:
Test Using 80 threads ...
Using license file /********************/gurobi902/linux64/gurobi.lic
Set parameter TokenServer to value ***************
Read LP format model from file model.lp
Reading time = 0.12 seconds
: 10882 rows, 38880 columns, 175220 nonzeros
the model is infeasible
Test Using 1 threads ...
Read LP format model from file model.lp
Reading time = 0.08 seconds
: 10882 rows, 38880 columns, 175220 nonzeros
Find Solution
Sort the constraints of each then compare digest hash of them.
$ md5sum <<< $(sort model.lp)
808a10ad7023917e2fa461be5c5704ef -
$ md5sum <<< $(sort model_reordered.lp)
808a10ad7023917e2fa461be5c5704ef -
To verify that the solution from the single-thead satisfies all the inequalities in the model:
$ ./testSol_using_model.sh "./Example_I/model.lp" "./Example_I/solution_1_cores.sol"
The output will be:
Does the solution satsify all the constraints? True