HiGHS icon indicating copy to clipboard operation
HiGHS copied to clipboard

C# API does not support adding multiple objectives

Open Vab123 opened this issue 4 weeks ago • 1 comments

The HighsLpSolver-class in the C# API does not support adding and clearing multiple linear objectives, despite this being exported by the DLLs.

https://github.com/ERGO-Code/HiGHS/blob/869cbd4df4eba475f5df0774036dce1fce490c14/highs/interfaces/highs_csharp_api.cs#L180

This could be added by the following code:

[DllImport(Highslibname)]
private static extern int Highs_clearLinearObjectives(IntPtr highs);

[DllImport(Highslibname)]
private static extern int Highs_addLinearObjective(IntPtr highs, double weight, int offset, double[] coefficients, double absTolerance, double relTolerance, int priority);

public HighsStatus clearLinearObjectives() 
{
	return (HighsStatus)Highs_clearLinearObjectives(_highs);
}

public HighsStatus addLinearObjective(double weight, int offset, double[] coefficients, double absTolerance, double relTolerance, int priority) 
{
	return (HighsStatus)Highs_addLinearObjective(_highs, weight, offset, coefficients, absTolerance, relTolerance, priority);
}

Vab123 avatar Nov 26 '25 08:11 Vab123

Thanks, we will add this to the C# API

jajhall avatar Nov 26 '25 17:11 jajhall