add import/export with proto on model_builder; add support for proto in solve_model.py

This commit is contained in:
Laurent Perron
2023-11-19 07:22:44 +01:00
parent 84962a4281
commit b5f749b794
6 changed files with 44 additions and 3 deletions

View File

@@ -26,16 +26,22 @@ _SOLVER = flags.DEFINE_string("solver", "sat", "Solver type to solve the model w
def main(argv: Sequence[str]) -> None:
"""Load a model and solves it."""
if len(argv) > 1:
raise app.UsageError("Too many command-line arguments.")
model = model_builder.ModelBuilder()
# Load MPS file.
if not model.import_from_mps_file(_INPUT.value):
print(f"Cannot import MPS file: '{_INPUT.value}'")
if _INPUT.value.endswith(".mps"):
if not model.import_from_mps_file(_INPUT.value):
print(f"Cannot import MPS file: '{_INPUT.value}'")
return
elif not model.import_from_proto_file(_INPUT.value):
print(f"Cannot import Proto file: '{_INPUT.value}'")
return
# Create solver.
solver = model_builder.ModelSolver(_SOLVER.value)
if not solver.solver_is_supported():