Alps 1.5.7
Loading...
Searching...
No Matches
AlpsKnowledgeBrokerSerial.h
Go to the documentation of this file.
1/*===========================================================================*
2 * This file is part of the Abstract Library for Parallel Search (ALPS). *
3 * *
4 * ALPS is distributed under the Eclipse Public License as part of the *
5 * COIN-OR repository (http://www.coin-or.org). *
6 * *
7 * Authors: *
8 * *
9 * Yan Xu, Lehigh University *
10 * Ted Ralphs, Lehigh University *
11 * *
12 * Conceptual Design: *
13 * *
14 * Yan Xu, Lehigh University *
15 * Ted Ralphs, Lehigh University *
16 * Laszlo Ladanyi, IBM T.J. Watson Research Center *
17 * Matthew Saltzman, Clemson University *
18 * *
19 * *
20 * Copyright (C) 2001-2019, Lehigh University, Yan Xu, and Ted Ralphs. *
21 *===========================================================================*/
22
23#ifndef AlpsKnowledgeBrokerSerial_h_
24#define AlpsKnowledgeBrokerSerial_h_
25
26#include "Alps.h"
27#include "AlpsEnumProcessT.h"
28#include "AlpsKnowledgeBroker.h"
29#include "AlpsMessage.h"
30#include "AlpsModel.h"
31#include "AlpsParams.h"
32
33//#############################################################################
34
36 private:
39
40 public:
43 :
45 {}
46
50 :
52 {
53 initializeSearch(0, NULL, model);
54 }
55
59 char* argv[],
60 AlpsModel& model)
61 :
63 {
64 initializeSearch(argc, argv, model);
65 }
66
67
70
71 //-------------------------------------------------------------------------
76
78 virtual void searchLog();
79
81 virtual double getIncumbentValue() const {
82 return getBestQuality();
83 }
84
87 virtual double getBestQuality() const {
90 }
91 else {
92 return ALPS_INC_MAX;
93 }
94 }
95
98 virtual void printBestSolution(char* outputFile = 0) const {
99
100 if (msgLevel_ < 1) return;
101
103 std::cout << "\nALPS did not find a solution."
104 << std::endl;
105 return;
106 }
107 if (outputFile != 0) {
108 // Write to outputFile
109 std::ofstream os(outputFile);
110 os << "============================================" << std::endl;
112 os << "Optimal solution:" << std::endl;
113 }
114 else {
115 os << "Best solution found:" << std::endl;
116 }
117 os << "Cost = " << getBestQuality();
118 os << std::endl;
119 dynamic_cast<AlpsSolution* >
121 }
122 else { // Write to std::cout
123 std::cout << "============================================" << std::endl;
125 std::cout << "Optimal solution:" << std::endl;
126 }
127 else {
128 std::cout << "Best solution found:" << std::endl;
129 }
130 std::cout << "Cost = " << getBestQuality();
131 std::cout << std::endl;
132 dynamic_cast<AlpsSolution* >
133 (getBestKnowledge(AlpsKnowledgeTypeSolution).first)->print(std::cout);
134 std::cout << "============================================" << std::endl;
135 }
136 }
138
140 virtual void initializeSearch(int argc,
141 char* argv[],
142 AlpsModel& model);
143
145 virtual void rootSearch(AlpsTreeNode* root);
146
147};
148#endif
@ AlpsKnowledgeTypeSolution
Definition: Alps.h:92
#define ALPS_INC_MAX
Definition: Alps.h:144
@ AlpsExitStatusOptimal
Definition: Alps.h:103
virtual void printBestSolution(char *outputFile=0) const
The process outputs the best solution and the quality that it finds to a file or std::out.
virtual void searchLog()
Search log.
AlpsKnowledgeBrokerSerial(int argc, char *argv[], AlpsModel &model)
Userful constructor.
AlpsKnowledgeBrokerSerial(AlpsModel &model)
Useful constructor.
virtual void rootSearch(AlpsTreeNode *root)
Search for best solution.
virtual double getIncumbentValue() const
The process queries the quality of the incumbent that it stores.
virtual double getBestQuality() const
The process queries the quality of the best solution that it finds.
AlpsKnowledgeBrokerSerial()
Default constructor.
virtual void initializeSearch(int argc, char *argv[], AlpsModel &model)
Reading in Alps and user parameter sets, and read in model data.
virtual ~AlpsKnowledgeBrokerSerial()
Destructor.
The base class of knowledge broker class.
virtual bool hasKnowledge(AlpsKnowledgeType kt) const
Query whether there are knowledges in the given type of knowledge pools.
virtual int getNumKnowledges(AlpsKnowledgeType kt) const
Query the number of knowledge in the given type of a knowledge pool.
AlpsExitStatus getSolStatus() const
Query search termination status.
virtual std::pair< AlpsKnowledge *, double > getBestKnowledge(AlpsKnowledgeType kt) const
Get the best knowledge in the given type of knowledge pools.
int msgLevel_
The leve of printing message to screen of the master and general message.
This class holds one node of the search tree.
Definition: AlpsTreeNode.h:50