[Coin-discuss] Question about the bcp_main() function

Laszlo Ladanyi ladanyi at us.ibm.com
Sat Aug 4 14:57:49 EDT 2007


While technically you are correct, there are several problems with this. The
first is that it works only in serial mode. The second, and bigger problem is
that at the moment BCP relies on the operating system to clean up a number of
variables, object, etc, when the code exits. By removing that exit statement
and returning instead lots of memory is leaked and you still can't access any
result from the function calling bcp_main, since when bcp_main returns all the
internal variables are lost. And for now everything is stored in internal
variables. 

To make it possible to call bcp_main multiple times one would need to expose a
few internal variables (maybe just BCP_tm_prob) where the data is stored, the
user would need to create such an object and pass it in, and BCP should use
the object passed in. Not impossible to do, not even too hard, it's just that
so far whenever I thought I would do it something more iportant popped up...
If someone is willing to take a stab at it submit the pactches I'd be more
than glad to include them in BCP.

Thanks,
--Laci

On Sat, 4 Aug 2007 diarrass at isima.fr wrote:

> Hello.
> Thank you very much for your answer. While waiting for someone's help I
> decided to enter the source code of Bcp (I am using Bcp-1.0.0) and check
> what happened in the bcp_main() function. I found that this function
> indirectly calls the member function
> BCP_single_environement::register_process(). However, this function
> (located in the file Bcp-1.0.0/Bcp/src/Member/BCP_message_single.cpp)
> contains the instruction "exit(0)" at its end. So I tried to delete this
> exit() and I observe that the main program does not exit after the first
> call of bcp_main(). Thus, I conclude that the problem was create by this
> instruction.
> 
> Best regards.
> 
> > It's a "feature"... BCP was originally written as the main function, and
> > the
> > user only provided functions (classes) to compile the whole thing
> > together.
> > Later, for compilation convenience, bcp_main was created, so that BCP can
> > be
> > compiled as a library, but still, BCP acts as if it were the main function
> > and
> > exits upon finishing the work. This could be changed; the user would have
> > to
> > create a BCP_tm_prob object, populate it properly, then invoke bcp_main.
> > Not
> > too difficult, but does require some thought on what to expose.
> > For now the easiest solution is to write your code to solve the problem
> > only
> > once, then invoke your code from a shell script several times with
> > different
> > parameters.
> >
> > --Laci
> >
> > On Thu, 2 Aug 2007 diarrass at isima.fr wrote:
> >
> >> Hi.
> >> I am a new user of Coin-Or Bcp module. I send this e-mail because I
> >> found
> >> a problem when developping a program using BCP. In fact, in this program
> >> I
> >> have to solve a series of integer programs using the
> >> branch-and-cut method and each integer program depends on an integer
> >> parameter v going from 0 to N (The main() function of this program is
> >> given below).
> >> I tried to call several times the bcp_main() function in a loop from 0
> >> to
> >> N but this loop only executes the first iteration (giving the correct
> >> result) and exits. It appears that the program exits just after the
> >> first
> >> call of the bcp_main() function.
> >> Is this a bug in BCP or is their a way or a new version of BCP to
> >> correct it?
> >>
> >> int main(int argc, char* argv[])
> >> {
> >>         int v;
> >>
> >>         //Lancement de la boucle sur v
> >>         for(v=0;v<10;v++)
> >>         {
> >>                 cout << "BB_TM V == " << v << endl;
> >>
> >>                 BB_init bb_init(&v);
> >>                 int res = bcp_main(argc, argv, &bb_init);
> >>
> >>                 cout << "APRES BCP_MAIN RES = " << res << endl;
> >>         }
> >>
> >>         cout << "FIN DE L'OPTIMISATION" << endl;
> >>
> >>         return(0);
> >> }
> >>
> >>
> >>
> >>
> >>
> >> _______________________________________________
> >> Coin-discuss mailing list
> >> Coin-discuss at list.coin-or.org
> >> http://list.coin-or.org/mailman/listinfo/coin-discuss
> >>
> >
> > _______________________________________________
> > Coin-discuss mailing list
> > Coin-discuss at list.coin-or.org
> > http://list.coin-or.org/mailman/listinfo/coin-discuss
> >
> 
> 




More information about the Coin-discuss mailing list