[Scip] SCIP_ConsData in constraint handler using C++
Grit Claßen
classen at math2.rwth-aachen.de
Tue Jun 19 15:09:37 MEST 2012
Hi Stefan,
first of all, I am using g++ to compile.
I had a look at the TSP and could not find a difference to what I have
implemented in my constraint handler apart from the fact that my class
is defined within another class. However, the "struct SCIP_ConsData"
seems to be a little tricky. I realised that defining the struct in an
internally defined class does not work. So I created a .h and .cpp file
for my constraint handler class, defined the struct SCIP_ConsData in the
.cpp file and it works.
Thank you for the hint to the TSP!
Best
Grit
On 06/19/2012 01:17 PM, Stefan Heinz wrote:
> Hi Grit,
>
> well just ignore the first part of my answer (the second part is
> correct). Have a look at the subtour elimination constraint handler of
> the TSP example.
>
> http://scip.zib.de/doc/examples/TSP/index.html
>
> http://scip.zib.de/doc/examples/TSP/ConshdlrSubtour_8cpp_source.html
>
> That C++ constraint handler uses a SCIP_ConsData.
>
> Does that help?
>
> Sorry Stefan
>
> On 06/19/12 12:58, Stefan Heinz wrote:
>> Hi Grit,
>>
>> On 06/18/12 17:23, Grit Claßen wrote:
>>> Hello,
>>>
>>> I am implementing a constraint handler for branching constraints in a
>>> Branch-and-Price framework. To store some information on the
>>> constraints, I would like to define a specific SCIP_ConsData.
>>> Following the examples (bin packing or graph coloring), the
>>> SCIP_ConsData could be defined like this:
>>>
>>> struct SCIP_ConsData
>>> {
>>> int itemid1; /**< item id one */
>>> int itemid2; /**< item id two */
>>> CONSTYPE type; /**< stores whether the
>>> items have to be in the SAME or DIFFER packing */
>>> int npropagatedvars; /**< number of variables
>>> that existed, the last time, the related node was
>>> * propagated, used to
>>> determine whether the constraint should be
>>> * repropagated*/
>>> int npropagations; /**< stores the number
>>> propagations runs of this constraint */
>>> unsigned int propagated:1; /**< is constraint
>>> already propagated? */
>>> SCIP_NODE* node; /**< the node in the
>>> B&B-tree at which the cons is sticking */
>>> };
>>>
>>>
>>> However, as I am using C++ this overload of "typedef struct
>>> SCIP_ConsData SCIP_CONSDATA" does not work, i.e., I cannot use
>>> SCIP_CONSDATA instead of SCIP_ConsData when implementing the callback
>>> functions of the constraint handler. The only way to handle constraint
>>> data, I can think of, is to use some maps (e.g. constraint to
>>> constraint data etc.). Is there a less cumbersome way?
>> Since you are using the C++ classes, the "objects" are just (private)
>> members of you constraint handler class. Which could look like the
>> following pricer class:
>> http://scip.zib.de/doc/examples/VRP/pricer__vrp_8h_source.html
>>
>>
>> BTW: You can also use the C plugins combined with C++ stuff (ike
>> std::vector). The only thing you have to do, is to compile all the stuff
>> with "g++" instead of "gcc".
>>
>> Best Stefan
>>> Thanks,
>>> Grit
>>> --
>>>
>>> Dipl.-Comp.Math. Grit Claßen
>>>
>>> UMIC Research Centre and Lehrstuhl II für Mathematik
>>> RWTH Aachen University
>>> 52056 Aachen
>>> Germany
>>>
>>> phone: +49 241 80 20753 or +49 241 80 94999
>>> http://www.math2.rwth-aachen.de
>>> http://www.isek.rwth-aachen.de
>>>
>>>
>>>
>>> _______________________________________________
>>> Scip mailing list
>>> Scip at zib.de
>>> http://listserv.zib.de/mailman/listinfo/scip
>>
>> _______________________________________________
>> Scip mailing list
>> Scip at zib.de
>> http://listserv.zib.de/mailman/listinfo/scip
>
>
--
Dipl.-Comp.Math. Grit Claßen
UMIC Research Centre and Lehrstuhl II für Mathematik
RWTH Aachen University
52056 Aachen
Germany
phone: +49 241 80 20753 or +49 241 80 94999
http://www.isek.rwth-aachen.de
http://www.math2.rwth-aachen.de
More information about the Scip
mailing list