SCIP-SDP  4.0.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-2021 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-2021 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: %10d %10d %10d %10d\n",
154  "Dual Slater",
157 
158  SCIPinfoMessage(scip, file, " %-14.14s: %10d %10d - %10d\n",
159  "Primal Slater",
161  }
162  else
163  {
164  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% %8.2f %% %8.2f %%\n",
165  "Dual Slater",
166  100.0 * (SCIP_Real) SCIPrelaxSdpGetNdualSlaterHolds(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp),
167  100.0 * (SCIP_Real) SCIPrelaxSdpGetNdualSlaterFails(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp),
168  100.0 * (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp),
169  100.0 * (SCIP_Real) SCIPrelaxSdpGetNdualSlaterUnknown(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp));
170 
171  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% - %8.2f %%\n",
172  "Primal Slater",
173  100.0 * (SCIP_Real) SCIPrelaxSdpGetNprimalSlaterHolds(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp),
174  100.0 * (SCIP_Real) SCIPrelaxSdpGetNprimalSlaterFails(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp),
175  100.0 * (SCIP_Real) SCIPrelaxSdpGetNprimalSlaterUnknown(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp));
176  }
177 
178  /* Slater solved statistics */
179  if ( strcmp(SCIPsdpiGetSolverName(), "SDPA") == 0 )
180  {
181  SCIPinfoMessage(scip, file, " Slater Solves : Fast Stable Penalty Bounded Unsolved\n");
182  if ( tabledata->absolute )
183  {
184  SCIPinfoMessage(scip, file, " %-14.14s: %10d %10d %10d %10d %10d\n",
185  "Slater holds",
188 
189  SCIPinfoMessage(scip, file, " %-14.14s: %10d %10d %10d %10d %10d\n",
190  "Slater fails",
193 
194  SCIPinfoMessage(scip, file, " %-14.14s: %10d %10d %10d %10d %10d\n",
195  "Infeasible",
198  }
199  else
200  {
201  if ( SCIPrelaxSdpGetNSlaterHolds(relaxsdp) > 0 )
202  {
203  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% %8.2f %% %8.2f %% %8.2f %%\n",
204  "Slater holds",
205  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsFast(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp),
206  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsStable(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp),
207  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsPenalty(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp),
208  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsBounded(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp),
209  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsUnsolved(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp));
210  }
211 
212  if ( SCIPrelaxSdpGetNSlaterFails(relaxsdp) > 0 )
213  {
214  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% %8.2f %% %8.2f %% %8.2f %%\n",
215  "Slater fails",
216  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsFast(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp),
217  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsStable(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp),
218  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsPenalty(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp),
219  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsBounded(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp),
220  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsUnsolved(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp));
221  }
222 
223  if ( SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp) > 0 )
224  {
225  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% %8.2f %% %8.2f %% %8.2f %%\n",
226  "Infeasible",
227  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasibleFast(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp),
228  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasibleStable(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp),
229  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasiblePenalty(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp),
230  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasibleBounded(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp),
231  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasibleUnsolved(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp));
232  }
233  }
234  }
235  else
236  {
237  SCIPinfoMessage(scip, file, " Slater : Fast Penalty Bounded Unsolved\n");
238  if ( tabledata->absolute )
239  {
240  SCIPinfoMessage(scip, file, " %-14.14s: %10d %10d %10d %10d\n",
241  "Slater holds",
244 
245  SCIPinfoMessage(scip, file, " %-14.14s: %10d %10d %10d %10d\n",
246  "Slater fails",
249 
250  SCIPinfoMessage(scip, file, " %-14.14s: %10d %10d %10d %10d\n",
251  "Infeasible",
254  }
255  else
256  {
257  if ( SCIPrelaxSdpGetNSlaterHolds(relaxsdp) > 0 )
258  {
259  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% %8.2f %% %8.2f %%\n",
260  "Slater holds",
261  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsFast(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp),
262  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsPenalty(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp),
263  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsBounded(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp),
264  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterHoldsUnsolved(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterHolds(relaxsdp));
265  }
266 
267  if ( SCIPrelaxSdpGetNSlaterFails(relaxsdp) > 0 )
268  {
269  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% %8.2f %% %8.2f %%\n",
270  "Slater fails",
271  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsFast(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp),
272  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsPenalty(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp),
273  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsBounded(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp),
274  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterFailsUnsolved(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSlaterFails(relaxsdp));
275  }
276 
277  if ( SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp) > 0 )
278  {
279  SCIPinfoMessage(scip, file, " %-14.14s: %8.2f %% %8.2f %% %8.2f %% %8.2f %%\n",
280  "Infeasible",
281  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasibleFast(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp),
282  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasiblePenalty(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp),
283  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasibleBounded(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp),
284  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSlaterInfeasibleUnsolved(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNdualSlaterInfeasible(relaxsdp));
285  }
286  }
287  }
288 
289  return SCIP_OKAY;
290 }
291 
292 
293 /*
294  * statistics table specific interface methods
295  */
296 
299  SCIP* scip
300  )
301 {
302  SCIP_TABLEDATA* tabledata;
303 
304  assert( scip != NULL );
305 
306  /* create statistics table data */
307  SCIP_CALL( SCIPallocMemory(scip, &tabledata) );
308 
309  /* include statistics table (deactivated by default since it needs relax/slatercheck) */
310  SCIP_CALL( SCIPincludeTable(scip, TABLE_NAME, TABLE_DESC, FALSE,
311  tableCopySlater, tableFreeSlater, NULL, NULL,
312  tableInitsolSlater, NULL, tableOutputSlater,
313  tabledata, TABLE_POSITION, TABLE_EARLIEST_STAGE) );
314 
315  /* add "absolute" parameter */
316  SCIP_CALL( SCIPaddBoolParam( scip, "table/slater/absolute", "Should statistics be printed in absolute numbers (true) or percentages (false)?",
317  &(tabledata->absolute), FALSE, FALSE, NULL, NULL) );
318 
319  return SCIP_OKAY;
320 }
static SCIP_DECL_TABLECOPY(tableCopySlater)
Definition: table_slater.c:72
int SCIPrelaxSdpGetNSlaterHoldsStable(SCIP_RELAX *relax)
Definition: relax_sdp.c:5822
static SCIP_DECL_TABLEOUTPUT(tableOutputSlater)
Definition: table_slater.c:120
int SCIPrelaxSdpGetNSlaterInfeasibleFast(SCIP_RELAX *relax)
Definition: relax_sdp.c:5932
int SCIPrelaxSdpGetNSlaterFailsBounded(SCIP_RELAX *relax)
Definition: relax_sdp.c:5910
int SCIPrelaxSdpGetNprimalSlaterHolds(SCIP_RELAX *relax)
Definition: relax_sdp.c:5767
SCIP_RETCODE SCIPincludeTableSlater(SCIP *scip)
Definition: table_slater.c:298
int SCIPrelaxSdpGetNdualSlaterHolds(SCIP_RELAX *relax)
Definition: relax_sdp.c:5723
const char * SCIPsdpiGetSolverName(void)
Definition: sdpi.c:1441
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:5734
General interface methods for SDP-preprocessing (mainly fixing variables and removing empty rows/cols...
int SCIPrelaxSdpGetNSlaterFailsFast(SCIP_RELAX *relax)
Definition: relax_sdp.c:5877
int SCIPrelaxSdpGetNSlaterFailsStable(SCIP_RELAX *relax)
Definition: relax_sdp.c:5888
int SCIPrelaxSdpGetNSdpInterfaceCalls(SCIP_RELAX *relax)
Definition: relax_sdp.c:5657
int SCIPrelaxSdpGetNSlaterHolds(SCIP_RELAX *relax)
Definition: relax_sdp.c:5800
int SCIPrelaxSdpGetNSlaterHoldsUnsolved(SCIP_RELAX *relax)
Definition: relax_sdp.c:5855
#define TABLE_POSITION
Definition: table_slater.c:50
int SCIPrelaxSdpGetNSlaterInfeasibleStable(SCIP_RELAX *relax)
Definition: relax_sdp.c:5943
int SCIPrelaxSdpGetNdualSlaterUnknown(SCIP_RELAX *relax)
Definition: relax_sdp.c:5756
int SCIPrelaxSdpGetNSlaterFailsPenalty(SCIP_RELAX *relax)
Definition: relax_sdp.c:5899
int SCIPrelaxSdpGetNSlaterHoldsFast(SCIP_RELAX *relax)
Definition: relax_sdp.c:5811
int SCIPrelaxSdpGetNSlaterInfeasiblePenalty(SCIP_RELAX *relax)
Definition: relax_sdp.c:5954
static SCIP_DECL_TABLEINITSOL(tableInitsolSlater)
Definition: table_slater.c:103
int SCIPrelaxSdpGetNSlaterFails(SCIP_RELAX *relax)
Definition: relax_sdp.c:5866
int SCIPrelaxSdpGetNSlaterHoldsBounded(SCIP_RELAX *relax)
Definition: relax_sdp.c:5844
int SCIPrelaxSdpGetNprimalSlaterFails(SCIP_RELAX *relax)
Definition: relax_sdp.c:5778
int SCIPrelaxSdpGetNSlaterInfeasibleBounded(SCIP_RELAX *relax)
Definition: relax_sdp.c:5965
int SCIPrelaxSdpGetNSlaterFailsUnsolved(SCIP_RELAX *relax)
Definition: relax_sdp.c:5921
int SCIPrelaxSdpGetNdualSlaterInfeasible(SCIP_RELAX *relax)
Definition: relax_sdp.c:5745
#define TABLE_NAME
Definition: table_slater.c:48
int SCIPrelaxSdpGetNSlaterHoldsPenalty(SCIP_RELAX *relax)
Definition: relax_sdp.c:5833
int SCIPrelaxSdpGetNprimalSlaterUnknown(SCIP_RELAX *relax)
Definition: relax_sdp.c:5789
int SCIPrelaxSdpGetNSlaterInfeasibleUnsolved(SCIP_RELAX *relax)
Definition: relax_sdp.c:5976
static SCIP_DECL_TABLEFREE(tableFreeSlater)
Definition: table_slater.c:85