OR-Tools  9.6
jobshop_scheduling_parser.h
Go to the documentation of this file.
1 // Copyright 2010-2022 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 #ifndef OR_TOOLS_SCHEDULING_JOBSHOP_SCHEDULING_PARSER_H_
15 #define OR_TOOLS_SCHEDULING_JOBSHOP_SCHEDULING_PARSER_H_
16 
17 #include <cstdint>
18 #include <string>
19 
20 #include "absl/strings/match.h"
22 #include "ortools/scheduling/jobshop_scheduling.pb.h"
23 
24 namespace operations_research {
25 namespace scheduling {
26 namespace jssp {
27 
28 class JsspParser {
29  public:
30  enum ProblemType {
37  PSS,
39  };
40 
41  enum ParserState {
54  DONE
55  };
56 
58 
59  // Parses a file to load a jobshop problem.
60  // Tries to auto detect the file format.
61  bool ParseFile(const std::string& filename);
62 
63  // Returns the loaded problem.
64  const JsspInputProblem& problem() const { return problem_; }
65 
66  private:
67  void ProcessJsspLine(const std::string& line);
68  void ProcessTaillardLine(const std::string& line);
69  void ProcessFlexibleLine(const std::string& line);
70  void ProcessSdstLine(const std::string& line);
71  void ProcessTardinessLine(const std::string& line);
72  void ProcessPssLine(const std::string& line);
73  void ProcessEarlyTardyLine(const std::string& line);
74 
75  void SetJobs(int job_count);
76  void SetMachines(int machine_count);
77  int strtoint32(const std::string& word);
78  int64_t strtoint64(const std::string& word);
79 
80  JsspInputProblem problem_;
81  int declared_machine_count_ = -1;
82  int declared_job_count_ = -1;
83  int current_job_index_ = 0;
84  int current_machine_index_ = 0;
85  int transition_index_ = 0;
86  ProblemType problem_type_ = UNDEFINED;
87  ParserState parser_state_ = START;
88 };
89 
90 } // namespace jssp
91 } // namespace scheduling
92 } // namespace operations_research
93 
94 #endif // OR_TOOLS_SCHEDULING_JOBSHOP_SCHEDULING_PARSER_H_
Collection of objects used to extend the Constraint Solver library.
int line
Definition: parse_proto.cc:31