Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
rcpsp_parser.h
Go to the documentation of this file.
1// Copyright 2010-2024 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_SCHEDULING_RCPSP_PARSER_H_
18#define OR_TOOLS_SCHEDULING_RCPSP_PARSER_H_
19
20#include <cstdint>
21#include <string>
22#include <vector>
23
24#include "absl/strings/string_view.h"
25#include "ortools/scheduling/rcpsp.pb.h"
26
27namespace operations_research {
28namespace scheduling {
29namespace rcpsp {
30
31// RCPSP parser.
32// Parse a RCPSP problem and load it into a RcpspProblem proto.
33// See description of the problem in ./rcpsp.proto
35 public:
37
38 // We keep the fully qualified name for swig.
39 ::operations_research::scheduling::rcpsp::RcpspProblem problem() const {
40 return rcpsp_;
41 }
42
43 // Returns false if an error occurred.
44 bool ParseFile(const std::string& file_name);
45
46 private:
47 enum LoadStatus {
48 NOT_STARTED,
49 HEADER_SECTION,
50 PROJECT_SECTION,
51 INFO_SECTION,
52 PRECEDENCE_SECTION,
53 REQUEST_SECTION,
54 RESOURCE_SECTION,
55 RESOURCE_MIN_SECTION,
56 PARSING_FINISHED,
57 ERROR_FOUND
58 };
59
60 void ProcessRcpspLine(const std::string& line);
61 void ProcessPattersonLine(const std::string& line);
62 void ProcessRcpspMaxLine(const std::string& line);
63 void ReportError(const std::string& line);
64 // Sets the number of declared tasks, and initialize data structures
65 // accordingly.
66 void SetNumDeclaredTasks(int t);
67 int strtoint32(absl::string_view word);
68 int64_t strtoint64(absl::string_view word);
69
70 std::string basedata_;
71 int64_t seed_;
72 LoadStatus load_status_;
73 int num_declared_tasks_;
74 int current_task_;
75 std::vector<std::vector<int> > temp_delays_;
76 std::vector<int> recipe_sizes_;
77 int unreads_;
78 RcpspProblem rcpsp_;
79};
80
81} // namespace rcpsp
82} // namespace scheduling
83} // namespace operations_research
84
85#endif // OR_TOOLS_SCHEDULING_RCPSP_PARSER_H_
bool ParseFile(const std::string &file_name)
Returns false if an error occurred.
::operations_research::scheduling::rcpsp::RcpspProblem problem() const
We keep the fully qualified name for swig.
In SWIG mode, we don't want anything besides these top-level includes.
int line