1 /*===========================================================================*/
2 /* */
3 /* This file is part of a demonstration application for use with the */
4 /* SYMPHONY Branch, Cut, and Price Library. This application is a solver for */
5 /* the Set Partitioning Problem. */
6 /* */
7 /* (c) Copyright 2005-2007 Marta Eso and Ted Ralphs. All Rights Reserved. */
8 /* */
9 /* This application was originally developed by Marta Eso and was modified */
10 /* Ted Ralphs (ted@lehigh.edu) */
11 /* */
12 /* This software is licensed under the Eclipse Public License. Please see */
13 /* accompanying file for terms. */
14 /* */
15 /*===========================================================================*/
16
17 /* SYMPHONY include files */
18 #include "sym_constants.h"
19 #include "sym_macros.h"
20 #include "sym_lp_u.h"
21
22 /*===========================================================================*/
23
24 /*===========================================================================*\
25 * This file contains the user-written functions for the LP process related
26 * to branching.
27 \*===========================================================================*/
28
29 /*===========================================================================*\
30 * This function determines whether to branch. You can essentially
31 * leave this up to SYMPHONY unless there is some compelling reason not to.
32 \*===========================================================================*/
33
user_shall_we_branch(void * user,double lpetol,int cutnum,int slacks_in_matrix_num,cut_data ** slacks_im_matrix,int slack_cut_num,cut_data ** slack_cuts,int varnum,var_desc ** vars,double * x,char * status,int * cand_num,branch_obj *** candidates,int * action)34 int user_shall_we_branch(void *user, double lpetol, int cutnum,
35 int slacks_in_matrix_num, cut_data **slacks_im_matrix,
36 int slack_cut_num, cut_data **slack_cuts, int varnum,
37 var_desc **vars, double *x, char *status,
38 int *cand_num, branch_obj ***candidates,
39 int *action)
40 {
41 return(USER__BRANCH_IF_MUST);
42 }
43
44 /*===========================================================================*/
45
46 /*===========================================================================*\
47 * Here, we select the branching candidates. This can essentially be
48 * left to SYMPHONY too using one of the built-in functions, but here, I
49 * demonstrate how to branch on cuts, which must be done by the user.
50 \*===========================================================================*/
51
user_select_candidates(void * user,double lpetol,int cutnum,int slacks_in_matrix_num,cut_data ** slacks_in_matrix,int slack_cut_num,cut_data ** slack_cuts,int varnum,var_desc ** vars,double * x,char * status,int * cand_num,branch_obj *** candidates,int * action,int bc_level)52 int user_select_candidates(void *user, double lpetol, int cutnum,
53 int slacks_in_matrix_num,
54 cut_data **slacks_in_matrix, int slack_cut_num,
55 cut_data **slack_cuts, int varnum, var_desc **vars,
56 double *x, char *status, int *cand_num,
57 branch_obj ***candidates, int *action,
58 int bc_level)
59
60 {
61 return(USER__CLOSE_TO_HALF_AND_EXPENSIVE);
62 }
63
64 /*===========================================================================*/
65
user_compare_candidates(void * user,branch_obj * can1,branch_obj * can2,double ub,double granularity,int * which_is_better)66 int user_compare_candidates(void *user, branch_obj *can1, branch_obj *can2,
67 double ub, double granularity,
68 int *which_is_better)
69 {
70 return(USER_DEFAULT);
71 }
72
73 /*===========================================================================*/
74
75 /*===========================================================================*\
76 * You can let SYMPHONY choose which child to retain. The default is
77 * to keep the one with the lower objective function value.
78 \*===========================================================================*/
79
user_select_child(void * user,double ub,branch_obj * can,char * action)80 int user_select_child(void *user, double ub, branch_obj *can, char *action)
81 {
82 return(USER_DEFAULT);
83 }
84
85 /*===========================================================================*/
86
87 /*===========================================================================*\
88 * Here, you can print out a more identifiable description of the
89 * branching object than just "variable 51".
90 \*===========================================================================*/
91
user_print_branch_stat(void * user,branch_obj * can,cut_data * cut,int n,var_desc ** vars,char * action)92 int user_print_branch_stat(void *user, branch_obj *can, cut_data *cut,
93 int n, var_desc **vars, char *action)
94 {
95 return(USER_DEFAULT);
96 }
97