SCIP-SDP  3.1.1
 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 programs based on SCIP. */
5 /* */
6 /* Copyright (C) 2011-2013 Discrete Optimization, TU Darmstadt */
7 /* EDOM, FAU Erlangen-Nürnberg */
8 /* 2014-2018 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-2018 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_CONSENFORELAX(consEnforelaxSavedsdpsettings)
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_CONSENFOPS(consEnfopsSavedsdpsettings)
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_CONSCHECK(consCheckSavedsdpsettings)
132 {/*lint --e{715}*/
133  assert( scip != NULL );
134  assert( conshdlr != NULL );
135  assert( strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0 );
136  assert( result != NULL );
137 
138  /* do nothing */
139  *result = SCIP_FEASIBLE;
140 
141  return SCIP_OKAY;
142 }
143 
144 
146 static
147 SCIP_DECL_CONSLOCK(consLockSavedsdpsettings)
148 {/*lint --e{715}*/
149  assert( scip != NULL );
150  assert( conshdlr != NULL );
151  assert( strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0 );
152 
153  /* do nothing */
154  return SCIP_OKAY;
155 }
156 
157 
159 static
160 SCIP_DECL_CONSHDLRCOPY(conshdlrCopySavedsdpsettings)
161 {
162  assert( scip != NULL );
163  assert( conshdlr != NULL );
164  assert( strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0 );
165  assert( valid != NULL );
166 
167  /* call inclusion method of constraint handler */
168  SCIP_CALL( SCIPincludeConshdlrSavedsdpsettings(scip) );
169 
170  *valid = TRUE;
171 
172  return SCIP_OKAY;
173 }
174 
175 
177 static
178 SCIP_DECL_CONSCOPY(consCopySavedsdpsettings)
179 { /*lint --e{715}*/
180 
181  if ( name )
182  {
183  SCIP_CALL( createConsSavedsdpsettings(scip, cons, name, SCIPconsSavedsdpsettingsGetSettings(sourcescip, sourcecons)) );
184  }
185  else
186  {
187  SCIP_CALL( createConsSavedsdpsettings(scip, cons, SCIPconsGetName(sourcecons), SCIPconsSavedsdpsettingsGetSettings(sourcescip, sourcecons)) );
188  }
189 
190  *valid = TRUE;
191  return SCIP_OKAY;
192 }
193 
194 
197  SCIP* scip
198  )
199 {
200  SCIP_CONSHDLR* conshdlr;
201 
202  /* include constraint handler */
203  conshdlr = NULL;
204  SCIP_CALL( SCIPincludeConshdlrBasic(scip, &conshdlr, CONSHDLR_NAME, CONSHDLR_DESC,
206  consEnfolpSavedsdpsettings, consEnfopsSavedsdpsettings, consCheckSavedsdpsettings, consLockSavedsdpsettings,
207  NULL) );
208  assert( conshdlr != NULL );
209 
210  /* set additional callbacks */
211  SCIP_CALL( SCIPsetConshdlrDelete(scip, conshdlr, consDeleteSavedsdpsettings) );
212  SCIP_CALL( SCIPsetConshdlrEnforelax(scip, conshdlr, consEnforelaxSavedsdpsettings) );
213  SCIP_CALL( SCIPsetConshdlrCopy(scip, conshdlr, conshdlrCopySavedsdpsettings, consCopySavedsdpsettings) );
214 
215  return SCIP_OKAY;
216 }
217 
218 
219 
220 /*
221  * External functions
222  */
223 
225 SCIP_RETCODE createConsSavedsdpsettings(
226  SCIP* scip,
227  SCIP_CONS** cons,
228  const char* name,
229  SCIP_SDPSOLVERSETTING settings
230  )
231 {
232  SCIP_CONSDATA* consdata = NULL;
233  SCIP_CONSHDLR* conshdlr;
234 
235  assert( scip != NULL );
236  assert( name != NULL );
237 
238  /* find the node data constraint handler */
239  conshdlr = SCIPfindConshdlr(scip, "Savedsdpsettings");
240  if ( conshdlr == NULL )
241  {
242  SCIPerrorMessage("savedsdpsettings constraint handler not found\n");
243  return SCIP_PLUGINNOTFOUND;
244  }
245 
246  /* create constraint data */
247  SCIP_CALL( SCIPallocBlockMemory(scip, &consdata) );
248  consdata->settings = settings;
249 
250  SCIPdebugMessage("Creating savedsdpsettings constraint <%s>.\n", name);
251 
252  /* create constraint */
253  SCIP_CALL( SCIPcreateCons(scip, cons, name, conshdlr, consdata, FALSE, FALSE, FALSE, FALSE, FALSE,
254  TRUE, FALSE, TRUE, FALSE, TRUE));
255 
256  return SCIP_OKAY;
257 }
258 
261  SCIP* scip,
262  SCIP_CONS* cons
263  )
264 {
265  SCIP_CONSDATA* consdata;
266 
267  assert( scip != NULL );
268  assert( cons != NULL );
269 
270  consdata = SCIPconsGetData(cons);
271  assert( consdata != NULL );
272 
273  return consdata->settings;
274 }
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:80
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)
static SCIP_DECL_CONSENFORELAX(consEnforelaxSavedsdpsettings)
char name[SCIP_MAXSTRLEN]
#define CONSHDLR_CHECKPRIORITY
static SCIP_DECL_CONSCOPY(consCopySavedsdpsettings)
constraint handler for saving SDP settings