[Scip] How to access a subscip in ObjPricer::scip_redcost?

Stefan Heinz heinz at zib.de
Thu Dec 23 21:11:11 MET 2010


Hi Sebastian,

now some additional comments.

As Timo and Gerald already mentioned, the subscip has to be a member
variable of your pricer class.

The question which is still open is: how to access this member. In case
your in your pricer class, the member are accessible right away. If you
want to access a member somewhere else you can get the pointer to your
pricer class be using the function SCIPgetObjPricer() or
SCIPfindObjPricer(). Both function are defined in
"src/objscip/objpricer.h" and return an pointer to an ObjPricer. That one
you have to cast into your pricer class. For example:

MyPricer* pricer = (MyPricer*)(SCIPfindObjPricer(scip, "Xmas"));

To get access to the subscip you need to implement a member function if
the member is a private member in your pricer which returns the subscip
pointer. That could look like that:

SCIP* subscip = pricer->getSubscip()

Is the member a public member, then you can access that one directly:

SCIP* subscip = pricer->subscip;

I hope that clears a little bit more the picture.

Merry Xmas
Stefan




> Hi Sebastian,
>
> as Timo suggested, everything that you would put into a pricerdata in C,
> you should add as global object variables in C++.
> The pricerdata is needed to store the C++ wrapper class, so if you
> overwrite it, your objpricer gets lost.
>
> Yes, there is also a method SCIPsetProbData() for setting your problem
> data in a C code. However, in C++, you are again not allowed to use the
> SCIP_PRICERDATA*, but should instead store all needed data as global
> object variables in your objprobdata. You can set the objprobdata if you
> create your problem with the method SCIPcreateObjProb() instead of
> SCIPcreateProb().
>
> Merry christmas,
> Gerald
>
> Sebastian Ruther schrieb:
>>   Hello,
>>
>> well it works the way you suggested. However, I found out that the
>> general problem is with the PricerData. I can't access it anywhere but
>> the function in which I call the constructor:
>>
>> PricerDataCG* pPricerDataCG = new PricerDataCG(iAc->second);
>> for which I define struct PricerDataCG : public SCIP_PricerData.
>>
>> I guess I need to tell scip that a pricer data exists:
>> SCIPpricerSetData(pricer, pPricerDataCG);
>> However, if I do this I get an unexpected exception error for line
>> SCIP_CALL( pricerdata->objpricer->scip_redcost(scip, pricer, lowerbound,
>> result) );     in solve.c
>> the debugger tells me that objpricer doesn't know function scip_redcost.
>>
>> If I exclude SCIPpricerSetData it compiles and runs fine but like I said
>> I can't use the pricerdata anywhere else.
>>
>> So what's the correct way to initialize/add a pricerdata object?
>>
>> BTW: is there an equivalent of SCIPpricerSetData probdata?
>>
>> Merry christmas
>> Sebastian
>>
>>
>> On 22/12/2010 10:05 PM, Timo Berthold wrote:
>>
>>> Hi Sebastian.
>>>
>>> In C, you would put this into the private data struct SCIP_PricerData.
>>> In C++,
>>> however, you can just define a SCIP* subscip as global object
>>> variables.
>>>
>>> Also see the doxygen HowTo for private data in pricers:
>>> http://scip.zib.de/doc/html/PRICER.html#PRICER_DATA
>>> and compare lines 122-131 of examples/VRP/src/priver_vrp.h
>>> which is written in C++
>>>
>>> Merry Xmas to downunder,
>>> Timo
>>>
>>>
>>> Am Mittwoch 22 Dezember 2010, 07:33:09 schrieb Sebastian Ruther:
>>>
>>>>    Hello,
>>>>
>>>> I'm implementing a Branch-and-Price algorithm. In the examples the
>>>> variables are always generated by the subscip which is generated in
>>>> the
>>>> ObjPricer::scip_redcost call. However, I don't want to generate the
>>>> subscip problem in every iteration so I generate my subscip in
>>>> ObjPricer::initsol by calling
>>>> SCIP*      subscip = NULL;
>>>> SCIP_CALL( SCIPcreate(&subscip) );
>>>> SCIP_CALL( SCIPincludeDefaultPlugins(subscip) );
>>>> SCIP_CALL( SCIPcreateProb(subscip, PricingNameBuf.str().c_str(), 0, 0,
>>>> 0, 0, 0, 0, 0) );
>>>>
>>>> How do I access the SCIP* subscip in the ObjPricer::scip_redcost
>>>> function? The parameter list only gives me the SCIP* scip which refers
>>>> to the master problem.
>>>>
>>>> Thanks
>>>> Sebastian
>>>> _______________________________________________
>>>> 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
>>
>
> _______________________________________________
> Scip mailing list
> Scip at zib.de
> http://listserv.zib.de/mailman/listinfo/scip
>



More information about the Scip mailing list