SCIP-SDP  4.0.0
table_relaxsdp.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 
39 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
40 
41 #include <assert.h>
42 
43 #include "table_relaxsdp.h"
44 #include "relax_sdp.h"
45 
46 
47 #define TABLE_NAME "relaxsdp"
48 #define TABLE_DESC "advanced SDP relaxator statistics table"
49 #define TABLE_ACTIVE TRUE
50 #define TABLE_POSITION 17100
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(tableCopyRelaxSdp)
73 { /*lint --e{715}*/
74  assert( scip != NULL );
75  assert( table != NULL );
76 
77  SCIP_CALL( SCIPincludeTableRelaxSdp(scip) );
78 
79  return SCIP_OKAY;
80 }
81 
82 
84 static
85 SCIP_DECL_TABLEFREE(tableFreeRelaxSdp)
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(tableInitsolRelaxSdp)
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(tableOutputRelaxSdp)
121 { /*lint --e{715}*/
122  SCIP_TABLEDATA* tabledata;
123  SCIP_RELAX* relaxsdp;
124  int ncalls;
125  int ninfeasible;
126  int nallfixed;
127  int nonevarsdp;
128 
129  assert( scip != NULL );
130  assert( table != NULL );
131 
132  tabledata = SCIPtableGetData(table);
133  assert( tabledata != NULL );
134 
135  relaxsdp = tabledata->relaxSDP;
136  assert( relaxsdp != NULL );
137 
138  SCIP_CALL( SCIPrelaxSdpGetStatistics(relaxsdp, &ninfeasible, &nallfixed, &nonevarsdp) );
139  ncalls = SCIPrelaxSdpGetNSdpInterfaceCalls(relaxsdp);
140 
141  if ( strcmp(SCIPsdpiGetSolverName(), "SDPA") == 0 )
142  {
143  SCIPinfoMessage(scip, file, " SDP-Solvers : Time Opttime Solves Iterations Iter/call Fast Medium Stable Penalty Unsolved Infeas Allfixed OnevarSDP\n");
144  if ( ncalls > 0 )
145  {
146  if ( tabledata->absolute )
147  {
148  SCIPinfoMessage(scip, file, " %-14.14s: %10.2f %10.2f %10d %10d %10.2f %10d %10d %10d %10d %10d %10d %10d %10d\n",
151  (SCIP_Real) SCIPrelaxSdpGetNIterations(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpCalls(relaxsdp),
153  SCIPrelaxSdpGetNSdpUnsolved(relaxsdp), ninfeasible, nallfixed, nonevarsdp);
154  }
155  else
156  {
157  SCIPinfoMessage(scip, file, " %-14.14s: %10.2f %10.2f %10d %10d %10.2f %8.2f %% %8.2f %% %8.2f %% %8.2f %% %8.2f %% %10d %10d %10d\n",
160  (SCIP_Real) SCIPrelaxSdpGetNIterations(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpCalls(relaxsdp),
161  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSdpFast(relaxsdp) / (SCIP_Real) ncalls,
162  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSdpMedium(relaxsdp) / (SCIP_Real) ncalls,
163  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSdpStable(relaxsdp) / (SCIP_Real) ncalls,
164  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSdpPenalty(relaxsdp) / (SCIP_Real) ncalls,
165  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSdpUnsolved(relaxsdp) / (SCIP_Real) ncalls,
166  ninfeasible, nallfixed, nonevarsdp);
167  }
168  }
169  else
170  {
171  SCIPinfoMessage(scip, file, " %-14.14s: %10.2f %10.2f %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s\n",
173  "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-");
174  }
175  }
176  else
177  {
178  SCIPinfoMessage(scip, file, " SDP-Solvers : Time Opttime Solves Iterations Iter/call Default Penalty Unsolved Infeas Allfixed OnevarSDP\n");
179  if ( ncalls > 0 )
180  {
181  if ( tabledata->absolute )
182  {
183  SCIPinfoMessage(scip, file, " %-14.14s: %10.2f %10.2f %10d %10d %10.2f %10d %10d %10d %10d %10d %10d\n",
186  (SCIP_Real) SCIPrelaxSdpGetNIterations(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpCalls(relaxsdp),
188  ninfeasible, nallfixed, nonevarsdp);
189  }
190  else
191  {
192  SCIPinfoMessage(scip, file, " %-14.14s: %10.2f %10.2f %10d %10d %10.2f %8.2f %% %8.2f %% %8.2f %% %10d %10d %10d\n",
195  (SCIP_Real) SCIPrelaxSdpGetNIterations(relaxsdp) / (SCIP_Real) SCIPrelaxSdpGetNSdpCalls(relaxsdp),
196  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSdpFast(relaxsdp) / (SCIP_Real) ncalls,
197  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSdpPenalty(relaxsdp) / (SCIP_Real) ncalls,
198  100.0 * (SCIP_Real) SCIPrelaxSdpGetNSdpUnsolved(relaxsdp) / (SCIP_Real) ncalls,
199  ninfeasible, nallfixed, nonevarsdp);
200  }
201  }
202  else
203  {
204  SCIPinfoMessage(scip, file, " %-14.14s: %10.2f %10.2f %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s\n",
206  "-", "-", "-", "-", "-", "-", "-", "-", "-", "-");
207  }
208  }
209 
210  return SCIP_OKAY;
211 }
212 
213 
214 /*
215  * statistics table specific interface methods
216  */
217 
220  SCIP* scip
221  )
222 {
223  SCIP_TABLEDATA* tabledata;
224 
225  assert( scip != NULL );
226 
227  /* create statistics table data */
228  SCIP_CALL( SCIPallocMemory(scip, &tabledata) );
229 
230  /* include statistics table */
231  SCIP_CALL( SCIPincludeTable(scip, TABLE_NAME, TABLE_DESC, TABLE_ACTIVE,
232  tableCopyRelaxSdp, tableFreeRelaxSdp, NULL, NULL,
233  tableInitsolRelaxSdp, NULL, tableOutputRelaxSdp,
234  tabledata, TABLE_POSITION, TABLE_EARLIEST_STAGE) );
235 
236  /* add "absolute" parameter */
237  SCIP_CALL( SCIPaddBoolParam( scip, "table/relaxsdp/absolute", "Should statistics be printed in absolute numbers (true) or percentages (false)?",
238  &(tabledata->absolute), FALSE, TRUE, NULL, NULL) );
239 
240  return SCIP_OKAY;
241 }
static SCIP_DECL_TABLEFREE(tableFreeRelaxSdp)
static SCIP_DECL_TABLEOUTPUT(tableOutputRelaxSdp)
SCIP_RETCODE SCIPincludeTableRelaxSdp(SCIP *scip)
int SCIPrelaxSdpGetNSdpPenalty(SCIP_RELAX *relax)
Definition: relax_sdp.c:5701
const char * SCIPsdpiGetSolverName(void)
Definition: sdpi.c:1441
#define TABLE_DESC
SDP-relaxator.
SCIP_RETCODE SCIPrelaxSdpGetStatistics(SCIP_RELAX *relax, int *ninfeasible, int *nallfixed, int *nonevarsdp)
Definition: relax_sdp.c:6006
int SCIPrelaxSdpGetNSdpUnsolved(SCIP_RELAX *relax)
Definition: relax_sdp.c:5712
#define TABLE_EARLIEST_STAGE
int SCIPrelaxSdpGetNSdpStable(SCIP_RELAX *relax)
Definition: relax_sdp.c:5690
int SCIPrelaxSdpGetNSdpMedium(SCIP_RELAX *relax)
Definition: relax_sdp.c:5679
SCIP_Real SCIPrelaxSdpGetOptTime(SCIP_RELAX *relax)
Definition: relax_sdp.c:5624
int SCIPrelaxSdpGetNSdpInterfaceCalls(SCIP_RELAX *relax)
Definition: relax_sdp.c:5657
int SCIPrelaxSdpGetNSdpCalls(SCIP_RELAX *relax)
Definition: relax_sdp.c:5646
advanced SDP relaxator statistics table
static SCIP_DECL_TABLEINITSOL(tableInitsolRelaxSdp)
int SCIPrelaxSdpGetNSdpFast(SCIP_RELAX *relax)
Definition: relax_sdp.c:5668
#define TABLE_ACTIVE
int SCIPrelaxSdpGetNIterations(SCIP_RELAX *relax)
Definition: relax_sdp.c:5635
#define TABLE_POSITION
#define TABLE_NAME
static SCIP_DECL_TABLECOPY(tableCopyRelaxSdp)
SCIP_Real SCIPrelaxSdpGetSolvingTime(SCIP *scip, SCIP_RELAX *relax)
Definition: relax_sdp.c:5987