SCIP-SDP  3.2.0
table_slater.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-2020 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-2020 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 
38 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
39 
40 #include <assert.h>
41 #include "string.h" /* for strcmp */
42 
43 #include "table_slater.h"
44 #include "relax_sdp.h"
45 #include "sdpi/sdpi.h"
46 
47 
48 #define TABLE_NAME "slater"
49 #define TABLE_DESC "Slater statistics table (needs relaxing/SDP/slatercheck > 0)"
50 #define TABLE_POSITION 16200
51 #define TABLE_EARLIEST_STAGE SCIP_STAGE_SOLVING
54 /*
55  * Data structures
56  */
57 
59 struct SCIP_TableData
60 {
61  SCIP_RELAX* relaxSDP;
62  SCIP_Bool absolute;
63 };
64 
65 
66 /*
67  * Callback methods of statistics table
68  */
69 
71 static
72 SCIP_DECL_TABLECOPY(tableCopySlater)
73 { /*lint --e{715}*/
74  assert( scip != NULL );
75  assert( table != NULL );
76 
77  SCIP_CALL( SCIPincludeTableSlater(scip) );
78 
79  return SCIP_OKAY;
80 }
81 
82 
84 static
85 SCIP_DECL_TABLEFREE(tableFreeSlater)
86 { /*lint --e{715}*/
87  SCIP_TABLEDATA* tabledata;
88 
89  assert( scip != NULL );
90  assert( table != NULL );
91  tabledata = SCIPtableGetData(table);
92  assert( tabledata != NULL );
93 
94  SCIPfreeMemory(scip, &tabledata);
95  SCIPtableSetData(table, NULL);
96 
97  return SCIP_OKAY;
98 }
99 
100 
102 static
103 SCIP_DECL_TABLEINITSOL(tableInitsolSlater)
104 { /*lint --e{715}*/
105  SCIP_TABLEDATA* tabledata;
106 
107  assert( table != NULL );
108  tabledata = SCIPtableGetData(table);
109  assert( tabledata != NULL );
110 
111  tabledata->relaxSDP = SCIPfindRelax(scip, "SDP");
112  assert( tabledata->relaxSDP != NULL );
113 
114  return SCIP_OKAY;
115 }
116 
117 
119 static
120 SCIP_DECL_TABLEOUTPUT(tableOutputSlater)
121 { /*lint --e{715}*/
122  SCIP_TABLEDATA* tabledata;
123  SCIP_RELAX* relaxsdp;
124  int relaxslatercheck;
125 
126  assert( scip != NULL );
127  assert( table != NULL );
128 
129  tabledata = SCIPtableGetData(table);
130  assert( tabledata != NULL );
131 
132  relaxsdp = tabledata->relaxSDP;
133  assert( relaxsdp != NULL );
134 
135  /* check if Slater statistics were stored in relaxator */
136  SCIP_CALL( SCIPgetIntParam(scip, "relaxing/SDP/slatercheck", &relaxslatercheck) );
137 
138  if ( relaxslatercheck == 0 )
139  {
140  SCIPinfoMessage(scip, file, " Slater: no information available when relaxing/SDP/slatercheck = 0\n");
141  return SCIP_OKAY;
142  }
143  else if ( relaxslatercheck < 0 || relaxslatercheck > 2 )
144  {
145  SCIPerrorMessage("Unknown parameter value %d for parameter relaxing/SDP/slatercheck in table/slater\n", relaxslatercheck);
146  return SCIP_PARAMETERWRONGVAL;
147  }
148 
149  /* Slater statistics */
150  SCIPinfoMessage(scip, file, " Slater : Holds Fails Infeasible Unknown\n");
151  if ( tabledata->absolute )
152  {
153  SCIPinfoMessage(scip, file, " %-14.14s: %10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT " "
154  "%10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT "\n",
155  "Dual Slater",
158 
159  SCIPinfoMessage(scip, file, " %-14.14s: %10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT " "
160  " - %10" SCIP_LONGINT_FORMAT "\n",
161  "Primal Slater",
163  }
164  else
165  {
166  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% %8.2f %% %8.2f %%\n",
167  "Dual Slater",
168  100.0 * (SCIP_Real) SCIPrelaxSdpGetNdualSlaterHolds(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp),
169  100.0 * (SCIP_Real) SCIPrelaxSdpGetNdualSlaterFails(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp),
170  100.0 * (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp),
171  100.0 * (SCIP_Real) SCIPrelaxSdpGetNdualSlaterUnknown(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp));
172 
173  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% - %8.2f %%\n",
174  "Primal Slater",
175  100.0 * (SCIP_Real) SCIPrelaxSdpGetNprimalSlaterHolds(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp),
176  100.0 * (SCIP_Real) SCIPrelaxSdpGetNprimalSlaterFails(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp),
177  100.0 * (SCIP_Real) SCIPrelaxSdpGetNprimalSlaterUnknown(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp));
178  }
179 
180 
181  /* Slater solved statistics */
182 
183  if ( strcmp(SCIPsdpiGetSolverName(), "SDPA") == 0 )
184  {
185  SCIPinfoMessage(scip, file, " Slater Solves : Fast Stable Penalty Bounded Unsolved\n");
186  if ( tabledata->absolute )
187  {
188  SCIPinfoMessage(scip, file, " %-14.14s: %10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT " "
189  "%10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT "\n",
190  "Slater holds",
193 
194  SCIPinfoMessage(scip, file, " %-14.14s: %10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT " "
195  "%10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT "\n",
196  "Slater fails",
199 
200  SCIPinfoMessage(scip, file, " %-14.14s: %10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT " "
201  "%10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT "\n",
202  "Infeasible",
205  }
206  else
207  {
208  if ( SCIPrelaxSdpGetNSlaterHolds(relaxsdp) > 0 )
209  {
210  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% %8.2f %% %8.2f %% %8.2f %%\n",
211  "Slater holds",
212  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsFast(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp),
213  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsStable(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp),
214  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsPenalty(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp),
215  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsBounded(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp),
216  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsUnsolved(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp));
217  }
218 
219  if ( SCIPrelaxSdpGetNSlaterFails(relaxsdp) > 0 )
220  {
221  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% %8.2f %% %8.2f %% %8.2f %%\n",
222  "Slater fails",
223  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsFast(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp),
224  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsStable(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp),
225  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsPenalty(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp),
226  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsBounded(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp),
227  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsUnsolved(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp));
228  }
229 
230  if ( SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp) > 0 )
231  {
232  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% %8.2f %% %8.2f %% %8.2f %%\n",
233  "Infeasible",
234  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasibleFast(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp),
235  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasibleStable(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp),
236  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasiblePenalty(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp),
237  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasibleBounded(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp),
238  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasibleUnsolved(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp));
239  }
240  }
241  }
242  else
243  {
244  SCIPinfoMessage(scip, file, " Slater : Fast Penalty Bounded Unsolved\n");
245  if ( tabledata->absolute )
246  {
247  SCIPinfoMessage(scip, file, " %-14.14s: %10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT " "
248  "%10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT "\n",
249  "Slater holds",
252 
253  SCIPinfoMessage(scip, file, " %-14.14s: %10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT " "
254  "%10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT "\n",
255  "Slater fails",
258 
259  SCIPinfoMessage(scip, file, " %-14.14s: %10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT " "
260  "%10" SCIP_LONGINT_FORMAT " %10" SCIP_LONGINT_FORMAT "\n",
261  "Infeasible",
264  }
265  else
266  {
267  if ( SCIPrelaxSdpGetNSlaterHolds(relaxsdp) > 0 )
268  {
269  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% %8.2f %% %8.2f %%\n",
270  "Slater holds",
271  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsFast(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp),
272  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsPenalty(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp),
273  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsBounded(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp),
274  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsUnsolved(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp));
275  }
276 
277  if ( SCIPrelaxSdpGetNSlaterFails(relaxsdp) > 0 )
278  {
279  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% %8.2f %% %8.2f %%\n",
280  "Slater fails",
281  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsFast(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp),
282  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsPenalty(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp),
283  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsBounded(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp),
284  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsUnsolved(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp));
285  }
286 
287  if ( SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp) > 0 )
288  {
289  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% %8.2f %% %8.2f %%\n",
290  "Infeasible",
291  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasibleFast(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp),
292  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasiblePenalty(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp),
293  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasibleBounded(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp),
294  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasibleUnsolved(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp));
295  }
296  }
297  }
298 
299  return SCIP_OKAY;
300 }
301 
302 
303 /*
304  * statistics table specific interface methods
305  */
306 
309  SCIP* scip
310  )
311 {
312  SCIP_TABLEDATA* tabledata;
313 
314  assert( scip != NULL );
315 
316  /* create statistics table data */
317  SCIP_CALL( SCIPallocMemory(scip, &tabledata) );
318 
319  /* include statistics table (deactivated by default since it needs relax/slatercheck) */
320  SCIP_CALL( SCIPincludeTable(scip, TABLE_NAME, TABLE_DESC, FALSE,
321  tableCopySlater, tableFreeSlater, NULL, NULL,
322  tableInitsolSlater, NULL, tableOutputSlater,
323  tabledata, TABLE_POSITION, TABLE_EARLIEST_STAGE) );
324 
325  /* add "absolute" parameter */
326  SCIP_CALL( SCIPaddBoolParam( scip, "table/slater/absolute", "Should statistics be printed in absolute numbers (true) or percentages (false)?",
327  &(tabledata->absolute), FALSE, FALSE, NULL, NULL) );
328 
329  return SCIP_OKAY;
330 }
static SCIP_DECL_TABLECOPY(tableCopySlater)
Definition: table_slater.c:72
int SCIPrelaxSdpGetNSlaterHoldsStable(SCIP_RELAX *relax)
Definition: relax_sdp.c:5312
static SCIP_DECL_TABLEOUTPUT(tableOutputSlater)
Definition: table_slater.c:120
int SCIPrelaxSdpGetNSlaterInfeasibleFast(SCIP_RELAX *relax)
Definition: relax_sdp.c:5422
int SCIPrelaxSdpGetNSlaterFailsBounded(SCIP_RELAX *relax)
Definition: relax_sdp.c:5400
int SCIPrelaxSdpGetNprimalSlaterHolds(SCIP_RELAX *relax)
Definition: relax_sdp.c:5257
SCIP_RETCODE SCIPincludeTableSlater(SCIP *scip)
Definition: table_slater.c:308
int SCIPrelaxSdpGetNdualSlaterHolds(SCIP_RELAX *relax)
Definition: relax_sdp.c:5213
const char * SCIPsdpiGetSolverName(void)
Definition: sdpi.c:1375
SDP-relaxator.
#define TABLE_EARLIEST_STAGE
Definition: table_slater.c:51
Slater statistics table.
#define TABLE_DESC
Definition: table_slater.c:49
int SCIPrelaxSdpGetNdualSlaterFails(SCIP_RELAX *relax)
Definition: relax_sdp.c:5224
General interface methods for SDP-preprocessing (mainly fixing variables and removing empty rows/cols...
int SCIPrelaxSdpGetNSlaterFailsFast(SCIP_RELAX *relax)
Definition: relax_sdp.c:5367
int SCIPrelaxSdpGetNSlaterFailsStable(SCIP_RELAX *relax)
Definition: relax_sdp.c:5378
int SCIPrelaxSdpGetNSdpInterfaceCalls(SCIP_RELAX *relax)
Definition: relax_sdp.c:5147
int SCIPrelaxSdpGetNSlaterHolds(SCIP_RELAX *relax)
Definition: relax_sdp.c:5290
int SCIPrelaxSdpGetNSlaterHoldsUnsolved(SCIP_RELAX *relax)
Definition: relax_sdp.c:5345
#define TABLE_POSITION
Definition: table_slater.c:50
int SCIPrelaxSdpGetNSlaterInfeasibleStable(SCIP_RELAX *relax)
Definition: relax_sdp.c:5433
int SCIPrelaxSdpGetNdualSlaterUnknown(SCIP_RELAX *relax)
Definition: relax_sdp.c:5246
int SCIPrelaxSdpGetNSlaterFailsPenalty(SCIP_RELAX *relax)
Definition: relax_sdp.c:5389
int SCIPrelaxSdpGetNSlaterHoldsFast(SCIP_RELAX *relax)
Definition: relax_sdp.c:5301
int SCIPrelaxSdpGetNSlaterInfeasiblePenalty(SCIP_RELAX *relax)
Definition: relax_sdp.c:5444
static SCIP_DECL_TABLEINITSOL(tableInitsolSlater)
Definition: table_slater.c:103
int SCIPrelaxSdpGetNSlaterFails(SCIP_RELAX *relax)
Definition: relax_sdp.c:5356
int SCIPrelaxSdpGetNSlaterHoldsBounded(SCIP_RELAX *relax)
Definition: relax_sdp.c:5334
int SCIPrelaxSdpGetNprimalSlaterFails(SCIP_RELAX *relax)
Definition: relax_sdp.c:5268
int SCIPrelaxSdpGetNSlaterInfeasibleBounded(SCIP_RELAX *relax)
Definition: relax_sdp.c:5455
int SCIPrelaxSdpGetNSlaterFailsUnsolved(SCIP_RELAX *relax)
Definition: relax_sdp.c:5411
int SCIPrelaxSdpGetNdualSlaterInfeasible(SCIP_RELAX *relax)
Definition: relax_sdp.c:5235
#define TABLE_NAME
Definition: table_slater.c:48
int SCIPrelaxSdpGetNSlaterHoldsPenalty(SCIP_RELAX *relax)
Definition: relax_sdp.c:5323
int SCIPrelaxSdpGetNprimalSlaterUnknown(SCIP_RELAX *relax)
Definition: relax_sdp.c:5279
int SCIPrelaxSdpGetNSlaterInfeasibleUnsolved(SCIP_RELAX *relax)
Definition: relax_sdp.c:5466
static SCIP_DECL_TABLEFREE(tableFreeSlater)
Definition: table_slater.c:85