help-glpk
[Top][All Lists]
Advanced

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

[Help-glpk] Branch and cut tree representation.


From: Guerino Iacobucci
Subject: [Help-glpk] Branch and cut tree representation.
Date: Tue, 23 Feb 2010 20:04:21 +0100

Good evening everyone,
i'm trying to represent the Branch and cut tree which I obtain using B&c Api by GraphViz tool.

#######################################
This is my test problem:

Maximize
obj: 3x1 + 10x2 + 6x3 + 8x4 + 15x5
Subject To
3x1 + 10x2 + 6x3 + 8x4 + 15x5 <=20
Bin 
x1  
x2 
x3 
x4 
x5
End
#######################################
This is my api's application:

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

void callback_func(glp_tree *tree, void *info) {

    int currentnode  = 0;
    int precnode = 0;
    int nextnode = 0;
    int treesize = 0;
    int upnode = 0;
    int nodelevel = 0;

    switch (glp_ios_reason(tree)) {
    case GLP_IBRANCH:
    glp_ios_tree_size(tree, NULL, NULL, &treesize);

    currentnode = glp_ios_curr_node(tree);
    if(currentnode >0)
    {
    nodelevel = glp_ios_node_level(tree, currentnode);
    upnode =  glp_ios_up_node(tree, currentnode);
    precnode = glp_ios_next_node(tree, currentnode);
    nextnode = glp_ios_prev_node(tree, currentnode);

        printf("\n treesize: %d",treesize);
        printf("\n node level: %d",nodelevel);
        printf("\n up node: %d",upnode);
        printf("\n current node: %d",currentnode);
        printf("\n prev node: %d",precnode);
        printf("\n next node: %d\n",nextnode);

    }
    break;

    default:
    break;
    }

}

int main(int argc, char *argv[]){
 glp_prob *lp=lpx_create_prob();
            glp_iocp parm;
            glp_read_lp(lp, NULL, input);
            lpx_set_int_parm(lp, LPX_K_OUTFRQ, 1);
            glp_init_iocp(&parm);
            parm.cb_func = callback_func;
            parm.cb_size=255;
            parm.presolve=GLP_ON;
            parm.pp_tech=GLP_PP_NONE;
int intopt =  glp_intopt(lp, &parm);
    return 0;
}

@@@ I get "input" from argv[].

###########################################
Not in this problem but in other problems i have wrong node list, i have that some current nodes have more than 1 up node and that is wrong, and some up nodes have more than 2 "children".
What I'm doing wrong?

Please anyone could help me?

Kind Regards,
IG 

reply via email to

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