Assigning solver options using Python. #2051
Replies: 2 comments 5 replies
-
You can't set options this way, although there is some argument for You need to make an explicit call to
Call
However the IPM solver is serial
Call
Call
However, if you're wanting to do this so that you can use costs or bounds greater than 1e15, I strongly advise you not to, as you increase the danger of the solver failing. You should rescale your variables and constraints so that the costs and bounds are rather less than 1e15. Remember that HiGHS will be solving your model using primal/dual tolerances of 1e-7 using double precision (16-digit arithmetic) arithmetic, so costs/bounds greater than 1e16*1e-7=1e9 are asking for trouble |
Beta Was this translation helpful? Give feedback.
-
Sure, I can help you with your questions regarding the HIGHS solver and its usage in Python. Let's address each of your questions one by one.
The default method for solving LP problems in HIGHS is the simplex method. If you want to use the interior point method (IPM), you need to set the appropriate parameter. The h.setOption('solver', 'ipm') After setting this option, you can call To set parameters in HIGHS, you can use the h.setOptionValue('parallel', 'on') If you want to check if a particular option is on or off, you can use the print(h.getOptionValue('parallel'))
If you want to disable the crossover, which is used after the IPM to obtain a basic feasible solution, you can set the h.setOptionValue('run_crossover', 'off')
To set the infinite cost and bound parameters, you can use the # Set the infinite cost
h.setOptionValue('infinite_cost', 1e+20) # Example value, adjust as needed
# Set the infinite bound
h.setOptionValue('infinite_bound', 1e+20) # Example value, adjust as needed Putting It All TogetherHere's how your script might look with the above changes: import highspy
import time
h = highspy.Highs()
# Read model
filename = 'abc.mps'
h.readModel(filename)
# Set options
h.setOptionValue('solver', 'ipm') # Use the interior point method
h.setOptionValue('parallel', 'on') # Enable parallel processing
h.setOptionValue('run_crossover', 'off') # Disable crossover
h.setOptionValue('infinite_cost', 1e+20) # Set infinite cost
h.setOptionValue('infinite_bound', 1e+20) # Set infinite bound
# Run the model
h.run()
print('Model ', filename, ' has status ', h.getModelStatus())
solution = h.getSolution()
basis = h.getBasis()
info = h.getInfo()
model_status = h.getModelStatus()
print('Model status = ', h.modelStatusToString(model_status))
print()
print('Optimal objective = ', info.objective_function_value)
print('Iteration count = ', info.simplex_iteration_count)
print('Primal solution status = ', h.solutionStatusToString(info.primal_solution_status))
print('Dual solution status = ', h.solutionStatusToString(info.dual_solution_status))
print('Basis validity = ', h.basisValidityToString(info.basis_validity))
print(h.getOptionValue('parallel'))
# Write solution
h.writeSolution("abc_solution.sol", 1) Make sure to replace the example values for |
Beta Was this translation helpful? Give feedback.
-
Hi. I am a complete beginner to using the HIGHS solver.
I am using it to solve a mps file using Python.
I have a very simple script, inspired from your documentation.
I have a few questions in this regard:
I read here that it is possible to use the interior point method for solving the problem. Is the default method simplex? What is the syntax for it? I tried
h.run(solver = "ipm")
, but I get TypeError with it.How can I set the
parallel
parameter in the above Python script? For ipm, is it off by default?How can I set
run_crossover
parameter to off in the above Python script? I see the crossover is set to on as default.How can I set
infinite_cost
parameter andinfinite_bound
parameter using Python?Beta Was this translation helpful? Give feedback.
All reactions