[FlopCpp] problem generalizing stampl.cpp

Tim Hultberg Tim.Hultberg at eumetsat.int
Mon Nov 26 06:47:32 EST 2007


Hi,
   you can do like this:

    Final_wealth = children[0]->Final_wealth;    
    for (int i=1; i<children.size(); i++) {
      Final_wealth = Final_wealth + children[i]->Final_wealth;
    }

I agree that this is ugly (i.e. not declarative). Your syntax would be nicer, but I guess it is hard to achieve, since the stages are not flopc++ constructs.

Btw.
I verified that 
   for (int i=0; i<children.size(); i++) {
      Final_wealth = Final_wealth + children[i]->Final_wealth;
    }
does NOT work. But I could probably make this possible.

Cheers, Tim



>>> Michal Kaut <mail at michalkaut.net> 26/11/2007 11:42 >>>
Hello,

I am trying to rewrite the stampl.cpp example to be able to handle 
general trees. My problem is that I do no know what to do with the 
objective function and the MP_expressions, which are currently written 
as a fixed sum of the two children:
: Final_wealth = children[0]->Final_wealth + children[1]->Final_wealth;

Is there any way of writing this expression for a general number of 
children? I do not have a problem assuming that the number of children 
is known at the moment the Stage-objects are created.

(My idea was to define MP_set CHILDREN and write something like
: Final_wealth = sum(CHILDREN, children[(int) CHILDREN]->Final_wealth);
but I can't find anything that would work.)


Any idea would be greatly appreciated.
Thanks a lot in advance.

Regards,
Michal Kaut
_______________________________________________
FlopCpp mailing list
FlopCpp at list.coin-or.org 
http://list.coin-or.org/mailman/listinfo/flopcpp




More information about the FlopCpp mailing list