Skip to content

Commit 74a9ed2

Browse files
gchateletMizux
authored andcommitted
Move course_scheduling from examples to ortools/scheduling (#4972)
Also export tests for Bazel
1 parent a7ffad1 commit 74a9ed2

File tree

8 files changed

+1526
-11
lines changed

8 files changed

+1526
-11
lines changed

ortools/scheduling/BUILD.bazel

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
1818
load("@protobuf//bazel:proto_library.bzl", "proto_library")
1919
load("@protobuf//bazel:py_proto_library.bzl", "py_proto_library")
20+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
2021
load("@rules_cc//cc:cc_library.bzl", "cc_library")
22+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
2123

2224
package(default_visibility = ["//visibility:public"])
2325

@@ -51,6 +53,29 @@ cc_library(
5153
],
5254
)
5355

56+
cc_test(
57+
name = "rcpsp_parser_test",
58+
size = "small",
59+
srcs = ["rcpsp_parser_test.cc"],
60+
data = [
61+
"//ortools/scheduling/testdata:c1510_1.mm.txt",
62+
"//ortools/scheduling/testdata:j301_1.sm",
63+
"//ortools/scheduling/testdata:mmlib100_j100100_1.mm.txt",
64+
"//ortools/scheduling/testdata:psp1.sch",
65+
"//ortools/scheduling/testdata:psp10_1.sch",
66+
"//ortools/scheduling/testdata:rg300_1.rcp",
67+
"//ortools/scheduling/testdata:rg30_set1_pat1.rcp",
68+
"//ortools/scheduling/testdata:rip1.sch",
69+
"//ortools/scheduling/testdata:ubo_10_psp2.sch",
70+
],
71+
deps = [
72+
":rcpsp_parser",
73+
"//ortools/base:gmock_main",
74+
"//ortools/base:path",
75+
"@abseil-cpp//absl/strings:string_view",
76+
],
77+
)
78+
5479
### Jobshop Scheduling ###
5580
proto_library(
5681
name = "jobshop_scheduling_proto",
@@ -81,6 +106,27 @@ cc_library(
81106
],
82107
)
83108

109+
cc_test(
110+
name = "jobshop_scheduling_parser_test",
111+
size = "small",
112+
srcs = ["jobshop_scheduling_parser_test.cc"],
113+
data = [
114+
"//ortools/scheduling/testdata:02a.fjs",
115+
"//ortools/scheduling/testdata:1010_1_3",
116+
"//ortools/scheduling/testdata:50_10_01_ta041.txt",
117+
"//ortools/scheduling/testdata:SDST10_ta001.txt",
118+
"//ortools/scheduling/testdata:ft06",
119+
"//ortools/scheduling/testdata:jb1.txt",
120+
"//ortools/scheduling/testdata:taillard-jobshop-15_15-1_225_100_150-1",
121+
],
122+
deps = [
123+
":jobshop_scheduling_parser",
124+
"//ortools/base:gmock_main",
125+
"//ortools/base:path",
126+
"@abseil-cpp//absl/strings:string_view",
127+
],
128+
)
129+
84130
### Course Scheduling ###
85131
proto_library(
86132
name = "course_scheduling_proto",
@@ -91,3 +137,47 @@ cc_proto_library(
91137
name = "course_scheduling_cc_proto",
92138
deps = [":course_scheduling_proto"],
93139
)
140+
141+
cc_library(
142+
name = "course_scheduling",
143+
srcs = ["course_scheduling.cc"],
144+
hdrs = ["course_scheduling.h"],
145+
deps = [
146+
":course_scheduling_cc_proto",
147+
"//ortools/base:mathutil",
148+
"//ortools/linear_solver:linear_solver_base",
149+
"//ortools/linear_solver:linear_solver_scip",
150+
"//ortools/sat:cp_model_cc_proto",
151+
"@abseil-cpp//absl/container:flat_hash_set",
152+
"@abseil-cpp//absl/log",
153+
"@abseil-cpp//absl/status",
154+
"@abseil-cpp//absl/strings:str_format",
155+
"@abseil-cpp//absl/types:span",
156+
],
157+
)
158+
159+
cc_binary(
160+
name = "course_scheduling_run",
161+
srcs = ["course_scheduling_run.cc"],
162+
deps = [
163+
":course_scheduling",
164+
":course_scheduling_cc_proto",
165+
"//ortools/base",
166+
"//ortools/base:file",
167+
"//ortools/base:timer",
168+
"@abseil-cpp//absl/flags:flag",
169+
"@abseil-cpp//absl/log",
170+
],
171+
)
172+
173+
cc_test(
174+
name = "course_scheduling_test",
175+
srcs = ["course_scheduling_test.cc"],
176+
deps = [
177+
":course_scheduling",
178+
":course_scheduling_cc_proto",
179+
"//ortools/base:gmock_main",
180+
"//ortools/base:mutable_memfile",
181+
"//ortools/base:parse_test_proto",
182+
],
183+
)

ortools/scheduling/CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313

14-
file(GLOB _SRCS "*.h" "*.cc")
14+
list(APPEND _SRCS
15+
course_scheduling.cc
16+
course_scheduling.h
17+
jobshop_scheduling_parser.cc
18+
jobshop_scheduling_parser.h
19+
rcpsp_parser.cc
20+
rcpsp_parser.h
21+
)
1522
set(NAME ${PROJECT_NAME}_scheduling)
1623

1724
# Will be merge in libortools.so
18-
#add_library(${NAME} STATIC ${_SRCS})
1925
add_library(${NAME} OBJECT ${_SRCS})
20-
set_target_properties(${NAME} PROPERTIES
21-
POSITION_INDEPENDENT_CODE ON
22-
)
26+
set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
2327
target_include_directories(${NAME} PRIVATE
2428
${PROJECT_SOURCE_DIR}
2529
${PROJECT_BINARY_DIR})
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
#include "examples/cpp/course_scheduling.h"
14+
#include "ortools/scheduling/course_scheduling.h"
1515

1616
#include <algorithm>
1717
#include <cmath>
@@ -21,10 +21,10 @@
2121
#include <vector>
2222

2323
#include "absl/container/flat_hash_set.h"
24+
#include "absl/log/log.h"
2425
#include "absl/status/status.h"
2526
#include "absl/strings/str_format.h"
2627
#include "absl/types/span.h"
27-
#include "ortools/base/logging.h"
2828
#include "ortools/base/mathutil.h"
2929
#include "ortools/linear_solver/linear_solver.h"
3030
#include "ortools/scheduling/course_scheduling.pb.h"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
#ifndef ORTOOLS_EXAMPLES_COURSE_SCHEDULING_H_
15-
#define ORTOOLS_EXAMPLES_COURSE_SCHEDULING_H_
14+
#ifndef ORTOOLS_SCHEDULING_COURSE_SCHEDULING_H_
15+
#define ORTOOLS_SCHEDULING_COURSE_SCHEDULING_H_
1616

1717
#include <utility>
1818
#include <vector>
@@ -83,4 +83,4 @@ class CourseSchedulingSolver {
8383

8484
} // namespace operations_research
8585

86-
#endif // ORTOOLS_EXAMPLES_COURSE_SCHEDULING_H_
86+
#endif // ORTOOLS_SCHEDULING_COURSE_SCHEDULING_H_

examples/cpp/course_scheduling_run.cc renamed to ortools/scheduling/course_scheduling_run.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323

2424
#include "absl/flags/flag.h"
2525
#include "absl/log/log.h"
26-
#include "examples/cpp/course_scheduling.h"
2726
#include "ortools/base/helpers.h"
2827
#include "ortools/base/init_google.h"
2928
#include "ortools/base/options.h"
3029
#include "ortools/base/timer.h"
30+
#include "ortools/scheduling/course_scheduling.h"
3131
#include "ortools/scheduling/course_scheduling.pb.h"
3232

3333
ABSL_FLAG(std::string, input, "",

0 commit comments

Comments
 (0)