[FlopCpp] indexing with parameters

Tim Hultberg Tim.Hultberg at eumetsat.int
Mon Dec 3 08:47:12 EST 2007


Yes, I believe you can do this more elegantly, using MP_subset.

Have a look in the stampl_imp.cpp example in branches/stochastic

In this example the shape of the tree is specified by a relation (MP_subset<2>) between the nodes and the stages (TN) and between the nodes and the scenarios (NS). From these two relations, the parent relation between nodes (ANC) can be inferred.

Hope it helps, Tim 






--------------------
Tim Hultberg, Product Implementation Expert
--------------------
EUMETSAT, European Organisation for the Exploitation of Meteorological Satellites
Am Kavelleriesand 31, D-64295 Darmstadt,Germany
tel: +49 6151 807 73 49


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

I have a model based on a tree, with variables indexed by nodes of the 
tree. In some constraints, I need to relate the nodes to their parents, 
i.e. I need to be able write something like x(Parent[NODES]) or 
x(Parent(NODES)) in an MP_expression, where NODES is an MP_set.

I found one solution for balanced trees, i.e. trees where the index of a 
predecessor can be computed as a simple function of the current index. 
For example, for a binary tree I have,
: MP_index_exp get_parent(MP_index &node) {
:     return floor((node-1) / 2);
: }
which allows me to write
: x(get_parent(NODES))
in an MP_expression.
My first question is whether there is a simpler (more elegant) way of 
doing this?

The main problem, however, is what to do in the case of general trees, 
i.e. trees where the parents are given as a data (such as double[][2], 
vector of pairs, MP_data indexed on NODES)?
How do I put "x(Parent[NODES])" to an MP_expression then?


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