#include <BCP_tm_user.hpp>
Inheritance diagram for BCP_tm_user:
Public Member Functions | |
int | process_id () const |
What is the process id of the current process. | |
void | send_message (const int target, const BCP_buffer &buf) |
Send a message to a particular process. | |
void | broadcast_message (const BCP_process_t proc_type, const BCP_buffer &buf) |
Broadcast the message to all processes of the given type. | |
virtual void | process_message (BCP_buffer &buf) |
Process a message that has been sent by another process' user part to this process' user part. | |
virtual void | display_feasible_solution (const BCP_solution *sol) |
Display a feasible solution. | |
virtual void | display_node_information (BCP_tree &search_tree, const BCP_tm_node &node) |
Display user information just before a new node is sent to the LP or diving into a node is acknowledged. | |
virtual void | display_final_information (const BCP_lp_statistics &lp_stat) |
Display information after BCP finished processing the search tree. | |
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_prob * | getTmProblemPointer () |
Get the pointer. | |
Informational methods for the user. | |
double | upper_bound () const |
Return what is the best known upper bound (might be BCP_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_string & | get_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 | |
BCP_tm_user () | |
virtual | ~BCP_tm_user () |
Being virtual, the destructor invokes the destructor for the real type of the object being deleted. | |
Packing and unpacking methods | |
virtual void | pack_module_data (BCP_buffer &buf, BCP_process_t ptype) |
Pack the initial information (info that the user wants to send over) for the process specified by the last argument. | |
virtual BCP_solution * | unpack_feasible_solution (BCP_buffer &buf) |
Unpack a MIP feasible solution that was packed by the BCP_lp_user::pack_feasible_solution() method. | |
virtual bool | replace_solution (const BCP_solution *old_sol, const BCP_solution *new_sol) |
Decide whether to replace old_sol with new_sol. | |
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) |
Create the core of the problem by filling out the last three arguments. | |
virtual void | create_root (BCP_vec< BCP_var * > &added_vars, BCP_vec< BCP_cut * > &added_cuts, BCP_user_data *&user_data) |
Create the set of extra variables and cuts that should be added to the formulation in the root node. | |
Initialize new phase | |
virtual void | init_new_phase (int phase, BCP_column_generation &colgen, CoinSearchTreeBase *&candidates) |
Do whatever initialization is necessary before the phase -th phase. | |
If desired, change the tree (the candidate list) in the search | |
tree manager using the setTree() method. This method is invoked after every insertion into the candidate list and also whenever a new solution is found. In the latter case new_solution is true .
The default invokes the newSolution() and the reevaluateSearchStrategy() methods from CoinSearchTreeManager. | |
virtual void | change_candidate_heap (CoinSearchTreeManager &candidates, const bool new_solution) |
Private Attributes | |
BCP_tm_prob * | p |
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 58 of file BCP_tm_user.hpp.
BCP_tm_user::BCP_tm_user | ( | ) | [inline] |
Definition at line 106 of file BCP_tm_user.hpp.
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 109 of file BCP_tm_user.hpp.
void BCP_tm_user::setTmProblemPointer | ( | BCP_tm_prob * | ptr | ) | [inline] |
Set the pointer.
Definition at line 69 of file BCP_tm_user.hpp.
References p.
Referenced by BCP_tm_main(), and BCP_single_environment::register_process().
BCP_tm_prob* BCP_tm_user::getTmProblemPointer | ( | ) | [inline] |
double BCP_tm_user::upper_bound | ( | ) | const |
Return what is the best known upper bound (might be BCP_DBL_MAX).
Definition at line 15 of file BCP_tm_user.cpp.
References p, and BCP_tm_prob::ub().
char BCP_tm_user::get_param | ( | const BCP_tm_par::chr_params | key | ) | const |
Definition at line 21 of file BCP_tm_user.cpp.
References BCP_parameter_set< Par >::entry(), p, and BCP_tm_prob::par.
int BCP_tm_user::get_param | ( | const BCP_tm_par::int_params | key | ) | const |
Definition at line 24 of file BCP_tm_user.cpp.
References BCP_parameter_set< Par >::entry(), p, and BCP_tm_prob::par.
double BCP_tm_user::get_param | ( | const BCP_tm_par::dbl_params | key | ) | const |
Definition at line 27 of file BCP_tm_user.cpp.
References BCP_parameter_set< Par >::entry(), p, and BCP_tm_prob::par.
const BCP_string & BCP_tm_user::get_param | ( | const BCP_tm_par::str_params | key | ) | const |
Definition at line 30 of file BCP_tm_user.cpp.
References BCP_parameter_set< Par >::entry(), p, and BCP_tm_prob::par.
void BCP_tm_user::set_param | ( | const BCP_tm_par::chr_params | key, | |
const bool | val | |||
) |
Definition at line 33 of file BCP_tm_user.cpp.
References p, BCP_tm_prob::par, and BCP_parameter_set< Par >::set_entry().
void BCP_tm_user::set_param | ( | const BCP_tm_par::chr_params | key, | |
const char | val | |||
) |
Definition at line 35 of file BCP_tm_user.cpp.
References p, BCP_tm_prob::par, and BCP_parameter_set< Par >::set_entry().
void BCP_tm_user::set_param | ( | const BCP_tm_par::int_params | key, | |
const int | val | |||
) |
Definition at line 37 of file BCP_tm_user.cpp.
References p, BCP_tm_prob::par, and BCP_parameter_set< Par >::set_entry().
void BCP_tm_user::set_param | ( | const BCP_tm_par::dbl_params | key, | |
const double | val | |||
) |
Definition at line 39 of file BCP_tm_user.cpp.
References p, BCP_tm_prob::par, and BCP_parameter_set< Par >::set_entry().
void BCP_tm_user::set_param | ( | const BCP_tm_par::str_params | key, | |
const char * | val | |||
) |
Definition at line 41 of file BCP_tm_user.cpp.
References p, BCP_tm_prob::par, and BCP_parameter_set< Par >::set_entry().
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.
Reimplemented in BB_tm, MCF1_tm, MCF2_tm, MCF3_tm, OS_tm, and OS_tm.
Definition at line 47 of file BCP_tm_user.cpp.
Referenced by BCP_tm_initialize_process_type(), and BCP_single_environment::register_process().
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(), p, BCP_tm_prob::param(), BCP_tm_par::ReportWhenDefaultIsExecuted, BCP_var::set_bcpind(), BCP_solution_generic::set_objective_value(), BCP_buffer::unpack(), and BCP_tm_prob::unpack_var_without_bcpind().
Referenced by BCP_tm_prob::process_message().
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 83 of file BCP_tm_user.cpp.
Referenced by BCP_tm_prob::process_message().
int BCP_tm_user::process_id | ( | ) | const |
What is the process id of the current process.
Definition at line 93 of file BCP_tm_user.cpp.
References BCP_process::get_process_id(), and p.
void BCP_tm_user::send_message | ( | const int | target, | |
const BCP_buffer & | buf | |||
) |
Send a message to a particular process.
Definition at line 100 of file BCP_tm_user.cpp.
References BCP_Msg_User, BCP_tm_prob::msg_env, p, and BCP_message_environment::send().
void BCP_tm_user::broadcast_message | ( | const BCP_process_t | proc_type, | |
const BCP_buffer & | buf | |||
) |
Broadcast the message to all processes of the given type.
Definition at line 107 of file BCP_tm_user.cpp.
References BCP_Msg_User, BCP_ProcessType_Any, BCP_ProcessType_CG, BCP_ProcessType_CP, BCP_ProcessType_EndProcess, BCP_ProcessType_LP, BCP_ProcessType_TM, BCP_ProcessType_TS, BCP_ProcessType_VG, BCP_ProcessType_VP, BCP_tm_prob::lp_procs, BCP_tm_prob::msg_env, BCP_message_environment::multicast(), and p.
void BCP_tm_user::process_message | ( | BCP_buffer & | buf | ) | [virtual] |
Process a message that has been sent by another process' user part to this process' user part.
Definition at line 153 of file BCP_tm_user.cpp.
Referenced by BCP_tm_prob::process_message().
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.
Reimplemented in BB_tm, MCF1_tm, MCF2_tm, MCF3_tm, OS_tm, and OS_tm.
Definition at line 163 of file BCP_tm_user.cpp.
References p, BCP_tm_prob::param(), and BCP_tm_par::ReportWhenDefaultIsExecuted.
Referenced by BCP_tm_create_core().
void BCP_tm_user::create_root | ( | BCP_vec< BCP_var * > & | added_vars, | |
BCP_vec< BCP_cut * > & | added_cuts, | |||
BCP_user_data *& | user_data | |||
) | [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.
Reimplemented in BB_tm, MCF1_tm, MCF2_tm, MCF3_tm, OS_tm, and OS_tm.
Definition at line 175 of file BCP_tm_user.cpp.
References p, BCP_tm_prob::param(), and BCP_tm_par::ReportWhenDefaultIsExecuted.
Referenced by BCP_tm_create_root().
void BCP_tm_user::display_feasible_solution | ( | const BCP_solution * | sol | ) | [virtual] |
Display a feasible solution.
Reimplemented in BB_tm, MCF1_tm, MCF2_tm, MCF3_tm, OS_tm, and OS_tm.
Definition at line 187 of file BCP_tm_user.cpp.
References BCP_solution_generic::display(), p, BCP_tm_prob::param(), and BCP_tm_par::ReportWhenDefaultIsExecuted.
Referenced by OS_tm::display_feasible_solution(), BB_tm::display_feasible_solution(), display_final_information(), and BCP_tm_prob::process_message().
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.
Referenced by BCP_tm_node_to_send::send().
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(), p, BCP_tm_prob::param(), BCP_tree::processed(), BCP_tm_prob::search_tree, BCP_tree::size(), BCP_tm_prob::start_time, BCP_tm_par::TmVerb_BestFeasibleSolution, BCP_tm_par::TmVerb_FinalStatistics, and BCP_tm_prob::user.
Referenced by BCP_tm_wrapup().
void BCP_tm_user::init_new_phase | ( | int | phase, | |
BCP_column_generation & | colgen, | |||
CoinSearchTreeBase *& | candidates | |||
) | [virtual] |
Do whatever initialization is necessary before the phase
-th phase.
(E.g., setting the pricing strategy.)
Reimplemented in MCF1_tm, MCF2_tm, and MCF3_tm.
Definition at line 240 of file BCP_tm_user.cpp.
References BCP_BestFirstSearch, BCP_BreadthFirstSearch, BCP_DepthFirstSearch, BCP_DoNotGenerateColumns_Fathom, BCP_PreferredFirstSearch, p, BCP_tm_prob::param(), BCP_tm_par::ReportWhenDefaultIsExecuted, and BCP_tm_par::TreeSearchStrategy.
Referenced by BCP_tm_tasks_before_new_phase(), MCF3_tm::init_new_phase(), MCF2_tm::init_new_phase(), and MCF1_tm::init_new_phase().
void BCP_tm_user::change_candidate_heap | ( | CoinSearchTreeManager & | candidates, | |
const bool | new_solution | |||
) | [virtual] |
Definition at line 267 of file BCP_tm_user.cpp.
References p, and BCP_tm_prob::ub().
Referenced by BCP_tm_prob::process_message().
BCP_tm_prob* BCP_tm_user::p [private] |
Definition at line 60 of file BCP_tm_user.hpp.
Referenced by broadcast_message(), change_candidate_heap(), create_root(), display_feasible_solution(), display_final_information(), get_param(), getTmProblemPointer(), init_new_phase(), initialize_core(), process_id(), send_message(), set_param(), setTmProblemPointer(), unpack_feasible_solution(), and upper_bound().