* remove python script * remove RTE actions * fix test_xpress_interface.cc * remove callback_xpress.py * revert writing colnames and rownames * accept suggestion from Mizux * clean * change cmake/README.md * try fix build bazel * try fix build bazel add MPSWriteError.h * xpress tests gracefully exit if Xpress not found * add integer and linear programming test for dotnet python and java * remove MPSWriteError * try fix Window build * remove useless line from CMakeLists.txt * try fix test under windows * reformat * use XPRESS_LP instead of XPRESS for linear programming examples * tools: add --platform arg when possible make script more resilient/cross-platform * [CP-SAT] convert to PEP8 convention * use XPRSmipoptimize and XPRSlpoptimize instead of XPRSminim and XPRSmaxim (#114) * use XPRSmipoptimize and XPRSlpoptimize instead of XPRSminim and XPRSmaxim * clean xpress/environment files * accept changes: empty char* parameter for XPRS*optimize * Add test on number iterations with LP basis * fix gtests flags * refactor * suggestions by @flomnes * remove unwanted files --------- Co-authored-by: Andrea Sgattoni <andrea.sgattoni@rte-france.com> Co-authored-by: Laurent Perron <lperron@google.com> Co-authored-by: Corentin Le Molgat <corentinl@google.com> Co-authored-by: Andrea Sgattoni <andrea.sgattoni@gmail.com>
40 lines
1.0 KiB
Python
40 lines
1.0 KiB
Python
|
|
from absl import app
|
|
from absl import flags
|
|
from ortools.linear_solver.python import model_builder
|
|
|
|
FLAGS = flags.FLAGS
|
|
|
|
_INPUT = flags.DEFINE_string('input', '', 'Input file to load and solve.')
|
|
_PARAMS = flags.DEFINE_string('params', '', 'Solver parameters in string format.')
|
|
_SOLVER = flags.DEFINE_string('solver', 'sat', 'Solver type to solve the model with.')
|
|
|
|
|
|
def main(_):
|
|
model = model_builder.ModelBuilder()
|
|
|
|
# Load MPS file.
|
|
if not model.import_from_mps_file(_INPUT.value):
|
|
print(f'Cannot import MPS file: \'{_INPUT.value}\'')
|
|
return
|
|
|
|
# Create solver.
|
|
solver = model_builder.ModelSolver(_SOLVER.value)
|
|
if not solver.solver_is_supported():
|
|
print(f'Cannot create solver with name \'{_SOLVER.value}\'')
|
|
return
|
|
|
|
# Set parameters.
|
|
if _PARAMS.value:
|
|
solver.set_solver_specific_parameters(_PARAMS.value)
|
|
|
|
# Enable the output of the solver.
|
|
solver.enable_output(True)
|
|
|
|
# And solve.
|
|
solver.solve(model)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app.run(main)
|