-
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.
added missing files, examples and Conic Cgl source files.
- Loading branch information
1 parent
81f8ca7
commit d0e4399
Showing
13 changed files
with
3,122 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# Copyright (C) 2015 Lehigh University. | ||
# All Rights Reserved. | ||
# This file is distributed under the Eclipse Public License. | ||
|
||
# Author: Aykut Bulut, [email protected], 06/19/2015 | ||
|
||
########################################################################## | ||
# You can modify this example makefile to fit for your own program. # | ||
# Usually, you only need to change the five CHANGEME entries below. # | ||
########################################################################## | ||
|
||
# To compile other examples, either changed the following line, or | ||
# add the argument DRIVER=problem_name to make | ||
DRIVER = gd1 | ||
|
||
# CHANGEME: This should be the name of your executable | ||
EXE = $(DRIVER)@EXEEXT@ | ||
|
||
# CHANGEME: Here is the name of all object files corresponding to the source | ||
# code that you wrote in order to define the problem statement | ||
OBJS = $(DRIVER).@OBJEXT@ | ||
|
||
# CHANGEME: Additional libraries | ||
ADDLIBS = | ||
|
||
# CHANGEME: Additional flags for compilation (e.g., include flags) | ||
ADDINCFLAGS = | ||
|
||
# CHANGEME: Directory to the sources for the (example) problem definition | ||
# files | ||
SRCDIR = @srcdir@ | ||
VPATH = @srcdir@ | ||
|
||
########################################################################## | ||
# Usually, you don't have to change anything below. Note that if you # | ||
# change certain compiler options, you might have to recompile the # | ||
# COIN package. # | ||
########################################################################## | ||
|
||
COIN_HAS_PKGCONFIG = @COIN_HAS_PKGCONFIG_TRUE@TRUE | ||
COIN_CXX_IS_CL = @COIN_CXX_IS_CL_TRUE@TRUE | ||
COIN_HAS_SAMPLE = @COIN_HAS_SAMPLE_TRUE@TRUE | ||
COIN_HAS_NETLIB = @COIN_HAS_NETLIB_TRUE@TRUE | ||
|
||
# C++ Compiler command | ||
CXX = @CXX@ | ||
|
||
# C++ Compiler options | ||
CXXFLAGS = @CXXFLAGS@ | ||
|
||
# additional C++ Compiler options for linking | ||
CXXLINKFLAGS = @RPATH_FLAGS@ | ||
|
||
# C Compiler command | ||
CC = @CC@ | ||
|
||
# C Compiler options | ||
CFLAGS = @CFLAGS@ | ||
|
||
# Sample data directory | ||
ifeq ($(COIN_HAS_SAMPLE), TRUE) | ||
ifeq ($(COIN_HAS_PKGCONFIG), TRUE) | ||
CXXFLAGS += -DSAMPLEDIR=\"`PKG_CONFIG_PATH=@COIN_PKG_CONFIG_PATH@ @PKG_CONFIG@ --variable=datadir coindatasample`\" | ||
CFLAGS += -DSAMPLEDIR=\"`PKG_CONFIG_PATH=@COIN_PKG_CONFIG_PATH@ @PKG_CONFIG@ --variable=datadir coindatasample`\" | ||
else | ||
CXXFLAGS += -DSAMPLEDIR=\"@SAMPLE_DATA_INSTALLED@\" | ||
CFLAGS += -DSAMPLEDIR=\"@SAMPLE_DATA_INSTALLED@\" | ||
endif | ||
endif | ||
|
||
# Netlib data directory | ||
ifeq ($(COIN_HAS_NETLIB), TRUE) | ||
ifeq ($(COIN_HAS_PKGCONFIG), TRUE) | ||
CXXFLAGS += -DNETLIBDIR=\"`PKG_CONFIG_PATH=@COIN_PKG_CONFIG_PATH@ @PKG_CONFIG@ --variable=datadir coindatanetlib`\" | ||
CFLAGS += -DNETLIBDIR=\"`PKG_CONFIG_PATH=@COIN_PKG_CONFIG_PATH@ @PKG_CONFIG@ --variable=datadir coindatanetlib`\" | ||
else | ||
CXXFLAGS += -DNETLIBDIR=\"@NETLIB_DATA_INSTALLED@\" | ||
CFLAGS += -DNETLIBDIR=\"@NETLIB_DATA_INSTALLED@\" | ||
endif | ||
endif | ||
|
||
# Include directories (we use the CYGPATH_W variables to allow compilation with Windows compilers) | ||
ifeq ($(COIN_HAS_PKGCONFIG), TRUE) | ||
INCL = `PKG_CONFIG_PATH=@COIN_PKG_CONFIG_PATH@ @PKG_CONFIG@ --cflags cglconic` | ||
else | ||
INCL = @CGLCONICLIB_CFLAGS_INSTALLED@ | ||
endif | ||
INCL += $(ADDINCFLAGS) | ||
|
||
# Linker flags | ||
ifeq ($(COIN_HAS_PKGCONFIG), TRUE) | ||
LIBS = `PKG_CONFIG_PATH=@COIN_PKG_CONFIG_PATH@ @PKG_CONFIG@ --libs cglconic` | ||
else | ||
ifeq ($(COIN_CXX_IS_CL), TRUE) | ||
LIBS = -link -libpath:`$(CYGPATH_W) @abs_lib_dir@` libCglConic.lib @CGLCONICLIB_LIBS_INSTALLED@ | ||
else | ||
LIBS = -L@abs_lib_dir@ -lCglConic @CGLCONICLIB_LIBS_INSTALLED@ | ||
endif | ||
endif | ||
|
||
# The following is necessary under cygwin, if native compilers are used | ||
CYGPATH_W = @CYGPATH_W@ | ||
|
||
# Here we list all possible generated objects or executables to delete them | ||
CLEANFILES = \ | ||
gd1.@OBJEXT@ bental@EXEEXT@ \ | ||
milp_cuts.@OBJEXT@ canonical@EXEEXT@ \ | ||
mir.@OBJEXT@ gd1@EXEEXT@ | ||
|
||
all: $(EXE) | ||
|
||
.SUFFIXES: .cpp .c .o .obj | ||
|
||
$(EXE): $(OBJS) | ||
bla=;\ | ||
for file in $(OBJS); do bla="$$bla `$(CYGPATH_W) $$file`"; done; \ | ||
$(CXX) $(CXXLINKFLAGS) $(CXXFLAGS) -o $@ $$bla $(LIBS) $(ADDLIBS) | ||
|
||
clean: | ||
rm -rf $(CLEANFILES) | ||
|
||
.cpp.o: | ||
$(CXX) $(CXXFLAGS) $(INCL) -c -o $@ `test -f '$<' || echo '$(SRCDIR)/'`$< | ||
|
||
|
||
.cpp.obj: | ||
$(CXX) $(CXXFLAGS) $(INCL) -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(SRCDIR)/$<'; fi` | ||
|
||
.c.o: | ||
$(CC) $(CFLAGS) $(INCL) -c -o $@ `test -f '$<' || echo '$(SRCDIR)/'`$< | ||
|
||
|
||
.c.obj: | ||
$(CC) $(CFLAGS) $(INCL) -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(SRCDIR)/$<'; fi` |
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,33 @@ | ||
NAME | ||
* Example from Julio's thesis section 4.2 | ||
OBJSENSE | ||
MIN | ||
ROWS | ||
N obj | ||
E c1 | ||
COLUMNS | ||
x1 obj 3 | ||
x1 c1 9 | ||
x2 obj 2 | ||
x2 c1 1 | ||
x3 obj 2 | ||
x3 c1 1 | ||
MARK0001 'MARKER' 'INTORG' | ||
x4 obj 1 | ||
x4 c1 1 | ||
MARK0001 'MARKER' 'INTEND' | ||
|
||
RHS | ||
rhs c1 10 | ||
RANGES | ||
BOUNDS | ||
FR bound x1 | ||
FR bound x2 | ||
FR bound x3 | ||
FR bound x4 | ||
CSECTION k1 0 QUAD | ||
x1 | ||
x2 | ||
x3 | ||
x4 | ||
ENDATA |
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,95 @@ | ||
//----------------------------------------------------- | ||
// Simple example usage of the cut generation library. | ||
// | ||
// This sample program adds general disjunction cuts from | ||
// Belotti et al. and resolves the relaxation problem to see | ||
// whether the bound is improved. | ||
// | ||
// usage: | ||
// solve_with_gd1 mpsFileName | ||
// example: | ||
// solve_with_mir ../../Data/Sample/p0033 | ||
//----------------------------------------------------- | ||
|
||
// STDLIB headers | ||
#include <cassert> | ||
#include <iostream> | ||
#include <string> | ||
#include <cassert> | ||
// CoinUtils headers | ||
#include <CoinError.hpp> | ||
#include <CoinWarmStartBasis.hpp> | ||
// OSI headers | ||
#include <OsiCuts.hpp> | ||
// OSICONIC header | ||
#include <OsiConicSolverInterface.hpp> | ||
// #include <OsiMosekSolverInterface.hpp> | ||
#include <OsiConicCuts.hpp> | ||
// COLA headers | ||
#include <ColaModel.hpp> | ||
// CGL headers | ||
// #include "CglKnapsackCover.hpp" | ||
// #include "CglSimpleRounding.hpp" | ||
// #include "CglGMI.hpp" | ||
// #include "CglGomory.hpp" | ||
// #include "CglMixedIntegerRounding.hpp" | ||
// #include "CglMixedIntegerRounding2.hpp" | ||
// Conic CGL headers | ||
#include "CglConicGD1.hpp" | ||
|
||
using std::cerr; | ||
using std::cout; | ||
using std::endl; | ||
using std::string; | ||
|
||
int main(int argc, const char *argv[]) { | ||
// If no parms specified then use these | ||
string mpsFileName = argv[1]; | ||
try { | ||
// Instantiate a specific solver interface | ||
OsiConicSolverInterface * si = new ColaModel(); | ||
// OsiConicSolverInterface * si = new OsiMosekSolverInterface(); | ||
// Read file describing problem | ||
si->readMps(mpsFileName.c_str(),"mps"); | ||
// Solve continuous problem | ||
si->initialSolve(); | ||
// Save the orig socp relaxation value for | ||
// comparisons later | ||
double origSocpObj = si->getObjValue(); | ||
// Instantiate cut generator | ||
CglConicGD1 cg(si); | ||
bool equalObj; | ||
CoinRelFltEq eq(0.0001); | ||
int num_cut = 0; | ||
double obj; | ||
//--------------------------------------------------- | ||
// Keep applying cuts until no more cuts are generated | ||
//--------------------------------------------------- | ||
do { | ||
// Get current solution value | ||
obj = si->getObjValue(); | ||
// Generate and apply cuts | ||
cg.generateAndAddCuts(*si); | ||
si->writeMps("after_cut"); | ||
si->resolve(); | ||
equalObj = eq(si->getObjValue(), obj); | ||
} while (!equalObj); | ||
// double const * sol = si->getColSolution(); | ||
// Print total number of cuts applied, | ||
// and total improvement in the SOCP objective value | ||
cout <<endl <<endl; | ||
cout << "----------------------------------------------------------" | ||
<<endl; | ||
cout << "Cut generation phase completed:" <<endl; | ||
cout << " " << cg.getNumCutsAdded() << " many cuts added." << endl; | ||
cout << " changing the SOCP objective value from " << origSocpObj | ||
<< " to " << si->getObjValue() <<endl; | ||
cout << "----------------------------------------------------------" | ||
<<endl; | ||
cout <<endl <<endl; | ||
} | ||
catch (CoinError e) { | ||
cout << e.className() << "::" << e.methodName() << " - " << e.message() << endl; | ||
} | ||
return 0; | ||
} |
Oops, something went wrong.