How to add decomposition scores
GCG uses scores to rate decompositions that are found by the detection. To continuously prefer different decompositions than GCG does by default with its set partitioning foreseeing max white score, you can program your own score.
A complete list of all scores contained in this release can be found here.
Adding your own Decomposition Score
With the following steps, we explain how you can add your own score to rate decompositions:
- Preparations
- Choose a name
myscore
for your decomposition score. - In the file class_partialdecomp.h, initialize your score:
- In the class
PARTIALDECOMP::PARTIALDECOMP(SCIP* _scip, ...)
, initialize it below the linebool originalProblem
by addingmyscore( -1. ),
. - In the class
PARTIALDECOMP::PARTIALDECOMP(const PARTIALDECOMP *partialdectocopy)
, add it to the partial decomposition to copy by addingmyscore = partialdectocopy->myscore;
- In the class
- [optional] In the function void PARTIALDECOMP::displayInfo(int detailLevel), add an output for the statistics for your score.
- Add a real variable
myscore
for your score to theclass PARTIALDECOMP
(below the section/* score values */
).
- Choose a name
- Creating your Score
In the file cons_decomp.cpp:- Write your score calculation function with the following signature (as an example, you can have a look at the
GCGconshdlrDecompCalcMaxWhiteScore()
function):SCIP_RETCODE GCGconshdlrDecompCalcMyScore(SCIP* scip,int partialdecid,SCIP_Real* score) - In the case switch in the function
PARTIALDECOMP::getScore(type)
in the file class_partialdecomp.h, add your calculation function. - Add a getter and a setter function
getMyScore()
andsetMyScore()
(as an example, take the functiongetMaxWhiteScore()
) in the file class_partialdecomp.h.
- Write your score calculation function with the following signature (as an example, you can have a look at the
- Make GCG use it
Add your score to- the arrays
scoretype_shortnames
andscoretype_descriptions
in the file scoretype.c. - the enum
scoretype
in the file type_scoretype.h. - the
struct Dec_Scores
in the file pub_decomp.h.
- the arrays