-
Notifications
You must be signed in to change notification settings - Fork 1
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
Anirudh Subramanyam
authored and
Anirudh Subramanyam
committed
Oct 15, 2019
0 parents
commit 37a1879
Showing
24 changed files
with
8,778 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
|
||
# do track lib.a, even though you're ignoring .a files above | ||
# !lib.a | ||
|
||
# only ignore the TODO file in the current directory, not subdir/TODO | ||
# /TODO | ||
|
||
# ignore all files in the build/ directory | ||
build/ | ||
|
||
# ignore doc/notes.txt, but not doc/server/arch.txt | ||
# doc/*.txt | ||
|
||
# ignore all .pdf files in the doc/ directory | ||
# doc/**/*.pdf |
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,66 @@ | ||
# CHECK CMAKE VERSION | ||
cmake_minimum_required(VERSION 2.8) | ||
|
||
# SPECIFY PROJECT NAME | ||
project(K_ADAPTABILITY) | ||
|
||
# SPECIFY SOURCE FILES (.CPP, .C) | ||
set(SOURCE_FILES | ||
./src/uncertainty.cpp | ||
./src/problemInfo.cpp | ||
./src/problemInfo_knp.cpp | ||
./src/problemInfo_spp.cpp | ||
./src/problemInfo_psp.cpp | ||
./src/indexingTools.cpp | ||
./src/robustSolver.cpp | ||
./src/test.cpp | ||
) | ||
|
||
# SPECIFY CUSTOM HEADER FILE DIRECTORIES (OR SET "DEFAULT" IF NONE) | ||
set(HDRDIR ./inc) | ||
|
||
# SPECIFY NAME OF EXECUTABLE | ||
set(EXEC kadaptability) | ||
|
||
# SET COMPILER DIRECTORY (OR SET "DEFAULT") | ||
set(COMPILER_DIR /usr/local/bin/g++) | ||
|
||
# SET CPLEX DIRECTORY | ||
set(CPLEX_DIR /opt/ibm/ILOG/CPLEX_Studio127) | ||
|
||
# CHECK OS | ||
if(APPLE) | ||
set(mySystem "osx") | ||
elseif(UNIX) | ||
set(mySystem "linux") | ||
else() | ||
message(FATAL_ERROR "ONLY UNIX IS SUPPORTED AT THIS TIME") | ||
endif() | ||
|
||
# SET COMPILER DIRECTORY | ||
if(NOT "${COMPILER_DIR}" STREQUAL "DEFAULT") | ||
set(CMAKE_CXX_COMPILER ${COMPILER_DIR}) | ||
endif() | ||
|
||
# SET COMPILER FLAGS | ||
set(COMP_FLAGS_DEBUG " -g -std=c++14 -m64 -O0 -DIL_STD -pthread -D_GLIBCXX_DEBUG -Wall -Wextra -fPIC -fno-strict-aliasing -fexceptions") | ||
set(COMP_FLAGS_RELEASE " -std=c++14 -m64 -O2 -DIL_STD -pthread -DNDEBUG -Wall -Wextra -fPIC -fno-strict-aliasing -fexceptions") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${COMP_FLAGS_DEBUG}") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${COMP_FLAGS_RELEASE}") | ||
|
||
# SET INCLUDE DIRECTORIES (.h .hpp) | ||
include_directories(${EXEC} ${CPLEX_DIR}/cplex/include ${CPLEX_DIR}/concert/include) | ||
|
||
# INCLUDE THE CUSTOM INC DIRECTORIES IF DEFINED | ||
if(NOT "${HDRDIR}" STREQUAL "DEFAULT") | ||
include_directories(${EXEX} ${HDRDIR}) | ||
endif() | ||
|
||
# SET LINK DIRECTORIES | ||
link_directories(${CPLEX_DIR}/cplex/lib/x86-64_${mySystem}/static_pic ${CPLEX_DIR}/concert/lib/x86-64_${mySystem}/static_pic) | ||
|
||
# CREATE THE TARGET (executable or library) | ||
add_executable(${EXEC} ${SOURCE_FILES}) | ||
|
||
# LINK THE DESIRED LIBRARIES | ||
target_link_libraries(${EXEC} concert ilocplex cplex m pthread) |
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,11 @@ | ||
Copyright 2019 by Anirudh Subramanyam, Chrysanthos Gounaris and Wolfram Wiesemann | ||
|
||
Anirudh Subramanyam and Chrysanthos Gounaris are affiliated with Carnegie Mellon University. Wolfram Wiesemann is affiliated with Imperial College London. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,55 @@ | ||
|
||
k-adaptability-solver | ||
==== | ||
|
||
k-adaptability-solver is a numerical optimization package, written in C++, for solving K-adaptability counterparts of two-stage mixed-integer robust optimization problems, based on our paper [K-Adaptability in Two-Stage Mixed-Integer Robust Optimization](https://arxiv.org/abs/1706.07097). | ||
|
||
If you use this code in your research, please cite: | ||
``` | ||
@article{sgw:19, | ||
title = {K-adaptability in two-stage mixed-integer robust optimization}, | ||
author = {Subramanyam, Anirudh and Gounaris, Chrysanthos E and Wiesemann, Wolfram}, | ||
journal = {Mathematical Programming Computation}, | ||
year = {2019} | ||
} | ||
``` | ||
## Requirements | ||
* Cmake 2.8 or higher | ||
* CPLEX 12.6 or higher | ||
* OS X or Linux OS | ||
|
||
## Installation on OS X and Linux | ||
* Obtain a copy of the CPLEX software and license [here](https://www.ibm.com/analytics/cplex-optimizer) | ||
* Specify the CPLEX installation directory in CMakeLists.txt | ||
* Enter the following commands on the terminal | ||
``` | ||
$ mkdir build | ||
$ cd build/ | ||
$ cmake Unix Makefiles -DCMAKE_BUILD_TYPE=Release .. | ||
$ make | ||
``` | ||
* You should find an executable `kadaptability` in the build/ directory | ||
|
||
## Note | ||
* You may also compile in debug mode by changing `Release` to `Debug` in the above command. | ||
* You may change the `TIME_LIMIT`, `MEMORY_LIMIT` and `NUM_THREADS` parameters in inc/Constants.h. If you do modify the defaults, please re-build for the changes to take effect. | ||
|
||
## Usage | ||
The problem (variables, objective function, constraints, uncertainty set etc) is modeled in the abstract class `KAdaptableInfo` defined in problemInfo.hpp/cpp. | ||
|
||
To solve a new problem, you must create a new class which will inherit from this abstract class. | ||
You must then override the following functions: | ||
|
||
* `makeVars` | ||
* `makeUncSet` | ||
* `makeConsX` | ||
* `makeConsY` | ||
* `create` | ||
* `clone` | ||
|
||
As an example, have a look at problemInfo_knp.hpp/cpp. This file implements examples 4.2 and 4.3 from the above paper. | ||
|
||
After you have implemented the above class, you can solve it by creating a `KAdaptableSolver` object and calling the function `solve_KAdaptability(K, heuristic, x)`. The solution vector is returned in `x`, and a summary of the run will be written to standard output. | ||
|
||
As an example, please follow the `main` function defined in src/test.cpp. | ||
|
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,30 @@ | ||
/***************************************************************************************/ | ||
/* */ | ||
/* Copyright 2018 by Anirudh Subramanyam, Chrysanthos Gounaris and Wolfram Wiesemann */ | ||
/* */ | ||
/* Licensed under the FreeBSD License (the "License"). */ | ||
/* You may not use this file except in compliance with the License. */ | ||
/* You may obtain a copy of the License at */ | ||
/* */ | ||
/* https://www.freebsd.org/copyright/freebsd-license.html */ | ||
/* */ | ||
/***************************************************************************************/ | ||
|
||
#ifndef CONSTANTS_H_ | ||
#define CONSTANTS_H_ | ||
|
||
// Exception numbers | ||
#define EXCEPTION_CPXINIT 1 // CPLEX could not be initialized | ||
#define EXCEPTION_CPXEXIT 2 // CPLEX could not be closed | ||
#define EXCEPTION_CPXNEWCOLS 3 // Error while trying to create new columns | ||
#define EXCEPTION_CPXNEWROWS 4 // Error while trying to create new rows | ||
#define EXCEPTION_X 5 // Invalid size of solution vector | ||
#define EXCEPTION_K 6 // Invalid policy index | ||
#define EXCEPTION_Q 7 // Invalid size of uncertain parameters | ||
|
||
// Defaults | ||
#define TIME_LIMIT 7200 | ||
#define MEMORY_LIMIT 3072 | ||
#define NUM_THREADS 1 | ||
|
||
#endif |
Oops, something went wrong.