Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add qdldl lin sys solver #211

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "external/qdldl"]
path = external/qdldl
url = https://github.com/osqp/qdldl.git
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ set(ecos_sources
"${CMAKE_CURRENT_SOURCE_DIR}/external/amd/src/amd_preprocess.c"
"${CMAKE_CURRENT_SOURCE_DIR}/external/amd/src/amd_valid.c"

# LDL
"${CMAKE_CURRENT_SOURCE_DIR}/external/ldl/src/ldl.c"

# ECOS
"${CMAKE_CURRENT_SOURCE_DIR}/src/cone.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ctrlc.c"
Expand All @@ -76,6 +73,9 @@ set(ecos_sources
"${CMAKE_CURRENT_SOURCE_DIR}/ecos_bb/ecos_bb_preproc.c"
)

# QDLDL library
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/external/qdldl")

# ECOS library
add_library(ecos SHARED ${ecos_headers} ${ecos_sources})

Expand All @@ -92,18 +92,20 @@ if(NOT MSVC)
target_link_libraries(ecos PRIVATE m)
endif()

# Link QDLDL library
target_link_libraries(ecos PUBLIC qdldl)

target_include_directories(ecos
PUBLIC
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/amd/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/ldl/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/qdldl/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/SuiteSparse_config>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/ecos>"
)

# Installation
include(GNUInstallDirs)

install(TARGETS ecos
EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Expand Down
25 changes: 11 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@

# Configuration of make process in ecos.mk
include ecos.mk
CFLAGS += -Iinclude -Iexternal/ldl/include -Iexternal/amd/include -Iexternal/SuiteSparse_config
CFLAGS += -Iinclude -Iexternal/qdldl/include -Iexternal/amd/include -Iexternal/SuiteSparse_config
TEST_INCLUDES = -Itest -Itest/generated

# Compile all C code, including the C-callable routine
.PHONY: all
all: libecos.a libecos_bb.a runecos runecosexp

# build Tim Davis' sparse LDL package
$(LDL):
( cd external/ldl ; $(MAKE) )
$(AR) -x external/ldl/libldl.a
external/qdldl/build/out/libqdldl.a:
( mkdir external/qdldl/build ; cd external/qdldl/build ; cmake .. ; cmake --build . ;)

# build Tim Davis' AMD package
$(AMD):
Expand All @@ -24,13 +22,13 @@ $(AMD):

# build ECOS
ECOS_OBJS = ecos.o kkt.o cone.o spla.o ctrlc.o timer.o preproc.o splamm.o equil.o expcone.o wright_omega.o
libecos.a: $(ECOS_OBJS) $(LDL) $(AMD)
libecos.a: $(ECOS_OBJS) $(AMD) external/qdldl/build/out/libqdldl.a
$(ARCHIVE) $@ $^
- $(RANLIB) $@

# build ECOS branch-and-bound
ECOS_BB_OBJS = $(ECOS_OBJS) ecos_bb_preproc.o ecos_bb.o
libecos_bb.a: $(ECOS_BB_OBJS) $(LDL) $(AMD)
libecos_bb.a: $(ECOS_BB_OBJS) $(AMD) external/qdldl/build/out/libqdldl.a
$(ARCHIVE) $@ $^
- $(RANLIB) $@

Expand Down Expand Up @@ -58,28 +56,28 @@ wright_omega.o : include/wright_omega.h
# ECOS demo
.PHONY: demo
demo: runecos
runecos: src/runecos.c libecos.a
runecos: src/runecos.c libecos.a external/qdldl/build/out/libqdldl.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
echo ECOS successfully built. Type ./runecos to run demo problem.

runecosexp: src/runecos_exp.c libecos.a
runecosexp: src/runecos_exp.c libecos.a external/qdldl/build/out/libqdldl.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
echo ECOS-Exp successfully built. Type ./runecosexp to run demo problem.

# Shared library
.PHONY: shared
shared: $(SHAREDNAME)
$(SHAREDNAME): $(LDL) $(AMD) $(ECOS_OBJS)
$(SHAREDNAME): $(AMD) $(ECOS_OBJS) external/qdldl/build/out/libqdldl.a
$(CC) $(CFLAGS) -shared -o $@ $^ $(LDFLAGS)

# ECOS tester
TEST_OBJS = qcml_utils.o norm.o sq_norm.o sum_sq.o quad_over_lin.o inv_pos.o
.PHONY: test
test: ecostester ecos_bb_test
ecostester: test/ecostester.c $(TEST_OBJS) libecos.a
ecostester: test/ecostester.c $(TEST_OBJS) libecos.a external/qdldl/build/out/libqdldl.a
$(CC) $(CFLAGS) $(TEST_INCLUDES) -o $@ $^ $(LDFLAGS)

ecos_bb_test: test/bb_test.c libecos_bb.a
ecos_bb_test: test/bb_test.c libecos_bb.a external/qdldl/build/out/libqdldl.a
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

%.o: test/generated/%.c test/generated/%.h
Expand All @@ -92,13 +90,12 @@ ecos_bb_test: test/bb_test.c libecos_bb.a
# remove object files, but keep the compiled programs and library archives
.PHONY: clean
clean:
( cd external/ldl ; $(MAKE) clean )
( cd external/qdldl/build ; $(MAKE) clean )
( cd external/amd ; $(MAKE) clean )
- $(RM) $(CLEAN)

# clean, and then remove compiled programs and library archives
.PHONY: purge
purge: clean
( cd external/ldl ; $(MAKE) purge )
( cd external/amd ; $(MAKE) purge )
- $(RM) libecos.a libecos_bb.a runecos runecosexp
4 changes: 2 additions & 2 deletions external/SuiteSparse_config/SuiteSparse_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ extern "C" {
#define SuiteSparse_long_max _I64_MAX
#define SuiteSparse_long_idd "I64d"
#else
#define SuiteSparse_long long
#define SuiteSparse_long_max LONG_MAX
#define SuiteSparse_long long long
#define SuiteSparse_long_max LLONG_MAX
#define SuiteSparse_long_idd "ld"
#endif
#define SuiteSparse_long_id "%" SuiteSparse_long_idd
Expand Down
28 changes: 0 additions & 28 deletions external/ldl/Makefile

This file was deleted.

138 changes: 0 additions & 138 deletions external/ldl/README.txt

This file was deleted.

Loading