OR-Tools  8.2
rcpsp_parser.h
Go to the documentation of this file.
1// Copyright 2010-2018 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14// A Project Scheduling Library parser.
15// See: http://www.om-db.wi.tum.de/psplib/ # PSP-Lib homepage.
16
17#ifndef OR_TOOLS_DATA_RCPSP_PARSER_H_
18#define OR_TOOLS_DATA_RCPSP_PARSER_H_
19
20#include <string>
21#include <vector>
22
24#include "ortools/data/rcpsp.pb.h"
25
26namespace operations_research {
27namespace data {
28namespace rcpsp {
29
30// RCPSP parser.
31// Parse a RCPSP problem and load it into a RcpspProblem proto.
32// See description of the problem in ./rcpsp.proto
34 public:
36
37 // We keep the fully qualified name for swig.
38 ::operations_research::data::rcpsp::RcpspProblem problem() const {
39 return rcpsp_;
40 }
41
42 // Returns false if an error occurred.
43 bool ParseFile(const std::string& file_name);
44
45 private:
46 enum LoadStatus {
47 NOT_STARTED,
48 HEADER_SECTION,
49 PROJECT_SECTION,
50 INFO_SECTION,
51 PRECEDENCE_SECTION,
52 REQUEST_SECTION,
53 RESOURCE_SECTION,
54 RESOURCE_MIN_SECTION,
55 PARSING_FINISHED,
56 ERROR_FOUND
57 };
58
59 void ProcessRcpspLine(const std::string& line);
60 void ProcessPattersonLine(const std::string& line);
61 void ProcessRcpspMaxLine(const std::string& line);
62 void ReportError(const std::string& line);
63 // Sets the number of declared tasks, and initialize data structures
64 // accordingly.
65 void SetNumDeclaredTasks(int t);
66 int strtoint32(const std::string& word);
67 int64 strtoint64(const std::string& word);
68
69 std::string basedata_;
70 int64 seed_;
71 LoadStatus load_status_;
72 int num_declared_tasks_;
73 int current_task_;
74 std::vector<std::vector<int> > temp_delays_;
75 std::vector<int> recipe_sizes_;
76 int unreads_;
77 RcpspProblem rcpsp_;
78};
79
80} // namespace rcpsp
81} // namespace data
82} // namespace operations_research
83
84#endif // OR_TOOLS_DATA_RCPSP_PARSER_H_
::operations_research::data::rcpsp::RcpspProblem problem() const
Definition: rcpsp_parser.h:38
bool ParseFile(const std::string &file_name)
Definition: rcpsp_parser.cc:36
int64_t int64
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...