Skip to content

Commit 1d09cd4

Browse files
authored
Merge pull request #3039 from Carl-Hossler/patch-1
Implement setBasis and setLogicalBasis methods
2 parents 0c51a16 + d3f667b commit 1d09cd4

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

highs/interfaces/highs_csharp_api.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,13 @@ private static extern int Highs_passHessian(
344344
private static extern int Highs_getHessianNumNz(IntPtr highs);
345345

346346
[DllImport(highslibname)]
347-
private static extern int Highs_getBasis(IntPtr highs, int[] colstatus, int[] rowstatus);
347+
private static extern int Highs_getBasis(IntPtr highs, int[] colstatus, int[] rowstatus);
348+
349+
[DllImport(highslibname)]
350+
private static extern int Highs_setBasis(IntPtr highs, int[] col_status, int[] row_status);
351+
352+
[DllImport(highslibname)]
353+
private static extern int Highs_setLogicalBasis(IntPtr highs);
348354

349355
[DllImport(highslibname)]
350356
private static extern double Highs_getObjectiveValue(IntPtr highs);
@@ -1022,6 +1028,18 @@ public HighsStatus setSolution(HighsSolution solution)
10221028
return (HighsStatus)HighsLpSolver.Highs_setSolution(this.highs, solution.colvalue, solution.rowvalue, solution.coldual, solution.rowdual);
10231029
}
10241030

1031+
public HighsStatus setBasis(HighsBasis basis)
1032+
{
1033+
int[] col_status = basis.colbasisstatus.Select(x => (int)x).ToArray();
1034+
int[] row_status = basis.rowbasisstatus.Select(x => (int)x).ToArray();
1035+
return (HighsStatus)HighsLpSolver.Highs_setBasis(this.highs, col_status, row_status);
1036+
}
1037+
1038+
public HighsStatus setLogicalBasis()
1039+
{
1040+
return (HighsStatus)HighsLpSolver.Highs_setLogicalBasis(this.highs);
1041+
}
1042+
10251043
/// <summary>Set a partial primal solution by passing values for a set of variables</summary>
10261044
/// <param name="valuesByIndex">A dictionary that maps variable indices to variable values</param>
10271045
/// <remarks>The sparse solution set by this function has values for a subset of the model's variables.

0 commit comments

Comments
 (0)