-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
210 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
VERSION := @PROJECT_VERSION@ | ||
# Let's discover something about where we run | ||
ifeq ($(OS),Windows_NT) | ||
OS = Windows | ||
endif | ||
ifeq ($(OS),Windows) | ||
SYSTEM = win | ||
else | ||
SYSTEM = unix | ||
endif | ||
.SECONDARY: | ||
# Useful directories. | ||
EX_DIR = examples | ||
EX_PATH = $(subst /,$S,$(EX_DIR)) | ||
# Unix specific part. | ||
ifeq ($(SYSTEM),unix) | ||
OS = $(shell uname -s) | ||
# C++ | ||
ifeq ($(OS),Linux) | ||
endif # ifeq($(OS),Linux) | ||
ifeq ($(OS),Darwin) # Assume Mac Os X | ||
endif # ifeq($(OS),Darwin) | ||
# Makefile | ||
S = / | ||
DEL = rm -f | ||
DEL_REC = rm -rf | ||
MKDIR = mkdir | ||
endif # SYSTEM == unix | ||
# Windows specific part. | ||
ifeq ($(SYSTEM),win) | ||
# Makefile | ||
S = \\ | ||
DEL = del | ||
DEL_REC = rd /S /Q | ||
MKDIR = md | ||
endif # SYSTEM == win | ||
BUILD_TYPE ?= Release | ||
.PHONY: all | ||
all: detect | ||
.PHONY: detect | ||
detect: | ||
@echo VERSION = $(VERSION) | ||
@echo SHELL = $(SHELL) | ||
@echo SYSTEM = $(SYSTEM) | ||
@echo PORT = $(PORT) | ||
@echo OS = $(OS) | ||
@echo CC = $(CC) | ||
@echo CC_BIN = $(CC_BIN) | ||
@echo CXX = $(CXX) | ||
@echo CXX_BIN = $(CXX_BIN) | ||
@echo CXXFLAGS = $(CXXFLAGS) | ||
@echo LDFLAGS = $(LDFLAGS) | ||
@echo OR_TOOLS_LNK = $(OR_TOOLS_LNK) | ||
@echo SOURCE = $(SOURCE) | ||
@echo SOURCE_PATH = $(SOURCE_PATH) | ||
@echo SOURCE_NAME = $(SOURCE_NAME) | ||
@echo SOURCE_SUFFIX = $(SOURCE_SUFFIX) | ||
ifeq ($(SYSTEM),win) | ||
@echo off & echo( | ||
else | ||
@echo | ||
endif | ||
############## | ||
## SOURCE ## | ||
############## | ||
.PHONY: build # Build a C++ program. | ||
.PHONY: run # Run a C++ program. | ||
# Check SOURCE argument | ||
SOURCE_SUFFIX = $(suffix $(SOURCE)) | ||
# will contain “/any/path/foo.cc” on unix and “\\any\\path\\foo.cc” on windows | ||
SOURCE_PATH = $(subst /,$S,$(SOURCE)) | ||
SOURCE_NAME = $(basename $(notdir $(SOURCE))) | ||
ifeq ($(SOURCE),) # Those rules will be used if SOURCE is empty | ||
build run: | ||
$(error no source file provided, the "$@" target must be used like so: \ | ||
make $@ SOURCE=relative/path/to/filename.extension) | ||
else #ifeq SOURCE | ||
ifeq (,$(wildcard $(SOURCE))) | ||
$(error File "$(SOURCE)" does not exist !) | ||
endif #ifeq SOURCE exist | ||
build: $(SOURCE) example/$(SOURCE_NAME)/CMakeLists.txt | ||
cd examples$S$(SOURCE_NAME) && cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) | ||
cd examples$S$(SOURCE_NAME) && cmake --build build --config $(BUILD_TYPE) -v | ||
run: build | ||
ifeq ($(SYSTEM),win) | ||
cd examples$S$(SOURCE_NAME) && cmake --build build --config $(BUILD_TYPE) --target RUN_TESTS -v | ||
else #ifeq win | ||
cd examples$S$(SOURCE_NAME) && cmake --build build --config $(BUILD_TYPE) --target test -v | ||
endif #ifeq Swin | ||
endif #ifeq SOURCE | ||
############# | ||
## Tests ## | ||
############# | ||
.PHONY: test | ||
test: | ||
$(MAKE) run SOURCE=examples/basic_example/basic_example.cc | ||
$(MAKE) run SOURCE=examples/linear_programming/linear_programming.cc | ||
$(MAKE) run SOURCE=examples/integer_programming/integer_programming.cc | ||
$(MAKE) run SOURCE=examples/simple_knapsack_program/simple_knapsack_program.cc | ||
$(MAKE) run SOURCE=examples/simple_max_flow_program/simple_max_flow_program.cc | ||
$(MAKE) run SOURCE=examples/simple_min_cost_flow_program/simple_min_cost_flow_program.cc | ||
$(MAKE) run SOURCE=examples/simple_lp_program/simple_lp_program.cc | ||
$(MAKE) run SOURCE=examples/simple_mip_program/simple_mip_program.cc | ||
$(MAKE) run SOURCE=examples/simple_sat_program/simple_sat_program.cc | ||
$(MAKE) run SOURCE=examples/simple_ls_program/simple_ls_program.cc | ||
$(MAKE) run SOURCE=examples/tsp/tsp.cc | ||
$(MAKE) run SOURCE=examples/vrp/vrp.cc | ||
$(MAKE) run SOURCE=examples/nurses_cp/nurses_cp.cc | ||
$(MAKE) run SOURCE=examples/nurses_sat/nurses_sat.cc | ||
$(MAKE) run SOURCE=examples/minimal_jobshop_cp/minimal_jobshop_cp.cc | ||
############ | ||
## MISC ## | ||
############ | ||
# Include user makefile | ||
-include Makefile.user | ||
print-% : ; @echo $* = $($*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,63 @@ | ||
# Introduction | ||
|
||
This file describes how to use OR-Tools in C++ with the binary archives. | ||
This file describes how to use OR-Tools in C++ with the binary archive. | ||
|
||
OR-Tools online documentation is | ||
[here](https://developers.google.com/optimization) | ||
OR-Tools online documentation is located at https://developers.google.com/optimization | ||
|
||
Full installation instructions are located | ||
[here](https://developers.google.com/optimization/install/cpp/) | ||
Full installation instructions are located at https://developers.google.com/optimization/install/cpp/ | ||
|
||
These modules have been tested under: | ||
|
||
- CentOS 8 (64 bit). | ||
- Debian 11 (64 bit). | ||
- CentOS 7 LTS and Stream 8 (64 bit). | ||
- Debian 10 and 11 (64 bit). | ||
- Fedora 33 and up (64 bit). | ||
- Ubuntu 18.04 LTS and up (64 bit). | ||
- MacOS 12.2 Monterey (64 bit). | ||
- Microsoft Windows with Visual Studio 2022 (64-bit) | ||
- Microsoft Windows with Visual Studio 2019 and 2022 (64-bit) | ||
|
||
Upon decompressing the archive, you will get the following structure: | ||
|
||
``` | ||
or-tools/ | ||
[LICENSE](LICENSE) <- Apache License | ||
or-tools_cpp/ | ||
[README.md](README.md) <- This file | ||
[examples/data/](examples/data) <- Data for the examples | ||
[examples/cpp](examples/cpp) <- C++ examples | ||
[bin](bin) <- directory containing executable files | ||
[include](include) <- directory containing headers files. | ||
[lib](lib) <- directory containing libraries files. | ||
[share](share) <- directory containing various files. | ||
[examples](examples) <- C++ examples. | ||
[Makefile](Makefile) <- Main Makefile for C++. | ||
``` | ||
|
||
Warning: While OR-Tools ships with SCIP, please consult the SCIP license | ||
to ensure that you are complying with it if you want to use this solver. | ||
|
||
# C++ | ||
|
||
Running the examples will involve compiling them, then running them. | ||
We have provided a makefile target to help you. | ||
|
||
Use Makefile: | ||
|
||
```shell | ||
make run SOURCE=examples/basic_example/basic_example.cc | ||
``` | ||
|
||
**OR** this is equivalent to compiling and running | ||
`examples/basic_example/basic_example.cc`. | ||
|
||
- on Unix: | ||
|
||
```shell | ||
cd examples/basic_example | ||
cmake -S . -B build | ||
cmake --build build | ||
``` | ||
|
||
- on Windows: | ||
|
||
```shell | ||
cd examples/basic_example | ||
cmake -S . -B build | ||
cmake --build build | ||
``` | ||
|