SCIP-SDP  2.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cons_savedsdpsettings.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of SCIPSDP - a solving framework for mixed-integer */
4 /* semidefinite programms based on SCIP. */
5 /* */
6 /* Copyright (C) 2011-2013 Discrete Optimization, TU Darmstadt */
7 /* EDOM, FAU Erlangen-Nürnberg */
8 /* 2014-2016 Discrete Optimization, TU Darmstadt */
9 /* */
10 /* */
11 /* This program is free software; you can redistribute it and/or */
12 /* modify it under the terms of the GNU Lesser General Public License */
13 /* as published by the Free Software Foundation; either version 3 */
14 /* of the License, or (at your option) any later version. */
15 /* */
16 /* This program is distributed in the hope that it will be useful, */
17 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
19 /* GNU Lesser General Public License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public License */
22 /* along with this program; if not, write to the Free Software */
23 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/
24 /* */
25 /* */
26 /* Based on SCIP - Solving Constraint Integer Programs */
27 /* Copyright (C) 2002-2016 Zuse Institute Berlin */
28 /* SCIP is distributed under the terms of the SCIP Academic Licence, */
29 /* see file COPYING in the SCIP distribution. */
30 /* */
31 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
32 
41 #include "cons_savedsdpsettings.h"
42 #include "scip/def.h" /* for SCIP_Real, _Bool, ... */
43 #include <string.h> /* for NULL, strcmp */
44 
45 /* turn off lint warnings for whole file: */
46 /*lint --e{788,818}*/
47 
48 /* constraint handler properties */
49 #define CONSHDLR_NAME "Savedsdpsettings"
50 #define CONSHDLR_DESC "constraint handler to store SDP settings for each node"
51 #define CONSHDLR_ENFOPRIORITY 0
52 #define CONSHDLR_CHECKPRIORITY 0
53 #define CONSHDLR_EAGERFREQ 100
55 #define CONSHDLR_NEEDSCONS TRUE
58 struct SCIP_ConsData
59 {
60  SCIP_SDPSOLVERSETTING settings;
61 };
62 
64 static
65 SCIP_DECL_CONSDELETE(consDeleteSavedsdpsettings)
66 { /*lint --e{715}*/
67  assert( scip != NULL );
68  assert( conshdlr != NULL );
69  assert( cons != NULL );
70  assert( consdata != NULL );
71  assert( *consdata != NULL );
72 
73  SCIPdebugMessage("Deleting store node data constraint: <%s>.\n", SCIPconsGetName(cons));
74 
75  SCIPfreeBlockMemory(scip, consdata);
76 
77  return SCIP_OKAY;
78 }
79 
80 
82 static
83 SCIP_DECL_CONSENFOLP(consEnfolpSavedsdpsettings)
84 {/*lint --e{715}*/
85  assert( scip != NULL );
86  assert( conshdlr != NULL );
87  assert( strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0 );
88  assert( result != NULL );
89 
90  /* do nothing */
91  *result = SCIP_FEASIBLE;
92 
93  return SCIP_OKAY;
94 }
95 
96 
98 static
99 SCIP_DECL_CONSENFOPS(consEnfopsSavedsdpsettings)
100 {/*lint --e{715}*/
101  assert( scip != NULL );
102  assert( conshdlr != NULL );
103  assert( strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0 );
104  assert( result != NULL );
105 
106  /* do nothing */
107  *result = SCIP_FEASIBLE;
108 
109  return SCIP_OKAY;
110 }
111 
112 
114 static
115 SCIP_DECL_CONSCHECK(consCheckSavedsdpsettings)
116 {/*lint --e{715}*/
117  assert( scip != NULL );
118  assert( conshdlr != NULL );
119  assert( strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0 );
120  assert( result != NULL );
121 
122  /* do nothing */
123  *result = SCIP_FEASIBLE;
124 
125  return SCIP_OKAY;
126 }
127 
128 
130 static
131 SCIP_DECL_CONSLOCK(consLockSavedsdpsettings)
132 {/*lint --e{715}*/
133  assert( scip != NULL );
134  assert( conshdlr != NULL );
135  assert( strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0 );
136 
137  /* do nothing */
138  return SCIP_OKAY;
139 }
140 
141 
143 static
144 SCIP_DECL_CONSHDLRCOPY(conshdlrCopySavedsdpsettings)
145 {
146  assert( scip != NULL );
147  assert( conshdlr != NULL );
148  assert( strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0 );
149  assert( valid != NULL );
150 
151  /* call inclusion method of constraint handler */
152  SCIP_CALL( SCIPincludeConshdlrSavedsdpsettings(scip) );
153 
154  *valid = TRUE;
155 
156  return SCIP_OKAY;
157 }
158 
159 
161 static
162 SCIP_DECL_CONSCOPY(consCopySavedsdpsettings)
163 { /*lint --e{715}*/
164 
165  /* do not do anything: no savedsdpsettings constraint should be present in the copy */
166  return SCIP_OKAY;
167 }
168 
169 
172  SCIP* scip
173  )
174 {
175  SCIP_CONSHDLR* conshdlr;
176 
177  /* include constraint handler */
178  conshdlr = NULL;
179  SCIP_CALL( SCIPincludeConshdlrBasic(scip, &conshdlr, CONSHDLR_NAME, CONSHDLR_DESC,
181  consEnfolpSavedsdpsettings, consEnfopsSavedsdpsettings, consCheckSavedsdpsettings, consLockSavedsdpsettings,
182  NULL) );
183  assert( conshdlr != NULL );
184 
185  /* set additional callbacks */
186  SCIP_CALL( SCIPsetConshdlrDelete(scip, conshdlr, consDeleteSavedsdpsettings) );
187  SCIP_CALL( SCIPsetConshdlrCopy(scip, conshdlr, conshdlrCopySavedsdpsettings, consCopySavedsdpsettings) );
188 
189  return SCIP_OKAY;
190 }
191 
192 
193 
194 /*
195  * External functions
196  */
197 
199 SCIP_RETCODE createConsSavedsdpsettings(
200  SCIP* scip,
201  SCIP_CONS** cons,
202  const char* name,
203  SCIP_SDPSOLVERSETTING settings
204  )
205 {
206  SCIP_CONSDATA* consdata = NULL;
207  SCIP_CONSHDLR* conshdlr;
208 
209  assert( scip != NULL );
210  assert( name != NULL );
211 
212  /* find the node data constraint handler */
213  conshdlr = SCIPfindConshdlr(scip, "Savedsdpsettings");
214  if ( conshdlr == NULL )
215  {
216  SCIPerrorMessage("savedsdpsettings constraint handler not found\n");
217  return SCIP_PLUGINNOTFOUND;
218  }
219 
220  /* create constraint data */
221  SCIP_CALL( SCIPallocBlockMemory(scip, &consdata) );
222  consdata->settings = settings;
223 
224  SCIPdebugMessage("Creating savedsdpsettings constraint <%s>.\n", name);
225 
226  /* create constraint */
227  SCIP_CALL( SCIPcreateCons(scip, cons, name, conshdlr, consdata, FALSE, FALSE, FALSE, FALSE, FALSE,
228  TRUE, FALSE, TRUE, FALSE, TRUE));
229 
230  return SCIP_OKAY;
231 }
232 
235  SCIP* scip,
236  SCIP_CONS* cons
237  )
238 {
239  SCIP_CONSDATA* consdata;
240 
241  assert( scip != NULL );
242  assert( cons != NULL );
243 
244  consdata = SCIPconsGetData(cons);
245  assert( consdata != NULL );
246 
247  return consdata->settings;
248 }
SCIP_RETCODE SCIPincludeConshdlrSavedsdpsettings(SCIP *scip)
static SCIP_DECL_CONSENFOLP(consEnfolpSavedsdpsettings)
static SCIP_DECL_CONSCHECK(consCheckSavedsdpsettings)
static SCIP_DECL_CONSENFOPS(consEnfopsSavedsdpsettings)
#define CONSHDLR_NEEDSCONS
enum SCIP_SDPSolverSetting SCIP_SDPSOLVERSETTING
Definition: type_sdpi.h:74
static SCIP_DECL_CONSDELETE(consDeleteSavedsdpsettings)
#define CONSHDLR_DESC
static SCIP_DECL_CONSHDLRCOPY(conshdlrCopySavedsdpsettings)
SCIP_RETCODE createConsSavedsdpsettings(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_SDPSOLVERSETTING settings)
#define CONSHDLR_NAME
#define CONSHDLR_ENFOPRIORITY
static SCIP_DECL_CONSLOCK(consLockSavedsdpsettings)
#define CONSHDLR_EAGERFREQ
SCIP_SDPSOLVERSETTING SCIPconsSavedsdpsettingsGetSettings(SCIP *scip, SCIP_CONS *cons)
#define CONSHDLR_CHECKPRIORITY
static SCIP_DECL_CONSCOPY(consCopySavedsdpsettings)
constraint handler for saving SDP settings