[Scip] How can I read the values of fixed variables in the collected feasible solutions

sheetal murkute shvm11 at gmail.com
Sun Aug 19 02:34:04 MEST 2012


Hello,


Thank you for your reply.

I tried using method SCIPgetSolVals() for reading the values of all the
variables of a solution. However, I get an error while using this method.


I am collecting the feasible solutions of a problem using the method
SCIPgetCountedSparseSolutions(). In this method, the collected feasible
solutions are stored in SPARSESOLUTION** structure array. However, the
input arguments for SCIPgetSolVals()contain the solution in the form of
structure SCIP_Sol*.


Therefore, my question is:

How can pass collected feasible solutions (in the form SPARSESOLUTION **)
to the method SCIPgetSolVals() (that requires solution as input argument in
the form of SCIP_Sol*) for reading values of all the variables?


I have attached the code snippet below:


SPARSESOLUTION ** feassols;

int* nsols;

int* nvars;

SCIP_VAR** curvars;

SCIP_VAR** fixedvars;

SCIP_VAR** origvars;

SCIP_Real* origvals;

SCIP_Bool valid;

int nn, nnn;



nn = SCIPgetNVars(scip);

nvars =&nn;

curvars = SCIPgetVars(scip);

assert( scip != NULL );

valid = TRUE;



// set the parameters for collecting feasible solutions

SCIP_CALL(SCIPsetParamsCountsols(scip));

SCIP_CALL( SCIPsetLongintParam( scip, "constraints/countsols/sollimit", 20)
);

SCIP_CALL( SCIPsetBoolParam( scip, "constraints/countsols/collect", TRUE) );

SCIP_CALL( SCIPcount(scip));



int nnn = SCIPgetNCountedSols(scip, &valid);

nsols = &nnn;



// collect feasible solutions of MIP



SCIPgetCountedSparseSolutions(scip, &curvars, nvars,&feassols,nsols);



// Read the values of all the variables in collected feasible solutions

int orignum = 0;

orignum = SCIPgetNOrigVars(scip);

origvars =  SCIPgetOrigVars(scip);

SCIP_SOL* origsol;

// I want to pass the collected solutions “feassols” instead of origsol



SCIP_CALL(SCIPgetSolVals(scip, origsol, orignum, origvars, origvals));





-Thanks with Best Regards,
 Sheetal

On Sun, Aug 12, 2012 at 7:26 AM, Gerald Gamrath <gamrath at zib.de> wrote:

> Dear Sheetal,
>
> you can find all methods that access the variable data structure directly
> in pub_var.h:
> http://scip.zib.de/doc/html/**pub__var_8h.shtml<http://scip.zib.de/doc/html/pub__var_8h.shtml>
> There, you can also find the methods mentioned by Michael, which are the
> correct way to get the value of a fixed variable.
>
> You can find public methods of SCIP either in pub_xyz.h for things that
> deal with structure xyz, e.g. var, cons, sol,...
> Methods that need more data, e.g. the problem (for transferring solution
> values), settings, and a solution can be found in scip.h.
> Additionally, all methods for a specific plugin, e.g. cons_linear can be
> found in the corresponding .h-file.
> Thus, if you are searching for a specific method, there are just two
> places to look: the corresponding pub_xyz.h file and scip.h (which is also
> devided into sections concerning different topics).
>
> However, back to your primary question, if you just want to get the
> solution with respect to the original variables, you can also do the
> following:
> 1) Get the original variables and their number by calling
> SCIPgetOrigvarsData():
>     http://scip.zib.de/doc/html/**scip_8h.shtml#**
> a26493edb8b80908a3c46ed8d66e33**5e9<http://scip.zib.de/doc/html/scip_8h.shtml#a26493edb8b80908a3c46ed8d66e335e9>
>     (alternatively, you can also use SCIPgetOrigVars() and
> SCIPgetNOrigvars():
>     http://scip.zib.de/doc/html/**scip_8h.shtml#**
> abec020b8686cac2812d1028deece8**5f9<http://scip.zib.de/doc/html/scip_8h.shtml#abec020b8686cac2812d1028deece85f9>)
> and
>     http://scip.zib.de/doc/html/**scip_8h.shtml#**
> aac6e0dce5ed1e58242b015a469b7c**e16<http://scip.zib.de/doc/html/scip_8h.shtml#aac6e0dce5ed1e58242b015a469b7ce16>
> )
> 2) Get the solution values of these variables via SCIPgetSolVal() or
> SCIPgetSolVals(), which gives you all values in one call:
>     http://scip.zib.de/doc/html/**scip_8h.shtml#**
> adbd8d051e9c1b3f2d84be42fb140c**112<http://scip.zib.de/doc/html/scip_8h.shtml#adbd8d051e9c1b3f2d84be42fb140c112>
>     http://scip.zib.de/doc/html/**scip_8h.shtml#**
> a982669e32c6756f863a1cc3741ecf**32c<http://scip.zib.de/doc/html/scip_8h.shtml#a982669e32c6756f863a1cc3741ecf32c>
>
> SCIP will automatically compute the value of an original variable when
> asked for its value in a transformed solution. That means that it handles
> fixed variables, but also (multi-)aggregated variables, which you would
> also have to do if you want to do everything by hand.
>
> Best,
> Gerald
>
> Am 12.08.2012 10:11, schrieb michael.winkler at zib.de:
>
>  Hi,
>>
>> you need to loop over all fixedvars and ask for
>> SCIPvarGetLbGlobal(fixedvars[.**.]) (or SCIPvarGetUbGlobal(fixedvars[.**
>> .])).
>> For fixed variables the global lowerbound and upperbound should be the
>> same.
>>
>> Best, Michael
>>
>>  Hello,
>>>
>>> I want to obtain the values of all the variables in the collected
>>> feasible
>>> solutions in SCIP.
>>> I could collect the feasible solutions and could transform those variable
>>> to the original variable space.
>>>
>>> I want to obtain the values of the fixed variables.
>>> I have used the following methods for getting number and SCIP_VAR**
>>> structure array of the fixed variables.
>>>
>>> SCIP_VAR** fixedvars;
>>> fixnum  = SCIPgetNFixedVars(scip);
>>> fixedvars = SCIPgetFixedVars(scip);
>>>
>>> Could you please let me know how I can read the values of the fixed
>>> variables in the collected feasible solutions.
>>> How can I read the values of structure elements for SCIP_VAR**?
>>>
>>> --
>>> Thanks with Best Regards,
>>> Sheetal
>>>
>>> :)
>>> ______________________________**_________________
>>> Scip mailing list
>>> Scip at zib.de
>>> http://listserv.zib.de/**mailman/listinfo/scip<http://listserv.zib.de/mailman/listinfo/scip>
>>>
>>>  ______________________________**_________________
>> Scip mailing list
>> Scip at zib.de
>> http://listserv.zib.de/**mailman/listinfo/scip<http://listserv.zib.de/mailman/listinfo/scip>
>>
>
>


-- 
Thanks with Best Regards,
Sheetal

:)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserv.zib.de/mailman/private/scip/attachments/20120819/de1e06fa/attachment.html


More information about the Scip mailing list