Пример #1
0
    public HighsBasis getBasis()
    {
        int nc = this.getNumCols();
        int nr = this.getNumRows();

        HighsBasis bas = new HighsBasis(nc, nr);

        HighsLpSolver.Highs_getBasis(this.highs, bas.colbasisstatus, bas.rowbasisstatus);
        return(bas);
    }
Пример #2
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));
    }
Пример #3
0
    public HighsBasis getBasis()
    {
        int nc = this.getNumCol();
        int nr = this.getNumRow();

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

        HighsLpSolver.Highs_getBasis(this.highs, colbasstat, rowbasstat);
        HighsBasis bas = new HighsBasis(colbasstat.Select(x => (HighsBasisStatus)x).ToArray(), rowbasstat.Select(x => (HighsBasisStatus)x).ToArray());

        return(bas);
    }
Пример #4
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]);
        }
    }
Пример #5
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, 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);
    }
Пример #6
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);
    }