Skip to content

Commit 06cd905

Browse files
committed
Merge remote-tracking branch 'origin/v10-minor'
2 parents bf8b831 + ca30591 commit 06cd905

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+358
-410
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ Fixed bugs
398398
- skip attempting to free transformed problem if SCIPtransformProb() failed with an error in SCIPpresolve(), since freeing
399399
the transformed problem is likely to fail as well
400400
- fixed memory leak in primal heuristic scheduler when there is a restart
401+
- fixed stopping when there is a candidate with a change in the LP bound for both children in strong branching of branch_fullstrong
402+
- fixed detection of sinks in varbound detection from cumulative constraints
403+
- fixed memory allocation when adding strong SBCs for enclosing orbit of symmetric subgroups (disabled by default)
401404

402405
Build system
403406
------------
@@ -406,6 +409,8 @@ Build system
406409

407410
### Makefile
408411

412+
- added experimental target to run cppcheck
413+
409414
Miscellaneous
410415
-------------
411416

INSTALL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ The SCIP makefile supports several targets (used via `make ... "target"`):
592592
| `depend` | Updates dependencies files. This is only needed if you add checks for preprocessor-defines `WITH_*` in source files. |
593593
| `check` | or `test`. Runs the check script. |
594594
| `lint` | Statically checks the code via flexelint. The call produces the file `lint.out` which contains all the detected warnings. |
595+
| `cppcheck` | Statically checks the code via cppcheck. The call produces the file `cppcheck.log` which contains the cppcheck output. |
595596
| `tags` | Generates tags which can be used in the editor **emacs** and **xemacs**. |
596597

597598
The SCIP makefiles are structured as follows.

Makefile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ SYMOBJFILES = $(addprefix $(LIBOBJDIR)/,$(SYMOBJ))
417417
SYMSRC = $(addprefix $(SRCDIR)/,$(SYMOBJ:.o=.c))
418418
LINTSYMSRC = $(addprefix $(SRCDIR)/,$(SYMOBJ:.o=.c))
419419
ifeq ($(NAUTYEXTERNAL),false)
420-
FLAGS += -I$(SRCDIR)/nauty/src -I$(SRCDIR)/nauty/include
421420
LIBOBJSUBDIRS += $(LIBOBJDIR)/nauty
422421
NAUTYOBJ = nauty/nauty.o
423422
NAUTYOBJ += nauty/nautil.o
@@ -448,7 +447,6 @@ SYMOBJFILES = $(addprefix $(LIBOBJDIR)/,$(SYMOBJ))
448447
SYMSRC = $(addprefix $(SRCDIR)/,$(SYMOBJ:.o=.cpp))
449448
LINTSYMSRC = $(addprefix $(SRCDIR)/,$(SYMOBJ:.o=.cpp))
450449
ifeq ($(NAUTYEXTERNAL),false)
451-
FLAGS += -I$(SRCDIR)/nauty/src -I$(SRCDIR)/nauty/include
452450
LIBOBJSUBDIRS += $(LIBOBJDIR)/nauty
453451
NAUTYOBJ = nauty/nauty.o
454452
NAUTYOBJ += nauty/nautil.o
@@ -1270,6 +1268,21 @@ else
12701268
$(SHELL) -c '$(SPLINT) -I$(SRCDIR) -I/usr/include/linux $(FLAGS) $(SPLINTFLAGS) $(filter %.c %.h,$(FILES)) >> splint.out;'
12711269
endif
12721270

1271+
CPPCHECKARGS := $(filter -I%,$(FLAGS))
1272+
CPPCHECKARGS += -j8
1273+
CPPCHECKARGS += --std=c99 --std=c++14
1274+
CPPCHECKARGS += --suppressions-list=suppressions.cppcheck --inline-suppr
1275+
CPPCHECKARGS += --enable=all --force --inconclusive
1276+
CPPCHECKARGS += --error-exitcode=5
1277+
.PHONY: cppcheck
1278+
cppcheck: $(SCIPLIBBASESRC) $(OBJSCIPLIBSRC) $(LPILIBSRC) $(TPILIBSRC) $(MAINSRC) $(SYMSRC) $(SCIPCONFIGHFILE) $(SCIPEXPORTHFILE) $(SCIPBUILDFLAGSFILE) githash
1279+
-rm -f cppcheck.log
1280+
ifeq ($(FILES),)
1281+
cppcheck $(CPPCHECKARGS) $^ 2>&1 | tee cppcheck.log
1282+
else
1283+
cppcheck $(CPPCHECKARGS) $(FILES) 2>&1 | tee cppcheck.log
1284+
endif
1285+
12731286
.PHONY: doc
12741287
doc:
12751288
cd doc; $(SHELL) builddoc.sh;
@@ -2004,6 +2017,7 @@ help:
20042017
@echo " - lint: Run lint on all SCIP files. (Needs flexelint.)"
20052018
@echo " - pclint: Run pclint on all SCIP files. (Needs pclint.)"
20062019
@echo " - splint: Run splint on all C SCIP files. (Needs splint.)"
2020+
@echo " - cppcheck: Run cppcheck on SCIP source files. (Needs cppcheck.)"
20072021
@echo " - clean: Removes all object files."
20082022
@echo " - cleanlibs: Remove all SCIP libraries."
20092023
@echo " - tags: Creates TAGS file that can be used in (x)emacs."

src/blockmemshell/memory.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,10 +1524,11 @@ void BMSclearChunkMemory_call(
15241524
int line /**< line number in source file of the function call */
15251525
)
15261526
{
1527-
debugMessage("clearing chunk memory %p [elemsize: %d]\n", (void*)chkmem, chkmem->elemsize);
1528-
15291527
if( chkmem != NULL )
1528+
{
1529+
debugMessage("clearing chunk memory %p [elemsize: %d]\n", (void*)chkmem, chkmem->elemsize);
15301530
clearChkmem(chkmem, NULL);
1531+
}
15311532
else
15321533
{
15331534
printErrorHeader(filename, line);
@@ -1544,10 +1545,11 @@ void BMSdestroyChunkMemory_call(
15441545
{
15451546
assert(chkmem != NULL);
15461547

1547-
debugMessage("destroying chunk memory %p [elemsize: %d]\n", (void*)*chkmem, (*chkmem)->elemsize);
1548-
15491548
if( *chkmem != NULL )
1549+
{
1550+
debugMessage("destroying chunk memory %p [elemsize: %d]\n", (void*)*chkmem, (*chkmem)->elemsize);
15501551
destroyChkmem(chkmem, NULL);
1552+
}
15511553
else
15521554
{
15531555
printErrorHeader(filename, line);
@@ -2442,7 +2444,7 @@ void BMSdisplayBlockMemory_call(
24422444
totalnelems > 0 ? 100.0 * (double) (totalneagerelems + totalnlazyelems) / (double) (totalnelems) : 0.0,
24432445
(double)allocedmem/(1024.0*1024.0));
24442446
#endif
2445-
printInfo("%d blocks (%d unused), %" LONGINT_FORMAT " bytes allocated, %" LONGINT_FORMAT " bytes free",
2447+
printInfo("%d blocks (%d unused), %" LONGINT_FORMAT " bytes allocated, %" LONGINT_FORMAT " bytes free", /* cppcheck-suppress syntaxError */
24462448
nblocks + nunusedblocks, nunusedblocks, allocedmem, freemem);
24472449
if( allocedmem > 0 )
24482450
printInfo(" (%.1f%%)", 100.0 * (double) freemem / (double) allocedmem);
@@ -2696,7 +2698,6 @@ void* BMSallocBufferMemory_work(
26962698
int line /**< line number in source file of the function call */
26972699
)
26982700
{
2699-
/* cppcheck-suppress unassignedVariable */
27002701
void* ptr;
27012702
#ifndef SCIP_NOBUFFERMEM
27022703
size_t bufnum;

src/blockmemshell/memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ size_t BMSgetNUsedBufferMemory(
878878
/** returns the number of allocated bytes in the buffer memory */
879879
SCIP_EXPORT
880880
long long BMSgetBufferMemoryUsed(
881-
const BMS_BUFMEM* bufmem /**< buffer memory */
881+
const BMS_BUFMEM* buffer /**< buffer memory */
882882
);
883883

884884
/** outputs statistics about currently allocated buffers to the screen */

src/scip/bandit_ucb.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ SCIP_DECL_BANDITSELECT(SCIPbanditSelectUcb)
177177
assert(meanscores != NULL);
178178

179179
/* compute the confidence width factor that is common for all actions */
180-
/* cppcheck-suppress unpreciseMathCall */
181180
widthfactor = banditdata->alpha * LOG1P((SCIP_Real)banditdata->nselections);
182181
widthfactor = sqrt(widthfactor);
183182
maxucb = -1.0;
@@ -283,7 +282,6 @@ SCIP_Real SCIPgetConfidenceBoundUcb(
283282
assert(banditdata->counter[action] > 0);
284283
uppercb = banditdata->meanscores[action];
285284

286-
/* cppcheck-suppress unpreciseMathCall */
287285
uppercb += sqrt(banditdata->alpha * LOG1P((SCIP_Real)banditdata->nselections) / (SCIP_Real)banditdata->counter[action]);
288286

289287
return uppercb;

src/scip/benders.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,19 +1978,17 @@ SCIP_RETCODE checkSubproblemConvexity(
19781978
SCIPbendersSetSubproblemType(benders, probnumber, SCIP_BENDERSSUBTYPE_NONCONVEXDIS);
19791979
else
19801980
SCIPABORT();
1981-
}
19821981

1983-
/* setting the non-linear subproblem flag */
1984-
if( probnumber >= 0 )
1982+
/* setting the non-linear subproblem flag */
19851983
SCIPbendersSetSubproblemIsNonlinear(benders, probnumber, isnonlinear);
1986-
else
1987-
SCIPbendersSetMasterIsNonlinear(benders, isnonlinear);
19881984

1989-
if( probnumber >= 0 )
1990-
{
19911985
SCIPsetDebugMsg(set, "subproblem <%s> has been found to be of type %d\n", SCIPgetProbName(subproblem),
19921986
SCIPbendersGetSubproblemType(benders, probnumber));
19931987
}
1988+
else
1989+
{
1990+
SCIPbendersSetMasterIsNonlinear(benders, isnonlinear);
1991+
}
19941992

19951993
/* releasing the fixed variable hashmap */
19961994
if( assumevarfixed != NULL )
@@ -2586,15 +2584,13 @@ SCIP_RETCODE checkSubproblemIndependence(
25862584
/* looping over all subproblems to check whether there exists at least one master problem variable */
25872585
for( i = 0; i < nsubproblems; i++ )
25882586
{
2589-
SCIP_Bool independent = FALSE;
2590-
25912587
/* if there are user defined solving or freeing functions, then it is not possible to declare the independence of
25922588
* the subproblems.
25932589
*/
25942590
if( benders->benderssolvesubconvex == NULL && benders->benderssolvesub == NULL
25952591
&& benders->bendersfreesub == NULL )
25962592
{
2597-
independent = TRUE;
2593+
SCIP_Bool independent = TRUE;
25982594

25992595
for( j = 0; j < nvars; j++ )
26002596
{
@@ -3501,7 +3497,7 @@ SCIP_RETCODE solveBendersSubproblems(
35013497
*/
35023498
if( solveloop == SCIP_BENDERSSOLVELOOP_CIP )
35033499
{
3504-
if( convexsub || (*substatus)[i] == SCIP_BENDERSSUBSTATUS_INFEAS )
3500+
if( convexsub )
35053501
solvesub = FALSE;
35063502
else
35073503
{

src/scip/benders.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ SCIP_RETCODE SCIPbendersCopyInclude(
6060
SCIP_SET* targetset, /**< SCIP_SET of SCIP to copy to */
6161
SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
6262
* target variables; must not be NULL */
63-
SCIP_Bool copysubproblems, /**< must the subproblems be copied with the Benders' decomposition copy */
63+
SCIP_Bool threadsafe, /**< must the Benders' decomposition copy be thread safe */
6464
SCIP_Bool* valid /**< was the copying process valid? */
6565
);
6666

@@ -181,7 +181,7 @@ SCIP_RETCODE SCIPbendersExecSubproblemSolve(
181181
SCIP_BENDERS* benders, /**< Benders' decomposition */
182182
SCIP_SET* set, /**< global SCIP settings */
183183
SCIP_SOL* sol, /**< primal CIP solution */
184-
int probnum, /**< the subproblem number */
184+
int probnumber, /**< the subproblem number */
185185
SCIP_BENDERSSOLVELOOP solveloop, /**< the solve loop iteration. The first iter is for LP, the second for IP */
186186
SCIP_Bool enhancement, /**< is the solve performed as part of an enhancement? */
187187
SCIP_Bool* solved, /**< flag to indicate whether the subproblem was solved */

src/scip/branch_fullstrong.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ SCIP_RETCODE SCIPselectVarStrongBranching(
305305
* cycle through the candidates, starting with the position evaluated in the last run
306306
*/
307307
nsbcalls = 0;
308-
bothgains = TRUE;
308+
bothgains = FALSE;
309309
for( i = 0, c = *start; i < nlpcands && (!bothgains || i < ncomplete); ++i, ++c )
310310
{
311311
c = c % nlpcands;

src/scip/branch_gomory.c

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ struct SCIP_BranchruleData
118118
* to that form. Specifically, non-basic variables at their lower bound are shifted so that the lower
119119
* bound is 0 and non-basic at their upper bound are complemented. */
120120
static
121-
SCIP_Bool getGMIFromRow(
121+
void getGMIFromRow(
122122
SCIP* scip, /**< SCIP data structure */
123123
int ncols, /**< Number of columns (original variables) in the LP */
124124
int nrows, /**< Number of rows (slack variables) in the LP */
@@ -334,8 +334,6 @@ SCIP_Bool getGMIFromRow(
334334
}
335335
}
336336
}
337-
338-
return TRUE;
339337
}
340338

341339

@@ -397,7 +395,6 @@ SCIP_DECL_BRANCHEXECLP(branchExeclpGomory)
397395
SCIP_Real cutrhs;
398396
SCIP_Real score;
399397
SCIP_Real bestscore;
400-
SCIP_Bool success;
401398
int nlpcands;
402399
int maxncands;
403400
int ncols;
@@ -506,38 +503,34 @@ SCIP_DECL_BRANCHEXECLP(branchExeclpGomory)
506503
SCIP_CALL( SCIPgetLPBInvARow(scip, basicvarpos2tableaurow[lppos], binvrow, binvarow, inds, &ninds) );
507504

508505
/* Compute the GMI cut */
509-
success = getGMIFromRow(scip, ncols, nrows, cols, rows, binvrow, binvarow, &lpcandssol[i], cutcoefs,
506+
getGMIFromRow(scip, ncols, nrows, cols, rows, binvrow, binvarow, &lpcandssol[i], cutcoefs,
510507
&cutrhs, branchruledata->useweakercuts);
511508

512509
/* Calculate the weighted sum score of measures */
513-
if ( success )
510+
cut = NULL;
511+
SCIP_CALL( SCIPcreateEmptyRowUnspec(scip, &cut, name, -SCIPinfinity(scip), cutrhs, TRUE, FALSE, TRUE) );
512+
for( j = 0; j < ncols; ++j )
514513
{
515-
cut = NULL;
516-
SCIP_CALL( SCIPcreateEmptyRowUnspec(scip, &cut, name, -SCIPinfinity(scip), cutrhs, TRUE,
517-
FALSE, TRUE) );
518-
for( j = 0; j < ncols; ++j )
514+
if( !SCIPisZero(scip, cutcoefs[j]) )
519515
{
520-
if( !SCIPisZero(scip, cutcoefs[j]) )
521-
{
522-
SCIP_CALL( SCIPaddVarToRow(scip, cut, SCIPcolGetVar(cols[j]),
523-
cutcoefs[SCIPcolGetLPPos(cols[j])]) );
524-
}
525-
}
526-
assert( SCIPgetCutEfficacy(scip, NULL, cut) >= -SCIPfeastol(scip) );
527-
if ( branchruledata-> efficacyweight != 0 )
528-
score += branchruledata->efficacyweight * SCIPgetCutEfficacy(scip, NULL, cut);
529-
if ( branchruledata->objparallelweight != 0 )
530-
score += branchruledata->objparallelweight * SCIPgetRowObjParallelism(scip, cut);
531-
if ( branchruledata->intsupportweight != 0 )
532-
score += branchruledata->intsupportweight * SCIPgetRowNumIntCols(scip, cut) / (SCIP_Real) SCIProwGetNNonz(cut);
533-
SCIP_CALL( SCIPreleaseRow(scip, &cut) );
534-
535-
/* Replace the best cut if score is higher */
536-
if (score > bestscore) {
537-
bestscore = score;
538-
bestcand = i;
516+
SCIP_CALL( SCIPaddVarToRow(scip, cut, SCIPcolGetVar(cols[j]), cutcoefs[SCIPcolGetLPPos(cols[j])]) );
539517
}
540518
}
519+
assert( SCIPgetCutEfficacy(scip, NULL, cut) >= -SCIPfeastol(scip) );
520+
if ( branchruledata-> efficacyweight != 0 )
521+
score += branchruledata->efficacyweight * SCIPgetCutEfficacy(scip, NULL, cut);
522+
if ( branchruledata->objparallelweight != 0 )
523+
score += branchruledata->objparallelweight * SCIPgetRowObjParallelism(scip, cut);
524+
if ( branchruledata->intsupportweight != 0 )
525+
score += branchruledata->intsupportweight * SCIPgetRowNumIntCols(scip, cut) / (SCIP_Real) SCIProwGetNNonz(cut);
526+
SCIP_CALL( SCIPreleaseRow(scip, &cut) );
527+
528+
/* Replace the best cut if score is higher */
529+
if (score > bestscore)
530+
{
531+
bestscore = score;
532+
bestcand = i;
533+
}
541534
}
542535

543536
/* Free temporary memory */

0 commit comments

Comments
 (0)