/home/coin/SVN-release/CoinAll-1.1.0/SYMPHONY/Applications/SPP+CUTS/include/spp_cg.h

Go to the documentation of this file.
00001 /*===========================================================================*/
00002 /*                                                                           */
00003 /* This file is part of a demonstration application for use with the         */
00004 /* SYMPHONY Branch, Cut, and Price Library. This application is a solver for */
00005 /* the Set Partitioning Problem.                                             */
00006 /*                                                                           */
00007 /* (c) Copyright 2005-2008 Marta Eso and Ted Ralphs. All Rights Reserved.    */
00008 /*                                                                           */
00009 /* This application was originally developed by Marta Eso and was modified   */
00010 /* Ted Ralphs (tkralphs@lehigh.edu)                                          */
00011 /*                                                                           */
00012 /* This software is licensed under the Common Public License. Please see     */
00013 /* accompanying file for terms.                                              */
00014 /*                                                                           */
00015 /*===========================================================================*/
00016 
00017 #ifndef _SPP_CG_H
00018 #define _SPP_CG_H
00019 
00020 /* system include files */
00021 #include <stdio.h>
00022 #include <sym_proto.h>
00023 
00024 /* SPP include files */
00025 #include "spp_constants.h"
00026 #include "spp_types.h"
00027 #include "spp_cg_params.h"
00028 
00029 typedef struct FNODE {        /*describes a node of the fractional graph*/
00030    int          *nbrs;        /* pointer into all_nbr */
00031    double       *edgecosts;   /*1-x_i-x_j, needed for odd holes, in the same
00032                                 order as the adj list, pointer into
00033                                 all_edgecost */
00034    int           degree;       /*degree of the node*/
00035    int           ind;          /*origind of the node, ie. the index of this
00036                                  variable in the initial problem the lp and
00037                                  the cut generator store*/
00038    double        val;          /*the value of this variable in the current
00039                                  lp solution*/
00040 }fnode;
00041 
00042 typedef struct FRAC_GRAPH {    /*graph corresponding to the current fractional
00043                                  solution. two nodes are adjacent iff their
00044                                  columns are non-orthogonal*/
00045    int    nodenum;     /*# of nodes = # of fractional values in current sol*/
00046    int    edgenum;     /*# of edges in the graph*/
00047    double density;     /*density= edgenum/(nodenum choose 2)*/
00048    int    min_deg_node;
00049    int    min_degree;
00050    int    max_deg_node;
00051    int    max_degree;
00052    fnode  *nodes;      /*pointers to the nodes*/
00053    int    *all_nbr;    /* array of all the neighbors. */
00054    double *all_edgecost;  /* array of all the costs */
00055    char   *node_node;  /*node-node incidence matrix of the graph, stored
00056                          row-ordered in a long vector*/
00057 }frac_graph;
00058 
00059 
00060 /* a level-graph is derived from another graph by taking one of the nodes
00061    of the graph as root and listing its connected component in a BFS
00062    fashion.
00063     lnodenum is the number of nodes in the level-graph
00064     levelnum is the number of BFS levels
00065     root     is the root of the level-graph
00066     lnodes   is a list of node indices (wrt the original graph) in the order
00067              they have been marked during BFS
00068     lbeg     is the position of each level within lnodes (like matbeg for
00069              matind)
00070     level_of_node is a list of levels for the nodes of the original graph.
00071              it is -1 if the node is not in the level-graph (i.e., not
00072              in the connected component of the root) */
00073 typedef struct LEVEL_GRAPH {
00074    int               lnodenum;
00075    int               levelnum;
00076    int               root;           /* lnodes[0] = root */
00077    int              *lnodes;         /* length: lnodenum */
00078    int              *lbeg;           /* length: levelnum + 1 */
00079    int              *level_of_node;  /* length: nodenum of orig. graph */
00080 }level_graph;
00081 
00082 typedef struct CUT_COLLECTION {
00083    int               size;
00084    int               max_size;
00085    cut_data        **cuts;      /* a collection of cuts that have been sent
00086                                    to the lp */
00087    double           *violation; /* degree of violation for these cuts */
00088    int              *mult;      /* the multiplicity of the cut -- just STAT */
00089 }cut_collection;
00090 
00091 typedef struct SPP_CG_TMP {
00092    int                *itmp_m;        
00093    int               **istartmp_m;
00094    /* the following must be reallocated if nodenum grows */
00095    int                *itmp_8nodenum;
00096    double             *dtmp_2nodenum;
00097    char               *ctmp_2nodenum;
00098    cut_data           *cuttmp;
00099 }spp_cg_tmp;
00100 
00101 
00102 /*
00103   tmp:  temporary data structures, space is allocated for them only once
00104         at the beginning and freed at the end only. Some fields are
00105         variable length
00106   soln: pointer to the current lp solution. needed only to simplify the
00107         arguments passed on to functions invoked from find_cuts
00108   cm_frac, rm_frac: column and row ordered versions of the problem matrix
00109         restricted to the columns in the fractional solution. matbeg, matind
00110         and rmatind are variable length.
00111   fgraph: pointer to the fractional graph that corresponds to the current
00112           lp solution. Fields are variable length.
00113   lgraph: a BFS enumeration of a connected component of fgraph, starting from
00114           a special node, the root. Fields are variable length.
00115   cut_coll: a local cut pool that contains the cuts that have been sent back
00116             to the lp. Originally allocated for 20 cuts but it is reallocated
00117             later as needed.
00118   
00119  */
00120 typedef struct SPP_CG_PROBLEM {
00121    spp_cg_params      *par;
00122    spp_cg_tmp         *tmp;
00123    int                 dg_id;  /* tid of the graph drawing process */
00124    char                wname[MAX_FILE_NAME_LENGTH +1];
00125                           /* name of window in which frac solns are displd */
00126    char                lname[MAX_FILE_NAME_LENGTH +1];
00127                           /* name of window in which level graph is displd */
00128    col_ordered        *cmatrix;
00129 
00130    int                 max_sol_length;  /* space is allocated for fgraph and
00131                                            rmatrix according to this value */
00132    col_ordered        *cm_frac;
00133    row_ordered        *rm_frac;
00134    frac_graph         *fgraph;
00135    frac_graph         *cfgraph;
00136    level_graph        *lgraph;
00137    cut_collection     *cut_coll;
00138 
00139    int                *num_cuts; 
00140    int                *alloc_cuts;
00141    cut_data         ***cuts;
00142         
00143 
00144 
00145 }spp_cg_problem;
00146 
00147 void allocate_var_length_structures PROTO((spp_cg_problem *spp, int max_ln));
00148 void free_var_length_structures PROTO((spp_cg_problem *spp));
00149 void construct_fractional_graph PROTO((spp_cg_problem *spp, int number,
00150                                        int *indices, double *values));
00151 void construct_cm_frac PROTO((spp_cg_problem *spp));
00152 void construct_rm_frac PROTO((spp_cg_problem *spp));
00153 void construct_complement_graph PROTO((frac_graph *fgraph,
00154                                        frac_graph *cfgraph));
00155 void construct_level_graph PROTO((frac_graph *fgraph, int root,
00156                                   level_graph *lgraph));
00157 int register_and_send_cut PROTO((spp_cg_problem *spp, cut_data *new_cut,
00158                                  double violation, double etol));
00159 
00160 void extend_clique_on_fgraph PROTO((spp_cg_problem *spp, cut_data *new_cut,
00161                                     double *pviolation));
00162 void translate_cut_to_indices PROTO((spp_cg_problem *spp, cut_data *cut));
00163 void rotate_odd_hole PROTO((int length, int *indices, int *itmp));
00164 
00165 int enumerate_maximal_cliques PROTO((spp_cg_problem *spp, int pos, double etol));
00166 void spp_delete_node PROTO((spp_cg_problem *spp, int del_ind,
00167                             int *pcurrent_nodenum, int *current_indices,
00168                             int *current_degrees, double *current_values));
00169 int choose_next_node PROTO((spp_cg_problem *spp, int current_nodenum,
00170                             int *current_indices, int *current_degrees,
00171                             double *current_values));
00172 int find_violated_star_cliques PROTO((spp_cg_problem *spp, double etol));
00173 int find_violated_row_cliques PROTO((spp_cg_problem *spp, double etol));
00174 int greedy_maximal_clique PROTO((spp_cg_problem *spp, cut_data *new_cut,
00175                                  int length, int *indices, int pos, double etol));
00176 int find_violated_odd_holes PROTO((spp_cg_problem *spp, double etol));
00177 double find_chordless_oh PROTO((spp_cg_problem *spp, frac_graph *fgraph,
00178                                 int u, int w, int *oh));
00179 void min_path_to_root PROTO((spp_cg_problem *spp, frac_graph *fgraph,
00180                              int u, int *path_u, double *pcost));
00181 double lift_nonviolated_odd_hole PROTO((spp_cg_problem *spp, int oh_len,
00182                                         int *oh, double lhs_oh, int *phub_len,
00183                                         int *hubs, int *hub_coef));
00184 int max_lhs_of_lifted_odd_hole PROTO((spp_cg_problem *spp, int oh_len,
00185                                       int *oh, int hub, int hub_len, int *hubs,
00186                                       int *hub_coef, char *label, int pos));
00187 int find_violated_odd_antiholes PROTO((spp_cg_problem *spp, double etol));
00188 double lift_nonviolated_odd_antihole PROTO((spp_cg_problem *spp, int oah_len,
00189                                             int *oah, double lhs_oah,
00190                                             int *phub_len, int *hubs,
00191                                             int *hub_coef, double etol));
00192 void translate_cut_to_indices PROTO((spp_cg_problem *spp, cut_data *cut));
00193 void rotate_odd_hole PROTO((int length, int *indices, int *itmp));
00194 
00195 #endif

Generated on Sun Nov 14 14:06:41 2010 for Coin-All by  doxygen 1.4.7