scs 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +98 -0
- data/ext/scs/extconf.rb +29 -0
- data/lib/scs.rb +17 -0
- data/lib/scs/ffi.rb +117 -0
- data/lib/scs/solver.rb +173 -0
- data/lib/scs/version.rb +3 -0
- data/vendor/scs/LICENSE.txt +21 -0
- data/vendor/scs/Makefile +164 -0
- data/vendor/scs/README.md +222 -0
- data/vendor/scs/include/aa.h +56 -0
- data/vendor/scs/include/cones.h +46 -0
- data/vendor/scs/include/ctrlc.h +33 -0
- data/vendor/scs/include/glbopts.h +177 -0
- data/vendor/scs/include/linalg.h +26 -0
- data/vendor/scs/include/linsys.h +64 -0
- data/vendor/scs/include/normalize.h +18 -0
- data/vendor/scs/include/rw.h +17 -0
- data/vendor/scs/include/scs.h +161 -0
- data/vendor/scs/include/scs_blas.h +51 -0
- data/vendor/scs/include/util.h +65 -0
- data/vendor/scs/linsys/amatrix.c +305 -0
- data/vendor/scs/linsys/amatrix.h +36 -0
- data/vendor/scs/linsys/amatrix.o +0 -0
- data/vendor/scs/linsys/cpu/direct/private.c +366 -0
- data/vendor/scs/linsys/cpu/direct/private.h +26 -0
- data/vendor/scs/linsys/cpu/direct/private.o +0 -0
- data/vendor/scs/linsys/cpu/indirect/private.c +256 -0
- data/vendor/scs/linsys/cpu/indirect/private.h +31 -0
- data/vendor/scs/linsys/cpu/indirect/private.o +0 -0
- data/vendor/scs/linsys/external/amd/LICENSE.txt +934 -0
- data/vendor/scs/linsys/external/amd/SuiteSparse_config.c +469 -0
- data/vendor/scs/linsys/external/amd/SuiteSparse_config.h +254 -0
- data/vendor/scs/linsys/external/amd/SuiteSparse_config.o +0 -0
- data/vendor/scs/linsys/external/amd/amd.h +400 -0
- data/vendor/scs/linsys/external/amd/amd_1.c +180 -0
- data/vendor/scs/linsys/external/amd/amd_1.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_2.c +1842 -0
- data/vendor/scs/linsys/external/amd/amd_2.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_aat.c +184 -0
- data/vendor/scs/linsys/external/amd/amd_aat.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_control.c +64 -0
- data/vendor/scs/linsys/external/amd/amd_control.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_defaults.c +37 -0
- data/vendor/scs/linsys/external/amd/amd_defaults.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_dump.c +179 -0
- data/vendor/scs/linsys/external/amd/amd_dump.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_global.c +16 -0
- data/vendor/scs/linsys/external/amd/amd_global.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_info.c +119 -0
- data/vendor/scs/linsys/external/amd/amd_info.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_internal.h +304 -0
- data/vendor/scs/linsys/external/amd/amd_order.c +199 -0
- data/vendor/scs/linsys/external/amd/amd_order.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_post_tree.c +120 -0
- data/vendor/scs/linsys/external/amd/amd_post_tree.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_postorder.c +206 -0
- data/vendor/scs/linsys/external/amd/amd_postorder.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_preprocess.c +118 -0
- data/vendor/scs/linsys/external/amd/amd_preprocess.o +0 -0
- data/vendor/scs/linsys/external/amd/amd_valid.c +92 -0
- data/vendor/scs/linsys/external/amd/amd_valid.o +0 -0
- data/vendor/scs/linsys/external/amd/changes +11 -0
- data/vendor/scs/linsys/external/qdldl/LICENSE +201 -0
- data/vendor/scs/linsys/external/qdldl/README.md +120 -0
- data/vendor/scs/linsys/external/qdldl/changes +4 -0
- data/vendor/scs/linsys/external/qdldl/qdldl.c +298 -0
- data/vendor/scs/linsys/external/qdldl/qdldl.h +177 -0
- data/vendor/scs/linsys/external/qdldl/qdldl.o +0 -0
- data/vendor/scs/linsys/external/qdldl/qdldl_types.h +21 -0
- data/vendor/scs/linsys/gpu/gpu.c +41 -0
- data/vendor/scs/linsys/gpu/gpu.h +85 -0
- data/vendor/scs/linsys/gpu/indirect/private.c +304 -0
- data/vendor/scs/linsys/gpu/indirect/private.h +36 -0
- data/vendor/scs/scs.mk +181 -0
- data/vendor/scs/src/aa.c +224 -0
- data/vendor/scs/src/aa.o +0 -0
- data/vendor/scs/src/cones.c +802 -0
- data/vendor/scs/src/cones.o +0 -0
- data/vendor/scs/src/ctrlc.c +77 -0
- data/vendor/scs/src/ctrlc.o +0 -0
- data/vendor/scs/src/linalg.c +84 -0
- data/vendor/scs/src/linalg.o +0 -0
- data/vendor/scs/src/normalize.c +93 -0
- data/vendor/scs/src/normalize.o +0 -0
- data/vendor/scs/src/rw.c +167 -0
- data/vendor/scs/src/rw.o +0 -0
- data/vendor/scs/src/scs.c +978 -0
- data/vendor/scs/src/scs.o +0 -0
- data/vendor/scs/src/scs_version.c +5 -0
- data/vendor/scs/src/scs_version.o +0 -0
- data/vendor/scs/src/util.c +196 -0
- data/vendor/scs/src/util.o +0 -0
- data/vendor/scs/test/data/small_random_socp +0 -0
- data/vendor/scs/test/minunit.h +13 -0
- data/vendor/scs/test/problem_utils.h +93 -0
- data/vendor/scs/test/problems/rob_gauss_cov_est.h +85 -0
- data/vendor/scs/test/problems/small_lp.h +50 -0
- data/vendor/scs/test/problems/small_random_socp.h +33 -0
- data/vendor/scs/test/random_socp_prob.c +171 -0
- data/vendor/scs/test/run_from_file.c +69 -0
- data/vendor/scs/test/run_tests +2 -0
- data/vendor/scs/test/run_tests.c +32 -0
- metadata +203 -0
data/lib/scs/version.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2012 Brendan O'Donoghue (bodonoghue85@gmail.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/vendor/scs/Makefile
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# MAKEFILE for scs
|
|
2
|
+
include scs.mk
|
|
3
|
+
|
|
4
|
+
SCS_OBJECTS = src/scs.o 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
|
+
|
|
6
|
+
SRC_FILES = $(wildcard src/*.c)
|
|
7
|
+
INC_FILES = $(wildcard include/*.h)
|
|
8
|
+
|
|
9
|
+
AMD_SOURCE = $(wildcard $(EXTSRC)/amd/*.c)
|
|
10
|
+
LDL_SOURCE = $(EXTSRC)/qdldl/qdldl.c
|
|
11
|
+
AMD_OBJS = $(AMD_SOURCE:.c=.o)
|
|
12
|
+
LDL_OBJS = $(LDL_SOURCE:.c=.o)
|
|
13
|
+
TARGETS = $(OUT)/demo_socp_indirect $(OUT)/demo_socp_direct $(OUT)/run_from_file_indirect $(OUT)/run_from_file_direct
|
|
14
|
+
|
|
15
|
+
.PHONY: default
|
|
16
|
+
|
|
17
|
+
default: $(TARGETS) $(OUT)/libscsdir.a $(OUT)/libscsindir.a $(OUT)/libscsdir.$(SHARED) $(OUT)/libscsindir.$(SHARED)
|
|
18
|
+
@echo "****************************************************************************************"
|
|
19
|
+
@echo "Successfully compiled scs, copyright Brendan O'Donoghue 2012."
|
|
20
|
+
@echo "To test, type '$(OUT)/demo_socp_indirect' to solve a random SOCP."
|
|
21
|
+
@echo "**********************************************************************************"
|
|
22
|
+
ifneq ($(USE_LAPACK), 0)
|
|
23
|
+
@echo "Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs"
|
|
24
|
+
else
|
|
25
|
+
@echo "NOT compiled with blas/lapack, cannot solve SDPs (can solve LPs, SOCPs, ECPs, and PCPs)."
|
|
26
|
+
@echo "To solve SDPs, install blas and lapack, then edit scs.mk to set USE_LAPACK=1"
|
|
27
|
+
@echo "and point to the library install locations, and recompile with 'make purge', 'make'."
|
|
28
|
+
endif
|
|
29
|
+
@echo "****************************************************************************************"
|
|
30
|
+
|
|
31
|
+
%.o : src/%.c
|
|
32
|
+
$(CC) $(CFLAGS) -c $< -o $@
|
|
33
|
+
|
|
34
|
+
src/scs.o : $(SRC_FILES) $(INC_FILES)
|
|
35
|
+
src/util.o : src/util.c include/util.h include/glbopts.h
|
|
36
|
+
src/cones.o : src/cones.c include/cones.h include/scs_blas.h
|
|
37
|
+
src/aa.o : src/aa.c include/aa.h include/scs_blas.h
|
|
38
|
+
src/rw.o : src/rw.c include/rw.h
|
|
39
|
+
src/cs.o : src/cs.c include/cs.h
|
|
40
|
+
src/linalg.o: src/linalg.c include/linalg.h
|
|
41
|
+
src/ctrl.o : src/ctrl.c include/ctrl.h
|
|
42
|
+
src/scs_version.o: src/scs_version.c include/glbopts.h
|
|
43
|
+
|
|
44
|
+
$(DIRSRC)/private.o: $(DIRSRC)/private.c $(DIRSRC)/private.h
|
|
45
|
+
$(INDIRSRC)/indirect/private.o: $(INDIRSRC)/private.c $(INDIRSRC)/private.h
|
|
46
|
+
$(LINSYS)/amatrix.o: $(LINSYS)/amatrix.c $(LINSYS)/amatrix.h
|
|
47
|
+
|
|
48
|
+
$(OUT)/libscsdir.a: $(SCS_OBJECTS) $(DIRSRC)/private.o $(AMD_OBJS) $(LDL_OBJS) $(LINSYS)/amatrix.o
|
|
49
|
+
mkdir -p $(OUT)
|
|
50
|
+
$(ARCHIVE) $@ $^
|
|
51
|
+
- $(RANLIB) $@
|
|
52
|
+
|
|
53
|
+
$(OUT)/libscsindir.a: $(SCS_OBJECTS) $(INDIRSRC)/private.o $(LINSYS)/amatrix.o
|
|
54
|
+
mkdir -p $(OUT)
|
|
55
|
+
$(ARCHIVE) $@ $^
|
|
56
|
+
- $(RANLIB) $@
|
|
57
|
+
|
|
58
|
+
$(OUT)/libscsdir.$(SHARED): $(SCS_OBJECTS) $(DIRSRC)/private.o $(AMD_OBJS) $(LDL_OBJS) $(LINSYS)/amatrix.o
|
|
59
|
+
mkdir -p $(OUT)
|
|
60
|
+
$(CC) $(CFLAGS) -shared -Wl,$(SONAME),$(@:$(OUT)/%=%) -o $@ $^ $(LDFLAGS)
|
|
61
|
+
|
|
62
|
+
$(OUT)/libscsindir.$(SHARED): $(SCS_OBJECTS) $(INDIRSRC)/private.o $(LINSYS)/amatrix.o
|
|
63
|
+
mkdir -p $(OUT)
|
|
64
|
+
$(CC) $(CFLAGS) -shared -Wl,$(SONAME),$(@:$(OUT)/%=%) -o $@ $^ $(LDFLAGS)
|
|
65
|
+
|
|
66
|
+
$(OUT)/demo_socp_direct: test/random_socp_prob.c $(OUT)/libscsdir.a
|
|
67
|
+
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
|
68
|
+
|
|
69
|
+
$(OUT)/demo_socp_indirect: test/random_socp_prob.c $(OUT)/libscsindir.a
|
|
70
|
+
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
|
71
|
+
|
|
72
|
+
$(OUT)/run_from_file_direct: test/run_from_file.c $(OUT)/libscsdir.a
|
|
73
|
+
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
|
74
|
+
|
|
75
|
+
$(OUT)/run_from_file_indirect: test/run_from_file.c $(OUT)/libscsindir.a
|
|
76
|
+
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
|
77
|
+
|
|
78
|
+
$(OUT)/run_from_file_gpu_indirect: test/run_from_file.c $(OUT)/libscsgpuindir.a
|
|
79
|
+
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(CULDFLAGS)
|
|
80
|
+
|
|
81
|
+
# basic testing
|
|
82
|
+
.PHONY: test
|
|
83
|
+
test: $(OUT)/run_tests_indirect $(OUT)/run_tests_direct
|
|
84
|
+
$(OUT)/run_tests_indirect: test/run_tests.c $(OUT)/libscsindir.a
|
|
85
|
+
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -Itest
|
|
86
|
+
$(OUT)/run_tests_direct: test/run_tests.c $(OUT)/libscsdir.a
|
|
87
|
+
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -Itest
|
|
88
|
+
|
|
89
|
+
.PHONY: test_gpu
|
|
90
|
+
test_gpu: $(OUT)/run_tests_gpu_indirect # $(OUT)/run_tests_gpu_direct
|
|
91
|
+
|
|
92
|
+
$(OUT)/run_tests_gpu_indirect: test/run_tests.c $(OUT)/libscsgpuindir.a
|
|
93
|
+
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(CULDFLAGS) -Itest
|
|
94
|
+
|
|
95
|
+
# $(OUT)/run_tests_gpu_direct: test/run_tests.c $(OUT)/libscsgpudir.a
|
|
96
|
+
# $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(CULDFLAGS) -Itest
|
|
97
|
+
|
|
98
|
+
# REQUIRES GPU AND CUDA INSTALLED
|
|
99
|
+
gpu: gpu_indirect # gpu_direct
|
|
100
|
+
|
|
101
|
+
# gpu_direct: $(OUT)/demo_socp_gpu_direct $(OUT)/libscsgpudir.$(SHARED) $(OUT)/libscsgpudir.a $(OUT)/run_from_file_gpu_direct
|
|
102
|
+
gpu_indirect: $(OUT)/demo_socp_gpu_indirect $(OUT)/libscsgpuindir.$(SHARED) $(OUT)/libscsgpuindir.a $(OUT)/run_from_file_gpu_indirect
|
|
103
|
+
|
|
104
|
+
$(LINSYS)/gpu/gpu.o: $(LINSYS)/gpu/gpu.c
|
|
105
|
+
$(CUCC) -c -o $@ $^ $(CUDAFLAGS)
|
|
106
|
+
|
|
107
|
+
# $(GPUDIR)/private.o: $(GPUDIR)/private.c
|
|
108
|
+
# $(CUCC) -c -o $(GPUDIR)/private.o $^ $(CUDAFLAGS)
|
|
109
|
+
|
|
110
|
+
$(GPUINDIR)/private.o: $(GPUINDIR)/private.c
|
|
111
|
+
$(CUCC) -c -o $(GPUINDIR)/private.o $^ $(CUDAFLAGS)
|
|
112
|
+
|
|
113
|
+
# $(OUT)/libscsgpudir.$(SHARED): $(SCS_OBJECTS) $(GPUDIR)/private.o $(AMD_OBJS) $(LINSYS)/amatrix.o $(LINSYS)/gpu/gpu.o
|
|
114
|
+
# mkdir -p $(OUT)
|
|
115
|
+
# $(CC) $(CFLAGS) -shared -Wl,$(SONAME),$(@:$(OUT)/%=%) -o $@ $^ $(LDFLAGS) $(CULDFLAGS)
|
|
116
|
+
|
|
117
|
+
# $(OUT)/libscsgpudir.a: $(SCS_OBJECTS) $(GPUDIR)/private.o $(AMD_OBJS) $(LINSYS)/amatrix.o $(LINSYS)/gpu/gpu.o
|
|
118
|
+
# mkdir -p $(OUT)
|
|
119
|
+
# $(ARCHIVE) $@ $^
|
|
120
|
+
# - $(RANLIB) $@
|
|
121
|
+
|
|
122
|
+
$(OUT)/libscsgpuindir.$(SHARED): $(SCS_OBJECTS) $(GPUINDIR)/private.o $(LINSYS)/amatrix.o $(LINSYS)/gpu/gpu.o
|
|
123
|
+
mkdir -p $(OUT)
|
|
124
|
+
$(CC) $(CFLAGS) -shared -Wl,$(SONAME),$(@:$(OUT)/%=%) -o $@ $^ $(LDFLAGS) $(CULDFLAGS)
|
|
125
|
+
|
|
126
|
+
$(OUT)/libscsgpuindir.a: $(SCS_OBJECTS) $(GPUINDIR)/private.o $(LINSYS)/amatrix.o $(LINSYS)/gpu/gpu.o
|
|
127
|
+
mkdir -p $(OUT)
|
|
128
|
+
$(ARCHIVE) $@ $^
|
|
129
|
+
- $(RANLIB) $@
|
|
130
|
+
|
|
131
|
+
# $(OUT)/demo_socp_gpu_direct: test/random_socp_prob.c $(OUT)/libscsgpudir.a
|
|
132
|
+
# $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(CULDFLAGS)
|
|
133
|
+
|
|
134
|
+
$(OUT)/demo_socp_gpu_indirect: test/random_socp_prob.c $(OUT)/libscsgpuindir.a
|
|
135
|
+
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(CULDFLAGS)
|
|
136
|
+
|
|
137
|
+
.PHONY: clean purge
|
|
138
|
+
clean:
|
|
139
|
+
@rm -rf $(TARGETS) $(SCS_OBJECTS) $(AMD_OBJS) $(LDL_OBJS) $(LINSYS)/*.o $(DIRSRC)/*.o $(INDIRSRC)/*.o $(GPUDIR)/*.o $(GPUINDIR)/*.o
|
|
140
|
+
@rm -rf $(OUT)/*.dSYM
|
|
141
|
+
@rm -rf matlab/*.mex*
|
|
142
|
+
@rm -rf .idea
|
|
143
|
+
@rm -rf python/*.pyc
|
|
144
|
+
@rm -rf python/build
|
|
145
|
+
purge: clean
|
|
146
|
+
@rm -rf $(OUT)
|
|
147
|
+
|
|
148
|
+
INSTALL_INC_FILES = $(INC_FILES)
|
|
149
|
+
|
|
150
|
+
INSTALL_TARGETS = $(OUT)/libscsdir.a $(OUT)/libscsindir.a $(OUT)/libscsdir.$(SHARED) $(OUT)/libscsindir.$(SHARED)
|
|
151
|
+
INSTALL_GPU_TARGETS = $(OUT)/libscsgpuindir.a $(OUT)/libscsgpuindir.$(SHARED) # $(OUT)/libscsgpudir.a $(OUT)/libscsgpudir.$(SHARED)
|
|
152
|
+
|
|
153
|
+
INSTALL_INC_DIR = $(DESTDIR)$(PREFIX)/include/scs/
|
|
154
|
+
INSTALL_LIB_DIR = $(DESTDIR)$(PREFIX)/lib/
|
|
155
|
+
|
|
156
|
+
.PHONY: install install_gpu
|
|
157
|
+
install: $(INSTALL_INC_FILES) $(INSTALL_TARGETS)
|
|
158
|
+
$(INSTALL) -d $(INSTALL_INC_DIR) $(INSTALL_LIB_DIR)
|
|
159
|
+
$(INSTALL) -m 644 $(INSTALL_INC_FILES) $(INSTALL_INC_DIR)
|
|
160
|
+
$(INSTALL) -m 644 $(INSTALL_TARGETS) $(INSTALL_LIB_DIR)
|
|
161
|
+
install_gpu: $(INSTALL_INC_FILES) $(INSTALL_GPU_TARGETS)
|
|
162
|
+
$(INSTALL) -d $(INSTALL_INC_DIR) $(INSTALL_LIB_DIR)
|
|
163
|
+
$(INSTALL) -m 644 $(INSTALL_INC_FILES) $(INSTALL_INC_DIR)
|
|
164
|
+
$(INSTALL) -m 644 $(INSTALL_GPU_TARGETS) $(INSTALL_LIB_DIR)
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
SCS
|
|
2
|
+
====
|
|
3
|
+
|
|
4
|
+
[](https://travis-ci.org/cvxgrp/scs)
|
|
5
|
+
[](https://ci.appveyor.com/project/bodono/scs/branch/master)
|
|
6
|
+
|
|
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
|
+
|
|
161
|
+
To use the libraries in your own source code, compile your code with the linker
|
|
162
|
+
option `-L(PATH_TO_SCS_LIBS)` and `-lscsdir` or `-lscsindir` (as needed). The
|
|
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**
|
|
219
|
+
|
|
220
|
+
If you get an error like `cannot find -lblas` or `cannot find -llapack`, then
|
|
221
|
+
you need to install blas and lapack and / or update your environment variables
|
|
222
|
+
to point to the install locations.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#ifndef AA_H_GUARD
|
|
2
|
+
#define AA_H_GUARD
|
|
3
|
+
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#include <stdio.h>
|
|
9
|
+
#include <stdlib.h>
|
|
10
|
+
#include <string.h>
|
|
11
|
+
#include "glbopts.h"
|
|
12
|
+
|
|
13
|
+
typedef scs_float aa_float;
|
|
14
|
+
typedef scs_int aa_int;
|
|
15
|
+
|
|
16
|
+
typedef struct ACCEL_WORK AaWork;
|
|
17
|
+
|
|
18
|
+
/* Initialize Anderson Acceleration, allocates memory.
|
|
19
|
+
*
|
|
20
|
+
* Args:
|
|
21
|
+
* dim: the dimension of the variable for aa
|
|
22
|
+
* aa_mem: the memory (number of past iterations used) for aa
|
|
23
|
+
* type1: bool, if True use type 1 aa, otherwise use type 2
|
|
24
|
+
*
|
|
25
|
+
* Reurns:
|
|
26
|
+
* Pointer to aa workspace
|
|
27
|
+
*/
|
|
28
|
+
AaWork *aa_init(aa_int dim, aa_int aa_mem, aa_int type1);
|
|
29
|
+
|
|
30
|
+
/* Apply Anderson Acceleration.
|
|
31
|
+
*
|
|
32
|
+
* Args:
|
|
33
|
+
* f: output of map at current iteration, overwritten with aa output at end.
|
|
34
|
+
* x: input to map at current iteration
|
|
35
|
+
* a: aa workspace from aa_init
|
|
36
|
+
*
|
|
37
|
+
* Returns:
|
|
38
|
+
* int, a value of 0 is success, <0 is failure at which point f is unchanged
|
|
39
|
+
*/
|
|
40
|
+
aa_int aa_apply(aa_float *f, const aa_float *x, AaWork *a);
|
|
41
|
+
|
|
42
|
+
/* Finish Anderson Acceleration, clears memory.
|
|
43
|
+
*
|
|
44
|
+
* Args:
|
|
45
|
+
* a: aa workspace from aa_init.
|
|
46
|
+
*/
|
|
47
|
+
void aa_finish(AaWork *a);
|
|
48
|
+
|
|
49
|
+
#define MAX_AA_NRM (1e4)
|
|
50
|
+
|
|
51
|
+
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
|
52
|
+
|
|
53
|
+
#ifdef __cplusplus
|
|
54
|
+
}
|
|
55
|
+
#endif
|
|
56
|
+
#endif
|