Skip to content

Commit

Permalink
Make the LP in call_highs_from_csharp.cs feasible!
Browse files Browse the repository at this point in the history
  • Loading branch information
jajhall committed Aug 28, 2024
1 parent af09d2d commit acafbf0
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions examples/call_highs_from_csharp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@

class Program {
static void Main(string[] args) {
// Test with an LP
double[] cc = {1, -2};
double[] cl = {0, 0};
double[] cu = {10, 10};
double[] rl = {0, 0};
double[] ru = {2, 1};
int[] astart = {0, 2};
int[] aindex = {0, 1, 0, 1};
double[] avalue = {1, 2, 1, 3};
// Illustrate the solution of a QP, after first solving just the LP
//
// minimize x_2 + (1/2)(2x_1^2 - 2x_1x_3 + 0.2x_2^2 + 2x_3^2)
//
// subject to x_1 + x_2 + x_3 >= 1; x>=0
double[] cc = {0, 1, 0};
double[] cl = {0, 0, 0};
double[] cu = {1.0e30, 1.0e30, 1.0e30};
double[] rl = {1};
double[] ru = {1.0e30};
int[] astart = {0, 3};
int[] aindex = {0, 1, 2};
double[] avalue = {1, 1, 1};
HighsObjectiveSense sense = HighsObjectiveSense.kMinimize;
double offset = 0;
HighsMatrixFormat a_format = HighsMatrixFormat.kColwise;
HighsMatrixFormat a_format = HighsMatrixFormat.kRowwise;

HighsModel model = new HighsModel(cc, cl, cu, rl, ru, astart, aindex, avalue, null, offset, a_format, sense);

Expand All @@ -44,9 +48,9 @@ static void Main(string[] args) {
for (int i=0; i<sol.colvalue.Length; i++) {
Console.WriteLine("x" + i + " = " + sol.colvalue[i] + " is " + bas.colbasisstatus[i]);
}
// Add a Hessian
// Add the Hessian
int dim = 2;
int[] qstart = {0, 2};
int[] qstart = {0, 2, 3};
int[] qindex = {0, 1, 1};
double[] qvalue = {2, -1, 2};
HessianFormat q_format = HessianFormat.kTriangular;
Expand Down

0 comments on commit acafbf0

Please sign in to comment.