How do I take the results of de mathprog using GLPK


I'm using a .mod file that was programmed in the Mathprog language, I'm establishing the connection to Java and taking the results through the GLPK library that reads the .mod file, but the result comes to me as text in the console and I need that data at least in the form of an arrangement, to put them later in a form. Below I leave the code that writes the results and also I leave an image of the reusltados, but in the form of text- I would love to be helped. Greetings] 1 ] 1

public static void main(String[] arg) {
           System.out.print("Usage: java Gmpl model.mod"+"\n");
            new LoadModel().LoadModel();
    public void LoadModel() {
            glp_prob lp;
            glp_tran tran;
            glp_iocp iocp;
            int skip = 0;
            int ret;
            lp = GLPK.glp_create_prob();
            System.out.println("Problem created");
            tran = GLPK.glp_mpl_alloc_wksp();
            ret = GLPK.glp_mpl_read_model(tran, fname , skip);
            if (ret != 0) {
                throw new RuntimeException("Model file not found: " + fname);
            // generate model
            GLPK.glp_mpl_generate(tran, null);
            // build model
            GLPK.glp_mpl_build_prob(tran, lp);
            // set solver parameters
            iocp = new glp_iocp();
            // solve model
            ret = GLPK.glp_intopt(lp, iocp);
            int[] list=new int[50];
            int flags;
            // postsolve model
            if (ret == 0) {
                GLPK.glp_mpl_postsolve(tran, lp, GLPKConstants.GLP_MIP);
                n = GLPK.glp_get_num_cols(lp);
//                int GLPK.GLPK.glp_print_ranges(glp_prob*P, 50,list, flags, fnameList);
            System.out.println("Columnas " + n);
            // free memory
        public void callback(glp_tree tree) {
        int reason = GLPK.glp_ios_reason(tree);
        if (reason == GLPKConstants.GLP_IBINGO) {
            System.out.println("Better solution found");
asked by Abel Eusébio 20.12.2018 в 07:01

0 answers