SCIP Doxygen Documentation
Loading...
Searching...
No Matches
event_newsol.c
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* SCIP --- Solving Constraint Integer Programs */
5/* */
6/* Copyright (c) 2002-2026 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file event_newsol.c
26 * @brief eventhdlr that adds new solutions to the candidate pool for the exchange heuristic
27 * @author Leon Eifler
28 */
29
30/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
31
32#include "event_newsol.h"
33#include "heur_cyckerlin.h"
34#include "probdata_cyc.h"
35
36#define EVENTHDLR_NAME "newsol"
37#define EVENTHDLR_DESC "event handler for solution events"
38
39/** copy method for event handler plugins (called when SCIP copies plugins) */
40static
41SCIP_DECL_EVENTCOPY(eventCopyNewsol)
42{ /*lint --e{715}*/
43 assert(scip != NULL);
44 assert(eventhdlr != NULL);
45
47
48 /* call inclusion method of event handler */
50
51 return SCIP_OKAY;
52}
53
54/** initialization method of event handler (called after problem was transformed) */
55static
56SCIP_DECL_EVENTINIT(eventInitNewsol)
57{ /*lint --e{715}*/
58 assert(scip != NULL);
59 assert(eventhdlr != NULL);
60
62
63 /* notify SCIP that your event handler wants to react on the event type best solution found */
65
66 return SCIP_OKAY;
67}
68
69/** deinitialization method of event handler (called before transformed problem is freed) */
70static
71SCIP_DECL_EVENTEXIT(eventExitNewsol)
72{ /*lint --e{715}*/
73 assert(scip != NULL);
74 assert(eventhdlr != NULL);
75
77
78 /* notify SCIP that your event handler wants to drop the event type best solution found */
80
81 return SCIP_OKAY;
82}
83
84/** execution method of event handler */
85static
86SCIP_DECL_EVENTEXEC(eventExecNewsol)
87{ /*lint --e{715}*/
88 SCIP_SOL* newsol;
89
90 assert(eventhdlr != NULL);
91 assert(event != NULL);
92 assert(scip != NULL);
94
96
98 return SCIP_OKAY;
99
100 SCIPdebugMsg(scip, "exec method of event handler for newsol solution found\n");
101
102 newsol = SCIPeventGetSol(event);
103 assert(newsol != NULL);
104
105 SCIPdebugMsg(scip, "catch event for solution %p with obj=%g.\n", (void*) newsol, SCIPgetSolOrigObj(scip, newsol));
106
108
109 return SCIP_OKAY;
110}
111
112/** includes event handler for best solution found */
114 SCIP* scip /**< SCIP data structure */
115 )
116{
117 SCIP_EVENTHDLRDATA* eventhdlrdata;
118 SCIP_EVENTHDLR* eventhdlr;
119 eventhdlrdata = NULL;
120
121 eventhdlr = NULL;
122 /* create event handler for events on watched variables */
124 eventExecNewsol, eventhdlrdata) );
125
126 assert(eventhdlr != NULL);
127
128 SCIP_CALL( SCIPsetEventhdlrCopy(scip, eventhdlr, eventCopyNewsol) );
129 SCIP_CALL( SCIPsetEventhdlrInit(scip, eventhdlr, eventInitNewsol) );
130 SCIP_CALL( SCIPsetEventhdlrExit(scip, eventhdlr, eventExitNewsol) );
131
132 return SCIP_OKAY;
133}
#define EVENTHDLR_NAME
#define EVENTHDLR_DESC
#define NULL
Definition def.h:257
#define SCIP_STRINGEQ(name, reference, retcode)
Definition def.h:454
#define SCIP_CALL(x)
Definition def.h:364
SCIP_RETCODE SCIPincludeEventHdlrNewsol(SCIP *scip)
eventhdlr that adds new solutions to the candidate pool for the exchange heuristic
SCIP_STAGE SCIPgetStage(SCIP *scip)
#define SCIPdebugMsg
SCIP_RETCODE SCIPsetEventhdlrCopy(SCIP *scip, SCIP_EVENTHDLR *eventhdlr,)
Definition scip_event.c:143
SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
Definition scip_event.c:111
SCIP_RETCODE SCIPsetEventhdlrExit(SCIP *scip, SCIP_EVENTHDLR *eventhdlr,)
Definition scip_event.c:185
const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr)
Definition event.c:396
SCIP_RETCODE SCIPsetEventhdlrInit(SCIP *scip, SCIP_EVENTHDLR *eventhdlr,)
Definition scip_event.c:171
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
Definition event.c:1194
SCIP_SOL * SCIPeventGetSol(SCIP_EVENT *event)
Definition event.c:1567
SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
Definition scip_event.c:293
SCIP_RETCODE SCIPdropEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
Definition scip_event.c:333
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1890
return SCIP_OKAY
SCIP_RETCODE addCandSolCyckerlin(SCIP *scip, SCIP_SOL *sol)
Improvement heuristic that trades bin-variables between clusters.
assert(minobj< SCIPgetCutoffbound(scip))
problem data for cycle clustering problem
struct SCIP_Eventhdlr SCIP_EVENTHDLR
Definition type_event.h:159
#define SCIP_DECL_EVENTEXIT(x)
Definition type_event.h:213
struct SCIP_EventhdlrData SCIP_EVENTHDLRDATA
Definition type_event.h:160
#define SCIP_DECL_EVENTEXEC(x)
Definition type_event.h:259
#define SCIP_DECL_EVENTCOPY(x)
Definition type_event.h:189
#define SCIP_DECL_EVENTINIT(x)
Definition type_event.h:205
#define SCIP_EVENTTYPE_BESTSOLFOUND
Definition type_event.h:106
@ SCIP_INVALIDCALL
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
Definition type_scip.h:39
@ SCIP_STAGE_SOLVING
Definition type_set.h:53
struct SCIP_Sol SCIP_SOL
Definition type_sol.h:57