Skip to content

Commit

Permalink
Merge branch 'resolve' into 'master'
Browse files Browse the repository at this point in the history
Resolve copy fix

See merge request integer/scip!3601
  • Loading branch information
svigerske committed Dec 1, 2024
2 parents 85352a1 + 77a7d77 commit 7704113
Show file tree
Hide file tree
Showing 17 changed files with 503 additions and 188 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Fixed bugs
- check variable cancellation in SCIPvarAddVlb() and SCIPvarAddVub() to avert wrong infeasibility
- SCIPfreeReoptSolve now also clears the partial solutions
- fixed bug in calculation of "fractionality score" for spatial branching candidates in cons_nonlinear
- add copy callbacks for default plugins presolver dualagg, presolver redvub, branchrule lookahead, branchrule cloud, heuristic dualval, heuristic repair, propagator nlobbt, separator gauge, and separator convexproj missing in SCIPsetCopyPlugins()

Unit tests
----------
Expand Down
15 changes: 15 additions & 0 deletions src/scip/branch_cloud.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ struct SCIP_BranchruleData
* Callback methods of branching rule
*/

/** copy method for branchrule plugins (called when SCIP copies plugins) */
static
SCIP_DECL_BRANCHCOPY(branchCopyCloud)
{ /*lint --e{715}*/
assert(scip != NULL);
assert(branchrule != NULL);
assert(strcmp(SCIPbranchruleGetName(branchrule), BRANCHRULE_NAME) == 0);

/* call inclusion method of branchrule */
SCIP_CALL( SCIPincludeBranchruleCloud(scip) );

return SCIP_OKAY;
}

/** destructor of branching rule to free user data (called when SCIP is exiting) */
static
SCIP_DECL_BRANCHFREE(branchFreeCloud)
Expand Down Expand Up @@ -704,6 +718,7 @@ SCIP_RETCODE SCIPincludeBranchruleCloud(
assert(branchrule != NULL);

/* set non-fundamental callbacks via setter functions */
SCIP_CALL( SCIPsetBranchruleCopy(scip, branchrule, branchCopyCloud) );
SCIP_CALL( SCIPsetBranchruleFree(scip, branchrule, branchFreeCloud) );
SCIP_CALL( SCIPsetBranchruleInit(scip, branchrule, branchInitCloud) );
SCIP_CALL( SCIPsetBranchruleExecLp(scip, branchrule, branchExeclpCloud) );
Expand Down
3 changes: 3 additions & 0 deletions src/scip/branch_lookahead.c
Original file line number Diff line number Diff line change
Expand Up @@ -5830,6 +5830,9 @@ SCIP_DECL_BRANCHCOPY(branchCopyLookahead)
assert(branchrule != NULL);
assert(strcmp(SCIPbranchruleGetName(branchrule), BRANCHRULE_NAME) == 0);

/* call inclusion method of branchrule */
SCIP_CALL( SCIPincludeBranchruleLookahead(scip) );

return SCIP_OKAY;
}

Expand Down
2 changes: 1 addition & 1 deletion src/scip/event_solvingphase.c
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ void testCriteria(
*/

/** copy method for event handler (called when SCIP copies plugins) */
/* todo this code needs to stay disabled as long as the soft limit event handler is not copied, because we save
/* @todo: this code needs to stay disabled as long as the soft limit event handler is not copied, because we save
* the soft time limit parameter but this will crash as soon as we are in a SCIP copy */
#ifdef SCIP_DISABLED_CODE
static
Expand Down
18 changes: 17 additions & 1 deletion src/scip/heur_dualval.c
Original file line number Diff line number Diff line change
Expand Up @@ -2512,8 +2512,23 @@ SCIP_RETCODE SCIPapplyHeurDualval(
return SCIP_OKAY;
}

/*
* Callback methods of primal heuristic
*/

/** copy method for primal heuristic plugins (called when SCIP copies plugins) */
static
SCIP_DECL_HEURCOPY(heurCopyDualval)
{ /*lint --e{715}*/
assert(scip != NULL);
assert(heur != NULL);
assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);

/* call inclusion method of primal heuristic */
SCIP_CALL( SCIPincludeHeurDualval(scip) );

/* Callback methods of primal heuristic */
return SCIP_OKAY;
}

/** destructor of primal heuristic to free user data (called when SCIP is exiting) */
static
Expand Down Expand Up @@ -2811,6 +2826,7 @@ SCIP_RETCODE SCIPincludeHeurDualval(
assert(heur != NULL);

/* set non fundamental callbacks via setter functions */
SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyDualval) );
SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeDualval) );
SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitDualval) );
SCIP_CALL( SCIPsetHeurExit(scip, heur, heurExitDualval) );
Expand Down
16 changes: 15 additions & 1 deletion src/scip/heur_repair.c
Original file line number Diff line number Diff line change
Expand Up @@ -1032,11 +1032,24 @@ SCIP_RETCODE applyRepair(
return SCIP_OKAY;
}


/*
* Callback methods of primal heuristic
*/

/** copy method for primal heuristic plugins (called when SCIP copies plugins) */
static
SCIP_DECL_HEURCOPY(heurCopyRepair)
{ /*lint --e{715}*/
assert(scip != NULL);
assert(heur != NULL);
assert(strcmp(SCIPheurGetName(heur), HEUR_NAME) == 0);

/* call inclusion method of primal heuristic */
SCIP_CALL( SCIPincludeHeurRepair(scip) );

return SCIP_OKAY;
}

/** destructor of primal heuristic to free user data (called when SCIP is exiting) */
static
SCIP_DECL_HEURFREE(heurFreeRepair)
Expand Down Expand Up @@ -1307,6 +1320,7 @@ SCIP_RETCODE SCIPincludeHeurRepair(
assert(heurdata != NULL);

/* set non fundamental callbacks via setter functions */
SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyRepair) );
SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeRepair) );
SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitRepair) );
SCIP_CALL( SCIPsetHeurExit(scip, heur, heurExitRepair) );
Expand Down
17 changes: 17 additions & 0 deletions src/scip/presol_dualagg.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "scip/presol_dualagg.h"
#include "scip/pub_matrix.h"
#include "scip/pub_message.h"
#include "scip/pub_presol.h"
#include "scip/pub_var.h"
#include "scip/scip_general.h"
#include "scip/scip_mem.h"
Expand Down Expand Up @@ -492,6 +493,19 @@ SCIP_RETCODE findDownlockAggregations(
* Callback methods of presolver
*/

/** copy method for presolver plugins (called when SCIP copies plugins) */
static
SCIP_DECL_PRESOLCOPY(presolCopyDualagg)
{ /*lint --e{715}*/
assert(scip != NULL);
assert(presol != NULL);
assert(strcmp(SCIPpresolGetName(presol), PRESOL_NAME) == 0);

/* call inclusion method of presolver */
SCIP_CALL( SCIPincludePresolDualagg(scip) );

return SCIP_OKAY;
}

/** execution method of presolver */
static
Expand Down Expand Up @@ -628,5 +642,8 @@ SCIP_RETCODE SCIPincludePresolDualagg(
SCIP_CALL( SCIPincludePresolBasic(scip, &presol, PRESOL_NAME, PRESOL_DESC, PRESOL_PRIORITY, PRESOL_MAXROUNDS,
PRESOL_TIMING, presolExecDualagg, NULL) );

/* set non fundamental callbacks via setter functions */
SCIP_CALL( SCIPsetPresolCopy(scip, presol, presolCopyDualagg) );

return SCIP_OKAY;
}
18 changes: 17 additions & 1 deletion src/scip/presol_redvub.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "scip/presol_redvub.h"
#include "scip/pub_matrix.h"
#include "scip/pub_message.h"
#include "scip/pub_presol.h"
#include "scip/pub_var.h"
#include "scip/scip_cons.h"
#include "scip/scip_general.h"
Expand Down Expand Up @@ -552,11 +553,23 @@ SCIP_RETCODE findVarAggrRedVbcons(
return SCIP_OKAY;
}


/*
* Callback methods of presolver
*/

/** copy method for presolver plugins (called when SCIP copies plugins) */
static
SCIP_DECL_PRESOLCOPY(presolCopyRedvub)
{ /*lint --e{715}*/
assert(scip != NULL);
assert(presol != NULL);
assert(strcmp(SCIPpresolGetName(presol), PRESOL_NAME) == 0);

/* call inclusion method of presolver */
SCIP_CALL( SCIPincludePresolRedvub(scip) );

return SCIP_OKAY;
}

/** execution method of presolver */
static
Expand Down Expand Up @@ -700,5 +713,8 @@ SCIP_RETCODE SCIPincludePresolRedvub(
SCIP_CALL( SCIPincludePresolBasic(scip, &presol, PRESOL_NAME, PRESOL_DESC, PRESOL_PRIORITY, PRESOL_MAXROUNDS,
PRESOL_TIMING, presolExecRedvub, NULL) );

/* set non fundamental callbacks via setter functions */
SCIP_CALL( SCIPsetPresolCopy(scip, presol, presolCopyRedvub) );

return SCIP_OKAY;
}
16 changes: 16 additions & 0 deletions src/scip/prop_nlobbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,20 @@ SCIP_RETCODE applyNlobbt(
* Callback methods of propagator
*/

/** copy method for propagating plugins (called when SCIP copies plugins) */
static
SCIP_DECL_PROPCOPY(propCopyNlobbt)
{ /*lint --e{715}*/
assert(scip != NULL);
assert(prop != NULL);
assert(strcmp(SCIPpropGetName(prop), PROP_NAME) == 0);

/* call inclusion method of propagator */
SCIP_CALL( SCIPincludePropNlobbt(scip) );

return SCIP_OKAY;
}

/** destructor of propagator to free user data (called when SCIP is exiting) */
static
SCIP_DECL_PROPFREE(propFreeNlobbt)
Expand Down Expand Up @@ -738,6 +752,8 @@ SCIP_RETCODE SCIPincludePropNlobbt(
propExecNlobbt, propdata) );
assert(prop != NULL);

/* set non fundamental callbacks via setter functions */
SCIP_CALL( SCIPsetPropCopy(scip, prop, propCopyNlobbt) );
SCIP_CALL( SCIPsetPropFree(scip, prop, propFreeNlobbt) );
SCIP_CALL( SCIPsetPropInitsol(scip, prop, propInitsolNlobbt) );
SCIP_CALL( SCIPsetPropExitsol(scip, prop, propExitsolNlobbt) );
Expand Down
4 changes: 2 additions & 2 deletions src/scip/scip_copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2830,8 +2830,8 @@ SCIP_RETCODE doCopy(
}

/** copies source SCIP to target SCIP; the copying process is done in the following order:
* 1) copy the plugins
* 2) copy the settings
* 1) copy those plugins that have copy callbacks
* 2) copy the settings for the present parameters
* 3) create problem data in target-SCIP and copy the problem data of the source-SCIP
* 4) copy all active variables except those that are marked as relaxation-only
* 5) copy all constraints
Expand Down
6 changes: 3 additions & 3 deletions src/scip/scip_copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -949,10 +949,10 @@ void SCIPsetSubscipDepth(
);

/** copies source SCIP to target SCIP; the copying process is done in the following order:
* 1) copy the plugins
* 2) copy the settings
* 1) copy those plugins that have copy callbacks
* 2) copy the settings for the present parameters
* 3) create problem data in target-SCIP and copy the problem data of the source-SCIP
* 4) copy all active variables except those are marked as relaxation-only
* 4) copy all active variables except those that are marked as relaxation-only
* 5) copy all constraints
*
* The source problem depends on the stage of the \p sourcescip - In SCIP_STAGE_PROBLEM, the original problem is copied,
Expand Down
Loading

0 comments on commit 7704113

Please sign in to comment.