bug-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-glpk] [Fwd: Re: [Fwd: Bus error for MIP solver / Simplex solver]]


From: Andrew Makhorin
Subject: [Bug-glpk] [Fwd: Re: [Fwd: Bus error for MIP solver / Simplex solver]]
Date: Tue, 08 May 2012 01:48:23 +0400

-------- Forwarded Message --------
From: Tony Khosravi <address@hidden>
To: Andrew Makhorin <address@hidden>
Cc: address@hidden
Subject: Re: [Bug-glpk] [Fwd: Bus error for MIP solver / Simplex solver]
Date: Mon, 7 May 2012 15:21:07 +0200

Hi,

I tested your code, and it works perfectly. I don't see the issue with
my code though. Is it somehow a problem with passing a parameter? 

Here is my code:

/* glpktest.c */

#include <stdio.h>
#include <stdlib.h>
#include <glpk.h>

int main() {


    glp_prob *mip;
    glp_tran *tran;
    glp_iocp *parm;
    int ret;
    mip = glp_create_prob();

//1.allocating workspace
    tran = glp_mpl_alloc_wksp(); 
//2.reading  model section
    ret = glp_mpl_read_model(tran, "sudoku.mod", 1);
    if (ret != 0) { 
    printf("Error on translating model\n");
    goto skip;
    }
// 3.reading data section
    ret = glp_mpl_read_data(tran, "sudoku.dat");
    if (ret != 0) { 
    printf("Error on translating data\n");
    goto skip;
    }
//4.generating model
    ret = glp_mpl_generate(tran, NULL);
    if (ret != 0) { 
    printf("Error on generating model\n");
    goto skip;
    }
//5.building the problem object
    glp_mpl_build_prob(tran, mip);
//6.solving the problem
    //With parm, no need to call the simplex
    //glp_simplex(mip, NULL);
    
    glp_init_iocp(parm); 
    parm->presolve = GLP_ON; 
    parm->binarize = GLP_ON; 
    glp_intopt(mip, parm);
    // ret =glp_print_mip(mip, "out.txt");
    // if (ret != 0) { 
    //     cerr << "Error on writing the solution" << endl;
    //     goto skip;
    // }
//7.postsolving the problem
    ret = glp_mpl_postsolve(tran, mip, GLP_MIP);
    if (ret != 0)
    printf("Error on postsolving model\n");
//8.freeing the workspace
skip: glp_mpl_free_wksp(tran);
    glp_delete_prob(mip);
    return 0;

}

/* eof */

If I use just the simplex method, the result is not good. 

As I said before, the java implementation is exactly the same, and it
works though.




2012/5/5 Andrew Makhorin <address@hidden>
        Hello,
        
        > Well, as nobody is able to find any solution, I tried couple
        of
        > things, unsuccessfully. However, I have run the program once
        again
        > with gdb to see where was the problem exactly, to dig a bit
        and to
        > maybe figure out the problem. Once again, unsuccessfully. I
        copy/paste
        > the debugger output here:
        >
        > #0  0x00007ffff7486edc in getenv ()
        > from /lib/x86_64-linux-gnu/libc.so.6
        > #1  0x00007ffff74eca9e in ?? ()
        from /lib/x86_64-linux-gnu/libc.so.6
        > #2  0x00007ffff74ecf52 in ?? ()
        from /lib/x86_64-linux-gnu/libc.so.6
        > #3  0x00007ffff7b22b8c in glp_time () at glpenv06.c:60
        > #4  0x00007ffff7b86c17 in init_csa (lp=<optimized out>,
        csa=<optimized
        > out>)
        >     at glpspx01.c:392
        > #5  _glp_spx_primal (lp=<optimized out>, parm=<optimized out>)
        >     at glpspx01.c:2590
        > #6  0x00007ffff7b0163b in glp_simplex (P=0x6aec20,
        > parm=0x7fffffffe0a0)
        >     at glpapi06.c:452
        > #7  0x00007ffff7b04a96 in preprocess_and_solve_mip
        > (parm=0x7fffffffe4f0,
        >     P=0x604500) at glpapi09.c:371
        > #8  glp_intopt (P=0x604500, parm=0x7fffffffe4f0) at
        glpapi09.c:593
        > #9  0x0000000000400c69 in main () at glpk.cpp:44
        >
        > at line 44, I have the following:
        >
        > glp_intopt(mip, parm);
        >
        > I have implemented a Java version of this program (linked to
        the java
        > libglpk) and it is an exact copy of the C++ code. Weird thing
        is it
        > works perfectly (I used the stand alone glpsol to check).
        >
        > It somehow solve my problem for this case, but it would be
        good to
        > know what is the issue with the c++ lib.
        
        
        I calculate that this bug is not related to glpk. According to
        the
        traceback you provided the exception occured in getenv which is
        called
        indirectly from glp_time. Since glp_time calls only two libc
        functions
        gettimeofday and gmtime, there is something wrong in the
        environment.
        
        I'd suggest you to run an equivalent of the following program:
        
        /* glpsol.c */
        
        #include <glpk.h>
        
        int main(int argc, const char *argv[])
        {     /* stand-alone LP/MIP solver */
             return glp_main(argc, argv);
        }
        
        /* eof */
        
        in the standard C environment you are using. If it works, please
        find
        the bug in your code. Thanks.
        
        
        Andrew Makhorin
        



-- 
Tony Khosravi Dehkourdi

MSc. Student - Computer Systems
Linköping University
Elève ingénieur -- Génie Informatique, Systèmes et Réseaux
d'Informations (GI06)
Université de Technologie de Compiègne
Tel:+46 7 60 69 51 57




reply via email to

[Prev in Thread] Current Thread [Next in Thread]