1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2021 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15
16 /**@file depthlevel.c
17 * @brief Test for freeing SCIP if depth level has been reached
18 * @author Marc Pfetsch
19 */
20
21 /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22
23 #include <string.h>
24 #include <signal.h>
25 #include "scip/scip.h"
26 #include "scip/scipdefplugins.h"
27 #include "scip/dialog_default.h"
28
29 #include "include/scip_test.h"
30
31 #undef SCIP_CALL
32 #define SCIP_CALL(x) do \
33 { \
34 SCIP_RETCODE _restat_; \
35 if( (_restat_ = (x)) != SCIP_OKAY ) \
36 { \
37 cr_assert(FALSE, "Error <%d> in function call\n", _restat_); \
38 } \
39 } \
40 while( FALSE )
41
42 SCIP* scip;
43
44 /** create unbounded infeasible problem:
45 * min 0
46 * s.t. 1/4 <= x - y <= 3/4
47 * x,y \in Z
48 */
49 static
setup(void)50 void setup(void)
51 {
52 SCIP_CONS* cons;
53 SCIP_VAR* xvar;
54 SCIP_VAR* yvar;
55 SCIP_VAR* vars[2];
56 SCIP_Real vals[2];
57
58 /* initialize SCIP */
59 SCIP_CALL( SCIPcreate(&scip) );
60
61 /* include default plugins */
62 SCIP_CALL( SCIPincludeDefaultPlugins(scip) );
63
64 SCIP_CALL( SCIPcreateProbBasic(scip, "unittest-depthlevel") );
65
66 /* create variables */
67 SCIP_CALL( SCIPcreateVarBasic(scip, &xvar, "x", -SCIPinfinity(scip), SCIPinfinity(scip), 0.0, SCIP_VARTYPE_INTEGER) );
68 SCIP_CALL( SCIPcreateVarBasic(scip, &yvar, "y", -SCIPinfinity(scip), SCIPinfinity(scip), 0.0, SCIP_VARTYPE_INTEGER) );
69
70 SCIP_CALL( SCIPaddVar(scip, xvar) );
71 SCIP_CALL( SCIPaddVar(scip, yvar) );
72
73 /* create inequalities */
74 vars[0] = xvar;
75 vars[1] = yvar;
76
77 vals[0] = 1.0;
78 vals[1] = -1.0;
79
80 SCIP_CALL( SCIPcreateConsBasicLinear(scip, &cons, "lower", 2, vars, vals, 0.25, 0.75) );
81 SCIP_CALL( SCIPaddCons(scip, cons) );
82
83 SCIP_CALL( SCIPreleaseCons(scip, &cons) );
84 SCIP_CALL( SCIPreleaseVar(scip, &xvar) );
85 SCIP_CALL( SCIPreleaseVar(scip, &yvar) );
86
87 /*SCIP_CALL( SCIPprintOrigProblem(scip, NULL, NULL, FALSE) ); */
88 }
89
90
91 /** run unittest */
92 Test(depthlevel, hit_depth_limit, .description = "show problem when hitting depth level", .init = setup, .signal = SIGABRT)
93 {
94 SCIP_RETCODE retcode;
95
96 /* this test can only work in debug mode, so we make it pass in opt mode */
97 #ifdef NDEBUG
98 abort(); /* return SIGABORT */
99 #endif
100
101 /* turn off presolving */
102 SCIP_CALL( SCIPsetIntParam(scip, "presolving/maxrounds", 0) );
103
104 /* use DFS */
105 SCIP_CALL( SCIPsetIntParam(scip, "nodeselection/dfs/stdpriority", 10000000) );
106
107 SCIP_CALL( SCIPsetIntParam(scip, "display/freq", 10000) );
108
109 /* solve */
110 retcode = SCIPsolve(scip);
111 cr_expect(retcode == SCIP_OKAY || retcode == SCIP_MAXDEPTHLEVEL);
112
113 /* print statistics */
114 /* SCIP_CALL( SCIPprintStatistics(scip, NULL) ); */
115
116 /* free transformed problem */
117 SCIP_CALL( SCIPfreeTransform(scip) );
118
119 /* free SCIP */
120 SCIP_CALL( SCIPfree(&scip) );
121
122 /* check for memory leaks */
123 cr_assert_eq(BMSgetMemoryUsed(), 0, "There is are memory leak!!");
124 }
125