Skip to content

Commit

Permalink
Completed call_highs_from_csharp.cs by passing a Hessian and resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
jajhall committed Aug 28, 2024
1 parent acafbf0 commit 0eee142
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion examples/call_highs_from_csharp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ static void Main(string[] args) {
Console.WriteLine("Status: " + status);
Console.WriteLine("Modelstatus: " + modelStatus);

for (int i=0; i<sol.colvalue.Length; i++) {
Console.WriteLine("Activity for col " + i + " = " + sol.colvalue[i]);
}
for (int i=0; i<sol.rowvalue.Length; i++) {
Console.WriteLine("Activity for row " + i + " = " + sol.rowvalue[i]);
}
Expand All @@ -54,7 +57,27 @@ static void Main(string[] args) {
int[] qindex = {0, 1, 1};
double[] qvalue = {2, -1, 2};
HessianFormat q_format = HessianFormat.kTriangular;

HighsHessian hessian = new HighsHessian(dim, qstart, qindex, qvalue, q_format);
status = solver.passHessian(hessian);
status = solver.run();
sol = solver.getSolution();
modelStatus = solver.GetModelStatus();

Console.WriteLine("Status: " + status);
Console.WriteLine("Modelstatus: " + modelStatus);

for (int i=0; i<sol.colvalue.Length; i++) {
Console.WriteLine("Activity for col " + i + " = " + sol.colvalue[i]);
}
for (int i=0; i<sol.rowvalue.Length; i++) {
Console.WriteLine("Activity for row " + i + " = " + sol.rowvalue[i]);
}
for (int i=0; i<sol.coldual.Length; i++) {
Console.WriteLine("Reduced cost x[" + i + "] = " + sol.coldual[i]);
}
for (int i=0; i<sol.rowdual.Length; i++) {
Console.WriteLine("Dual value for row " + i + " = " + sol.rowdual[i]);
}

}
}

0 comments on commit 0eee142

Please sign in to comment.