Debian Codegraph @

SYMPHONY/Applications/USER/src/CutPool/user_cp.c

raw
1 /*===========================================================================*/
2 /* */
3 /* This file is part of the SYMPHONY Branch, Cut, and Price Library. */
4 /* */
5 /* SYMPHONY was jointly developed by Ted Ralphs ([email protected]) and */
6 /* Laci Ladanyi ([email protected]). */
7 /* */
8 /* (c) Copyright 2000-2007 Ted Ralphs. All Rights Reserved. */
9 /* */
10 /* This software is licensed under the Eclipse Public License. Please see */
11 /* accompanying file for terms. */
12 /* */
13 /*===========================================================================*/
14
15 /* system include files */
16 #include <stdio.h>
17
18 /* SYMPHONY include files */
19 #include "sym_constants.h"
20 #include "sym_cp_u.h"
21
22 /* User include files */
23 #include "user.h"
24
25 /*===========================================================================*/
26
27 /*===========================================================================*\
28 * This file contains the user-written functions of the cut pool process.
29 \*===========================================================================*/
30
31 /*===========================================================================*\
32 * Here is where the user must receive all of the data sent from
33 * user_send_cp_data() and set up data structures. Note that this function is
34 * only called if one of COMPILE_IN_CP, COMPILE_IN_LP, or COMPILE_IN_TM is
35 * FALSE. For sequential computation, nothing is needed here.
36 \*===========================================================================*/
37
38 int user_receive_cp_data(void **user)
39 {
40 return(USER_DEFAULT);
41 }
42
43 /*===========================================================================*/
44
45 /*===========================================================================*\
46 * If the user wants to fill in a customized routine for sending and receiving
47 * the LP solution, it can be done here. For most cases, the default routines
48 * are fine.
49 \*===========================================================================*/
50
51 int user_receive_lp_solution_cp(void *user)
52 {
53 return(USER_DEFAULT);
54 }
55
56 /*===========================================================================*/
57
58 /*===========================================================================*\
59 * When a new solution arrives to the cut pool, this function is invoked
60 * so that the user can prepare for checking many cuts (probably set up
61 * some data structures that make ckecking more efficient).
62 \*===========================================================================*/
63
64 int user_prepare_to_check_cuts(void *user, int varnum, int *indices,
65 double *values)
66 {
67 user_problem *prob = (user_problem *) user;
68
69 return(USER_DEFAULT);
70 }
71
72
73 /*===========================================================================*/
74
75 /*===========================================================================*\
76 * Check to see whether a particular cut is violated by the current LP sol.
77 \*===========================================================================*/
78
79 int user_check_cut(void *user, double etol, int number, int *indices,
80 double *values, cut_data *cut, int *is_violated,
81 double *quality)
82 {
83 /*------------------------------------------------------------------------*\
84 * Here the cut is "unpacked" and checked for violation. Each cut is
85 * stored as compactly as possible. The subtour elimination constraints
86 * are stored as a vector of bits indicating which side of the cut each
87 * node is on. If the cut is violated, it is sent back to the lp.
88 * Otherwise, "touches" is incremented. "Touches" is a measure of the
89 * effectiveness of a cut and indicates how long it has been since a
90 * cut was useful
91 \*------------------------------------------------------------------------*/
92
93 /* This code is just here as a template for customization. Uncomment to use.*/
94 #if 0
95 user_problem *prob = (user_problem *) user;
96
97 switch (cut->type){
98
99 default:
100 printf("Cut type not recognized! \n\n");
101 *is_violated = FALSE;
102 return(USER_SUCCESS);
103 }
104 #endif
105
106 return(USER_DEFAULT);
107 }
108
109 /*===========================================================================*/
110
111 /*===========================================================================*\
112 * This function is invoked when all cuts that needed to be checked for
113 * the current solution have been checked already. (Disassemble the
114 * data structures built up in 'user_prepare_to_check_cuts'.
115 \*===========================================================================*/
116
117 int user_finished_checking_cuts(void *user)
118 {
119 return(USER_DEFAULT);
120 }
121
122 /*===========================================================================*/
123
124 /*===========================================================================*\
125 * Here, we free up the data structures. If the default setup is used with
126 * sequential computation, nothing needs to be filled in here.
127 \*===========================================================================*/
128
129 int user_free_cp(void **user)
130 {
131 return(USER_DEFAULT);
132 }
133
134 /*===========================================================================*/
135