All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
How to add propagators Propagators are used to tighten the domains of the variables. Like for cutting planes, there are two different types of domain propagations. Constraint based (primal) domain propagation algorithms are part of the corresponding constraint handlers, see CONSPROP. In contrast, domain propagators usually provide dual propagations, i.e., propagations that can be applied using the objective function and the current best known primal solution. This section deals with such propagators. A complete list of all propagators contained in this release can be found here. We now explain how users can add their own propagators. Take the pseudo objective function propagator (src/scip/prop_pseudoobj.c) as an example. As all other default plugins, it is written in C. C++ users can easily adapt the code by using the scip::ObjProp wrapper base class and implement the Additional documentation for the callback methods of a propagator can be found in the file type_prop.h. Here is what you have to do to implement a propagator:
Properties of a PropagatorAt the top of the new file "prop_mypropagator.c" you can find the propagator properties. These are given as compiler defines. The presolving-related properties are optional, they only have to be defined if the propagator supports presolving routines. In the C++ wrapper class, you have to provide the propagator properties by calling the constructor of the abstract base class scip::ObjProp from within your constructor. The properties you have the following meaning: Fundamental properties of a propagator
Optional propagator propertiesThe following properties are optional and only need to be defined if the propagator supports presolving, that is, if the presolving callback is implemented.
Propagator DataBelow the title "Data structures" you can find a struct called Interface MethodsAt the bottom of "prop_mypropagator.c", you can find the interface method SCIPincludeSepaMypropagator(), which also appears in "prop_mypropagator.h" SCIPincludePropMypropagator() is called by the user, if (s)he wants to include the propagator, i.e., if (s)he wants to use the propagator in his/her application. This method only has to be adjusted slightly. It is responsible for notifying SCIP of the presence of the propagator. For this, you can either call SCIPincludeProp(), or SCIPincludePropBasic() since SCIP version 3.0. In the latter variant, additional callbacks must be added via setter functions as, e.g., SCIPsetPropCopy(). We recommend this latter variant because it is more stable towards future SCIP versions which might have more callbacks, whereas source code using the first variant must be manually adjusted with every SCIP release containing new callbacks for separators in order to compile. If you are using propagator data, you have to allocate the memory for the data at this point. You can do this by calling SCIP_CALL( SCIPallocMemory(scip, &propdata) );
You also have to initialize the fields in You may also add user parameters for your propagator, see the method SCIPincludePropPseudoobj() in src/scip/prop_pseudoobj.c for an example. Fundamental Callback Methods of a PropagatorThe fundamental callback methods of the plugins are the ones that have to be implemented in order to obtain an operational algorithm. They are passed together with the propagator itself to SCIP using SCIPincludeProp() or SCIPincludePropBasic(), see Interface Methods. Propagator plugins have one fundamental callback method, namely the PROPEXEC method method. This method has to be implemented for every propagator; the other callback methods are optional. In the C++ wrapper class scip::ObjProp, the scip_exec() method (which corresponds to the PROPEXEC callback) is a virtual abstract member function. You have to implement it in order to be able to construct an object of your propagator class. Additional documentation for the callback methods can be found in type_prop.h. PROPEXECThe PROPEXEC callback is called during presolving and during the subproblem processing. It should perform the actual domain propagation, which means that it should tighten the variables' bounds. The technique of domain propagation, which is the main workhorse of constraint programming, is called "node preprocessing" in the Integer Programming community. The PROPEXEC callback has the following options:
Additional Callback Methods of a PropagatorThe additional callback methods do not need to be implemented in every case. However, some of them have to be implemented for most applications, they can be used, for example, to initialize and free private data. Additional callbacks can either be passed directly with SCIPincludeProp() to SCIP or via specific setter functions after a call of SCIPincludePropBasic(), see also Interface Methods. PROPRESPROPIf the propagator wants to support conflict analysis, it has to supply the PROPRESPROP method. It also should call SCIPinferVarLbProp() or SCIPinferVarUbProp() in the domain propagation instead of SCIPchgVarLb() or SCIPchgVarUb() in order to deduce bound changes on variables. In the SCIPinferVarLbProp() and SCIPinferVarUbProp() calls, the propagator provides a pointer to itself and an integer value "inferinfo" that can be arbitrarily chosen. The propagation conflict resolving method PROPRESPROP must then be implemented to provide the "reasons" for the bound changes, i.e., the bounds of variables at the time of the propagation, which forced the propagator to set the conflict variable's bound to its current value. It can use the "inferinfo" tag to identify its own propagation rule and thus identify the "reason" bounds. The bounds that form the reason of the assignment must then be provided by calls to SCIPaddConflictLb() and SCIPaddConflictUb() in the propagation conflict resolving method. See the description of the propagation conflict resolving method CONSRESPROP of constraint handlers for further details. Omitting the PROPRESPROP callback circumvents the implementation of the usually rather complex conflict resolving method. Yet, it will make the conflict analysis less effective. We suggest to first omit the conflict resolving method and check how effective the propagation method is. If it produces a lot of propagations for your application, you definitely should consider implementing the conflict resolving method. PROPFREEIf you are using propagator data, you have to implement this method in order to free the propagator data. This can be done by the following procedure: static
SCIP_DECL_PROPFREE(propFreeMypropagator)
{
SCIP_PROPDATA* propdata;
propdata = SCIPpropGetData(prop);
assert(propdata != NULL);
SCIPfreeMemory(scip, &propdata);
SCIPpropSetData(prop, NULL);
return SCIP_OKAY;
}
If you have allocated memory for fields in your propagator data, remember to free this memory before freeing the propagator data itself. If you are using the C++ wrapper class, this method is not available. Instead, just use the destructor of your class to free the member variables of your class. PROPINITThe PROPINIT callback is executed after the problem is transformed. The propagator may, e.g., use this call to initialize its propagator data. PROPCOPYThe PROPCOPY callback is executed when a SCIP instance is copied, e.g. to solve a sub-SCIP. By defining this callback as PROPEXITThe PROPEXIT callback is executed before the transformed problem is freed. In this method, the propagator should free all resources that have been allocated for the solving process in PROPINIT. PROPINITPREThe PROPINITPRE callback is executed before the preprocessing is started, even if presolving is turned off. The propagator may use this call to initialize its presolving data before the presolving process begins. PROPEXITPREThe PROPEXITPRE callback is executed after the preprocessing has been finished, even if presolving is turned off. The propagator may use this call, e.g., to clean up its presolving data. Besides clean up, no time consuming operations should be done. PROPINITSOLThe PROPINITSOL callback is executed when the presolving is finished and the branch-and-bound process is about to begin. The propagator may use this call to initialize its branch-and-bound specific data. PROPEXITSOLThe PROPEXITSOL callback is executed before the branch-and-bound process is freed. The propagator should use this call to clean up its branch-and-bound data. PROPPRESOLSeaches for domain propagations, analogous to the PROPEXEC callback. However, this callback is called during preprocessing. To inform SCIP that the presolving method found a reduction the result pointer has to be set in a proper way. The following options are possible:
Please see also the Optional propagator properties section to learn about the properties PROP_PRESOL_PRIORITY, PROP_PRESOL_MAXROUNDS, and PROP_PRESOL_DELAY, which influence the behaviour of SCIP calling PROPPRESOL. |