Operational Research Library  1.0
LinearAssignmentProblem.h
Go to the documentation of this file.
1 #ifndef LINEARASSIGNMENTPROBLEM_H
2 #define LINEARASSIGNMENTPROBLEM_H
3 
4 #include <iostream>
5 #include <fstream>
6 #include <sstream>
7 #include <algorithm>
8 #include <vector>
9 #include "RandomHelper.h"
10 #include "IData.h"
11 
12 namespace operational_research
13 {
14 
23 {
24 private:
25  // Number of objects.
26  unsigned int objects;
27 
28  // Costs of assignment.
29  std::vector<std::vector<double> > costs;
30 
36  bool checkSchedule(const std::vector<unsigned int>& schedule);
37 
45  void writeResultToFile(const std::vector<unsigned int>& schedule, double costFunctionValue, const std::string& filename);
46 
47 public:
54  LinearAssignmentProblem(unsigned int objects, const std::vector<std::vector<double> >& costs);
55 
64  LinearAssignmentProblem(unsigned int objects, double minCost, double maxCost, bool integerValues = false);
65 
72  LinearAssignmentProblem(const std::string& filename);
73 
80  void setData(unsigned int objects, const std::vector<std::vector<double> >& costs);
81 
90  void generateData(unsigned int objects, double minCost, double maxCost, bool integerValues = false);
91 
98  void readDataFromFile(const std::string& filename);
99 
105  void writeDataToFile(const std::string& filename);
106 
110  void showData();
111 
118  double evaluateLSAP(const std::vector<unsigned int>& schedule);
119 
128  double evaluateLSAP(const std::vector<unsigned int>& schedule, const std::string& filename);
129 
136  double evaluateLBAP(const std::vector<unsigned int>& schedule);
137 
146  double evaluateLBAP(const std::vector<unsigned int>& schedule, const std::string& filename);
147 
152  const std::vector<std::vector<double> >& getCosts() const {
153  return costs;
154  }
155 
160  unsigned int getObjects() const {
161  return objects;
162  }
163 };
164 
165 } // namespace operational_research
166 
167 #endif // LINEARASSIGNMENTPROBLEM_H
Interface for reading, writing and displaying data.
void readDataFromFile(const std::string &filename)
Reads linear assignment problem data from a file with a filename.
Definition: LinearAssignmentProblem.cpp:144
Definition: BinPackingProblem.cpp:3
void showData()
Shows linear assignment problem data.
Definition: LinearAssignmentProblem.cpp:237
void writeDataToFile(const std::string &filename)
Writes linear assignment problem data to a file with a filename.
Definition: LinearAssignmentProblem.cpp:251
double evaluateLSAP(const std::vector< unsigned int > &schedule)
Evaluates linear sum assignment problem.
Definition: LinearAssignmentProblem.cpp:69
const std::vector< std::vector< double > > & getCosts() const
Getter for costs.
Definition: LinearAssignmentProblem.h:152
Definition: LinearAssignmentProblem.h:22
unsigned int getObjects() const
Getter for number of objects.
Definition: LinearAssignmentProblem.h:160
double evaluateLBAP(const std::vector< unsigned int > &schedule)
Evaluates linear bottleneck assignment problem.
Definition: LinearAssignmentProblem.cpp:41
Simple pseudo random number generator class.
void setData(unsigned int objects, const std::vector< std::vector< double > > &costs)
Setter for linear assignment problem data.
Definition: LinearAssignmentProblem.cpp:209
void generateData(unsigned int objects, double minCost, double maxCost, bool integerValues=false)
Generates linear assignment problem data according to setup.
Definition: LinearAssignmentProblem.cpp:97
LinearAssignmentProblem(unsigned int objects, const std::vector< std::vector< double > > &costs)
Constructor.
Definition: LinearAssignmentProblem.cpp:11
Definition: IData.h:14