[Scip] Problems with SCIPcopy() and SCIPcopyProb()

Daniel Karch karch at math.tu-berlin.de
Tue Dec 20 12:10:39 MET 2011


I think I may have found a bug ... or I really don't understand something.
;-)
The "ERROR: cannot call method <SCIPgetTransformedVar> in problem creation
stage" (see below)
disappears when I change

SCIP_VAR * ty = NULL;
SCIP_CALL( SCIPgetTransformedVar(scip, y_vars(uv,s), &ty) );

to

SCIP_VAR * ty = SCIPvarGetTransVar(y_vars(uv,s));

Aren't those to calls supposed to be equivalent?

  Daniel

2011/12/20 Daniel Karch <karch at math.tu-berlin.de>

> Wow, that was fast! :-)
>
> Unfortunately, that does not work either:
>
> [src/scip/scip.c:187] ERROR: cannot call method <SCIPgetTransformedVar> in
> problem creation stage
> [src/scip/scip.c:8817] ERROR: Error <-8> in function call
> [src/ProbDataMinCon.cpp:76] ERROR: Error <-8> in function call
> [src/objscip/objprobdata.cpp:162] ERROR: Error <-8> in function call
> [src/scip/prob.c:217] ERROR: Error <-8> in function call
> [src/scip/scip.c:1068] ERROR: Error <-8> in function call
> [src/scip/scip.c:1967] ERROR: Error <-8> in function call
> [src/scip/heur_rens.c:393] ERROR: Error <-8> in function call
> [src/scip/heur_rens.c:696] ERROR: Error <-8> in function call
> [src/scip/heur.c:398] ERROR: Error <-8> in function call
> [src/scip/solve.c:241] ERROR: Error <-8> in function call
> [src/scip/solve.c:3328] ERROR: Error <-8> in function call
> [src/scip/solve.c:3879] ERROR: Error <-8> in function call
> [src/scip/scip.c:7543] ERROR: Error <-8> in function call
> [src/scip/scipshell.c:135] ERROR: Error <-8> in function call
> [src/scip/scipshell.c:341] ERROR: Error <-8> in function call
> [src/cppmain.cpp:85] ERROR: Error <-8> in function call
> SCIP Error (-8): method cannot be called at this time in solution process
>
> Do I also have to implement the scip_trans callback?
>
>   Daniel
>
> P.S.: By the way, I think the documentation does not make it very clear
> when the transformed variables have to be used ...
>
>
>
> 2011/12/20 Robert Schwarz <schwarz at zib.de>
>
>> Hi Daniel
>>
>> On 12/20/2011 11:17 AM, Daniel Karch wrote:
>> > src/scip/scip.c:1422: SCIPcopyVars: Assertion
>> `SCIPgetNIntVars(sourcescip)
>> > + SCIPgetNBinVars(sourcescip) <= SCIPgetNIntVars(targetscip) +
>> > SCIPgetNBinVars(targetscip) && SCIPgetNIntVars(targetscip) +
>> > SCIPgetNBinVars(targetscip) <= SCIPgetNIntVars(sourcescip) +
>> > SCIPgetNBinVars(sourcescip) + nfixedbinvars + nfixedintvars' failed.
>> >
>> > I get
>> >
>> > SCIPgetNIntVars(sourcescip) + SCIPgetNBinVars(sourcescip) +
>> nfixedbinvars +
>> > nfixedintvars == 25093
>> >
>> > and
>> >
>> > SCIPgetNIntVars(targetscip) + SCIPgetNBinVars(targetscip) == 27366
>> >
>> > After the presolving, the problem has 2273 binary variables, which is
>> > exactly the difference here.
>> > I figured out that the problem occurs in scip.c, l. 1966:
>> >
>> > /* create problem in the target SCIP and copying the source problem
>> data */
>> > SCIP_CALL( SCIPcopyProb(sourcescip, targetscip, localvarmap,
>> localconsmap,
>> > global, name) );
>> >
>> > /* copy all active variables */
>> > SCIP_CALL( SCIPcopyVars(sourcescip, targetscip, localvarmap,
>> localconsmap,
>> > global) );
>> >
>> > The call to SCIPcopyProb() calls my scip_copy() callback and copies all
>> the
>> > variables, and the subsequent call to SCIPcopyVars() copies the active
>> > variables *again*.
>> > Now I don't really know what to do. The TSP example is the only one I am
>> > aware of that implements the scip_copy() callback in the ProbData class,
>> > and I did it just like it is
>> > done there.
>> >
>> > Any suggestions?
>>
>> I just had the same problem. In your copy method of your ProbData class,
>> you probably copy the variables of the original problem, whereas the
>> SCIPcopyVars() line copies the variables of the transformed problem.
>> This also explains the difference in cardinality.
>>
>> Otherwise SCIPgetVarCopy() can figure out which variables have already
>> been copied.
>>
>> I suggest you also copy the transformed variables in your probdata,
>> using SCIPgetTransformedVar.
>>
>> Hope that helps.
>>
>> --
>> Robert Schwarz
>> schwarz at zib.de
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserv.zib.de/mailman/private/scip/attachments/20111220/72402761/attachment.html


More information about the Scip mailing list