Esempio n. 1
0
 public HighsModel(double[] colcost, double[] collower, double[] colupper, double[] rowlower, double[] rowupper,
                   int[] astart, int[] aindex, double[] avalue, double offset = 0, HighsMatrixFormat a_format = HighsMatrixFormat.kColwise, HighsObjectiveSense sense = HighsObjectiveSense.kMinimize)
 {
     this.colcost  = colcost;
     this.collower = collower;
     this.colupper = colupper;
     this.rowlower = rowlower;
     this.rowupper = rowupper;
     this.astart   = astart;
     this.aindex   = aindex;
     this.avalue   = avalue;
     this.offset   = offset;
     this.a_format = a_format;
     this.sense    = sense;
 }
Esempio n. 2
0
    static void Main(string[] args)
    {
        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 };
        HighsObjectiveSense sense    = HighsObjectiveSense.kMinimize;
        double              offset   = 0;
        HighsMatrixFormat   a_format = HighsMatrixFormat.kColwise;

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

        HighsLpSolver solver = new HighsLpSolver();

        HighsStatus status = solver.passLp(model);

        status = solver.run();
        HighsSolution    sol         = solver.getSolution();
        HighsBasis       bas         = solver.getBasis();
        HighsModelStatus modelStatus = solver.GetModelStatus();

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

        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]);
        }
        for (int i = 0; i < sol.colvalue.Length; i++)
        {
            Console.WriteLine("x" + i + " = " + sol.colvalue[i] + " is " + bas.colbasisstatus[i]);
        }
    }
Esempio n. 3
0
 public HighsStatus changeObjectiveSense(HighsObjectiveSense sense)
 {
     return((HighsStatus)HighsLpSolver.Highs_changeObjectiveSense(this.highs, (int)sense));
 }