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

sheetal murkute shvm11 at gmail.com
Sun Aug 26 22:40:56 MEST 2012


Hello,



Thank you for your reply. That helped a lot. I could collect the values of
all the integral variables including fixed variables for each collected
feasible solution. For this, I have set the "presolving/donotmultaggr" and
"presolving/donotaggr" parameters to 1 for disabling aggregation.



I want to collect the values of all the continuous variables for each
collected solution. For this, I initially use SCIPfreeTransform() function
to reset the problem to original state. Then I fix the integral variables
to the values collected for each solution. And finally I solve the problem
to get values of continuous variables.



1. 1.  I initially collect the feasible solutions using scipcount().



2. 2.  I am using SCIPfreeTransform() only to reset the problem before
fixing integral variables for each solution. I get segmentation fault if I
use SCIPfreeTransform().



3.  3. If I remove SCIPfreeTransform() and just fix the variables and
solve, it errors out while fixing the variables for each solution stating
“invalid SCIP stage”.

 *Complete error message:         **[src/scip/scip.c:12290] ERROR: invalid
SCIP stage <8>*





*Could you please let me know if there is anything wrong in the method I
use to collect the values of all the continuous variables for each of the
collected feasible solutions?*



Below is the code snippet that describes the flow of my code:





// Collect 20 feasible solutions using SCIPcount



//Loop over each collected solution

for(j=0; j < 20; ++j)

{

// create an empty vector tempsolvec and

// store the values of all integral variables including fixed variables for
each

// collect feasible solutions into a vector tempsolvec



// reset the ‘scip’ problem to its original state:

       SCIPfreeTransform(scip);



//. . .I get a segmentation fault upon using this. If I do not use this, it
gives error ‘invalid SCIP //stage’ while fixing the variables below using
SCIPfixVar()





// fixed the integer bounded variables to the values stored in tempsolvec
vector:



       SCIP_Bool fixed;

       SCIP_Bool infeasible;

       SCIP_Real fixedval;



       SCIP_VAR** tofixvar;

       tofixvar = SCIPgetVars(scip);





       //loop over all the variables

       for(i=0; i < nvars; ++i)

       {

       fixedval = tempsolvec[i];

//I get the “invalid scip stage” errors on the line below:

       *SCIPfixVar(scip,tofixvar[i],fixedval, &infeasible, &fixed);*

       }



// solve the problem

       SCIP_CALL_EXC(SCIPsolve(scip));

       tempsolvec.clear();

}







-Thanks with Best Regards,

 Sheetal



On Tue, Aug 21, 2012 at 9:15 AM, <michael.winkler at zib.de> wrote:

> Hi,
>
> > 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*.
> >
>
> as you already have noticed using SCIPgetSolVals() needs a SCIP_SOL* as
> input argument, but when counting solutions in the end you only have an
> array of SPARSESOLUTION*.
> These data structures are different and "cannot" be converted into each
> other.
>
> The SPARSESOLUTION data structure consist of two SCIP_Real arrays with the
> lower bound values and the upper bound values of all the variables which
> you get when calling SCIPgetCountedSparseSolutions().
>
> In your case, you wanted to know the values of variables, which were
> already fixed(, aggregated, multi-aggregated) in presolving and therefore
> not in the variables array returned when calling
> SCIPgetCountedSparseSolutions().
>
> Let's assume that you do not have any (multi-)aggregated variables (,
> which you could also force by calling
>
> SCIPsetBoolParam(scip, "presolving/donotmultaggr", 1) and
> SCIPsetBoolParam(scip, "presolving/donotaggr", 1) before calling
>
> SCIPcount()).
>
> In the above case you can easily run over the fixed variables
>
> >>>> SCIP_VAR** fixedvars;
> >>>> fixnum  = SCIPgetNFixedVars(scip);
> >>>> fixedvars = SCIPgetFixedVars(scip);
>
> and ask for:
>
> >>> SCIPvarGetLbGlobal(fixedvars[*]) or
> >>> SCIPvarGetUbGlobal(fixedvars[*])
>
> because the lower and upper bound should be the same (in feasibility
> tolerance) for fixed variables.
>
> For the more general way, if you have aggregated and even multi-aggregated
> variables you need to call SCIPgetProbvarLinearSum() (see
> http://scip.zib.de/doc/html/scip_8h.shtml#a0509a5028381b92e3e40cde775db7ac9
> )
> for each variable in your 'fixedvars' array.
>
> For all the returned (active) variables you need to check the values in
> the SPARSESOLUTION and calculate the values of the (multi-)aggregated
> variables yourself.
>
> E.g. You have one fixed variable x1. (Code is not tested)
>
> SCIP_CALL( SCIPallocBufferArray(scip, &repvars, SCIPgetNVars(scip)) );
> SCIP_CALL( SCIPallocBufferArray(scip, &scalars, SCIPgetNVars(scip)) );
>
> repvars[0] = x1;
> scalars[0] = 1.0;
> constant = 0;
> nrepvars = 1;
>
> SCIP_CALL( SCIPgetProbvarLinearSum(scip, repvars, scalars, &nrepvars,
> SCIPgetNVars(scip), &constant, &requiredsize, TRUE) );
>
> solval = constant;
>
> for( v = 0; v < nrepvars; ++v )
> {
>    solval += scalars[v] * getSolValSparsesolution(sparsesol,
> sparsesolvars, repvars[v]);
> }
>
> You need to implement getSolValSparsesolution(). ('sparsesol' is you
> SPARSESOLUTION*, and 'sparsesolvars' the corresponding variables.)
>
> The solution value of the fixed variable 'x1' is then 'solval'.
>
>
> Best, Michael
>
>
>


-- 
Thanks with Best Regards,
Sheetal

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


More information about the Scip mailing list