[Scip] segmentation fault while reading stored feasible solutions

sheetal murkute shvm11 at gmail.com
Fri Jun 1 19:44:40 MEST 2012


Hi,

I am getting segmentation fault while reading the counted feasible solution
values.
It displays the values of *nsols, and variable bounds for 1st solution in
the sparsesolution structure array.
However, it gives segmentation fault for forther solutions.
I have written the code as follows.

SPARSESOLUTION ** feassols;
SCIP_VAR** curvars;
int* nsols;
int* nvars;
SCIP_Bool valid;
int nn, nnn;
nn = SCIPgetNVars(scip);
nvars =&nn;
curvars = SCIPgetVars(scip);
assert( scip != NULL );
valid = TRUE;

 SCIP_CALL(SCIPsetParamsCountsols(scip));
SCIP_CALL( SCIPsetLongintParam( scip, "constraints/countsols/sollimit",
2000) );
SCIP_CALL( SCIPsetBoolParam( scip, "constraints/countsols/collect", TRUE) );

SCIP_CALL( SCIPcount(scip));
 nnn = SCIPgetNCountedSols(scip, &valid);
nsols = &nnn;

SCIPgetCountedSparseSolutions(scip, &curvars, nvars,&feassols,nsols);
cout << "total nuber of feasible solutions :" << *nsols<< endl;

*******************************************************************************************************

When I print the variable values of 1st solution , I get the correct output.
        SPARSESOLUTION * feas;
feas = *feassols;
 for(i=0; i < *nvars; ++i)
cout <<* feas[0].lbvalues[i]* << " ";
cout << endl;

for(i=0; i < *nvars; ++i)
cout << *feas[0].ubvalues[i]* << " ";
cout << endl;

output:
total nuber of feasible solutions :2000
lbvalues:  0 0 0 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 1 1 1 0 1 1 1 0
1 1
ubvalues: 0 0 0 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 1 1 1 0 1 1 1 0 1
1

However, If I print the next solution, I get segmentation fault.
        for(i=0; i < *nvars; ++i)
cout << *feas[1].lbvalues[i]* << " ";
cout << endl;

for(i=0; i < *nvars; ++i)
cout <<* feas[1].ubvalues[i]* << " ";
cout << endl;

Can you please suggest what is going wrong while accessing the structure
SPARSESOLUTION*** ?


-Thanks with Best Regards,
 Sheetal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserv.zib.de/mailman/private/scip/attachments/20120601/f869f5a0/attachment.html


More information about the Scip mailing list