Example #1
0
    public static int call(HighsModel model, ref HighsSolution sol, ref HighsBasis bas)
    {
        int nc  = model.colcost.Length;
        int nr  = model.rowlower.Length;
        int nnz = model.avalue.Length;

        return(HighsLpSolver.Highs_call(nc, nr, nnz, model.colcost, model.collower, model.colupper,
                                        model.rowlower, model.rowupper, model.astart, model.aindex, model.avalue,
                                        sol.colvalue, sol.coldual, sol.rowvalue, sol.rowdual, bas.colbasisstatus, bas.rowbasisstatus));
    }
Example #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]);
        }
    }
    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, 4 };
        int[]    aindex = { 0, 1, 0, 1 };
        double[] avalue = { 1, 2, 1, 3 };

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

        HighsSolution sol = new HighsSolution(2, 2);

        HighsBasis bas = new HighsBasis(2, 2);

        int status = HighsLpSolver.call(model, ref sol, ref bas);

        Console.WriteLine("Status: " + status);
    }
Example #4
0
    public static HighsStatus call(HighsModel model, ref HighsSolution sol, ref HighsBasis bas, ref HighsModelStatus modelstatus)
    {
        int nc  = model.colcost.Length;
        int nr  = model.rowlower.Length;
        int nnz = model.avalue.Length;

        int[] colbasstat = new int[nc];
        int[] rowbasstat = new int[nr];

        int modelstate = 0;

        HighsStatus status = (HighsStatus)HighsLpSolver.Highs_call(nc, nr, nnz, model.colcost, model.collower, model.colupper,
                                                                   model.rowlower, model.rowupper, model.astart, model.aindex, model.avalue,
                                                                   sol.colvalue, sol.coldual, sol.rowvalue, sol.rowdual, colbasstat, rowbasstat, ref modelstate);

        modelstatus = (HighsModelStatus)modelstate;

        bas.colbasisstatus = colbasstat.Select(x => (HighsBasisStatus)x).ToArray();
        bas.rowbasisstatus = rowbasstat.Select(x => (HighsBasisStatus)x).ToArray();

        return(status);
    }
Example #5
0
 public HighsStatus passLp(HighsModel model)
 {
     return((HighsStatus)HighsLpSolver.Highs_passLp(this.highs, model.colcost.Length, model.rowlower.Length, model.avalue.Length,
                                                    (int)model.a_format, (int)model.sense, model.offset, model.colcost, model.collower, model.colupper, model.rowlower, model.rowupper, model.astart, model.aindex, model.avalue));
 }
Example #6
0
 public HighsStatus loadModel(HighsModel model)
 {
     return((HighsStatus)HighsLpSolver.Highs_loadModel(this.highs, model.colcost.Length, model.rowlower.Length, model.avalue.Length,
                                                       model.colcost, model.collower, model.colupper, model.rowlower, model.rowupper, model.astart, model.aindex, model.avalue));
 }