scs 0.2.2 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/LICENSE.txt +18 -18
- data/README.md +19 -14
- data/lib/scs/ffi.rb +31 -20
- data/lib/scs/solver.rb +32 -9
- data/lib/scs/version.rb +1 -1
- data/vendor/scs/CITATION.cff +39 -0
- data/vendor/scs/CMakeLists.txt +320 -0
- data/vendor/scs/Makefile +32 -23
- data/vendor/scs/README.md +9 -218
- data/vendor/scs/include/aa.h +67 -23
- data/vendor/scs/include/cones.h +22 -19
- data/vendor/scs/include/glbopts.h +107 -79
- data/vendor/scs/include/linalg.h +3 -4
- data/vendor/scs/include/linsys.h +58 -44
- data/vendor/scs/include/normalize.h +6 -5
- data/vendor/scs/include/rw.h +8 -2
- data/vendor/scs/include/scs.h +257 -141
- data/vendor/scs/include/scs_types.h +34 -0
- data/vendor/scs/include/scs_work.h +83 -0
- data/vendor/scs/include/util.h +3 -15
- data/vendor/scs/linsys/cpu/direct/private.c +241 -232
- data/vendor/scs/linsys/cpu/direct/private.h +13 -7
- data/vendor/scs/linsys/cpu/indirect/private.c +194 -118
- data/vendor/scs/linsys/cpu/indirect/private.h +7 -4
- data/vendor/scs/linsys/csparse.c +87 -0
- data/vendor/scs/linsys/csparse.h +34 -0
- data/vendor/scs/linsys/external/amd/SuiteSparse_config.c +6 -6
- data/vendor/scs/linsys/external/amd/SuiteSparse_config.h +6 -1
- data/vendor/scs/linsys/external/amd/amd_internal.h +1 -1
- data/vendor/scs/linsys/external/amd/amd_order.c +5 -5
- data/vendor/scs/linsys/external/qdldl/changes +2 -0
- data/vendor/scs/linsys/external/qdldl/qdldl.c +29 -46
- data/vendor/scs/linsys/external/qdldl/qdldl.h +33 -41
- data/vendor/scs/linsys/external/qdldl/qdldl_types.h +11 -3
- data/vendor/scs/linsys/gpu/gpu.c +58 -21
- data/vendor/scs/linsys/gpu/gpu.h +70 -35
- data/vendor/scs/linsys/gpu/indirect/private.c +394 -157
- data/vendor/scs/linsys/gpu/indirect/private.h +27 -12
- data/vendor/scs/linsys/scs_matrix.c +478 -0
- data/vendor/scs/linsys/scs_matrix.h +70 -0
- data/vendor/scs/scs.mk +14 -10
- data/vendor/scs/src/aa.c +394 -110
- data/vendor/scs/src/cones.c +497 -359
- data/vendor/scs/src/ctrlc.c +15 -5
- data/vendor/scs/src/linalg.c +107 -26
- data/vendor/scs/src/normalize.c +30 -72
- data/vendor/scs/src/rw.c +202 -27
- data/vendor/scs/src/scs.c +769 -571
- data/vendor/scs/src/scs_version.c +11 -3
- data/vendor/scs/src/util.c +37 -106
- data/vendor/scs/test/minunit.h +22 -8
- data/vendor/scs/test/problem_utils.h +180 -25
- data/vendor/scs/test/problems/degenerate.h +130 -0
- data/vendor/scs/test/problems/hs21_tiny_qp.h +124 -0
- data/vendor/scs/test/problems/hs21_tiny_qp_rw.h +116 -0
- data/vendor/scs/test/problems/infeasible_tiny_qp.h +100 -0
- data/vendor/scs/test/problems/qafiro_tiny_qp.h +199 -0
- data/vendor/scs/test/problems/random_prob +0 -0
- data/vendor/scs/test/problems/random_prob.h +45 -0
- data/vendor/scs/test/problems/rob_gauss_cov_est.h +188 -31
- data/vendor/scs/test/problems/small_lp.h +14 -13
- data/vendor/scs/test/problems/small_qp.h +352 -0
- data/vendor/scs/test/problems/test_validation.h +43 -0
- data/vendor/scs/test/problems/unbounded_tiny_qp.h +82 -0
- data/vendor/scs/test/random_socp_prob.c +54 -53
- data/vendor/scs/test/rng.h +109 -0
- data/vendor/scs/test/run_from_file.c +20 -11
- data/vendor/scs/test/run_tests.c +35 -2
- metadata +29 -98
- data/vendor/scs/linsys/amatrix.c +0 -305
- data/vendor/scs/linsys/amatrix.h +0 -36
- data/vendor/scs/linsys/amatrix.o +0 -0
- data/vendor/scs/linsys/cpu/direct/private.o +0 -0
- data/vendor/scs/linsys/cpu/indirect/private.o +0 -0
- data/vendor/scs/linsys/external/amd/SuiteSparse_config.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_1.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_2.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_aat.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_control.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_defaults.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_dump.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_global.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_info.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_order.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_post_tree.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_postorder.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_preprocess.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_valid.o +0 -0
- data/vendor/scs/linsys/external/qdldl/qdldl.o +0 -0
- data/vendor/scs/src/aa.o +0 -0
- data/vendor/scs/src/cones.o +0 -0
- data/vendor/scs/src/ctrlc.o +0 -0
- data/vendor/scs/src/linalg.o +0 -0
- data/vendor/scs/src/normalize.o +0 -0
- data/vendor/scs/src/rw.o +0 -0
- data/vendor/scs/src/scs.o +0 -0
- data/vendor/scs/src/scs_version.o +0 -0
- data/vendor/scs/src/util.o +0 -0
- data/vendor/scs/test/data/small_random_socp +0 -0
- data/vendor/scs/test/problems/small_random_socp.h +0 -33
- data/vendor/scs/test/run_tests +0 -2
@@ -0,0 +1,320 @@
|
|
1
|
+
# CMakeLists.txt file for scs
|
2
|
+
# This software may be modified and distributed under the terms of the MIT License
|
3
|
+
|
4
|
+
cmake_minimum_required(VERSION 3.5)
|
5
|
+
|
6
|
+
project(scs
|
7
|
+
LANGUAGES C
|
8
|
+
VERSION 3.1.1)
|
9
|
+
|
10
|
+
# Defines the CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR and many other useful macros.
|
11
|
+
# See https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
|
12
|
+
include(GNUInstallDirs)
|
13
|
+
|
14
|
+
# Control where libraries and executables are placed during the build.
|
15
|
+
# With the following settings executables are placed in <the top level of the
|
16
|
+
# build tree>/bin and libraries/archives in <top level of the build tree>/lib.
|
17
|
+
# This is particularly useful to run ctests on libraries built on Windows
|
18
|
+
# machines: tests, which are executables, are placed in the same folders of
|
19
|
+
# dlls, which are treated as executables as well, so that they can properly
|
20
|
+
# find the libraries to run. This is a because of missing RPATH on Windows.
|
21
|
+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
|
22
|
+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
|
23
|
+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
|
24
|
+
|
25
|
+
# To build shared libraries in Windows, we set CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS to TRUE.
|
26
|
+
# See https://cmake.org/cmake/help/v3.4/variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS.html
|
27
|
+
# See https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/
|
28
|
+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
29
|
+
|
30
|
+
# Under MSVC, we set CMAKE_DEBUG_POSTFIX to "d" to add a trailing "d" to library
|
31
|
+
# built in debug mode. In this Windows user can compile, build and install the
|
32
|
+
# library in both Release and Debug configuration avoiding naming clashes in the
|
33
|
+
# installation directories.
|
34
|
+
if(MSVC)
|
35
|
+
set(CMAKE_DEBUG_POSTFIX "d")
|
36
|
+
endif()
|
37
|
+
|
38
|
+
# Build position independent code.
|
39
|
+
# Position Independent Code (PIC) is commonly used for shared libraries so that
|
40
|
+
# the same shared library code can be loaded in each program address space in a
|
41
|
+
# location where it will not overlap with any other uses of such memory.
|
42
|
+
# In particular, this option avoids problems occurring when a process wants to
|
43
|
+
# load more than one shared library at the same virtual address.
|
44
|
+
# Since shared libraries cannot predict where other shared libraries could be
|
45
|
+
# loaded, this is an unavoidable problem with the traditional shared library
|
46
|
+
# concept.
|
47
|
+
# Generating position-independent code is often the default behavior for most
|
48
|
+
# modern compilers.
|
49
|
+
# Moreover linking a static library that is not built with PIC from a shared
|
50
|
+
# library will fail on some compiler/architecture combinations.
|
51
|
+
# Further details on PIC can be found here:
|
52
|
+
# https://eli.thegreenplace.net/2011/11/03/position-independent-code-pic-in-shared-libraries/
|
53
|
+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
54
|
+
|
55
|
+
# Disable C and C++ compiler extensions.
|
56
|
+
# C/CXX_EXTENSIONS are ON by default to allow the compilers to use extended
|
57
|
+
# variants of the C/CXX language.
|
58
|
+
# However, this could expose cross-platform bugs in user code or in the headers
|
59
|
+
# of third-party dependencies and thus it is strongly suggested to turn
|
60
|
+
# extensions off.
|
61
|
+
set(CMAKE_C_EXTENSIONS OFF)
|
62
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
63
|
+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
64
|
+
|
65
|
+
### Options
|
66
|
+
# Shared/Dynamic or Static library?
|
67
|
+
option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON)
|
68
|
+
|
69
|
+
# Enable RPATH support for installed binaries and libraries
|
70
|
+
include(AddInstallRPATHSupport)
|
71
|
+
add_install_rpath_support(BIN_DIRS "${CMAKE_INSTALL_FULL_BINDIR}"
|
72
|
+
LIB_DIRS "${CMAKE_INSTALL_FULL_LIBDIR}"
|
73
|
+
INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}"
|
74
|
+
USE_LINK_PATH)
|
75
|
+
|
76
|
+
# Encourage user to specify a build type (e.g. Release, Debug, etc.), otherwise set it to Release.
|
77
|
+
if(NOT CMAKE_CONFIGURATION_TYPES)
|
78
|
+
if(NOT CMAKE_BUILD_TYPE)
|
79
|
+
message(STATUS "Setting build type to 'Release' as none was specified.")
|
80
|
+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Release")
|
81
|
+
endif()
|
82
|
+
endif()
|
83
|
+
|
84
|
+
|
85
|
+
# Build test related commands?
|
86
|
+
option(BUILD_TESTING "Create tests using CMake" OFF)
|
87
|
+
if(BUILD_TESTING)
|
88
|
+
enable_testing()
|
89
|
+
endif()
|
90
|
+
|
91
|
+
# Add uninstall target
|
92
|
+
# After 'make install' can run 'make uninstall' to remove.
|
93
|
+
include(AddUninstallTarget)
|
94
|
+
|
95
|
+
### Some variables useful for sampling the building process
|
96
|
+
# Note that the GPU profile is not compiled.
|
97
|
+
set(LINSYS linsys)
|
98
|
+
set(DIRSRC ${LINSYS}/cpu/direct)
|
99
|
+
set(INDIRSRC ${LINSYS}/cpu/indirect)
|
100
|
+
set(EXTERNAL ${LINSYS}/external)
|
101
|
+
|
102
|
+
# Options
|
103
|
+
# ----------------------------------------------
|
104
|
+
# Use floats instead of doubles
|
105
|
+
option(SFLOAT "Use single precision floats rather than doubles" OFF)
|
106
|
+
message(STATUS "Single precision floats (32bit) are ${SFLOAT}")
|
107
|
+
|
108
|
+
# Use long integers for indexing
|
109
|
+
option(DLONG "Use long integers (64bit) for indexing" OFF)
|
110
|
+
message(STATUS "Long integers (64bit) are ${DLONG}")
|
111
|
+
|
112
|
+
|
113
|
+
set(COMPILER_OPTS "-DUSE_LAPACK -DCOPYAMATRIX -DCTRLC")
|
114
|
+
|
115
|
+
# Primitive types
|
116
|
+
if(SFLOAT)
|
117
|
+
set(SCS_FLOAT_TYPE "float")
|
118
|
+
set(COMPILER_OPTS "-DSFLOAT ${COMPILER_OPTS}")
|
119
|
+
else()
|
120
|
+
set(SCS_FLOAT_TYPE "double")
|
121
|
+
endif()
|
122
|
+
|
123
|
+
if(DLONG)
|
124
|
+
set(SCS_INT_TYPE "long long")
|
125
|
+
set(COMPILER_OPTS "-DDLONG ${COMPILER_OPTS}")
|
126
|
+
else()
|
127
|
+
set(SCS_INT_TYPE "int")
|
128
|
+
endif()
|
129
|
+
|
130
|
+
message(STATUS "COMPILER_OPTS = ${COMPILER_OPTS}")
|
131
|
+
|
132
|
+
# TODO this is a hack that overwrites the scs_types.h file, we should
|
133
|
+
# find a way to do this that doesn't pollute the master directory.
|
134
|
+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/scs_types.h.in
|
135
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/scs_types.h
|
136
|
+
NEWLINE_STYLE LF)
|
137
|
+
|
138
|
+
# Public headers
|
139
|
+
set(${PROJECT_NAME}_PUBLIC_HDR
|
140
|
+
include/scs_types.h
|
141
|
+
include/scs.h)
|
142
|
+
|
143
|
+
# Common source files
|
144
|
+
set(${PROJECT_NAME}_SRC
|
145
|
+
src/aa.c
|
146
|
+
src/cones.c
|
147
|
+
src/ctrlc.c
|
148
|
+
src/linalg.c
|
149
|
+
src/normalize.c
|
150
|
+
src/rw.c
|
151
|
+
src/scs.c
|
152
|
+
src/scs_version.c
|
153
|
+
src/util.c
|
154
|
+
${LINSYS}/csparse.c
|
155
|
+
${LINSYS}/scs_matrix.c)
|
156
|
+
|
157
|
+
# Common header files
|
158
|
+
set(${PROJECT_NAME}_HDR
|
159
|
+
include/aa.h
|
160
|
+
include/cones.h
|
161
|
+
include/ctrlc.h
|
162
|
+
include/glbopts.h
|
163
|
+
include/linalg.h
|
164
|
+
include/linsys.h
|
165
|
+
include/normalize.h
|
166
|
+
include/rw.h
|
167
|
+
include/scs.h
|
168
|
+
include/scs_blas.h
|
169
|
+
include/scs_types.h
|
170
|
+
include/scs_work.h
|
171
|
+
include/util.h
|
172
|
+
${LINSYS}/csparse.h
|
173
|
+
${LINSYS}/scs_matrix.h)
|
174
|
+
|
175
|
+
# get all the c file in amd/external
|
176
|
+
file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_SRC
|
177
|
+
${EXTERNAL}/amd/*.c
|
178
|
+
)
|
179
|
+
|
180
|
+
# get all the h file in amd/external
|
181
|
+
file(GLOB ${PROJECT_NAME}_AMD_EXTERNAL_HDR
|
182
|
+
${EXTERNAL}/amd/*.h
|
183
|
+
)
|
184
|
+
|
185
|
+
# get all the c file in amd/external
|
186
|
+
file(GLOB ${PROJECT_NAME}_LDL_EXTERNAL_HDR
|
187
|
+
${EXTERNAL}/qdldl/*.h
|
188
|
+
)
|
189
|
+
|
190
|
+
### Direct method
|
191
|
+
# Here we compile the direct method library
|
192
|
+
set(${PROJECT_NAME}_DIRECT ${PROJECT_NAME}dir)
|
193
|
+
add_library(${${PROJECT_NAME}_DIRECT}
|
194
|
+
${${PROJECT_NAME}_HDR}
|
195
|
+
${${PROJECT_NAME}_SRC}
|
196
|
+
${DIRSRC}/private.c
|
197
|
+
${DIRSRC}/private.h
|
198
|
+
${EXTERNAL}/qdldl/qdldl.c
|
199
|
+
${${PROJECT_NAME}_AMD_EXTERNAL_SRC}
|
200
|
+
${${PROJECT_NAME}_AMD_EXTERNAL_HDR}
|
201
|
+
${${PROJECT_NAME}_LDL_EXTERNAL_HDR})
|
202
|
+
|
203
|
+
target_include_directories(${${PROJECT_NAME}_DIRECT} PRIVATE
|
204
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/amd;${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/qdldl;${CMAKE_CURRENT_SOURCE_DIR}/${DIRSRC};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>")
|
205
|
+
|
206
|
+
target_include_directories(${${PROJECT_NAME}_DIRECT} PUBLIC
|
207
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
208
|
+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
|
209
|
+
|
210
|
+
# Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs
|
211
|
+
target_compile_definitions(${${PROJECT_NAME}_DIRECT} PRIVATE ${COMPILER_OPTS})
|
212
|
+
|
213
|
+
# The library depends on math (m) blas and lapack
|
214
|
+
target_link_libraries(${${PROJECT_NAME}_DIRECT} PRIVATE
|
215
|
+
m
|
216
|
+
blas
|
217
|
+
lapack)
|
218
|
+
|
219
|
+
# Set some properties
|
220
|
+
set_target_properties(${${PROJECT_NAME}_DIRECT} PROPERTIES
|
221
|
+
VERSION ${scs_VERSION}
|
222
|
+
PUBLIC_HEADER "${${PROJECT_NAME}_PUBLIC_HDR}")
|
223
|
+
|
224
|
+
add_library(scs::${${PROJECT_NAME}_DIRECT} ALIAS ${${PROJECT_NAME}_DIRECT})
|
225
|
+
|
226
|
+
# Install the library
|
227
|
+
install(TARGETS ${${PROJECT_NAME}_DIRECT}
|
228
|
+
EXPORT ${PROJECT_NAME}
|
229
|
+
COMPONENT runtime
|
230
|
+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
|
231
|
+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
|
232
|
+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
|
233
|
+
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
|
234
|
+
|
235
|
+
# Add the direct method to the set of the compiled targets
|
236
|
+
set_property(GLOBAL APPEND PROPERTY scs_TARGETS ${${PROJECT_NAME}_DIRECT})
|
237
|
+
|
238
|
+
### Indirect method
|
239
|
+
# Here we compile the indirect method library
|
240
|
+
set(${PROJECT_NAME}_INDIRECT ${PROJECT_NAME}indir)
|
241
|
+
add_library(${${PROJECT_NAME}_INDIRECT}
|
242
|
+
${${PROJECT_NAME}_HDR}
|
243
|
+
${${PROJECT_NAME}_SRC}
|
244
|
+
${INDIRSRC}/private.c
|
245
|
+
${INDIRSRC}/private.h
|
246
|
+
${${${PROJECT_NAME}_INDIRECT}_HDR}
|
247
|
+
)
|
248
|
+
|
249
|
+
|
250
|
+
target_include_directories(${${PROJECT_NAME}_INDIRECT} PRIVATE
|
251
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/amd;${CMAKE_CURRENT_SOURCE_DIR}/${EXTERNAL}/qdldl;${CMAKE_CURRENT_SOURCE_DIR}/${INDIRSRC};${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>")
|
252
|
+
|
253
|
+
target_include_directories(${${PROJECT_NAME}_INDIRECT} PUBLIC
|
254
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
255
|
+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
|
256
|
+
|
257
|
+
# Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs
|
258
|
+
target_compile_definitions(${${PROJECT_NAME}_INDIRECT} PRIVATE ${COMPILER_OPTS} -DINDIRECT)
|
259
|
+
|
260
|
+
# The library depends on math (m) blas and lapack
|
261
|
+
target_link_libraries(${${PROJECT_NAME}_INDIRECT} PUBLIC
|
262
|
+
m
|
263
|
+
blas
|
264
|
+
lapack)
|
265
|
+
|
266
|
+
# Set some properties
|
267
|
+
set_target_properties(${${PROJECT_NAME}_INDIRECT} PROPERTIES
|
268
|
+
VERSION ${scs_VERSION}
|
269
|
+
PUBLIC_HEADER "${${PROJECT_NAME}_PUBLIC_HDR}")
|
270
|
+
|
271
|
+
add_library(scs::${${PROJECT_NAME}_INDIRECT} ALIAS ${${PROJECT_NAME}_INDIRECT})
|
272
|
+
|
273
|
+
# Install the library
|
274
|
+
install(TARGETS ${${PROJECT_NAME}_INDIRECT}
|
275
|
+
EXPORT ${PROJECT_NAME}
|
276
|
+
COMPONENT runtime
|
277
|
+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
|
278
|
+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
|
279
|
+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
|
280
|
+
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/scs")
|
281
|
+
|
282
|
+
# Add the indirect method to the set of the compiled targets
|
283
|
+
set_property(GLOBAL APPEND PROPERTY scs_TARGETS ${${PROJECT_NAME}_INDIRECT})
|
284
|
+
|
285
|
+
### Install the .cmake file.
|
286
|
+
# Thanks to thanks file it will be possible to link scs to consumer libraries
|
287
|
+
include(InstallBasicPackageFiles)
|
288
|
+
install_basic_package_files(${PROJECT_NAME}
|
289
|
+
NAMESPACE scs::
|
290
|
+
VERSION ${${PROJECT_NAME}_VERSION}
|
291
|
+
TARGETS_PROPERTY scs_TARGETS
|
292
|
+
COMPATIBILITY SameMajorVersion
|
293
|
+
VARS_PREFIX ${PROJECT_NAME}
|
294
|
+
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
295
|
+
|
296
|
+
### Add the tests
|
297
|
+
if(BUILD_TESTING)
|
298
|
+
add_executable(run_tests_direct test/run_tests.c)
|
299
|
+
target_compile_definitions(run_tests_direct PRIVATE ${COMPILER_OPTS})
|
300
|
+
target_link_libraries(run_tests_direct PRIVATE
|
301
|
+
scs::scsdir)
|
302
|
+
target_include_directories(run_tests_direct PRIVATE
|
303
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>" )
|
304
|
+
|
305
|
+
add_test(NAME run_tests_direct
|
306
|
+
COMMAND run_tests_direct
|
307
|
+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
308
|
+
|
309
|
+
add_executable(run_tests_indirect test/run_tests.c)
|
310
|
+
target_compile_definitions(run_tests_indirect PRIVATE ${COMPILER_OPTS})
|
311
|
+
target_link_libraries(run_tests_indirect PRIVATE
|
312
|
+
scs::scsindir)
|
313
|
+
target_include_directories(run_tests_indirect PRIVATE
|
314
|
+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>" )
|
315
|
+
|
316
|
+
add_test(NAME run_tests_indirect
|
317
|
+
COMMAND run_tests_indirect
|
318
|
+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
319
|
+
|
320
|
+
endif()
|
data/vendor/scs/Makefile
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# MAKEFILE for scs
|
2
2
|
include scs.mk
|
3
3
|
|
4
|
-
SCS_OBJECTS = src/
|
4
|
+
SCS_OBJECTS = src/util.o src/cones.o src/aa.o src/rw.o src/linalg.o src/ctrlc.o src/scs_version.o src/normalize.o
|
5
|
+
SCS_O = src/scs.o
|
6
|
+
SCS_INDIR_O = src/scs_indir.o
|
5
7
|
|
6
8
|
SRC_FILES = $(wildcard src/*.c)
|
7
9
|
INC_FILES = $(wildcard include/*.h)
|
@@ -17,7 +19,7 @@ TARGETS = $(OUT)/demo_socp_indirect $(OUT)/demo_socp_direct $(OUT)/run_from_file
|
|
17
19
|
default: $(TARGETS) $(OUT)/libscsdir.a $(OUT)/libscsindir.a $(OUT)/libscsdir.$(SHARED) $(OUT)/libscsindir.$(SHARED)
|
18
20
|
@echo "****************************************************************************************"
|
19
21
|
@echo "Successfully compiled scs, copyright Brendan O'Donoghue 2012."
|
20
|
-
@echo "To test, type '$(OUT)/
|
22
|
+
@echo "To test, type '$(OUT)/demo_socp_direct' to solve a random SOCP."
|
21
23
|
@echo "**********************************************************************************"
|
22
24
|
ifneq ($(USE_LAPACK), 0)
|
23
25
|
@echo "Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs"
|
@@ -28,38 +30,43 @@ else
|
|
28
30
|
endif
|
29
31
|
@echo "****************************************************************************************"
|
30
32
|
|
33
|
+
$(SCS_O): src/scs.c $(INC_FILES)
|
34
|
+
$(CC) $(CFLAGS) -c $< -o $@
|
35
|
+
|
36
|
+
$(SCS_INDIR_O): src/scs.c $(INC_FILES)
|
37
|
+
$(CC) $(CFLAGS) -DINDIRECT=1 -c $< -o $@
|
38
|
+
|
31
39
|
%.o : src/%.c
|
32
40
|
$(CC) $(CFLAGS) -c $< -o $@
|
33
41
|
|
34
|
-
src/
|
35
|
-
src/
|
36
|
-
src/
|
37
|
-
src/
|
38
|
-
src/
|
39
|
-
src/
|
40
|
-
src/
|
41
|
-
src/ctrl.o : src/ctrl.c include/ctrl.h
|
42
|
-
src/scs_version.o: src/scs_version.c include/glbopts.h
|
42
|
+
src/util.o : src/util.c $(INC_FILES)
|
43
|
+
src/cones.o : src/cones.c $(INC_FILES)
|
44
|
+
src/aa.o : src/aa.c $(INC_FILES)
|
45
|
+
src/rw.o : src/rw.c $(INC_FILES)
|
46
|
+
src/linalg.o: src/linalg.c $(INC_FILES)
|
47
|
+
src/ctrl.o : src/ctrl.c $(INC_FILES)
|
48
|
+
src/scs_version.o: src/scs_version.c $(INC_FILES)
|
43
49
|
|
44
50
|
$(DIRSRC)/private.o: $(DIRSRC)/private.c $(DIRSRC)/private.h
|
45
51
|
$(INDIRSRC)/indirect/private.o: $(INDIRSRC)/private.c $(INDIRSRC)/private.h
|
46
|
-
$(LINSYS)/
|
52
|
+
$(LINSYS)/scs_matrix.o: $(LINSYS)/scs_matrix.c $(LINSYS)/scs_matrix.h
|
53
|
+
$(LINSYS)/csparse.o: $(LINSYS)/csparse.c $(LINSYS)/csparse.h
|
47
54
|
|
48
|
-
$(OUT)/libscsdir.a: $(SCS_OBJECTS) $(DIRSRC)/private.o $(AMD_OBJS) $(LDL_OBJS) $(LINSYS)/
|
55
|
+
$(OUT)/libscsdir.a: $(SCS_O) $(SCS_OBJECTS) $(DIRSRC)/private.o $(AMD_OBJS) $(LDL_OBJS) $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o
|
49
56
|
mkdir -p $(OUT)
|
50
57
|
$(ARCHIVE) $@ $^
|
51
58
|
- $(RANLIB) $@
|
52
59
|
|
53
|
-
$(OUT)/libscsindir.a: $(SCS_OBJECTS) $(INDIRSRC)/private.o $(LINSYS)/
|
60
|
+
$(OUT)/libscsindir.a: $(SCS_INDIR_O) $(SCS_OBJECTS) $(INDIRSRC)/private.o $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o
|
54
61
|
mkdir -p $(OUT)
|
55
62
|
$(ARCHIVE) $@ $^
|
56
63
|
- $(RANLIB) $@
|
57
64
|
|
58
|
-
$(OUT)/libscsdir.$(SHARED): $(SCS_OBJECTS) $(DIRSRC)/private.o $(AMD_OBJS) $(LDL_OBJS) $(LINSYS)/
|
65
|
+
$(OUT)/libscsdir.$(SHARED): $(SCS_O) $(SCS_OBJECTS) $(DIRSRC)/private.o $(AMD_OBJS) $(LDL_OBJS) $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o
|
59
66
|
mkdir -p $(OUT)
|
60
67
|
$(CC) $(CFLAGS) -shared -Wl,$(SONAME),$(@:$(OUT)/%=%) -o $@ $^ $(LDFLAGS)
|
61
68
|
|
62
|
-
$(OUT)/libscsindir.$(SHARED): $(SCS_OBJECTS) $(INDIRSRC)/private.o $(LINSYS)/
|
69
|
+
$(OUT)/libscsindir.$(SHARED): $(SCS_INDIR_O) $(SCS_OBJECTS) $(INDIRSRC)/private.o $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o
|
63
70
|
mkdir -p $(OUT)
|
64
71
|
$(CC) $(CFLAGS) -shared -Wl,$(SONAME),$(@:$(OUT)/%=%) -o $@ $^ $(LDFLAGS)
|
65
72
|
|
@@ -108,22 +115,22 @@ $(LINSYS)/gpu/gpu.o: $(LINSYS)/gpu/gpu.c
|
|
108
115
|
# $(CUCC) -c -o $(GPUDIR)/private.o $^ $(CUDAFLAGS)
|
109
116
|
|
110
117
|
$(GPUINDIR)/private.o: $(GPUINDIR)/private.c
|
111
|
-
$(CUCC) -c -o
|
118
|
+
$(CUCC) -c -o $@ $^ $(CUDAFLAGS)
|
112
119
|
|
113
|
-
# $(OUT)/libscsgpudir.$(SHARED): $(SCS_OBJECTS) $(GPUDIR)/private.o $(AMD_OBJS) $(LINSYS)/
|
120
|
+
# $(OUT)/libscsgpudir.$(SHARED): $(SCS_O) $(SCS_OBJECTS) $(GPUDIR)/private.o $(AMD_OBJS) $(LINSYS)/scs_matrix.o $(LINSYS)/gpu/gpu.o
|
114
121
|
# mkdir -p $(OUT)
|
115
122
|
# $(CC) $(CFLAGS) -shared -Wl,$(SONAME),$(@:$(OUT)/%=%) -o $@ $^ $(LDFLAGS) $(CULDFLAGS)
|
116
123
|
|
117
|
-
# $(OUT)/libscsgpudir.a: $(SCS_OBJECTS) $(GPUDIR)/private.o $(AMD_OBJS) $(LINSYS)/
|
124
|
+
# $(OUT)/libscsgpudir.a: $(SCS_INDIR_O) $(SCS_OBJECTS) $(GPUDIR)/private.o $(AMD_OBJS) $(LINSYS)/scs_matrix.o $(LINSYS)/gpu/gpu.o
|
118
125
|
# mkdir -p $(OUT)
|
119
126
|
# $(ARCHIVE) $@ $^
|
120
127
|
# - $(RANLIB) $@
|
121
128
|
|
122
|
-
$(OUT)/libscsgpuindir.$(SHARED): $(SCS_OBJECTS) $(GPUINDIR)/private.o $(LINSYS)/
|
129
|
+
$(OUT)/libscsgpuindir.$(SHARED): $(SCS_O) $(SCS_OBJECTS) $(GPUINDIR)/private.o $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o $(LINSYS)/gpu/gpu.o
|
123
130
|
mkdir -p $(OUT)
|
124
131
|
$(CC) $(CFLAGS) -shared -Wl,$(SONAME),$(@:$(OUT)/%=%) -o $@ $^ $(LDFLAGS) $(CULDFLAGS)
|
125
132
|
|
126
|
-
$(OUT)/libscsgpuindir.a: $(SCS_OBJECTS) $(GPUINDIR)/private.o $(LINSYS)/
|
133
|
+
$(OUT)/libscsgpuindir.a: $(SCS_INDIR_O) $(SCS_OBJECTS) $(GPUINDIR)/private.o $(LINSYS)/scs_matrix.o $(LINSYS)/csparse.o $(LINSYS)/gpu/gpu.o
|
127
134
|
mkdir -p $(OUT)
|
128
135
|
$(ARCHIVE) $@ $^
|
129
136
|
- $(RANLIB) $@
|
@@ -136,7 +143,7 @@ $(OUT)/demo_socp_gpu_indirect: test/random_socp_prob.c $(OUT)/libscsgpuindir.a
|
|
136
143
|
|
137
144
|
.PHONY: clean purge
|
138
145
|
clean:
|
139
|
-
@rm -rf $(TARGETS) $(SCS_OBJECTS) $(AMD_OBJS) $(LDL_OBJS) $(LINSYS)/*.o $(DIRSRC)/*.o $(INDIRSRC)/*.o $(GPUDIR)/*.o $(GPUINDIR)/*.o
|
146
|
+
@rm -rf $(TARGETS) $(SCS_O) $(SCS_INDIR_O) $(SCS_OBJECTS) $(AMD_OBJS) $(LDL_OBJS) $(LINSYS)/*.o $(DIRSRC)/*.o $(INDIRSRC)/*.o $(GPUDIR)/*.o $(GPUINDIR)/*.o $(LINSYS)/gpu/*.o
|
140
147
|
@rm -rf $(OUT)/*.dSYM
|
141
148
|
@rm -rf matlab/*.mex*
|
142
149
|
@rm -rf .idea
|
@@ -153,7 +160,7 @@ INSTALL_GPU_TARGETS = $(OUT)/libscsgpuindir.a $(OUT)/libscsgpuindir.$(SHARED) #
|
|
153
160
|
INSTALL_INC_DIR = $(DESTDIR)$(PREFIX)/include/scs/
|
154
161
|
INSTALL_LIB_DIR = $(DESTDIR)$(PREFIX)/lib/
|
155
162
|
|
156
|
-
.PHONY: install install_gpu
|
163
|
+
.PHONY: install install_gpu direct indirect
|
157
164
|
install: $(INSTALL_INC_FILES) $(INSTALL_TARGETS)
|
158
165
|
$(INSTALL) -d $(INSTALL_INC_DIR) $(INSTALL_LIB_DIR)
|
159
166
|
$(INSTALL) -m 644 $(INSTALL_INC_FILES) $(INSTALL_INC_DIR)
|
@@ -162,3 +169,5 @@ install_gpu: $(INSTALL_INC_FILES) $(INSTALL_GPU_TARGETS)
|
|
162
169
|
$(INSTALL) -d $(INSTALL_INC_DIR) $(INSTALL_LIB_DIR)
|
163
170
|
$(INSTALL) -m 644 $(INSTALL_INC_FILES) $(INSTALL_INC_DIR)
|
164
171
|
$(INSTALL) -m 644 $(INSTALL_GPU_TARGETS) $(INSTALL_LIB_DIR)
|
172
|
+
direct:$(OUT)/libscsdir.$(SHARED) $(OUT)/demo_socp_direct $(OUT)/run_from_file_direct $(OUT)/run_tests_direct
|
173
|
+
indirect:$(OUT)/libscsindir.$(SHARED) $(OUT)/demo_socp_indirect $(OUT)/run_from_file_indirect $(OUT)/run_tests_indirect
|
data/vendor/scs/README.md
CHANGED
@@ -1,222 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<h1 align="center" margin=0px>
|
2
|
+
<img src="https://github.com/cvxgrp/scs/blob/master/docs/src/_static/scs_logo.png" alt="Intersection of a cone and a polyhedron" width="450">
|
3
|
+
</h1>
|
3
4
|
|
4
|
-
[![Build Status](https://
|
5
|
-
[![
|
5
|
+
[![Build Status](https://github.com/cvxgrp/scs/actions/workflows/build.yml/badge.svg)](https://github.com/cvxgrp/scs/actions/workflows/build.yml)
|
6
|
+
[![Documentation](https://img.shields.io/badge/docs-online-brightgreen?logo=read-the-docs&style=flat)](https://www.cvxgrp.org/scs/)
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/github/cvxgrp/scs/badge.svg?branch=master)](https://coveralls.io/github/cvxgrp/scs?branch=master)
|
6
8
|
|
7
|
-
SCS (`splitting conic solver`) is a numerical optimization package for solving
|
8
|
-
large-scale convex cone problems, based on our paper [Conic Optimization via
|
9
|
-
Operator Splitting and Homogeneous Self-Dual
|
10
|
-
Embedding](http://www.stanford.edu/~boyd/papers/scs.html). It is written in C
|
11
|
-
and can be used in other C, C++,
|
12
|
-
[Python](https://github.com/bodono/scs-python),
|
13
|
-
[Matlab](https://github.com/bodono/scs-matlab),
|
14
|
-
[R](https://github.com/bodono/scs-r),
|
15
|
-
[Julia](https://github.com/JuliaOpt/SCS.jl), and
|
16
|
-
[Ruby](https://github.com/ankane/scs),
|
17
|
-
programs via the linked
|
18
|
-
interfaces. It can also be called as a solver from convex optimization
|
19
|
-
toolboxes [CVX](http://cvxr.com/cvx/) (3.0 or later),
|
20
|
-
[CVXPY](https://github.com/cvxgrp/cvxpy),
|
21
|
-
[Convex.jl](https://github.com/JuliaOpt/Convex.jl), and
|
22
|
-
[Yalmip](https://github.com/johanlofberg/YALMIP).
|
23
|
-
|
24
|
-
The current version is `2.1.2`. If you wish to cite SCS, please use the
|
25
|
-
following:
|
26
|
-
```
|
27
|
-
@article{ocpb:16,
|
28
|
-
author = {B. O'Donoghue and E. Chu and N. Parikh and S. Boyd},
|
29
|
-
title = {Conic Optimization via Operator Splitting and Homogeneous Self-Dual Embedding},
|
30
|
-
journal = {Journal of Optimization Theory and Applications},
|
31
|
-
month = {June},
|
32
|
-
year = {2016},
|
33
|
-
volume = {169},
|
34
|
-
number = {3},
|
35
|
-
pages = {1042-1068},
|
36
|
-
url = {http://stanford.edu/~boyd/papers/scs.html},
|
37
|
-
}
|
38
|
-
@misc{scs,
|
39
|
-
author = {B. O'Donoghue and E. Chu and N. Parikh and S. Boyd},
|
40
|
-
title = {{SCS}: Splitting Conic Solver, version 2.1.2},
|
41
|
-
howpublished = {\url{https://github.com/cvxgrp/scs}},
|
42
|
-
month = nov,
|
43
|
-
year = 2019
|
44
|
-
}
|
45
|
-
```
|
46
|
-
|
47
|
-
----
|
48
|
-
SCS numerically solves convex cone programs using the alternating direction
|
49
|
-
method of multipliers
|
50
|
-
([ADMM](http://web.stanford.edu/~boyd/papers/admm_distr_stats.html)). It
|
51
|
-
returns solutions to both the primal and dual problems if the problem is
|
52
|
-
feasible, or a certificate of infeasibility otherwise. It solves the following
|
53
|
-
primal cone problem:
|
54
|
-
|
55
|
-
```
|
56
|
-
minimize c'x
|
57
|
-
subject to Ax + s = b
|
58
|
-
s in K
|
59
|
-
```
|
60
|
-
over variables `x` and `s`, where `A`, `b` and `c` are user-supplied data and
|
61
|
-
`K` is a user-defined convex cone. The dual problem is given by
|
62
|
-
```
|
63
|
-
maximize -b'y
|
64
|
-
subject to -A'y == c
|
65
|
-
y in K^*
|
66
|
-
```
|
67
|
-
over variable `y`, where `K^*` denotes the dual cone to `K`.
|
68
|
-
|
69
|
-
The cone `K` can be any Cartesian product of the following primitive cones:
|
70
|
-
+ zero cone `{x | x = 0 }` (dual to the free cone `{x | x in R}`)
|
71
|
-
+ positive orthant `{x | x >= 0}`
|
72
|
-
+ second-order cone `{(t,x) | ||x||_2 <= t}`
|
73
|
-
+ positive semidefinite cone `{ X | min(eig(X)) >= 0, X = X^T }`
|
74
|
-
+ exponential cone `{(x,y,z) | y e^(x/y) <= z, y>0 }`
|
75
|
-
+ dual exponential cone `{(u,v,w) | −u e^(v/u) <= e w, u<0}`
|
76
|
-
+ power cone `{(x,y,z) | x^a * y^(1-a) >= |z|, x>=0, y>=0}`
|
77
|
-
+ dual power cone `{(u,v,w) | (u/a)^a * (v/(1-a))^(1-a) >= |w|, u>=0, v>=0}`
|
78
|
-
|
79
|
-
The rows of the data matrix `A` correspond to the cones in `K`. **The rows of
|
80
|
-
`A` must be in the order of the cones given above, i.e., first come the rows
|
81
|
-
that correspond to the zero/free cones, then those that correspond to the
|
82
|
-
positive orthants, then SOCs, etc.** For a `k` dimensional semidefinite cone
|
83
|
-
when interpreting the rows of the data matrix `A` SCS assumes that the `k x k`
|
84
|
-
matrix variable has been vectorized by scaling the off-diagonal entries by
|
85
|
-
`sqrt(2)` and stacking the **lower triangular elements column-wise** to create a
|
86
|
-
vector of length `k(k+1)/2`. See the section on semidefinite programming below.
|
87
|
-
|
88
|
-
At termination SCS returns solution `(x*, s*, y*)` if the problem is feasible,
|
89
|
-
or a certificate of infeasibility otherwise. See
|
90
|
-
[here](http://web.stanford.edu/~boyd/cvxbook/) for more details about
|
91
|
-
cone programming and certificates of infeasibility.
|
92
|
-
|
93
|
-
**Anderson Acceleration**
|
94
|
-
|
95
|
-
By default SCS uses Anderson acceleration (AA) to speed up convergence. The
|
96
|
-
number of iterates that SCS uses in the AA calculation can be controlled by the
|
97
|
-
parameter `acceleration_lookback` in the settings struct. It defaults to 10. AA
|
98
|
-
is available as a standalone package [here](https://github.com/cvxgrp/aa). More
|
99
|
-
details are available in our paper on AA
|
100
|
-
[here](https://stanford.edu/~boyd/papers/nonexp_global_aa1.html).
|
101
|
-
|
102
|
-
**Semidefinite Programming**
|
103
|
-
|
104
|
-
SCS assumes that the matrix variables and the input data corresponding to
|
105
|
-
semidefinite cones have been vectorized by **scaling the off-diagonal entries by
|
106
|
-
`sqrt(2)`** and stacking the lower triangular elements **column-wise**. For a `k
|
107
|
-
x k` matrix variable (or data matrix) this operation would create a vector of
|
108
|
-
length `k(k+1)/2`. Scaling by `sqrt(2)` is required to preserve the
|
109
|
-
inner-product.
|
110
|
-
|
111
|
-
**To recover the matrix solution this operation must be inverted on the
|
112
|
-
components of the vector returned by SCS corresponding to semidefinite cones**.
|
113
|
-
That is, the off-diagonal entries must be scaled by `1/sqrt(2)` and the upper
|
114
|
-
triangular entries are filled in by copying the values of lower triangular
|
115
|
-
entries.
|
116
|
-
|
117
|
-
More explicitly, we want to express
|
118
|
-
`Tr(C X)` as `vec(C)'*vec(X)`, where the `vec` operation takes the `k x k` matrix
|
119
|
-
```
|
120
|
-
X = [ X11 X12 ... X1k
|
121
|
-
X21 X22 ... X2k
|
122
|
-
...
|
123
|
-
Xk1 Xk2 ... Xkk ]
|
124
|
-
```
|
125
|
-
and produces a vector consisting of
|
126
|
-
```
|
127
|
-
vec(X) = (X11, sqrt(2)*X21, ..., sqrt(2)*Xk1, X22, sqrt(2)*X32, ..., Xkk).
|
128
|
-
```
|
129
|
-
|
130
|
-
**Linear equation solvers**
|
131
|
-
|
132
|
-
Each iteration of SCS requires the solution of a set of linear equations. This
|
133
|
-
package includes two implementations for solving linear equations: a direct
|
134
|
-
solver which uses a cached LDL factorization and an indirect solver based on
|
135
|
-
conjugate gradients. The indirect solver can be run on either the cpu or
|
136
|
-
gpu.
|
137
|
-
|
138
|
-
The direct solver uses external numerical linear algebra packages:
|
139
|
-
* [QDLDL](https://github.com/oxfordcontrol/qdldl)
|
140
|
-
* [AMD](http://www.cise.ufl.edu/research/sparse/).
|
141
|
-
|
142
|
-
### Using SCS in C
|
143
|
-
Typing `make` at the command line will compile the code and create SCS libraries
|
144
|
-
in the `out` folder. To run the tests execute:
|
145
|
-
```sh
|
146
|
-
make
|
147
|
-
make test
|
148
|
-
test/run_tests
|
149
|
-
```
|
150
|
-
|
151
|
-
If `make` completes successfully, it will produce two static library files,
|
152
|
-
`libscsdir.a`, `libscsindir.a`, and two dynamic library files `libscsdir.ext`,
|
153
|
-
`libscsindir.ext` (where `.ext` extension is platform dependent) in the same
|
154
|
-
folder. It will also produce two demo binaries in the `out` folder named
|
155
|
-
`demo_socp_direct`, and `demo_socp_indirect`. If you have a GPU and have CUDA
|
156
|
-
installed, you can also execture `make gpu` to compile SCS to run on the GPU
|
157
|
-
which will create additional libraries and demo binaries in the `out` folder
|
158
|
-
corresponding to the gpu version. Note that the GPU version requires 32 bit
|
159
|
-
ints, which can be enforced by compiling with `DLONG=0`.
|
160
9
|
|
161
|
-
|
162
|
-
|
163
|
-
API and required data structures are defined in the file `include/scs.h`. The
|
164
|
-
four main API functions are:
|
165
|
-
|
166
|
-
* `ScsWork * scs_init(const ScsData * d, const ScsCone * k, ScsInfo * info);`
|
167
|
-
|
168
|
-
This initializes the ScsWork struct containing the workspace that scs will
|
169
|
-
use, and performs the necessary preprocessing (e.g. matrix factorization).
|
170
|
-
All inputs `d`, `k`, and `info` must be memory allocated before calling.
|
171
|
-
|
172
|
-
* `scs_int scs_solve(ScsWork * w, const ScsData * d, const ScsCone * k, ScsSolution * sol, ScsInfo * info);`
|
173
|
-
|
174
|
-
This solves the problem as defined by ScsData `d` and ScsCone `k` using the
|
175
|
-
workspace in `w`. The solution is returned in `sol` and information about
|
176
|
-
the solve is returned in `info` (outputs must have memory allocated before
|
177
|
-
calling). None of the inputs can be NULL. You can call `scs_solve` many
|
178
|
-
times for one call to `scs_init`, so long as the matrix `A` does not change
|
179
|
-
(vectors `b` and `c` can change).
|
180
|
-
|
181
|
-
* `void scs_finish(ScsWork * w);`
|
182
|
-
|
183
|
-
Called after all solves completed to free allocated memory and other
|
184
|
-
cleanup.
|
185
|
-
|
186
|
-
* `scs_int scs(const ScsData * d, const ScsCone * k, ScsSolution * sol, ScsInfo * info);`
|
187
|
-
|
188
|
-
Convenience method that simply calls all the above routines in order, for
|
189
|
-
cases where the workspace does not need to be reused. All inputs must have
|
190
|
-
memory allocated before this call.
|
191
|
-
|
192
|
-
The data matrix `A` is specified in column-compressed format and the vectors `b`
|
193
|
-
and `c` are specified as dense arrays. The solutions `x` (primal), `s` (slack),
|
194
|
-
and `y` (dual) are returned as dense arrays. Cones are specified as the struct
|
195
|
-
defined in `include/scs.h`, the rows of `A` must correspond to the cones in the
|
196
|
-
exact order as specified by the cone struct (i.e. put linear cones before
|
197
|
-
second-order cones etc.).
|
198
|
-
|
199
|
-
**Warm-start**
|
200
|
-
|
201
|
-
You can warm-start SCS (supply a guess of the solution) by setting `warm_start`
|
202
|
-
in the ScsData struct to `1` and supplying the warm-starts in the ScsSolution
|
203
|
-
struct (`x`,`y`, and `s`). All inputs must be warm-started if any one is. These
|
204
|
-
are used to initialize the iterates in `scs_solve`.
|
205
|
-
|
206
|
-
**Re-using matrix factorization**
|
207
|
-
|
208
|
-
If using the direct version you can factorize the matrix once and solve many
|
209
|
-
times. Simply call `scs_init` once, and use `scs_solve` many times with the same
|
210
|
-
workspace, changing the input data `b` and `c` (and optionally warm-starts) for
|
211
|
-
each iteration.
|
212
|
-
|
213
|
-
**Using your own linear system solver**
|
214
|
-
|
215
|
-
To use your own linear system solver simply implement all the methods and the
|
216
|
-
two structs in `include/linsys.h` and plug it in.
|
217
|
-
|
218
|
-
**BLAS / LAPACK install error**
|
10
|
+
SCS (`splitting conic solver`) is a numerical optimization package for solving
|
11
|
+
large-scale convex cone problems. The current version is `3.1.1`.
|
219
12
|
|
220
|
-
|
221
|
-
you need to install blas and lapack and / or update your environment variables
|
222
|
-
to point to the install locations.
|
13
|
+
The full documentation is available [here](https://www.cvxgrp.org/scs/).
|