@@ -460,6 +460,7 @@ def solve_problem_from_file(
460460
461461 # Use HiGHS to parse the problem file and find the set of variable names, needed to parse solution
462462 h = highspy .Highs ()
463+ h .silent ()
463464 h .readModel (path_to_string (problem_fn ))
464465 variables = {v .name for v in h .getVariables ()}
465466
@@ -755,11 +756,11 @@ def solve_problem_from_model(
755756 )
756757
757758 h = model .to_highspy (explicit_coordinate_names = explicit_coordinate_names )
759+ self ._set_solver_params (h , log_fn )
758760
759761 return self ._solve (
760762 h ,
761763 solution_fn ,
762- log_fn ,
763764 warmstart_fn ,
764765 basis_fn ,
765766 model = model ,
@@ -804,23 +805,35 @@ def solve_problem_from_file(
804805
805806 problem_fn_ = path_to_string (problem_fn )
806807 h = highspy .Highs ()
808+ self ._set_solver_params (h , log_fn )
809+
807810 h .readModel (problem_fn_ )
808811
809812 return self ._solve (
810813 h ,
811814 solution_fn ,
812- log_fn ,
813815 warmstart_fn ,
814816 basis_fn ,
815817 io_api = read_io_api_from_problem_file (problem_fn ),
816818 sense = read_sense_from_problem_file (problem_fn ),
817819 )
818820
821+ def _set_solver_params (
822+ self ,
823+ highs_solver : highspy .Highs ,
824+ log_fn : Path | None = None ,
825+ ) -> None :
826+ if log_fn is not None :
827+ self .solver_options ["log_file" ] = path_to_string (log_fn )
828+ logger .info (f"Log file at { self .solver_options ['log_file' ]} " )
829+
830+ for k , v in self .solver_options .items ():
831+ highs_solver .setOptionValue (k , v )
832+
819833 def _solve (
820834 self ,
821835 h : highspy .Highs ,
822836 solution_fn : Path | None = None ,
823- log_fn : Path | None = None ,
824837 warmstart_fn : Path | None = None ,
825838 basis_fn : Path | None = None ,
826839 model : Model | None = None ,
@@ -877,13 +890,6 @@ def _solve(
877890 highspy .HighsModelStatus .kUnknown : TerminationCondition .unknown ,
878891 }
879892
880- if log_fn is not None :
881- self .solver_options ["log_file" ] = path_to_string (log_fn )
882- logger .info (f"Log file at { self .solver_options ['log_file' ]} " )
883-
884- for k , v in self .solver_options .items ():
885- h .setOptionValue (k , v )
886-
887893 if warmstart_fn is not None and warmstart_fn .suffix == ".sol" :
888894 h .readSolution (path_to_string (warmstart_fn ), 0 )
889895 elif warmstart_fn :
0 commit comments