Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

BCP_tm_user Class Reference

#include <BCP_tm_user.hpp>

List of all members.

Public Member Functions

virtual void display_feasible_solution (const BCP_solution *sol)
virtual void display_node_information (BCP_tree &search_tree, const BCP_tm_node &node)
virtual void display_final_information (const BCP_lp_statistics &lp_stat)
Methods to set and get the pointer to the BCP_tm_prob
object. It is unlikely that the users would want to muck around with these (especially with the set method!) but they are here to provide total control.

void setTmProblemPointer (BCP_tm_prob *ptr)
 Set the pointer.

BCP_tm_probgetTmProblemPointer ()
 Get the pointer.

Informational methods for the user.
double upper_bound () const
 Return what is the best known upper bound (might be DBL_MAX).

Methods to get/set BCP parameters on the fly
char get_param (const BCP_tm_par::chr_params key) const
int get_param (const BCP_tm_par::int_params key) const
double get_param (const BCP_tm_par::dbl_params key) const
const BCP_stringget_param (const BCP_tm_par::str_params key) const
void set_param (const BCP_tm_par::chr_params key, const bool val)
void set_param (const BCP_tm_par::chr_params key, const char val)
void set_param (const BCP_tm_par::int_params key, const int val)
void set_param (const BCP_tm_par::dbl_params key, const double val)
void set_param (const BCP_tm_par::str_params key, const char *val)
Constructor, Destructor
virtual ~BCP_tm_user ()
Packing and unpacking methods
virtual void pack_module_data (BCP_buffer &buf, BCP_process_t ptype)
virtual BCP_solutionunpack_feasible_solution (BCP_buffer &buf)
virtual bool replace_solution (const BCP_solution *old_sol, const BCP_solution *new_sol)
Methods that pack/unpack warmstart, var_algo and cut_algo objects.
The packing methods take an object and a buffer as an argument and the user is supposed to pack the object into the buffer.

The argument of the unpacking methods is just the buffer. The user is supposed to return a pointer to the unpacked object.

virtual void pack_warmstart (const BCP_warmstart *ws, BCP_buffer &buf)
virtual BCP_warmstartunpack_warmstart (BCP_buffer &buf)
virtual void pack_var_algo (const BCP_var_algo *var, BCP_buffer &buf)
virtual BCP_var_algounpack_var_algo (BCP_buffer &buf)
virtual void pack_cut_algo (const BCP_cut_algo *cut, BCP_buffer &buf)
virtual BCP_cut_algounpack_cut_algo (BCP_buffer &buf)
virtual void pack_user_data (const BCP_user_data *ud, BCP_buffer &buf)
virtual BCP_user_data * unpack_user_data (BCP_buffer &buf)
Initial setup (creating core and root)
virtual void initialize_core (BCP_vec< BCP_var_core * > &vars, BCP_vec< BCP_cut_core * > &cuts, BCP_lp_relax *&matrix)
virtual void create_root (BCP_vec< BCP_var * > &added_vars, BCP_vec< BCP_cut * > &added_cuts, BCP_user_data *&user_data, BCP_pricing_status &pricing_status)
Initialize new phase
virtual void init_new_phase (int phase, BCP_column_generation &colgen)
Compare two search tree nodes. Return true if the first node
should be processed before the second one.

Default: The default behavior is controlled by the TreeSearchStrategy parameter which is set to 0 (BCP_BestFirstSearch) by default.

virtual bool compare_tree_nodes (const BCP_tm_node *node0, const BCP_tm_node *node1)

Private Attributes

BCP_tm_probp


Detailed Description

The BCP_tm_user class is the base class from which the user can derive a problem specific class to be used in the TM process.

In that derived class the user can store data to be used in the methods she overrides. Also that is the object the user must return in the USER_initialize::tm_init() method.

There are two kind of methods in the class. The non-virtual methods are helper functions for the built-in defaults, but the user can use them as well. The virtual methods execute steps in the BCP algorithm where the user might want to override the default behavior.

The default implementations fall into three major categories.

Definition at line 57 of file BCP_tm_user.hpp.


Constructor & Destructor Documentation

virtual BCP_tm_user::~BCP_tm_user  )  [inline, virtual]
 

Being virtual, the destructor invokes the destructor for the real type of the object being deleted.

Definition at line 108 of file BCP_tm_user.hpp.

00108 {}


Member Function Documentation

void BCP_tm_user::create_root BCP_vec< BCP_var * > &  added_vars,
BCP_vec< BCP_cut * > &  added_cuts,
BCP_user_data *&  user_data,
BCP_pricing_status &  pricing_status
[virtual]
 

Create the set of extra variables and cuts that should be added to the formulation in the root node. Also decide how variable pricing shuld be done, that is, if column generation is requested in the init_new_phase() method of this class then column generation should be performed according to pricing_status.

Default: empty method, meaning that no variables/cuts are added, there is no user data and no pricing should be done.

Definition at line 174 of file BCP_tm_user.cpp.

References BCP_tm_prob::param().

00178 {
00179   if (p->param(BCP_tm_par::ReportWhenDefaultIsExecuted)) {
00180     printf(" TM: Default BCP_tm_user::create_root() executed.\n");
00181   }
00182 }

void BCP_tm_user::display_feasible_solution const BCP_solution sol  )  [virtual]
 

Display a feasible solution

Definition at line 187 of file BCP_tm_user.cpp.

References BCP_solution_generic::display(), and BCP_tm_prob::param().

Referenced by display_final_information().

00188 {
00189   if (p->param(BCP_tm_par::ReportWhenDefaultIsExecuted)) {
00190     printf("\
00191  TM: Default BCP_tm_user::display_feasible_solution() executed.\n");
00192   }
00193 
00194   const BCP_solution_generic* gsol =
00195     dynamic_cast<const BCP_solution_generic*>(sol);
00196   if (! gsol) {
00197     throw BCP_fatal_error("\
00198 BCP_tm_user::display_feasible_solution() invoked with non-generic sol.\n");
00199   }
00200 
00201   gsol->display();
00202 }

void BCP_tm_user::display_final_information const BCP_lp_statistics lp_stat  )  [virtual]
 

Display information after BCP finished processing the search tree.

Definition at line 216 of file BCP_tm_user.cpp.

References BCP_lp_statistics::display(), display_feasible_solution(), BCP_tm_prob::feas_sol, BCP_tree::maxdepth(), BCP_solution::objective_value(), BCP_tm_prob::param(), BCP_tm_prob::search_tree, BCP_tree::size(), BCP_tm_prob::start_time, and BCP_tm_prob::user.

00217 {
00218    if (p->param(BCP_tm_par::TmVerb_FinalStatistics)) {
00219       printf("TM: Running time: %.3f\n", CoinCpuTime() - p->start_time);
00220       printf("TM: search tree size: %i   max depth: %i\n",
00221              int(p->search_tree.size()), p->search_tree.maxdepth());
00222       lp_stat.display();
00223 
00224       if (! p->feas_sol) {
00225          printf("TM: No feasible solution is found\n");
00226       } else {
00227          printf("TM: The best solution found has value %f\n",
00228                 p->feas_sol->objective_value());
00229          if (p->param(BCP_tm_par::TmVerb_BestFeasibleSolution)) {
00230             p->user->display_feasible_solution(p->feas_sol);
00231          }
00232       }
00233    }
00234 }

void BCP_tm_user::display_node_information BCP_tree search_tree,
const BCP_tm_node node
[virtual]
 

Display user information just before a new node is sent to the LP or diving into a node is acknowledged.

Definition at line 208 of file BCP_tm_user.cpp.

00210 {
00211 }

void BCP_tm_user::init_new_phase int  phase,
BCP_column_generation &  colgen
[virtual]
 

Do whatever initialization is necessary before the phase-th phase. (E.g., setting the pricing strategy.)

Definition at line 239 of file BCP_tm_user.cpp.

References BCP_tm_prob::param().

00240 {
00241   if (p->param(BCP_tm_par::ReportWhenDefaultIsExecuted)) {
00242     printf(" TM: Default init_new_phase() executed.\n");
00243   }
00244   colgen = BCP_DoNotGenerateColumns_Fathom;
00245 }

void BCP_tm_user::initialize_core BCP_vec< BCP_var_core * > &  vars,
BCP_vec< BCP_cut_core * > &  cuts,
BCP_lp_relax *&  matrix
[virtual]
 

Create the core of the problem by filling out the last three arguments. These variables/cuts will always stay in the LP relaxation and the corresponding matrix is described by the specified matrix. If there is no core variable or cut then the returned pointer for to the matrix should be a null pointer.

Default: empty method, meaning that there are no variables/cuts in the core and this the core matrix is empty (0 pointer) as well.

Definition at line 162 of file BCP_tm_user.cpp.

References BCP_tm_prob::param().

00165 {
00166   if (p->param(BCP_tm_par::ReportWhenDefaultIsExecuted)) {
00167     printf(" TM: Default BCP_tm_user::initialize_core() executed.\n");
00168   }
00169 }

void BCP_tm_user::pack_cut_algo const BCP_cut_algo cut,
BCP_buffer buf
[virtual]
 

Pack an algorithmic cut

Definition at line 126 of file BCP_tm_user.cpp.

00127 {
00128   throw BCP_fatal_error("\
00129 BCP_tm_user::pack_cut_algo() invoked but not overridden!\n");
00130 }

void BCP_tm_user::pack_module_data BCP_buffer buf,
BCP_process_t  ptype
[virtual]
 

Pack the initial information (info that the user wants to send over) for the process specified by the last argument. The information packed here will be unpacked in the unpack_module_data() method of the user defined class in the appropriate process.
Default: empty method.

Definition at line 47 of file BCP_tm_user.cpp.

00047 {}

void BCP_tm_user::pack_user_data const BCP_user_data *  ud,
BCP_buffer buf
[virtual]
 

Pack an user data

Definition at line 142 of file BCP_tm_user.cpp.

00143 {
00144   throw BCP_fatal_error("\
00145 BCP_tm_user::pack_user_data() invoked but not overridden!\n");
00146 }

void BCP_tm_user::pack_var_algo const BCP_var_algo var,
BCP_buffer buf
[virtual]
 

Pack an algorithmic variable

Definition at line 110 of file BCP_tm_user.cpp.

00111 {
00112   throw BCP_fatal_error("\
00113 BCP_tm_user::pack_var_algo() invoked but not overridden!\n");
00114 }

void BCP_tm_user::pack_warmstart const BCP_warmstart ws,
BCP_buffer buf
[virtual]
 

Pack warmstarting information

Definition at line 88 of file BCP_tm_user.cpp.

References BCP_tm_prob::param().

00089 {
00090   if (p->param(BCP_tm_par::ReportWhenDefaultIsExecuted)) {
00091     printf(" TM: Default BCP_tm_user::pack_warmstart() executed.\n");
00092   }
00093   BCP_pack_warmstart(ws, buf);
00094 }

bool BCP_tm_user::replace_solution const BCP_solution old_sol,
const BCP_solution new_sol
[virtual]
 

Decide whether to replace old_sol with new_sol. When this method is invoked it has already been tested that they have the same objective function value. The purpose of the method is that the user can have a secondary objective function.

Definition at line 79 of file BCP_tm_user.cpp.

00081 {
00082    return false;
00083 }

BCP_cut_algo * BCP_tm_user::unpack_cut_algo BCP_buffer buf  )  [virtual]
 

Unpack an algorithmic cut

Definition at line 134 of file BCP_tm_user.cpp.

00135 {
00136   throw BCP_fatal_error("\
00137 BCP_tm_user::unpack_cut_algo() invoked but not overridden!\n");
00138 }

BCP_solution * BCP_tm_user::unpack_feasible_solution BCP_buffer buf  )  [virtual]
 

Unpack a MIP feasible solution that was packed by the BCP_lp_user::pack_feasible_solution() method.

Default: Unpacks a BCP_solution_generic object. The built-in default should be used if and only if the built-in default was used in BCP_lp_user::pack_feasible_solution().

Definition at line 52 of file BCP_tm_user.cpp.

References BCP_solution_generic::add_entry(), BCP_tm_prob::param(), BCP_var::set_bcpind(), BCP_buffer::unpack(), and BCP_tm_prob::unpack_var_without_bcpind().

00053 {
00054   if (p->param(BCP_tm_par::ReportWhenDefaultIsExecuted)) {
00055     printf(" TM: Default unpack_feasible_solution() executed.\n");
00056   }
00057 
00058   BCP_solution_generic* soln = new BCP_solution_generic;
00059 
00060   int varnum;
00061   buf.unpack(varnum);
00062 
00063   double val;
00064   int bcpind;
00065   while (--varnum >= 0) {
00066     buf.unpack(val);
00067     buf.unpack(bcpind);
00068     BCP_var* var = p->unpack_var_without_bcpind(buf);
00069     var->set_bcpind(bcpind);
00070     soln->add_entry(var, val);
00071   }
00072 
00073   return soln;
00074 }

BCP_user_data * BCP_tm_user::unpack_user_data BCP_buffer buf  )  [virtual]
 

Unpack an user data

Definition at line 150 of file BCP_tm_user.cpp.

00151 {
00152   throw BCP_fatal_error("\
00153 BCP_tm_user::unpack_user_data() invoked but not overridden!\n");
00154 }

BCP_var_algo * BCP_tm_user::unpack_var_algo BCP_buffer buf  )  [virtual]
 

Unpack an algorithmic variable

Definition at line 118 of file BCP_tm_user.cpp.

00119 {
00120   throw BCP_fatal_error("\
00121 BCP_tm_user::unpack_var_algo() invoked but not overridden!\n");
00122 }

BCP_warmstart * BCP_tm_user::unpack_warmstart BCP_buffer buf  )  [virtual]
 

Unpack warmstarting information

Definition at line 99 of file BCP_tm_user.cpp.

References BCP_tm_prob::param().

00100 {
00101   if (p->param(BCP_tm_par::ReportWhenDefaultIsExecuted)) {
00102     printf(" TM: Default BCP_tm_user::unpack_warmstart() executed.\n");
00103   }
00104   return BCP_unpack_warmstart(buf);
00105 }


The documentation for this class was generated from the following files:
Generated on Wed Dec 3 14:32:42 2003 for BCP by doxygen 1.3.5