Skip to content

Commit fd27995

Browse files
committed
Add warm start capability to HIGHS
1 parent 8b917fc commit fd27995

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

mip/highs.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import glob
44
import numbers
55
import logging
6-
import os
76
import os.path
87
import sys
98
from typing import Dict, List, Optional, Tuple, Union
@@ -159,6 +158,10 @@
159158
const void* highs, double* col_value, double* col_dual,
160159
double* row_value, double* row_dual
161160
);
161+
HighsInt Highs_setSolution(
162+
const void* highs, double* col_value, double* row_value,
163+
double* col_dual, double* row_dual
164+
);
162165
HighsInt Highs_deleteRowsBySet(
163166
void* highs, const HighsInt num_set_entries, const HighsInt* set
164167
);
@@ -507,7 +510,13 @@ def set_objective_sense(self: "SolverHighs", sense: str):
507510
check(self._lib.Highs_changeObjectiveSense(self._model, sense_map[sense]))
508511

509512
def set_start(self: "SolverHighs", start: List[Tuple["mip.Var", numbers.Real]]):
510-
raise NotImplementedError("HiGHS doesn't support a start solution.")
513+
# using zeros for unset variables
514+
nvars = len(self.model.vars)
515+
cval = ffi.new("double[]", [0.0 for _ in range(nvars)])
516+
for col in start:
517+
cval[col[0].idx] = col[1]
518+
519+
self._lib.Highs_setSolution(self._model, cval, ffi.NULL, ffi.NULL, ffi.NULL)
511520

512521
def set_objective(self: "SolverHighs", lin_expr: "mip.LinExpr", sense: str = ""):
513522
# set coefficients

0 commit comments

Comments
 (0)