File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -372,7 +372,11 @@ def optimize(
372
372
status = self ._lib .Highs_run (self ._model )
373
373
374
374
# store solution values for later access
375
- if self ._has_primal_solution ():
375
+ opt_status = self .get_status ()
376
+ if opt_status in (
377
+ mip .OptimizationStatus .OPTIMAL ,
378
+ mip .OptimizationStatus .FEASIBLE ,
379
+ ):
376
380
# TODO: also handle primal/dual rays?
377
381
n , m = self .num_cols (), self .num_rows ()
378
382
col_value = ffi .new ("double[]" , n )
@@ -388,10 +392,12 @@ def optimize(
388
392
if self ._has_dual_solution ():
389
393
self ._pi = [row_dual [i ] for i in range (m )]
390
394
391
- return self . get_status ()
395
+ return opt_status
392
396
393
397
def get_objective_value (self : "SolverHighs" ) -> numbers .Real :
394
- return self ._lib .Highs_getObjectiveValue (self ._model )
398
+ # only give value if we have stored a solution
399
+ if self ._x :
400
+ return self ._lib .Highs_getObjectiveValue (self ._model )
395
401
396
402
def get_log (
397
403
self : "SolverHighs" ,
You can’t perform that action at this time.
0 commit comments