├── dimacs ├── copo14.mat ├── nql30.mat ├── minphase.mat ├── filter48_socp.mat ├── hamming_7_5_6.mat └── sched_50_50_scaled.mat ├── Solver ├── Mexfun │ ├── mexmat.dll │ ├── mexnnz.dll │ ├── mexMatvec.dll │ ├── mexProd2.dll │ ├── mexexpand.dll │ ├── mexinprod.dll │ ├── mexmat.mexa64 │ ├── mexmat.mexglx │ ├── mexmat.mexw32 │ ├── mexmat.mexw64 │ ├── mexnnz.mexa64 │ ├── mexnnz.mexglx │ ├── mexnnz.mexw32 │ ├── mexnnz.mexw64 │ ├── mexqops.dll │ ├── mexschur.dll │ ├── mexskron.dll │ ├── mexsmat.dll │ ├── mexsvec.dll │ ├── mextriang.dll │ ├── mexProd2.mexa64 │ ├── mexProd2.mexglx │ ├── mexProd2.mexw32 │ ├── mexProd2.mexw64 │ ├── mexProd2nz.dll │ ├── mexmat.mexmaci │ ├── mexnnz.mexmaci │ ├── mexqops.mexa64 │ ├── mexqops.mexglx │ ├── mexqops.mexmaci │ ├── mexqops.mexw32 │ ├── mexqops.mexw64 │ ├── mexschur.mexa64 │ ├── mexschur.mexglx │ ├── mexschur.mexw32 │ ├── mexschur.mexw64 │ ├── mexschurfun.dll │ ├── mexskron.mexa64 │ ├── mexskron.mexglx │ ├── mexskron.mexw32 │ ├── mexskron.mexw64 │ ├── mexsmat.mexa64 │ ├── mexsmat.mexglx │ ├── mexsmat.mexmaci │ ├── mexsmat.mexw32 │ ├── mexsmat.mexw64 │ ├── mexsvec.mexa64 │ ├── mexsvec.mexglx │ ├── mexsvec.mexmaci │ ├── mexsvec.mexw32 │ ├── mexsvec.mexw64 │ ├── mextriangsp.dll │ ├── mexMatvec.mexa64 │ ├── mexMatvec.mexglx │ ├── mexMatvec.mexmaci │ ├── mexMatvec.mexw32 │ ├── mexMatvec.mexw64 │ ├── mexProd2.mexmaci │ ├── mexProd2.mexmaci64 │ ├── mexProd2nz.mexa64 │ ├── mexProd2nz.mexglx │ ├── mexProd2nz.mexmaci │ ├── mexProd2nz.mexw32 │ ├── mexProd2nz.mexw64 │ ├── mexProd2sp.mexa64 │ ├── mexProd2sp.mexglx │ ├── mexexpand.mexa64 │ ├── mexexpand.mexglx │ ├── mexexpand.mexmaci │ ├── mexexpand.mexw32 │ ├── mexexpand.mexw64 │ ├── mexinprod.mexa64 │ ├── mexinprod.mexglx │ ├── mexinprod.mexmaci │ ├── mexinprod.mexw32 │ ├── mexinprod.mexw64 │ ├── mexmat.mexmaci64 │ ├── mexmatold.mexglx │ ├── mexnnz.mexmaci64 │ ├── mexqops.mexmaci64 │ ├── mexschur.mexmaci │ ├── mexschur.mexmaci64 │ ├── mexschurfun.mexa64 │ ├── mexschurfun.mexglx │ ├── mexschurfun.mexw32 │ ├── mexschurfun.mexw64 │ ├── mexskron.mexmaci │ ├── mexskron.mexmaci64 │ ├── mexsmat.mexmaci64 │ ├── mexsvec.mexmaci64 │ ├── mextriang.mexa64 │ ├── mextriang.mexglx │ ├── mextriang.mexmaci │ ├── mextriang.mexw32 │ ├── mextriang.mexw64 │ ├── mextriangsp.mexa64 │ ├── mextriangsp.mexglx │ ├── mextriangsp.mexw32 │ ├── mextriangsp.mexw64 │ ├── Oldfiles │ │ ├── mexchol.dll │ │ ├── mexchol.mexglx │ │ ├── mexchol_.mexglx │ │ ├── mexpertdiagold.c │ │ ├── mexchol.c │ │ ├── mexchol_.c │ │ ├── mexqprod.c │ │ └── mexschurfun_old.c │ ├── mexMatvec.mexmaci64 │ ├── mexProd2nz.mexmaci64 │ ├── mexexpand.mexmaci64 │ ├── mexinprod.mexmaci64 │ ├── mexschurfun.mexmaci │ ├── mextriang.mexmaci64 │ ├── mextriangsp.mexmaci │ ├── pre7.5 │ │ ├── mexmat.mexglx │ │ ├── mexnnz.mexglx │ │ ├── mexMatvec.mexglx │ │ ├── mexProd2.mexglx │ │ ├── mexexpand.mexglx │ │ ├── mexinprod.mexglx │ │ ├── mexqops.mexglx │ │ ├── mexschur.mexglx │ │ ├── mexskron.mexglx │ │ ├── mexsmat.mexglx │ │ ├── mexsvec.mexglx │ │ ├── mextriang.mexglx │ │ ├── mexProd2nz.mexglx │ │ ├── mexschurfun.mexglx │ │ └── mextriangsp.mexglx │ ├── mexschurfun.mexmaci64 │ ├── mextriangsp.mexmaci64 │ ├── header.h │ ├── mexfun71 │ │ ├── mexexpand_71.c │ │ └── mexnnz_71.c │ ├── mexnnz.c │ └── mexexpand.c ├── Mexfun_old │ ├── mexmat.dll │ ├── mexnnz.dll │ ├── mexqops.dll │ ├── mexsmat.dll │ ├── mexsvec.dll │ ├── mexMatvec.dll │ ├── mexProd2.dll │ ├── mexProd2nz.dll │ ├── mexexpand.dll │ ├── mexinprod.dll │ ├── mexmat.mexa64 │ ├── mexmat.mexglx │ ├── mexmat.mexw64 │ ├── mexnnz.mexa64 │ ├── mexnnz.mexglx │ ├── mexnnz.mexw64 │ ├── mexqops.mexa64 │ ├── mexqops.mexglx │ ├── mexqops.mexw64 │ ├── mexschur.dll │ ├── mexskron.dll │ ├── mexsmat.mexa64 │ ├── mexsmat.mexglx │ ├── mexsmat.mexw64 │ ├── mexsvec.mexa64 │ ├── mexsvec.mexglx │ ├── mexsvec.mexw64 │ ├── mextriang.dll │ ├── mexMatvec.mexa64 │ ├── mexMatvec.mexglx │ ├── mexMatvec.mexw64 │ ├── mexProd2.mexa64 │ ├── mexProd2.mexglx │ ├── mexProd2.mexw64 │ ├── mexexpand.mexa64 │ ├── mexexpand.mexglx │ ├── mexexpand.mexw64 │ ├── mexinprod.mexa64 │ ├── mexinprod.mexglx │ ├── mexinprod.mexw64 │ ├── mexmatold.mexglx │ ├── mexschur.mexa64 │ ├── mexschur.mexglx │ ├── mexschur.mexw64 │ ├── mexschurfun.dll │ ├── mexskron.mexa64 │ ├── mexskron.mexglx │ ├── mexskron.mexw64 │ ├── mextriang.mexa64 │ ├── mextriang.mexglx │ ├── mextriang.mexw64 │ ├── mextriangsp.dll │ ├── mexProd2nz.mexa64 │ ├── mexProd2nz.mexglx │ ├── mexProd2nz.mexw64 │ ├── mexProd2sp.mexa64 │ ├── mexProd2sp.mexglx │ ├── mexschur_new.mexa64 │ ├── mexschurfun.mexa64 │ ├── mexschurfun.mexglx │ ├── mexschurfun.mexw64 │ ├── mextriangsp.mexa64 │ ├── mextriangsp.mexglx │ ├── mextriangsp.mexw64 │ ├── Oldfiles │ │ ├── mexchol.dll │ │ ├── mexchol.mexglx │ │ ├── mexchol_.mexglx │ │ ├── mexpertdiagold.c │ │ ├── mexchol.c │ │ ├── mexchol_.c │ │ ├── mexqprod.c │ │ └── mexschurfun_old.c │ ├── mexfun71 │ │ ├── mexexpand_71.c │ │ └── mexnnz_71.c │ ├── mexnnz.c │ └── mexexpand.c ├── mytime.m ├── Oldmfiles │ ├── schurmat_lblkold.m │ ├── HKMcorrold.m │ ├── NTcorrold.m │ ├── Installmex_old.m │ ├── iterrefine.m │ ├── Installmex.m │ ├── scaling_old.m │ └── schurmat_sblkold.m ├── qprod.m ├── checkdense.m ├── randmat.m ├── smat.m ├── Arrow.m ├── detect_priminfeas.m ├── convertRcone.m ├── schurmat_lblk.m ├── sqlptermcode.m ├── linsysolvefun.m ├── blkcholfun.m ├── NTcorr.m ├── HKMcorr.m ├── linsysolvefun_old.m ├── skron.m ├── qops.m ├── Atyfun.m ├── NTdirfun.m ├── Prod3.m ├── HKMdirfun.m ├── AXfun.m ├── blkbarrier.m ├── Prod2.m ├── NTscaling.m ├── blktrace.m ├── SDPvalBounds.m ├── svec.m ├── NTpred.m ├── scaling.m └── combine_blk.m ├── Citation ├── Examples ├── mcpschur.m ├── graph2.m ├── gppschur.m ├── viewgraph.m ├── corrmat.m ├── sdphankel.m ├── lmifun.m ├── orthbasis.m ├── lmifun2.m ├── geometric_mean.m ├── lmiexamp1.m ├── ToeplitzApproxSQQ.m ├── chebymat.m ├── igmres.m ├── lmiexamp3.m ├── randmaxdet.m ├── max_kcut.m ├── maxcut.m ├── ToeplitzApprox.m ├── Asum.m ├── Doptdesign.m ├── lmiexamp2.m ├── logchebyRcone.m ├── thetaproblem.m ├── gpp.m └── etp.m ├── Copyright ├── startup.m └── HSDSolver ├── HSDHKMcorr.m ├── HSDNTcorr.m ├── HSDNTdirfun.m ├── HSDHKMdirfun.m ├── HSDNTpred.m ├── etc └── HSDgmres.m └── HSDsqlpCpert.m /dimacs/copo14.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/dimacs/copo14.mat -------------------------------------------------------------------------------- /dimacs/nql30.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/dimacs/nql30.mat -------------------------------------------------------------------------------- /dimacs/minphase.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/dimacs/minphase.mat -------------------------------------------------------------------------------- /Solver/Mexfun/mexmat.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexmat.dll -------------------------------------------------------------------------------- /Solver/Mexfun/mexnnz.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexnnz.dll -------------------------------------------------------------------------------- /dimacs/filter48_socp.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/dimacs/filter48_socp.mat -------------------------------------------------------------------------------- /dimacs/hamming_7_5_6.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/dimacs/hamming_7_5_6.mat -------------------------------------------------------------------------------- /Solver/Mexfun/mexMatvec.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexMatvec.dll -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2.dll -------------------------------------------------------------------------------- /Solver/Mexfun/mexexpand.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexexpand.dll -------------------------------------------------------------------------------- /Solver/Mexfun/mexinprod.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexinprod.dll -------------------------------------------------------------------------------- /Solver/Mexfun/mexmat.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexmat.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexmat.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexmat.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexmat.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexmat.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mexmat.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexmat.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexnnz.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexnnz.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexnnz.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexnnz.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexnnz.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexnnz.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mexnnz.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexnnz.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexqops.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexqops.dll -------------------------------------------------------------------------------- /Solver/Mexfun/mexschur.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexschur.dll -------------------------------------------------------------------------------- /Solver/Mexfun/mexskron.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexskron.dll -------------------------------------------------------------------------------- /Solver/Mexfun/mexsmat.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexsmat.dll -------------------------------------------------------------------------------- /Solver/Mexfun/mexsvec.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexsvec.dll -------------------------------------------------------------------------------- /Solver/Mexfun/mextriang.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mextriang.dll -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2nz.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2nz.dll -------------------------------------------------------------------------------- /Solver/Mexfun/mexmat.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexmat.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/mexnnz.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexnnz.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/mexqops.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexqops.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexqops.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexqops.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexqops.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexqops.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/mexqops.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexqops.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mexqops.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexqops.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexschur.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexschur.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexschur.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexschur.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexschur.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexschur.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mexschur.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexschur.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexschurfun.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexschurfun.dll -------------------------------------------------------------------------------- /Solver/Mexfun/mexskron.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexskron.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexskron.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexskron.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexskron.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexskron.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mexskron.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexskron.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexsmat.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexsmat.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexsmat.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexsmat.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexsmat.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexsmat.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/mexsmat.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexsmat.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mexsmat.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexsmat.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexsvec.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexsvec.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexsvec.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexsvec.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexsvec.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexsvec.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/mexsvec.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexsvec.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mexsvec.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexsvec.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/mextriangsp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mextriangsp.dll -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexmat.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexmat.dll -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexnnz.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexnnz.dll -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexqops.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexqops.dll -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexsmat.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexsmat.dll -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexsvec.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexsvec.dll -------------------------------------------------------------------------------- /dimacs/sched_50_50_scaled.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/dimacs/sched_50_50_scaled.mat -------------------------------------------------------------------------------- /Solver/Mexfun/mexMatvec.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexMatvec.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexMatvec.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexMatvec.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexMatvec.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexMatvec.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/mexMatvec.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexMatvec.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mexMatvec.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexMatvec.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2nz.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2nz.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2nz.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2nz.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2nz.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2nz.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2nz.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2nz.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2nz.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2nz.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2sp.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2sp.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2sp.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2sp.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexexpand.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexexpand.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexexpand.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexexpand.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexexpand.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexexpand.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/mexexpand.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexexpand.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mexexpand.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexexpand.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexinprod.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexinprod.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexinprod.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexinprod.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexinprod.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexinprod.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/mexinprod.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexinprod.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mexinprod.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexinprod.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexmat.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexmat.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexmatold.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexmatold.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexnnz.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexnnz.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexqops.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexqops.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexschur.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexschur.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/mexschur.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexschur.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexschurfun.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexschurfun.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexschurfun.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexschurfun.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexschurfun.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexschurfun.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mexschurfun.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexschurfun.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexskron.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexskron.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/mexskron.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexskron.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexsmat.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexsmat.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexsvec.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexsvec.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/mextriang.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mextriang.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mextriang.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mextriang.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mextriang.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mextriang.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/mextriang.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mextriang.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mextriang.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mextriang.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/mextriangsp.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mextriangsp.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun/mextriangsp.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mextriangsp.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mextriangsp.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mextriangsp.mexw32 -------------------------------------------------------------------------------- /Solver/Mexfun/mextriangsp.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mextriangsp.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexMatvec.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexMatvec.dll -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexProd2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexProd2.dll -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexProd2nz.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexProd2nz.dll -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexexpand.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexexpand.dll -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexinprod.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexinprod.dll -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexmat.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexmat.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexmat.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexmat.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexmat.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexmat.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexnnz.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexnnz.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexnnz.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexnnz.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexnnz.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexnnz.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexqops.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexqops.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexqops.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexqops.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexqops.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexqops.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexschur.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexschur.dll -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexskron.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexskron.dll -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexsmat.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexsmat.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexsmat.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexsmat.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexsmat.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexsmat.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexsvec.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexsvec.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexsvec.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexsvec.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexsvec.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexsvec.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mextriang.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mextriang.dll -------------------------------------------------------------------------------- /Solver/Mexfun/Oldfiles/mexchol.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/Oldfiles/mexchol.dll -------------------------------------------------------------------------------- /Solver/Mexfun/mexMatvec.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexMatvec.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexProd2nz.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexProd2nz.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexexpand.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexexpand.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexinprod.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexinprod.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/mexschurfun.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexschurfun.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/mextriang.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mextriang.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/mextriangsp.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mextriangsp.mexmaci -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mexmat.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mexmat.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mexnnz.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mexnnz.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexMatvec.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexMatvec.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexMatvec.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexMatvec.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexMatvec.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexMatvec.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexProd2.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexProd2.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexProd2.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexProd2.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexProd2.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexProd2.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexexpand.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexexpand.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexexpand.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexexpand.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexexpand.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexexpand.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexinprod.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexinprod.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexinprod.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexinprod.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexinprod.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexinprod.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexmatold.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexmatold.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexschur.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexschur.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexschur.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexschur.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexschur.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexschur.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexschurfun.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexschurfun.dll -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexskron.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexskron.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexskron.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexskron.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexskron.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexskron.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mextriang.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mextriang.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mextriang.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mextriang.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mextriang.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mextriang.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mextriangsp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mextriangsp.dll -------------------------------------------------------------------------------- /Solver/Mexfun/Oldfiles/mexchol.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/Oldfiles/mexchol.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/mexschurfun.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mexschurfun.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/mextriangsp.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/mextriangsp.mexmaci64 -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mexMatvec.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mexMatvec.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mexProd2.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mexProd2.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mexexpand.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mexexpand.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mexinprod.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mexinprod.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mexqops.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mexqops.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mexschur.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mexschur.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mexskron.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mexskron.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mexsmat.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mexsmat.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mexsvec.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mexsvec.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mextriang.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mextriang.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexProd2nz.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexProd2nz.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexProd2nz.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexProd2nz.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexProd2nz.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexProd2nz.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexProd2sp.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexProd2sp.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexProd2sp.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexProd2sp.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexschur_new.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexschur_new.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexschurfun.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexschurfun.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexschurfun.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexschurfun.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexschurfun.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mexschurfun.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mextriangsp.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mextriangsp.mexa64 -------------------------------------------------------------------------------- /Solver/Mexfun_old/mextriangsp.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mextriangsp.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/mextriangsp.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/mextriangsp.mexw64 -------------------------------------------------------------------------------- /Solver/Mexfun/Oldfiles/mexchol_.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/Oldfiles/mexchol_.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mexProd2nz.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mexProd2nz.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mexschurfun.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mexschurfun.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/pre7.5/mextriangsp.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun/pre7.5/mextriangsp.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/Oldfiles/mexchol.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/Oldfiles/mexchol.dll -------------------------------------------------------------------------------- /Solver/Mexfun_old/Oldfiles/mexchol.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/Oldfiles/mexchol.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun_old/Oldfiles/mexchol_.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kim-ChuanToh/SDPT3/HEAD/Solver/Mexfun_old/Oldfiles/mexchol_.mexglx -------------------------------------------------------------------------------- /Solver/Mexfun/header.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef MWSIZE_MAX 3 | #define mwIndex int 4 | #define mwSignedIndex int 5 | #define mwSize int 6 | #endif 7 | 8 | #if !defined(_WIN32) 9 | #define dgemv dgemv_ 10 | #endif 11 | 12 | #define mwIndex ptrdiff_t 13 | #define mwSize ptrdiff_t -------------------------------------------------------------------------------- /Citation: -------------------------------------------------------------------------------- 1 | SDPT3 Version 4.0 2 | A MATLAB software for semidefinite-quadratic-linear programming 3 | Copyright (c) 1997 by 4 | Kim-Chuan Toh, Michael J. Todd, and Reha H. Tutuncu 5 | 6 | If you find this software useful for your work, please cite the 7 | followings: 8 | 9 | [1] K.C. Toh, M.J. Todd, and R.H. Tutuncu, 10 | SDPT3 --- a Matlab software package for semidefinite programming, 11 | Optimization Methods and Software, 11 (1999), pp. 545--581. 12 | [2] R.H Tutuncu, K.C. Toh, and M.J. Todd, 13 | Solving semidefinite-quadratic-linear programs using SDPT3, 14 | Mathematical Programming Ser. B, 95 (2003), pp. 189--217. 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Examples/mcpschur.m: -------------------------------------------------------------------------------- 1 | %%**************************************************** 2 | %% mcpschur: compute schur matrix of HKM or NT direction 3 | %% for MCP and maxG problems. 4 | %% 5 | %% [schurmat] = mcpschur(X,Zinv,schurfun_par); 6 | %% 7 | %% Ak= -ek*ek'; 8 | %%***************************************************************** 9 | %% SDPT3: version 4.0 10 | %% Copyright (c) 1997 by 11 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 12 | %% Last Modified: 16 Sep 2004 13 | %%***************************************************************** 14 | 15 | function [schurmat] = mcpschur(X,Zinv,schurfun_pars); 16 | 17 | schurmat = X .* Zinv; 18 | %%**************************************************** 19 | -------------------------------------------------------------------------------- /Examples/graph2.m: -------------------------------------------------------------------------------- 1 | %%****************************************************** 2 | %% graph: generate random adjacency matrix. 3 | %% 4 | %% B = graph(n,prob); 5 | %% 6 | %% see maxcut.m 7 | %% 8 | %% SDPT3: version 3.0 9 | %% Copyright (c) 1997 by 10 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 11 | %% Last modified: 2 Feb 01 12 | %%****************************************************** 13 | 14 | function B = graph(n,prob) 15 | 16 | B = zeros(n,n); 17 | if nargin <= 1; prob = 0.5; end; 18 | for i = 1:n 19 | for j = i+1:n 20 | r = rand(1); 21 | if (r < prob); B(i,j) = 1; B(j,i) = 1; end; 22 | end; 23 | end; 24 | %%====================================================== 25 | -------------------------------------------------------------------------------- /Solver/mytime.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% SDPT3: version 4.0 3 | %% Copyright (c) 1997 by 4 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 5 | %% Last Modified: 16 Sep 2004 6 | %%***************************************************************** 7 | function [hh,mm,ss] = mytime(t); 8 | 9 | t = round(t); 10 | h = floor(t/3600); 11 | m = floor(rem(t,3600)/60); 12 | s = rem(rem(t,60),60); 13 | 14 | hh = num2str(h); 15 | if (h > 0) & (m < 10) 16 | mm = ['0',num2str(m)]; 17 | else 18 | mm = num2str(m); 19 | end 20 | if (s < 10) 21 | ss = ['0',num2str(s)]; 22 | else 23 | ss = num2str(s); 24 | end 25 | %%********************************************** 26 | -------------------------------------------------------------------------------- /Solver/Oldmfiles/schurmat_lblkold.m: -------------------------------------------------------------------------------- 1 | %%******************************************************************* 2 | %% schurmat_lblk: 3 | %% 4 | %% SDPT3: version 3.0 5 | %% Copyright (c) 1997 by 6 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 7 | %% Last modified: 2 Feb 01 8 | %%******************************************************************* 9 | 10 | function [schur,UU,VV] = schurmat_lblk(blk,At,schur,UU,VV,p,dd); 11 | 12 | n = sum(blk{p,2}); 13 | decolidx = checkdense(At{p}'); 14 | ddsch = dd{p}; 15 | if ~isempty(decolidx); 16 | len = length(decolidx); 17 | Ad = (spdiags(sqrt(ddsch(decolidx)),0,len,len)*At{p}(decolidx,:))'; 18 | UU = [UU Ad]; 19 | VV = [VV Ad]; 20 | ddsch(decolidx) = zeros(len,1); 21 | end 22 | schur = schur + At{p}' *spdiags(ddsch,0,n,n) *At{p}; 23 | %%******************************************************************* 24 | -------------------------------------------------------------------------------- /Solver/qprod.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% qprod: 3 | %% 4 | %% Input: A = [A1 A2 ... An] 5 | %% x = [x1; x2; ...; xn] 6 | %% Output: [A1*x1 A2*x2 ... An*xn] 7 | %%***************************************************************** 8 | %% SDPT3: version 4.0 9 | %% Copyright (c) 1997 by 10 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 11 | %% Last Modified: 16 Sep 2004 12 | %%***************************************************************** 13 | 14 | function Ax = qprod(pblk,A,x); 15 | 16 | if (size(pblk,1) > 1) 17 | error('qprod: pblk can only have 1 row'); 18 | end 19 | if issparse(x); x = full(x); end; %% for spconvert 20 | n = length(x); 21 | ii = [1:n]'; 22 | jj = mexexpand(pblk{2},[1:length(pblk{2})]'); 23 | X = spconvert([ii, jj, x]); 24 | Ax = A*X; 25 | %%*************************************************** 26 | -------------------------------------------------------------------------------- /Copyright: -------------------------------------------------------------------------------- 1 | SDPT3 Version 4.0 2 | A MATLAB software for semidefinite-quadratic-linear programming 3 | Copyright (c) 1997 by 4 | Kim-Chuan Toh, Michael J. Todd, and Reha H. Tutuncu 5 | 6 | This version of the above software is distributed under the GNU General Public License 2.0. 7 | 8 | For commercial applications that may be incompatible with this license, 9 | please contact the authors to discuss alternatives. 10 | 11 | This software is free software; you can redistribute it and/or 12 | modify it under the terms of the GNU General Public License 2.0 13 | as published by the Free Software Foundation Inc., 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Solver/checkdense.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% checkdense : identify the dense columns of a matrix 3 | %% 4 | %%***************************************************************** 5 | %% SDPT3: version 4.0 6 | %% Copyright (c) 1997 by 7 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 8 | %% Last Modified: 16 Sep 2004 9 | %%***************************************************************** 10 | 11 | function idxden = checkdense(A); 12 | 13 | [m,n] = size(A); 14 | idxden = []; 15 | nzratio = 1; 16 | if (m > 1000); nzratio = 0.20; end; 17 | if (m > 2000); nzratio = 0.10; end; 18 | if (m > 5000); nzratio = 0.05; end; 19 | if (nzratio < 1) 20 | nzcolA = sum(spones(A)); 21 | idxden = find(nzcolA > nzratio*m); 22 | if (length(idxden) > max(200,0.1*n)) 23 | idxden = []; 24 | end 25 | end 26 | %%******************************************************************** 27 | -------------------------------------------------------------------------------- /Examples/gppschur.m: -------------------------------------------------------------------------------- 1 | %%**************************************************** 2 | %% gppschur: compute schur matrix of HKM direction 3 | %% for GPP problems. 4 | %% 5 | %% schur = gppschur(X,Zinv,schurfun_par); 6 | %% 7 | %% Ak = -e*e' if k = 1 8 | %% = -ek*ek' if k > 1. 9 | %%***************************************************************** 10 | %% SDPT3: version 4.0 11 | %% Copyright (c) 1997 by 12 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 13 | %% Last Modified: 16 Sep 2004 14 | %%***************************************************************** 15 | function schur = gppschur(X,Zinv,schurfun_par); 16 | 17 | n = size(X,1); 18 | e = ones(n,1); 19 | m = n+1; 20 | schur = zeros(m); 21 | schur(2:m,2:m) = X .* Zinv; 22 | tmp = (X*e) .* (Zinv*e); 23 | schur(2:m,1) = tmp; 24 | schur(1,2:m) = tmp'; 25 | schur(1,1) = (e'*X*e) * (e'*Zinv*e); 26 | %%**************************************************** 27 | -------------------------------------------------------------------------------- /Examples/viewgraph.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% viewgraph: plot the graph of an adjacency matrix. 3 | %%***************************************************************** 4 | %% SDPT3: version 4.0 5 | %% Copyright (c) 1997 by 6 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 7 | %% Last Modified: 16 Sep 2004 8 | %%***************************************************************** 9 | 10 | function viewgraph(B); 11 | 12 | n = length(B); 13 | z = exp(2*pi*sqrt(-1)*[0:n-1]/n); 14 | circle = exp(2*pi*sqrt(-1)*linspace(0,1,100)); 15 | plot(circle,':'); hold on 16 | axis('square'); 17 | for i = 1:n 18 | idx = find(B(i,i+1:n) == 1); 19 | idx = idx + i; 20 | for k = 1:length(idx) 21 | z1 = z(i); z2 = z(idx(k)); 22 | plot([real(z1) real(z2)],[imag(z1) imag(z2)]); 23 | end; 24 | end; 25 | plot(z,'.r','markersize',16); 26 | hold off; 27 | %%===================================================== 28 | -------------------------------------------------------------------------------- /Solver/randmat.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% randmat: generate an mxn matrix using matlab's 3 | %% rand or randn functions using state = k. 4 | %%***************************************************************** 5 | %% SDPT3: version 4.0 6 | %% Copyright (c) 1997 by 7 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 8 | %% Last Modified: 16 Sep 2004 9 | %%***************************************************************** 10 | 11 | function v = randmat(m,n,k,randtype) 12 | 13 | try 14 | s = rng; 15 | rng(k); 16 | if strcmp(randtype,'n') 17 | v = randn(m,n); 18 | elseif strcmp(randtype,'u') 19 | v = rand(m,n); 20 | end 21 | rng(s); 22 | catch 23 | if strcmp(randtype,'n') 24 | s = randn('state'); 25 | randn('state',k); 26 | v = randn(m,n); 27 | randn('state',s); 28 | elseif strcmp(randtype,'u') 29 | s = rand('state'); 30 | rand('state',k); 31 | v = rand(m,n); 32 | rand('state',s); 33 | end 34 | end 35 | %%****************************************************** -------------------------------------------------------------------------------- /startup.m: -------------------------------------------------------------------------------- 1 | %%********************************************************************** 2 | %% startup.m: set up search paths, and default parameters 3 | %% for sqlp.m 4 | %% 5 | %% SDPT3: version 3.0 6 | %% Copyright (c) 1997 by 7 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 8 | %% Last modified: 2 Feb 01 9 | %%********************************************************************** 10 | 11 | warning off; 12 | 13 | SDPT3Home = pwd; 14 | addpath(genpath(SDPT3Home)); 15 | %% 16 | %% obsolete: 17 | %% eval(['addpath ',strcat(SDPT3Home,'/')]); 18 | %% eval(['addpath ',strcat(SDPT3Home,'/Solver')]); 19 | %% eval(['addpath ',strcat(SDPT3Home,'/Solver/Mexfun')]); 20 | %% eval(['addpath ',strcat(SDPT3Home,'/HSDSolver')]); 21 | %% eval(['addpath ',strcat(SDPT3Home,'/Examples')]); 22 | %% 23 | %% obsolete: eval(['addpath ',strcat(SDPT3Home,'/Linsysolver/spchol')]); 24 | %% 25 | %% specify default parameters for sqlp.m, 26 | %% they are specified in the structure called OPTIONS. 27 | %% 28 | %% OPTIONS = sqlparameters; 29 | %%********************************************************************** 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Solver/smat.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% smat: compute the matrix smat(x). 3 | %% 4 | %% M = smat(blk,x,isspM); 5 | %%***************************************************************** 6 | %% SDPT3: version 4.0 7 | %% Copyright (c) 1997 by 8 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 9 | %% Last Modified: 16 Sep 2004 10 | %%***************************************************************** 11 | 12 | function M = smat(blk,xvec,isspM) 13 | 14 | if (nargin < 3); isspM = zeros(size(blk,1),1); end 15 | %% 16 | if ~iscell(xvec) 17 | if strcmp(blk{1},'s') 18 | M = mexsmat(blk,xvec,isspM); 19 | else 20 | M = xvec; 21 | end 22 | else 23 | M = cell(size(blk,1),1); 24 | if (length(isspM)==1) 25 | isspM = isspM*ones(size(blk,1),1); 26 | end 27 | for p=1:size(blk,1) 28 | pblk = blk(p,:); 29 | if strcmp(pblk{1},'s'); 30 | M{p} = mexsmat(pblk,xvec{p},isspM(p)); 31 | else 32 | M{p} = xvec{p}; 33 | end 34 | end 35 | end 36 | %%********************************************************* 37 | 38 | -------------------------------------------------------------------------------- /Solver/Arrow.m: -------------------------------------------------------------------------------- 1 | %%******************************************************** 2 | %% Arrow: 3 | %% 4 | %% Fx = Arrow(pblk,f,x,options); 5 | %% 6 | %% if options == 0; 7 | %% Fx = Arr(F)*x 8 | %% if options == 1; 9 | %% Fx = Arr(F)^{-1}*x 10 | %%***************************************************************** 11 | %% SDPT3: version 4.0 12 | %% Copyright (c) 1997 by 13 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 14 | %% Last Modified: 16 Sep 2004 15 | %%***************************************************************** 16 | 17 | function Fx = Arrow(pblk,f,x,options); 18 | 19 | if nargin == 3; options = 0; end; 20 | 21 | s = 1 + [0, cumsum(pblk{2})]; 22 | idx1 = s(1:length(pblk{2})); 23 | if options == 0 24 | inprod = mexqops(pblk{2},f,x,1); 25 | Fx = mexqops(pblk{2},f(idx1),x,3) + mexqops(pblk{2},x(idx1),f,3); 26 | Fx(idx1) = inprod; 27 | else 28 | gamf2 = mexqops(pblk{2},f,f,2); 29 | gamprod = mexqops(pblk{2},f,x,2); 30 | alpha = gamprod./gamf2; 31 | Fx = mexqops(pblk{2},1./f(idx1),x,3) - mexqops(pblk{2},alpha./f(idx1),f,3); 32 | Fx(idx1) = alpha; 33 | end 34 | %% 35 | %%******************************************************** 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Solver/detect_priminfeas.m: -------------------------------------------------------------------------------- 1 | %%******************************************************************* 2 | %% solve min { t | Ax+y=b, norm(y) <= t, x\in K } 3 | %% to detect primal infeasible problem 4 | %%******************************************************************* 5 | 6 | function [dist] = detect_infeas(blk,At,C,b) 7 | 8 | m = length(b); 9 | AAt = At; bblk = blk; CC = ops(C,'zeros'); 10 | numblk = size(blk,1); 11 | dd = zeros(1,m); 12 | for p=1:numblk 13 | dd = dd + sqrt(sum(At{p}.*At{p})); 14 | end 15 | dd = 1./min(1e4,max(1,dd')); 16 | D = spdiags(dd,0,m,m); 17 | for p=1:numblk 18 | AAt{p}= AAt{p}*D; %%important to scale 19 | end 20 | b = b.*dd; 21 | AAt{numblk+1,1} = [zeros(1,m); speye(m)]; 22 | CC{numblk+1,1} = [1; zeros(m,1)]; 23 | bblk{numblk+1,1} = 'q'; bblk{numblk+1,2} = m+1; 24 | OPTIONS.gaptol = 1e-12; 25 | [obj,X,y,Z,info] = sqlp(bblk,AAt,CC,b,OPTIONS); 26 | err = max(info.dimacs); 27 | dist = mean(obj); 28 | if (err < 1e-6) && (dist/err > 20) 29 | fprintf('\n primal problem is infeasible: err = %3.2e, dist = %3.2e\n',err,dist); 30 | end 31 | %%******************************************************************* 32 | -------------------------------------------------------------------------------- /HSDSolver/HSDHKMcorr.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% HSDHKMcorr: corrector step for the HKM direction. 3 | %%***************************************************************** 4 | %% SDPT3: version 4.0 5 | %% Copyright (c) 1997 by 6 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 7 | %% Last Modified: 16 Sep 2004 8 | %%***************************************************************** 9 | 10 | function [par,dX,dy,dZ,resnrm] = HSDHKMcorr(blk,At,par,rp,Rd,sigmu,hRd,... 11 | dX,dZ,coeff,L,X,Z); 12 | 13 | global printlevel 14 | global matfct_options solve_ok 15 | %% 16 | [rhs,EinvRc] = HSDHKMrhsfun(blk,At,par,X,Z,rp,Rd,sigmu,hRd,dX,dZ); 17 | m = length(rp); ncolU = size(coeff.mat12,2); 18 | rhs = [rhs; zeros(m+ncolU-length(rhs),1)]; 19 | %% 20 | solve_ok = 1; resnrm = norm(rhs); 21 | [xx,resnrm,solve_ok] = HSDbicgstab(coeff,rhs,L,[],[],printlevel); 22 | if (solve_ok<=0) & (printlevel) 23 | fprintf('\n warning: iterative solver fails: %3.1f.',solve_ok); 24 | end 25 | if (par.printlevel>=3); fprintf('%2.0f ',length(resnrm)-1); end 26 | %% 27 | [par,dX,dy,dZ] = HSDHKMdirfun(blk,At,par,Rd,EinvRc,X,xx); 28 | %%***************************************************************** 29 | -------------------------------------------------------------------------------- /HSDSolver/HSDNTcorr.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% HSDNTcorr: corrector step for the NT direction. 3 | %%***************************************************************** 4 | %% SDPT3: version 4.0 5 | %% Copyright (c) 1997 by 6 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 7 | %% Last Modified: 16 Sep 2004 8 | %%***************************************************************** 9 | 10 | function [par,dX,dy,dZ,resnrm] = HSDNTcorr(blk,At,par,rp,Rd,sigmu,hRd,... 11 | dX,dZ,coeff,L,X,Z) 12 | 13 | global printlevel 14 | global matfct_options solve_ok 15 | %% 16 | [rhs,EinvRc] = HSDNTrhsfun(blk,At,par,X,Z,rp,Rd,sigmu,hRd,dX,dZ); 17 | m = length(rp); ncolU = size(coeff.mat12,2); 18 | rhs = [rhs; zeros(m+ncolU-length(rhs),1)]; 19 | %% 20 | solve_ok = 1; resnrm = norm(rhs); 21 | [xx,resnrm,solve_ok] = HSDbicgstab(coeff,rhs,L,[],[],printlevel); 22 | if (solve_ok<=0) & (printlevel) 23 | fprintf('\n warning: iterative solver fails: %3.1f.',solve_ok); 24 | end 25 | if (par.printlevel>=3); fprintf(' %2.0f',length(resnrm)-1); end 26 | %% 27 | [par,dX,dy,dZ] = HSDNTdirfun(blk,At,par,Rd,EinvRc,xx); 28 | %%************************************************************************ 29 | 30 | 31 | -------------------------------------------------------------------------------- /Solver/convertRcone.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% convertRcone: convert rotated cone to socp cone 3 | %% 4 | %% [blk,At,C,b,T] = convertRcone(blk,At,C,b); 5 | %%***************************************************************** 6 | %% SDPT3: version 4.0 7 | %% Copyright (c) 1997 by 8 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 9 | %% Last Modified: 16 Sep 2004 10 | %%***************************************************************** 11 | 12 | 13 | function [blk,At,C,b,T] = convertRcone(blk,At,C,b); 14 | 15 | T = cell(size(blk,1),1); 16 | for p = 1:size(blk,1) 17 | pblk = blk(p,:); 18 | if strcmp(pblk{1},'r') 19 | if (min(pblk{2}) < 3) 20 | error('rotated cones must be at least 3-dimensional'); 21 | end 22 | n = sum(pblk{2}); len = length(pblk{2}); 23 | ss = [0,cumsum(pblk{2})]; 24 | idx = 1+ss(1:len)'; 25 | ir2 = 1/sqrt(2)*ones(len,1); 26 | dd = [idx,idx,ir2-1; idx,idx+1,ir2; 27 | idx+1,idx,ir2; idx+1,idx+1,-ir2-1]; 28 | T{p} = speye(n,n) + spconvert([dd; n,n,0]); 29 | blk{p,1} = 'q'; 30 | At{p,1} = T{p}*At{p,1}; 31 | C{p,1} = T{p}*C{p,1}; 32 | end 33 | end 34 | %%*************************************************************** 35 | -------------------------------------------------------------------------------- /Solver/schurmat_lblk.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% schurmat_lblk: compute A*D*A' 3 | %%***************************************************************** 4 | %% SDPT3: version 4.0 5 | %% Copyright (c) 1997 by 6 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 7 | %% Last Modified: 16 Sep 2004 8 | %%***************************************************************** 9 | 10 | function [schur,UU,EE] = schurmat_lblk(blk,At,par,schur,UU,EE,p,dd) 11 | 12 | global idxdenAl 13 | 14 | iter = par.iter; 15 | n = sum(blk{p,2}); 16 | 17 | if (iter==1) 18 | idxdenAl{p} = checkdense(At{p}'); 19 | end 20 | ddsch = dd{p}; 21 | if ~isempty(idxdenAl{p}); 22 | idxden = idxdenAl{p}; 23 | len = length(idxden); 24 | Ad = At{p}(idxden,:)' *spdiags(sqrt(ddsch(idxden)),0,len,len); 25 | UU = [UU, Ad]; 26 | if isempty(EE) 27 | count = 0; 28 | else 29 | count = max(max(EE(:,1)),max(EE(:,2))); 30 | end 31 | tmp = count + [1:len]'; 32 | EE = [EE; [tmp, tmp, -ones(len,1)] ]; 33 | ddsch(idxden) = zeros(len,1); 34 | end 35 | schurtmp = At{p}' *spdiags(ddsch,0,n,n) *At{p}; 36 | schur = schur + schurtmp; 37 | %%******************************************************************* 38 | -------------------------------------------------------------------------------- /Examples/corrmat.m: -------------------------------------------------------------------------------- 1 | %%**************************************************** 2 | %% corrmat: find the nearest correlation matrix 3 | %% to a given symmetric matrix. 4 | %% 5 | %% [blk,At,C,b] = corrmat(H); 6 | %% 7 | %% min || X - H ||_F 8 | %% s.t. diag(X) = e, X psd. 9 | %% 10 | %% min t 11 | %% s.t. diag(X) = e 12 | %% svec(X) + y = svec(H), 13 | %% X psd, ||y||_2 <= t. 14 | %%***************************************************************** 15 | %% SDPT3: version 4.0 16 | %% Copyright (c) 1997 by 17 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 18 | %% Last Modified: 16 Sep 2004 19 | %%***************************************************************** 20 | 21 | function [blk,At,C,b] = corrmat(H); 22 | 23 | if size(H,1) ~= size(H,2); error('corrmat: matrix must be square'); end; 24 | n = length(H); 25 | n2 = n*(n+1)/2; 26 | 27 | blk{1,1} = 's'; blk{1,2} = n; 28 | for k=1:n; AA{1,k} = spconvert([k,k,1; n,n,0]); end; 29 | matrepdiag = svec(blk(1,:),AA); 30 | At{1,1} = [matrepdiag{1}, speye(n2)]; 31 | 32 | blk{2,1} = 'q'; blk{2,2} = n2+1; 33 | At{2,1} = [sparse(n,n2+1); sparse(n2,1), speye(n2)]; 34 | b = [ones(n,1); svec(blk(1,:),H)]; 35 | C{1,1} = sparse(n,n); C{2,1} = [1; zeros(n2,1)]; 36 | %%**************************************************** 37 | -------------------------------------------------------------------------------- /Examples/sdphankel.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% min sum_k bk*yk 3 | %% s.t. sum yk*Hk <= 0 4 | %% y1 = 1 5 | %% Hk = -hankel(ek) if 1 <= k <= n 6 | %% = -hankel(0,e(k-n+1)) if n+1 <= k <=2*n-1 7 | %% 8 | %% [blk,At,C,b] = sdphankel(n); 9 | %%***************************************************************** 10 | %% SDPT3: version 4.0 11 | %% Copyright (c) 1997 by 12 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 13 | %% Last Modified: 16 Sep 2004 14 | %%***************************************************************** 15 | 16 | function [blk,At,C,b] = sdphankel(n); 17 | 18 | randn('seed',0); 19 | tmp = randn(n,n); 20 | tmp = tmp+tmp'; 21 | X{1} = tmp + norm(tmp,'fro')*speye(n,n); 22 | %% 23 | for k = 1:n 24 | ek = zeros(n,1); ek(k) = -1; 25 | AA{k} = sparse(hankel(ek)); 26 | end 27 | zz = zeros(n,1); 28 | for k = n+1:2*n-1 29 | ek = zeros(n,1); ek(k-n+1) = -1; 30 | AA{k} = sparse(hankel(zz,ek)); 31 | end 32 | blk{1,1} = 's'; blk{1,2} = n; 33 | At = svec(blk,AA,1); 34 | C{1} = spconvert([n n 0]); 35 | b = AXfun(blk,At,[],X); 36 | %% 37 | blk{2,1} = 'u'; blk{2,2} = 1; 38 | ee = zeros(1,2*n-1); ee(1) = 1; 39 | At{2,1} = ee; 40 | C{2,1} = 1; 41 | %%*************************************************** 42 | -------------------------------------------------------------------------------- /Solver/Oldmfiles/HKMcorrold.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% HKMcorr: corrector step for the HKM direction. 3 | %% 4 | %% SDPT3: version 3.0 5 | %% Copyright (c) 1997 by 6 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 7 | %% Last modified: 2 Feb 01 8 | %%***************************************************************** 9 | 10 | function [dX,dy,dZ] = HKMcorr(blk,At,par,rp,Rd,sigmu,hRd,... 11 | dX,dZ,schur,L,UU,VV,E,SMWmat,X,Z); 12 | 13 | global matlabversion 14 | global matfct_options solve_ok; 15 | %% 16 | [rhs,EinvRc] = HKMrhsfun(blk,At,par,X,Z,rp,Rd,sigmu,hRd,dX,dZ); 17 | rhs = [rhs; zeros(length(rp)+size(UU,2)-length(rhs),1)]; 18 | if strcmp(matfct_options,'chol') 19 | [xx,solve_ok] = schursysolve(schur,schur,UU,VV,E,rhs,matfct_options,SMWmat); 20 | elseif strcmp(matfct_options,'spchol') 21 | [xx,solve_ok] = schursysolve(schur,L,UU,VV,E,rhs,matfct_options,SMWmat); 22 | elseif strcmp(matfct_options,'MA47') 23 | xx = mexMA47slv(length(rhs),L.a,L.iw,rhs); 24 | elseif strcmp(matfct_options,'splu') 25 | xx(L.perm,1) = L.q*( L.u \ (L.l \ (L.p*rhs(L.perm)))); 26 | elseif strcmp(matfct_options,'lu') 27 | xx = L.u \ (L.l \ (L.p*rhs)); 28 | end 29 | [dX,dy,dZ] = HKMdirfun(blk,At,par,Rd,EinvRc,X,xx); 30 | %%***************************************************************** 31 | -------------------------------------------------------------------------------- /Solver/Oldmfiles/NTcorrold.m: -------------------------------------------------------------------------------- 1 | %%************************************************************************ 2 | %% NTcorr: corrector step for the NT direction. 3 | %% 4 | %% SDPT3: version 3.0 5 | %% Copyright (c) 1997 by 6 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 7 | %% Last modified: 2 Feb 01 8 | %%************************************************************************ 9 | 10 | function [dX,dy,dZ] = NTcorr(blk,At,par,rp,Rd,sigmu,hRd,... 11 | dX,dZ,schur,L,UU,VV,E,SMWmat,X,Z); 12 | 13 | global matlabversion 14 | global matfct_options solve_ok; 15 | %% 16 | [rhs,EinvRc] = NTrhsfun(blk,At,par,X,Z,rp,Rd,sigmu,hRd,dX,dZ); 17 | rhs = [rhs; zeros(length(rp)+size(UU,2)-length(rhs),1)]; 18 | if strcmp(matfct_options,'chol') 19 | [xx,solve_ok] = schursysolve(schur,schur,UU,VV,E,rhs,matfct_options,SMWmat); 20 | elseif strcmp(matfct_options,'spchol') 21 | [xx,solve_ok] = schursysolve(schur,L,UU,VV,E,rhs,matfct_options,SMWmat); 22 | elseif strcmp(matfct_options,'MA47') 23 | xx = mexMA47slv(length(rhs),L.a,L.iw,rhs); 24 | elseif strcmp(matfct_options,'splu') 25 | xx(L.perm,1) = L.q*( L.u \ (L.l \ (L.p*rhs(L.perm)))); 26 | elseif strcmp(matfct_options,'lu') 27 | xx = L.u \ (L.l \ (L.p*rhs)); 28 | end 29 | [dX,dy,dZ] = NTdirfun(blk,At,par,Rd,EinvRc,xx); 30 | %%************************************************************************ 31 | 32 | 33 | -------------------------------------------------------------------------------- /Solver/sqlptermcode.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% sqlptermcode.m: explains the termination code in sqlp.m 3 | %%***************************************************************** 4 | %% SDPT3: version 4.0 5 | %% Copyright (c) 1997 by 6 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 7 | %% Last Modified: 16 Sep 2004 8 | %%***************************************************************** 9 | 10 | function termcode = sqlptermcode; 11 | 12 | fprintf('\n 3: norm(X) or norm(Z) diverging'); 13 | fprintf('\n 2: dual problem is suspected to be infeasible') 14 | fprintf('\n 1: primal problem is suspected to be infeasible') 15 | fprintf('\n 0: max(relative gap,infeasibility) < gaptol'); 16 | fprintf('\n -1: relative gap < infeasibility'); 17 | fprintf('\n -2: lack of progress in predictor or corrector'); 18 | fprintf('\n -3: X or Z not positive definite'); 19 | fprintf('\n -4: difficulty in computing predictor or corrector direction'); 20 | fprintf('\n -5: progress in relative gap or infeasibility is bad'); 21 | fprintf('\n -6: maximum number of iterations reached'); 22 | fprintf('\n -7: primal infeasibility has deteriorated too much'); 23 | fprintf('\n -8: progress in relative gap has deteriorated'); 24 | fprintf('\n -9: lack of progress in infeasibility'); 25 | fprintf('\n') 26 | %%************************************************************************* 27 | -------------------------------------------------------------------------------- /Solver/linsysolvefun.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% linsysolvefun: Solve H*x = b 3 | %% 4 | %% x = linsysolvefun(L,b) 5 | %% where L contains the triangular factors of H. 6 | %%***************************************************************** 7 | %% SDPT3: version 4.0 8 | %% Copyright (c) 1997 by 9 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 10 | %% Last Modified: 16 Sep 2004 11 | %%***************************************************************** 12 | 13 | function x = linsysolvefun(L,b) 14 | 15 | x = zeros(size(b)); 16 | for k=1:size(b,2) 17 | if strcmp(L.matfct_options,'chol') 18 | x(L.perm,k) = mextriang(L.R, mextriang(L.R,b(L.perm,k),2) ,1); 19 | %% x(L.perm,k) = L.R \ (b(L.perm,k)' / L.R)'; 20 | elseif strcmp(L.matfct_options,'spchol') 21 | x(L.perm,k) = mextriangsp(L.Rt,mextriangsp(L.R,b(L.perm,k),2),1); 22 | elseif strcmp(L.matfct_options,'ldl') 23 | x(L.p,k) = ((L.D\ (L.L \ b(L.p,k)))' / L.L)'; 24 | elseif strcmp(L.matfct_options,'spldl') 25 | btmp = b(:,k).*L.s; 26 | xtmp(L.p,1) = L.Lt\ (L.D\ (L.L \ btmp(L.p))); 27 | x(:,k) = xtmp.*L.s; 28 | elseif strcmp(L.matfct_options,'lu') 29 | x(:,k) = L.U \ (L.L \ b(L.p,k)); 30 | elseif strcmp(L.matfct_options,'splu') 31 | btmp = b(:,k)./L.s; 32 | x(L.q,k) = L.U \ (L.L \ (btmp(L.p))); 33 | end 34 | end 35 | %%************************************************************************* 36 | -------------------------------------------------------------------------------- /Solver/Mexfun/Oldfiles/mexpertdiagold.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * mexpertdiag(X,pertdiag) 3 | * add pertdiag to the diagonal of X (a square matrix) 4 | ************************************************************************/ 5 | 6 | #include "mex.h" 7 | #include 8 | 9 | /******************************************************************** 10 | PROCEDURE mexFunction - Entry for Matlab 11 | *********************************************************************/ 12 | void mexFunction(const int nlhs, mxArray *plhs[], 13 | const int nrhs, const mxArray *prhs[]) 14 | { 15 | int n; 16 | double *X, *pertdiag; 17 | int j,jn; 18 | 19 | 20 | if(nrhs != 2) 21 | mexErrMsgTxt("mexpertdiag: requires 2 input arguments."); 22 | if(nlhs > 0) 23 | mexErrMsgTxt("mexpertdiag: requires no output argument."); 24 | 25 | X = mxGetPr(prhs[0]); 26 | if (mxIsSparse(prhs[0])) 27 | mexErrMsgTxt("Sparse X not supported by mexpertdiag."); 28 | n = mxGetM(prhs[0]); 29 | if ( n != mxGetN(prhs[0]) ) 30 | mexErrMsgTxt("X should be square."); 31 | pertdiag = mxGetPr(prhs[1]); 32 | if (mxIsSparse(prhs[1])) 33 | mexErrMsgTxt("Sparse pertdiag not supported by mexpertdiag."); 34 | 35 | 36 | for (j=0; j 8 | 9 | /******************************************************************** 10 | PROCEDURE mexFunction - Entry for Matlab 11 | *********************************************************************/ 12 | void mexFunction(const int nlhs, mxArray *plhs[], 13 | const int nrhs, const mxArray *prhs[]) 14 | { 15 | int n; 16 | double *X, *pertdiag; 17 | int j,jn; 18 | 19 | 20 | if(nrhs != 2) 21 | mexErrMsgTxt("mexpertdiag: requires 2 input arguments."); 22 | if(nlhs > 0) 23 | mexErrMsgTxt("mexpertdiag: requires no output argument."); 24 | 25 | X = mxGetPr(prhs[0]); 26 | if (mxIsSparse(prhs[0])) 27 | mexErrMsgTxt("Sparse X not supported by mexpertdiag."); 28 | n = mxGetM(prhs[0]); 29 | if ( n != mxGetN(prhs[0]) ) 30 | mexErrMsgTxt("X should be square."); 31 | pertdiag = mxGetPr(prhs[1]); 32 | if (mxIsSparse(prhs[1])) 33 | mexErrMsgTxt("Sparse pertdiag not supported by mexpertdiag."); 34 | 35 | 36 | for (j=0; j 0, x <= 10} 5 | %% 6 | %% where B = 4xn matrix, 7 | %% d = 4x1 vector 8 | %% 9 | %% [blk,At,C,b,xx] = geometric_mean(B,d,solve); 10 | %% 11 | %% E.g. p = 6; m = 4; B = [rand(2,p); -rand(2,p)]; d = rand(m,1); 12 | %% 13 | %%***************************************************************** 14 | %% SDPT3: version 4.0 15 | %% Copyright (c) 1997 by 16 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 17 | %% Last Modified: 16 Sep 2004 18 | %%***************************************************************** 19 | 20 | function [blk,At,C,b,xx] = geometric_mean(B,d,solve); 21 | 22 | if (nargin == 2); solve = 0; end 23 | 24 | n = size(B,2); 25 | zz = zeros(1,n); 26 | r2 = sqrt(2); 27 | blk{1,1} = 'r'; blk{1,2} = [3,3,3]; 28 | blk{2,1} = 'l'; blk{2,2} = [2]; 29 | At{1,1} = -[B(1,:),0,0,0; B(2,:),0,0,0; zz,r2,0,0; ... 30 | B(3,:),0,0,0; B(4,:),0,0,0; zz,0,r2,0; ... 31 | zz, 1,0,0; zz, 0,1,0; zz, 0,0,r2]; 32 | At{2,1} = -[B(1,:),0,0,0; B(3,:),0,0,0]; 33 | C{1,1} = [d(1:2); 0; d(3:4); 0; 0;0;0]; 34 | C{2,1} = [d(1); d(3)]; 35 | b = [zeros(n,1); 0;0;1]; 36 | blk{3,1} = 'l'; blk{3,2} = n; 37 | At{3,1} = [eye(n), zeros(n,3)]; C{3,1} = 10*ones(n,1); 38 | if (solve) 39 | [bblk,AAt,CC,bb,T] = convertRcone(blk,At,C,b); 40 | [obj,X,y,Z] = sqlp(bblk,AAt,CC,bb); 41 | xx = y(1:n); 42 | end 43 | %%****************************************************************** 44 | -------------------------------------------------------------------------------- /Examples/lmiexamp1.m: -------------------------------------------------------------------------------- 1 | %%*********************************************************** 2 | %% lmiexamp1: generate SDP data for the following LMI problem 3 | %% 4 | %% max -eta 5 | %% s.t. B*P + P*B' <= 0 6 | %% -P <= -I 7 | %% P - eta*I <= 0 8 | %% P(1,1) = 1 9 | %%*********************************************************** 10 | %% Here is an example on how to use this function to 11 | %% find an optimal P. 12 | %% 13 | %% B = [-1 0 0; 5 -2 0; 1 1 -1]; 14 | %% [blk,At,C,b] = lmiexamp1(B); 15 | %% [obj,X,y,Z] = sqlp(blk,At,C,b); 16 | %% P = smat(blk(1,:),y); 17 | %%***************************************************************** 18 | %% SDPT3: version 4.0 19 | %% Copyright (c) 1997 by 20 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 21 | %% Last Modified: 16 Sep 2004 22 | %%***************************************************************** 23 | 24 | function [blk,At,C,b] = lmiexamp1(B); 25 | 26 | n = length(B); n2 = n*(n+1)/2; 27 | I = speye(n); 28 | z0 = sparse(n2,1); 29 | blktmp{1,1} = 's'; blktmp{1,2} = n; 30 | %% 31 | blk{1,1} = 's'; blk{1,2} = n; 32 | blk{2,1} = 's'; blk{2,2} = n; 33 | blk{3,1} = 's'; blk{3,2} = n; 34 | blk{4,1} = 'u'; blk{4,2} = 1; 35 | %% 36 | At{1,1} = [lmifun(B,I), z0]; 37 | At{2,1} = [lmifun(-I/2,I), z0]; 38 | At{3,1} = [lmifun(I/2,I), svec(blktmp,-I,1)]; 39 | At{4,1} = sparse([1, zeros(1,n2)]); 40 | %% 41 | C{1,1} = sparse(n,n); 42 | C{2,1} = -speye(n); 43 | C{3,1} = sparse(n,n); 44 | C{4,1} = 1; 45 | %% 46 | b = [zeros(n2,1); -1]; 47 | %%********************************************************** 48 | -------------------------------------------------------------------------------- /Solver/NTcorr.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% NTcorr: corrector step for the NT direction. 3 | %%***************************************************************** 4 | %% SDPT3: version 4.0 5 | %% Copyright (c) 1997 by 6 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 7 | %% Last Modified: 16 Sep 2004 8 | %%***************************************************************** 9 | 10 | function [dX,dy,dZ] = NTcorr(blk,At,par,rp,Rd,sigmu,hRd,... 11 | dX,dZ,coeff,L,X,Z); 12 | 13 | global matfct_options solve_ok 14 | 15 | printlevel = par.printlevel; 16 | %% 17 | [rhs,EinvRc] = NTrhsfun(blk,At,par,X,Z,rp,Rd,sigmu,hRd,dX,dZ); 18 | m = length(rp); ncolU = size(coeff.mat12,2); 19 | rhs = [rhs; zeros(m+ncolU-length(rhs),1)]; 20 | %% 21 | solve_ok = 1; resnrm = norm(rhs); 22 | if strcmp(matfct_options,'chol') | strcmp(matfct_options,'spchol') ... 23 | | strcmp(matfct_options,'ldl') | strcmp(matfct_options,'spldl') 24 | [xx,resnrm,solve_ok] = symqmr(coeff,rhs,L,[],[],printlevel); 25 | if (solve_ok<=0) & (printlevel) 26 | fprintf('\n warning: symqmr fails: %3.1f.',solve_ok); 27 | end 28 | else 29 | [xx,resnrm,solve_ok] = mybicgstab(coeff,rhs,L,[],[],printlevel); 30 | if (solve_ok<=0) & (printlevel) 31 | fprintf('\n warning: bicgstab fails: %3.1f.',solve_ok); 32 | end 33 | end 34 | if (printlevel>=3); fprintf('%2.0d ',length(resnrm)-1); end 35 | %% 36 | [dX,dy,dZ] = NTdirfun(blk,At,par,Rd,EinvRc,xx,m); 37 | %%************************************************************************ 38 | 39 | 40 | -------------------------------------------------------------------------------- /Solver/HKMcorr.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% HKMcorr: corrector step for the HKM direction. 3 | %% 4 | %%***************************************************************** 5 | %% SDPT3: version 4.0 6 | %% Copyright (c) 1997 by 7 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 8 | %% Last Modified: 16 Sep 2004 9 | %%***************************************************************** 10 | 11 | 12 | function [dX,dy,dZ,resnrm,EinvRc] = HKMcorr(blk,At,par,rp,Rd,sigmu,hRd,... 13 | dX,dZ,coeff,L,X,Z); 14 | 15 | global matfct_options solve_ok 16 | 17 | printlevel = par.printlevel; 18 | %% 19 | [rhs,EinvRc] = HKMrhsfun(blk,At,par,X,Z,rp,Rd,sigmu,hRd,dX,dZ); 20 | m = length(rp); ncolU = size(coeff.mat12,2); 21 | rhs = [rhs; zeros(m+ncolU-length(rhs),1)]; 22 | %% 23 | solve_ok = 1; resnrm = norm(rhs); 24 | if strcmp(matfct_options,'chol') | strcmp(matfct_options,'spchol') ... 25 | | strcmp(matfct_options,'ldl') | strcmp(matfct_options,'spldl') 26 | [xx,resnrm,solve_ok] = symqmr(coeff,rhs,L,[],[],printlevel); 27 | if (solve_ok<=0) & (printlevel) 28 | fprintf('\n warning: symqmr fails: %3.1f.',solve_ok); 29 | end 30 | else 31 | [xx,resnrm,solve_ok] = mybicgstab(coeff,rhs,L,[],[],printlevel); 32 | if (solve_ok<=0) & (printlevel) 33 | fprintf('\n warning: bicgstab fails: %3.1f.',solve_ok); 34 | end 35 | end 36 | if (printlevel>=3); fprintf('%2.0d ',length(resnrm)-1); end 37 | %% 38 | [dX,dy,dZ] = HKMdirfun(blk,At,par,Rd,EinvRc,X,xx,m); 39 | %%***************************************************************** 40 | -------------------------------------------------------------------------------- /Solver/linsysolvefun_old.m: -------------------------------------------------------------------------------- 1 | %%************************************************************************* 2 | %% linsysolvefun: Solve H*x = b 3 | %% 4 | %% x = linsysolvefun(L,b) 5 | %% where L contains the triangular factors of H. 6 | %% 7 | %% SDPT3: version 3.1 8 | %% Copyright (c) 1997 by 9 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 10 | %% Last Modified: 16 Sep 2004 11 | %%************************************************************************* 12 | 13 | function x = linsysolvefun(L,b) 14 | 15 | x = zeros(size(b)); 16 | for k=1:size(b,2) 17 | if strcmp(L.matfct_options,'chol') 18 | x(L.perm,k) = mextriang(L.R, mextriang(L.R,b(L.perm,k),2) ,1); 19 | %% x(L.perm,k) = L.R \ (b(L.perm,k)' / L.R)'; 20 | elseif strcmp(L.matfct_options,'spchol') 21 | x(L.perm,k) = mextriangsp(L.Rt,mextriangsp(L.R,b(L.perm,k),2),1); 22 | elseif strcmp(L.matfct_options,'ldl') 23 | x(L.perm,k) = ((L.D\ (L.L \ b(L.perm,k)))' / L.L)'; 24 | elseif strcmp(L.matfct_options,'spldl') 25 | x(L.perm,k) = L.Lt\ (L.D\ (L.L \ b(L.perm,k))); 26 | elseif strcmp(L.matfct_options,'lu') 27 | x(:,k) = L.u \ (L.l \ b(L.perm,k)); 28 | elseif strcmp(L.matfct_options,'splu') 29 | if (L.symmatrix) 30 | %% coefficient matrix is symmetric 31 | %% A = P'*L*U*Q' --> A = Q*U'*L'*P 32 | btmp = b(L.perm,k); 33 | xtmp = mextriangsp(L.l,mextriangsp(L.u,btmp(L.q),2),1); 34 | x(L.perm,k) = xtmp(L.p); 35 | else 36 | btmp = b(L.perm,k); 37 | x(L.perm,k) = L.q*( L.u \ (L.l \ (L.p*btmp))); 38 | end 39 | end 40 | end 41 | %%************************************************************************* 42 | -------------------------------------------------------------------------------- /Examples/ToeplitzApproxSQQ.m: -------------------------------------------------------------------------------- 1 | %%************************************************************************* 2 | %% ToeplitzApproxSQQ: find the nearest symmetric positive definite Toeplitz 3 | %% matrix to a given symmetric matrix F. 4 | %% 5 | %% max -y0 6 | %% s.t. y0*B + T(y) (S>=) 0 7 | %% [y0; gam.*y] + [0; q./gam] (Q>=) 0 8 | %% 9 | %% where B = diag([zeros(n,1); 1]) 10 | %% q(1) = - Tr(F); q(k+1) = -sum of upper and lower kth diagonals of F 11 | %% gam(1) = sqrt(n); gam(k) = sqrt(2*(n-k+1)) for k=2:n 12 | %%***************************************************************** 13 | %% SDPT3: version 4.0 14 | %% Copyright (c) 1997 by 15 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 16 | %% Last Modified: 16 Sep 2004 17 | %%***************************************************************** 18 | 19 | function [blk,At,C,b] = ToeplitzApproxSQQ(F) 20 | 21 | n = length(F); 22 | gam = sqrt([n, 2*(n-1:-1:1)]'); 23 | q = zeros(n,1); 24 | q(1) = -sum(diag(F)); 25 | for k=1:n-1 26 | q(k+1) = -2*sum(diag(F,k)); 27 | end 28 | beta = norm(F,'fro')^2; 29 | 30 | blk{1,1} = 's'; blk{1,2} = n+1; 31 | blk{2,1} = 'q'; blk{2,2} = n+1; 32 | 33 | b = [-1; zeros(n,1)]; 34 | C{1,1} = sparse(n+1,n+1); 35 | C{2,1} = [0; q./gam]; 36 | 37 | Acell = cell(1,n+1); 38 | Acell{1} = -spconvert([n+1,n+1,1]); 39 | Acell{2} = -spdiags([ones(n,1); 0],0,n+1,n+1); 40 | for k = 1:n-1 41 | tmp = -spdiags([ones(n,1); 0],k,n+1,n+1); 42 | Acell{k+2} = tmp + tmp'; 43 | end 44 | At(1,1) = svec(blk(1,:),Acell,1); 45 | 46 | At{2,1} = -spdiags([1; gam],0,n+1,n+1); 47 | %%*********************************************************************** -------------------------------------------------------------------------------- /Examples/chebymat.m: -------------------------------------------------------------------------------- 1 | %%********************************************************************* 2 | %% chebymat: compute the Chebyshev polynomial of 3 | %% deg m of a matrix B. 4 | %% 5 | %% [blk,Avec,C,b,X0,y0,Z0,objval,p] = chebymat(B,m,feas,solve); 6 | %% 7 | %% B = a square matrix. 8 | %% m = degree of polynomial. 9 | %% feas = 1 if want feasible starting point 10 | %% = 0 if otherwise. 11 | %% solve = 0 just to initialize 12 | %% = 1 if want to solve using sdp.m 13 | %% = 2 if want to solve using sdphlf.m 14 | %% 15 | %% p = Chebyshev polynomial of B in Matlab format. 16 | %%***************************************************************** 17 | %% SDPT3: version 4.0 18 | %% Copyright (c) 1997 by 19 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 20 | %% Last Modified: 16 Sep 2004 21 | %%***************************************************************** 22 | 23 | function [blk,Avec,C,b,X0,y0,Z0,objval,p] = chebymat(B,m,feas,solve); 24 | 25 | if (nargin <= 3); solve = 0; end; 26 | if (nargin <= 2); feas = 0; end; 27 | 28 | N = length(B); 29 | if (m >= N); error('degree >= size of B'); end; 30 | 31 | A = cell(1,m+1); 32 | [V,H,R] = orthbasis(B,m); 33 | A{1} = V{m+1}; 34 | for k = 2:m+1; A{k} = V{k-1}; end; 35 | [blk,Avec,C,b,X0,y0,Z0,objval,xx] = norm_min(A,feas,solve); 36 | %% 37 | if (solve) 38 | y = -xx; 39 | h = R(1:m+1,1:m+1) \ [zeros(m,1); 1]; 40 | x1 = R(1:m,1:m)*(h(m+1)*y(1:m) + h(1:m)); 41 | p = [1; -x1(m:-1:1)]; 42 | objval = norm(polyvalm(p,B)); 43 | else 44 | objval = []; p = []; 45 | end 46 | %%********************************************************************* 47 | -------------------------------------------------------------------------------- /Solver/Mexfun/Oldfiles/mexchol.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * U = mexchol(X) X = U'*U 3 | * Computes upper-triangular Cholesky factor U of full symmetric positive 4 | * definite matrix X. 5 | * 6 | * Uses LAPACK routine DPOTRF 7 | ************************************************************************/ 8 | 9 | #include "mex.h" 10 | #include 11 | 12 | /******************************************************************** 13 | PROCEDURE mexFunction - Entry for Matlab 14 | *********************************************************************/ 15 | void mexFunction(const int nlhs, mxArray *plhs[], 16 | const int nrhs, const mxArray *prhs[]) 17 | { 18 | int n; 19 | double *x, *info; 20 | char *chn; 21 | int infotmp=0, j,k,jn; 22 | 23 | 24 | if(nrhs < 1) 25 | mexErrMsgTxt("mexchol: requires 1 input arguments."); 26 | if(nlhs > 1) 27 | mexErrMsgTxt("mexchol: requires 1 output argument."); 28 | 29 | x = mxGetPr(prhs[0]); 30 | if (mxIsSparse(prhs[0])) 31 | mexErrMsgTxt("Sparse X not supported by mexchol."); 32 | n = mxGetM(prhs[0]); 33 | if ( n != mxGetN(prhs[0]) ) 34 | mexErrMsgTxt("X should be square."); 35 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 36 | info = mxGetPr(plhs[0]); 37 | 38 | chn = "U"; 39 | dpotrf(chn, &n, x, &n, &infotmp); 40 | info[0] = (double)infotmp; 41 | /***** make lower triangular part of x zero *****/ 42 | for (j=0; j 11 | 12 | /******************************************************************** 13 | PROCEDURE mexFunction - Entry for Matlab 14 | *********************************************************************/ 15 | void mexFunction(const int nlhs, mxArray *plhs[], 16 | const int nrhs, const mxArray *prhs[]) 17 | { 18 | int n; 19 | double *x, *info; 20 | char *chn; 21 | int infotmp=0, j,k,jn; 22 | 23 | 24 | if(nrhs < 1) 25 | mexErrMsgTxt("mexchol: requires 1 input arguments."); 26 | if(nlhs > 1) 27 | mexErrMsgTxt("mexchol: requires 1 output argument."); 28 | 29 | x = mxGetPr(prhs[0]); 30 | if (mxIsSparse(prhs[0])) 31 | mexErrMsgTxt("Sparse X not supported by mexchol."); 32 | n = mxGetM(prhs[0]); 33 | if ( n != mxGetN(prhs[0]) ) 34 | mexErrMsgTxt("X should be square."); 35 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 36 | info = mxGetPr(plhs[0]); 37 | 38 | chn = "U"; 39 | dpotrf_ (chn, &n, x, &n, &infotmp); 40 | info[0] = (double)infotmp; 41 | /***** make lower triangular part of x zero *****/ 42 | for (j=0; j 11 | 12 | /******************************************************************** 13 | PROCEDURE mexFunction - Entry for Matlab 14 | *********************************************************************/ 15 | void mexFunction(const int nlhs, mxArray *plhs[], 16 | const int nrhs, const mxArray *prhs[]) 17 | { 18 | int n; 19 | double *x, *info; 20 | char *chn; 21 | int infotmp=0, j,k,jn; 22 | 23 | 24 | if(nrhs < 1) 25 | mexErrMsgTxt("mexchol: requires 1 input arguments."); 26 | if(nlhs > 1) 27 | mexErrMsgTxt("mexchol: requires 1 output argument."); 28 | 29 | x = mxGetPr(prhs[0]); 30 | if (mxIsSparse(prhs[0])) 31 | mexErrMsgTxt("Sparse X not supported by mexchol."); 32 | n = mxGetM(prhs[0]); 33 | if ( n != mxGetN(prhs[0]) ) 34 | mexErrMsgTxt("X should be square."); 35 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 36 | info = mxGetPr(plhs[0]); 37 | 38 | chn = "U"; 39 | dpotrf(chn, &n, x, &n, &infotmp); 40 | info[0] = (double)infotmp; 41 | /***** make lower triangular part of x zero *****/ 42 | for (j=0; j 11 | 12 | /******************************************************************** 13 | PROCEDURE mexFunction - Entry for Matlab 14 | *********************************************************************/ 15 | void mexFunction(const int nlhs, mxArray *plhs[], 16 | const int nrhs, const mxArray *prhs[]) 17 | { 18 | int n; 19 | double *x, *info; 20 | char *chn; 21 | int infotmp=0, j,k,jn; 22 | 23 | 24 | if(nrhs < 1) 25 | mexErrMsgTxt("mexchol: requires 1 input arguments."); 26 | if(nlhs > 1) 27 | mexErrMsgTxt("mexchol: requires 1 output argument."); 28 | 29 | x = mxGetPr(prhs[0]); 30 | if (mxIsSparse(prhs[0])) 31 | mexErrMsgTxt("Sparse X not supported by mexchol."); 32 | n = mxGetM(prhs[0]); 33 | if ( n != mxGetN(prhs[0]) ) 34 | mexErrMsgTxt("X should be square."); 35 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 36 | info = mxGetPr(plhs[0]); 37 | 38 | chn = "U"; 39 | dpotrf_ (chn, &n, x, &n, &infotmp); 40 | info[0] = (double)infotmp; 41 | /***** make lower triangular part of x zero *****/ 42 | for (j=0; j= N); error('degree >= size of B'); end; 35 | 36 | A = cell(1,m+1); 37 | [V,H,R] = orthbasis(B,m-1); 38 | A{1} = eye(N); 39 | for k = [1:m]; A{k+1} = B*V{k}; end; 40 | [blk,Avec,C,b,X0,y0,Z0,objval,xx] = norm_min(A,feas,solve); 41 | if (solve) 42 | y = xx; 43 | x1 = R(1:m,1:m)*y(1:m); 44 | p = [x1(m:-1:1); 1]; 45 | else 46 | objval = []; p = []; 47 | end 48 | %%******************************************************************** 49 | -------------------------------------------------------------------------------- /Solver/Oldmfiles/Installmex_old.m: -------------------------------------------------------------------------------- 1 | %% 2 | %% Run this script in Matlab command window 3 | %% 4 | 5 | function Installmex 6 | 7 | curdir = pwd; 8 | fprintf(' current directory is: %s\n',curdir); 9 | %% 10 | %% generate mex files in Mexfun 11 | %% 12 | if strcmp(computer,'PCWIN64') | strcmp(computer,'GLNXA64') 13 | computer_model = 64; 14 | else 15 | computer_model = 32; 16 | end 17 | matlabversion = sscanf(version,'%f'); 18 | matlabversion = matlabversion(1); 19 | tmp = version('-release'); 20 | matlabrelease = str2num(tmp(1:4)); 21 | fsp = filesep; 22 | %% 23 | %% 24 | %% 25 | src = [curdir,fsp,'Solver',fsp,'Mexfun']; 26 | eval(['cd ','Solver',fsp,'Mexfun']); 27 | fprintf ('\n Now compiling the mexFunctions in:\n'); 28 | fprintf (' %s\n',src); 29 | 30 | fname{1} = 'mexProd2'; 31 | fname{2} = 'mexProd2nz'; 32 | fname{3} = 'mexinprod'; 33 | fname{4} = 'mexmat'; 34 | fname{5} = 'mexsmat'; 35 | fname{6} = 'mexsvec'; 36 | fname{7} = 'mexschur'; 37 | fname{8} = 'mexqops'; 38 | fname{9} = 'mexexpand'; 39 | fname{10} = 'mexskron'; 40 | fname{11} = 'mexnnz'; 41 | fname{12} = 'mexschurfun'; 42 | fname{13} = 'mexMatvec'; 43 | fname{14} = 'mextriang'; 44 | fname{15} = 'mextriangsp'; 45 | %% 46 | if (matlabversion < 7.3) & (matlabrelease <= 2008) 47 | mexcmd = 'mex -O '; 48 | else 49 | mexcmd = 'mex -O -largeArrayDims '; 50 | end 51 | for k = 1:length(fname) 52 | cmd([mexcmd,fname{k},'.c']); 53 | end 54 | cd .. 55 | cd .. 56 | %%*********************************************** 57 | function cmd(s) 58 | 59 | fprintf(' %s\n',s); 60 | eval(s); 61 | %%*********************************************** 62 | -------------------------------------------------------------------------------- /Solver/qops.m: -------------------------------------------------------------------------------- 1 | %%******************************************************** 2 | %% qops: Fu = qops(pblk,w,f,options,u); 3 | %% 4 | %% options = 1, Fu(i) = 5 | %% = 2, Fu(i) = 2*wi(1)*fi(1)- 6 | %% = 3, Fui = w(i)*fi 7 | %% = 4, Fui = w(i)*fi, Fui(1) = -Fui(1). 8 | %% options = 5, Fu = w [ f'*u ; ub + fb*alp ], where 9 | %% alp = (f'*u + u0)/(1+f0); 10 | %% options = 6, compute Finv*u. 11 | %% 12 | %% Note F = w [f0 fb'; fb I+ fb*fb'/(1+f0) ], where 13 | %% f0*f0 - fb*fb' = 1. 14 | %% Finv = (1/w) [f0 -fb'; -fb I+ fb*fb'/(1+f0) ]. 15 | %%***************************************************************** 16 | %% SDPT3: version 4.0 17 | %% Copyright (c) 1997 by 18 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 19 | %% Last Modified: 16 Sep 2004 20 | %%***************************************************************** 21 | 22 | function Fu = qops(pblk,w,f,options,u); 23 | 24 | if (options >= 1 & options <= 4) 25 | Fu = mexqops(pblk{2},w,f,options); 26 | elseif (options == 5) 27 | s = 1 + [0 cumsum(pblk{2})]; 28 | idx1 = s(1:length(pblk{2})); 29 | inprod = mexqops(pblk{2},f,u,1); 30 | tmp = (u(idx1)+inprod)./(1+f(idx1)); 31 | Fu = u + mexqops(pblk{2},tmp,f,3); 32 | Fu(idx1) = inprod; 33 | Fu = mexqops(pblk{2},w,Fu,3); 34 | elseif (options == 6) 35 | s = 1 + [0 cumsum(pblk{2})]; 36 | idx1 = s(1:length(pblk{2})); 37 | gamprod = mexqops(pblk{2},f,u,2); 38 | tmp = (u(idx1)+gamprod)./(1+f(idx1)); 39 | Fu = u - mexqops(pblk{2},tmp,f,3); 40 | Fu(idx1) = gamprod; 41 | Fu = mexqops(pblk{2},1./w,Fu,3); 42 | end 43 | %%******************************************************** 44 | 45 | 46 | -------------------------------------------------------------------------------- /Solver/Atyfun.m: -------------------------------------------------------------------------------- 1 | %%********************************************************* 2 | %% Atyfun: compute sum_{k=1}^m yk*Ak. 3 | %% 4 | %% Q = Atyfun(blk,At,permA,isspAy,y); 5 | %% 6 | %% Note: permA and isspAy may be set to []. 7 | %%***************************************************************** 8 | %% SDPT3: version 4.0 9 | %% Copyright (c) 1997 by 10 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 11 | %% Last Modified: 16 Sep 2004 12 | %%***************************************************************** 13 | 14 | function Q = Atyfun(blk,At,permA,isspAy,y); 15 | 16 | if isempty(permA); ismtpermA = 1; else; ismtpermA = 0; end 17 | 18 | Q = cell(size(blk,1),1); 19 | if isempty(isspAy); isspAy = ones(size(blk,1),1); end 20 | for p = 1:size(blk,1) 21 | pblk = blk(p,:); 22 | if strcmp(pblk{1},'s') 23 | n = sum(pblk{2}); 24 | m1 = size(At{p,1},2); 25 | if (~isempty(At{p,1})) 26 | if (ismtpermA) 27 | tmp = At{p,1}*y(1:m1); 28 | else 29 | tmp = At{p,1}*y(permA(p,1:m1),1); 30 | end 31 | Q{p} = smat(pblk,tmp,isspAy(p)); 32 | else 33 | Q{p} = sparse(n,n); 34 | end 35 | if (length(pblk) > 2) %% for low rank constraints 36 | len = sum(pblk{3}); 37 | m2 = length(pblk{3}); 38 | y2 = y(m1+[1:m2]); 39 | dd = At{p,3}; 40 | idxD = [0; find(diff(dd(:,1))); size(dd,1)]; 41 | yy2 = mexexpand(diff(idxD),y2); 42 | DD = spconvert([dd(:,2:3),dd(:,4).*yy2; len,len,0]); 43 | Q{p} = Q{p} + At{p,2}*DD*At{p,2}'; 44 | end 45 | else 46 | Q{p} = At{p,1}*y; 47 | end 48 | end 49 | %%********************************************************* 50 | 51 | -------------------------------------------------------------------------------- /Examples/lmiexamp3.m: -------------------------------------------------------------------------------- 1 | %%*********************************************************** 2 | %% lmiexamp3: generate SDP data for the following LMI problem 3 | %% 4 | %% max eta 5 | %% s.t. [A*P+P*A' P*B'] + eta*[0 0] <= [-G 0] 6 | %% [B*P 0 ] [0 I] [ 0 0] 7 | %% P >= 0 8 | %% P and eta are variables, P symmetric. 9 | %% 10 | %% Ref: Body et al, Linear matrix inequalities in system and 11 | %% control theory, p. 10. 12 | %%*********************************************************** 13 | %% Here is an example on how to use this function to 14 | %% find an optimal P. 15 | %% 16 | %% A = [-1 0 0; 0 -2 0; 1 1 -1]; 17 | %% B = [1 3 5; 2 4 6]; 18 | %% G = ones(3,3); 19 | %% 20 | %% [blk,Avec,C,b] = lmiexamp3(A,B,G); 21 | %% [obj,X,y,Z] = sqlp(blk,Avec,C,b); 22 | %% n = size(A,2); N = n*(n+1)/2; 23 | %% blktmp{1,1} = 's'; blktmp{1,2} = n; 24 | %% P = smat(blktmp,y(1:N)); 25 | %%***************************************************************** 26 | %% SDPT3: version 4.0 27 | %% Copyright (c) 1997 by 28 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 29 | %% Last Modified: 16 Sep 2004 30 | %%***************************************************************** 31 | 32 | function [blk,Avec,C,b] = lmiexamp3(A,B,G); 33 | %% 34 | [m,n] = size(A); 35 | [m2,n2] = size(B); 36 | if (n ~= n2); error('lmiexamp3: A, B not compatible'); end; 37 | %% 38 | blk{1,1} = 's'; blk{1,2} = m + m2; 39 | I = speye(n); 40 | Avec(1,1) = lmifun2(A,I,I,B); 41 | tmp = [sparse(m,n+m2); sparse(m2,n) speye(m2,m2)]; 42 | Avec{1} = [Avec{1} svec(blk,tmp,1)]; 43 | %% 44 | C{1,1} = [-G sparse(m,m2); sparse(m2,n+m2)]; 45 | %% 46 | N = n*(n+1)/2; 47 | b = [zeros(N,1); 1]; 48 | %%********************************************************** 49 | 50 | -------------------------------------------------------------------------------- /Solver/Oldmfiles/iterrefine.m: -------------------------------------------------------------------------------- 1 | %%************************************************************************* 2 | %% iterrefine: Iterative refinement. 3 | %% This step is crucial to ensure that computed solution 4 | %% is sufficiently accuraete. 5 | %% 6 | %% SDPT3: version 3.1 7 | %% Copyright (c) 1997 by 8 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 9 | %% Last Modified: 16 Sep 2004 10 | %%************************************************************************* 11 | 12 | function [x,resnrm,solve_ok] = iterrefine(A,b,L,x0); 13 | 14 | tol = 1e-6; 15 | maxit = 10; 16 | bnorm = max(1,norm(b)); 17 | tolb = tol*bnorm; 18 | x = x0; 19 | solve_ok = 1; 20 | resnrm(1) = bnorm; 21 | %% 22 | for iter = 1:maxit 23 | x0 = x; 24 | if isstruct(A); r = b-matvec(A,x); else; r=b-A*x; end; 25 | err = norm(r); 26 | resnrm(iter+1) = err; 27 | 28 | if (err < tolb); break; end; 29 | if (iter > 1) & (resnrm(iter+1)/resnrm(iter) > 0.9) 30 | x = x0; solve_ok = 0; break; 31 | end 32 | d = linsysolvefun(L,r); 33 | x = x + d; 34 | end 35 | %%************************************************************************* 36 | %% matvec: matrix-vector multiply. 37 | %% matrix = [A.mat11 A.mat12; A.mat12' A.mat22] 38 | %%************************************************************************* 39 | 40 | function Ax = matvec(A,x); 41 | 42 | m = length(A.mat11); m2 = length(x)-m; 43 | x1 = x(1:m); 44 | Ax = A.mat11*x1; 45 | if (m2 > 0) 46 | x2 = x(m+[1:m2]); 47 | Ax = Ax + A.mat12*x2; 48 | Ax2 = (x1'*A.mat12)' + A.mat22*x2; 49 | Ax = [Ax; Ax2]; 50 | end 51 | return; 52 | %%************************************************************************* 53 | -------------------------------------------------------------------------------- /HSDSolver/HSDNTdirfun.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% HSDNTdirfun: compute (dX,dZ), given dy, for the NT direction. 3 | %%***************************************************************** 4 | %% SDPT3: version 4.0 5 | %% Copyright (c) 1997 by 6 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 7 | %% Last Modified: 16 Sep 2004 8 | %%***************************************************************** 9 | 10 | function [par,dX,dy,dZ] = HSDNTdirfun(blk,At,par,Rd,EinvRc,xx) 11 | 12 | global solve_ok 13 | 14 | dX = cell(size(blk,1),1); dZ = cell(size(blk,1),1); dy = []; 15 | if (any(isnan(xx)) | any(isinf(xx))) 16 | solve_ok = 0; 17 | fprintf('\n HSDNTdirfun: solution contains NaN or inf.'); 18 | return; 19 | end 20 | %% 21 | m = par.m; 22 | dy2 = xx(1:m+2); 23 | %% 24 | for p=1:size(blk,1) 25 | pblk = blk(p,:); 26 | if strcmp(pblk{1},'l') 27 | dZ(p) = ops(Rd(p),'-',Atyfun(pblk,At(p,:),[],[],dy2)); 28 | tmp = par.dd{p}.*dZ{p}; 29 | dX{p} = EinvRc{p} - tmp; 30 | elseif strcmp(pblk{1},'q') 31 | dZ(p) = ops(Rd(p),'-',Atyfun(pblk,At(p,:),[],[],dy2)); 32 | tmp = par.dd{p}.*dZ{p} + qops(pblk,qops(pblk,dZ{p},par.ee{p},1),par.ee{p},3); 33 | dX{p} = EinvRc{p} - tmp; 34 | elseif strcmp(pblk{1},'s') 35 | dZ(p) = ops(Rd(p),'-',Atyfun(pblk,At(p,:),par.permA(p,:),par.isspAy(p),dy2)); 36 | tmp = Prod3(pblk,par.W{p},dZ{p},par.W{p},1); 37 | dX{p} = EinvRc{p}-tmp; 38 | end 39 | end 40 | dy = dy2(1:m); 41 | par.dtau = dy2(m+1); 42 | par.dtheta = dy2(m+2); 43 | par.dkap = (par.mu./par.tau - par.kap) - par.kap*(par.dtau/par.tau); 44 | %%******************************************************************* 45 | -------------------------------------------------------------------------------- /Solver/Mexfun/Oldfiles/mexqprod.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * mexqprod.c : C mex file 3 | * 4 | * jj = mexqprod(blk); 5 | * 6 | * Input: blk = [n1, n2, ..., nk] 7 | * 8 | * Output: [1 1...1 2 2 ... 2 .... k k ...k]' 9 | * n1 n2 nk 10 | * 11 | * SDPT3: version 3.0 12 | * Copyright (c) 1997 by 13 | * K.C. Toh, M.J. Todd, R.H. Tutuncu 14 | * Last Modified: 2 Feb 01 15 | ***********************************************************************/ 16 | 17 | #include 18 | #include 19 | 20 | /********************************************************** 21 | * 22 | ***********************************************************/ 23 | void mexFunction( 24 | int nlhs, mxArray *plhs[], 25 | int nrhs, const mxArray *prhs[] ) 26 | 27 | { double *blksize, *jj; 28 | 29 | int k, l, blkdim, numblk, cols, idx; 30 | 31 | /* CHECK FOR PROPER NUMBER OF ARGUMENTS */ 32 | 33 | if (nrhs !=1){ 34 | mexErrMsgTxt("mexqprod: requires 1 input arguments."); } 35 | if (nlhs > 1){ 36 | mexErrMsgTxt("mexqprod: requires 1 output argument."); } 37 | 38 | /* CHECK THE DIMENSIONS */ 39 | 40 | if (mxIsCell(prhs[0])) { 41 | mexErrMsgTxt("mexqprod: blk must be a double array."); } 42 | numblk = mxGetN(prhs[0]); 43 | blksize = mxGetPr(prhs[0]); 44 | cols = 0; 45 | for (k=0; k 18 | #include 19 | 20 | /********************************************************** 21 | * 22 | ***********************************************************/ 23 | void mexFunction( 24 | int nlhs, mxArray *plhs[], 25 | int nrhs, const mxArray *prhs[] ) 26 | 27 | { double *blksize, *jj; 28 | 29 | int k, l, blkdim, numblk, cols, idx; 30 | 31 | /* CHECK FOR PROPER NUMBER OF ARGUMENTS */ 32 | 33 | if (nrhs !=1){ 34 | mexErrMsgTxt("mexqprod: requires 1 input arguments."); } 35 | if (nlhs > 1){ 36 | mexErrMsgTxt("mexqprod: requires 1 output argument."); } 37 | 38 | /* CHECK THE DIMENSIONS */ 39 | 40 | if (mxIsCell(prhs[0])) { 41 | mexErrMsgTxt("mexqprod: blk must be a double array."); } 42 | numblk = mxGetN(prhs[0]); 43 | blksize = mxGetPr(prhs[0]); 44 | cols = 0; 45 | for (k=0; k + - log(det(X2)) 5 | %% A1(X1) + A2(X2) = b, X1 psd, X2 pd 6 | %% 7 | %% [blk,At,C,b,OPTIONS] = randmaxdet(n,p,m); 8 | %% n = dimension of SDP variable X1 9 | %% p = dimension of logdet variable X2 10 | %% m = number of equality constraints 11 | %%***************************************************************** 12 | %% SDPT3: version 4.0 13 | %% Copyright (c) 1997 by 14 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 15 | %% Last Modified: 16 Sep 2004 16 | %%***************************************************************** 17 | 18 | function [blk,At,C,b,OPTIONS] = randmaxdet(n,p,m); 19 | 20 | Y1 = randn(n); Y1 = .5*(Y1 + Y1'); 21 | Y1 = Y1 - min(0,1.1*min(real(eig(Y1))))*eye(n); 22 | blk{1,1} = 's'; blk{1,2} = n; 23 | b = zeros(m,1); 24 | F = cell(1,m); 25 | for k = 1:m 26 | Fk = randn(n); Fk = .5*(Fk + Fk'); 27 | F{1,k} = Fk; 28 | b(k) = sum(sum(Y1.*Fk)); 29 | end; 30 | At(1) = svec(blk(1,:),F); 31 | F0 = randn(n); F0 = .5*(F0+F0'); 32 | C{1,1} = F0 - min(0,1.1*min(real(eig(F0))))*eye(n); 33 | parbarrier{1} = 0; 34 | %% 35 | if (p > 0) 36 | Y2 = randn(p); Y2 = .5*(Y2 + Y2'); 37 | Y2 = Y2 - min(0,1.1*min(real(eig(Y2))))*eye(p); 38 | blk{2,1} = 's'; blk{2,2} = p; 39 | for k = 1:m 40 | Gk = randn(p); Gk = .5*(Gk + Gk'); 41 | G{1,k} = Gk; 42 | b(k) = b(k) + sum(sum(Y2.*Gk)); 43 | end; 44 | At(2,1) = svec(blk(2,:),G); 45 | G0 = randn(p); G0 = .5*(G0+G0'); 46 | C{2,1} = G0 - min(0,1.1*min(real(eig(G0))))*eye(p); 47 | parbarrier{2} = 1; 48 | end 49 | OPTIONS.parbarrier = parbarrier; 50 | %%*************************************************************** 51 | -------------------------------------------------------------------------------- /HSDSolver/HSDHKMdirfun.m: -------------------------------------------------------------------------------- 1 | %%****************************************************************** 2 | %% HSDHKMdirfun: compute (dX,dZ), given dy, for the HKM direction. 3 | %%***************************************************************** 4 | %% SDPT3: version 4.0 5 | %% Copyright (c) 1997 by 6 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 7 | %% Last Modified: 16 Sep 2004 8 | %%***************************************************************** 9 | 10 | function [par,dX,dy,dZ] = HSDHKMdirfun(blk,At,par,Rd,EinvRc,X,xx); 11 | 12 | global solve_ok 13 | 14 | dX = cell(size(blk,1),1); dZ = cell(size(blk,1),1); dy = []; 15 | if (any(isnan(xx)) | any(isinf(xx))) 16 | solve_ok = 0; 17 | fprintf('\n HSDHKMdirfun: solution contains NaN or inf.'); 18 | return; 19 | end 20 | %% 21 | m = par.m; 22 | dy2 = xx(1:m+2); 23 | %% 24 | for p=1:size(blk,1) 25 | pblk = blk(p,:); 26 | if strcmp(pblk{1},'l') 27 | dZ(p) = ops(Rd(p),'-',Atyfun(pblk,At(p,:),[],[],dy2)); 28 | dX{p} = EinvRc{p} - par.dd{p}.*dZ{p}; 29 | elseif strcmp(pblk{1},'q') 30 | dZ(p) = ops(Rd(p),'-',Atyfun(pblk,At(p,:),[],[],dy2)); 31 | tmp = par.dd{p}.*dZ{p} ... 32 | + qops(pblk,qops(pblk,dZ{p},par.Zinv{p},1),X{p},3) ... 33 | + qops(pblk,qops(pblk,dZ{p},X{p},1),par.Zinv{p},3); 34 | dX{p} = EinvRc{p} - tmp; 35 | elseif strcmp(pblk{1},'s') 36 | dZ(p) = ops(Rd(p),'-',Atyfun(pblk,At(p,:),par.permA(p,:),par.isspAy(p),dy2)); 37 | tmp = Prod3(pblk,X{p},dZ{p},par.Zinv{p},0); 38 | tmp = 0.5*(tmp+tmp'); 39 | dX{p} = EinvRc{p}-tmp; 40 | end 41 | end 42 | dy = dy2(1:m); 43 | par.dtau = dy2(m+1); 44 | par.dtheta = dy2(m+2); 45 | par.dkap = (par.mu./par.tau - par.kap) - par.kap*(par.dtau/par.tau); 46 | %%******************************************************************* 47 | -------------------------------------------------------------------------------- /Examples/max_kcut.m: -------------------------------------------------------------------------------- 1 | %%******************************************************* 2 | %% max_kcut: MAX k-CUT problem. 3 | %% 4 | %% (primal problem) min 5 | %% s.t. diag(X) = b 6 | %% Xij >= -1/(K-1) for all i ~= j 7 | %% X positive semidefinite 8 | %% 9 | %% Here, b = e, C = -(1-1/K)/2* (diag(B*e)-B). 10 | %%------------------------------------------------------- 11 | %% [blk,Avec,C,b,objval,X] = max_kcut(B,K,solve); 12 | %% 13 | %% B: weighted adjacency matrix of a graph. 14 | %% solve = 0 just to initialize 15 | %% = 1 if want to solve the problem. 16 | %% 17 | %% See graph.m --- generate random adjacency matrix. 18 | %%***************************************************************** 19 | %% SDPT3: version 4.0 20 | %% Copyright (c) 1997 by 21 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 22 | %% Last Modified: 16 Sep 2004 23 | %%***************************************************************** 24 | 25 | function [blk,Avec,C,b,objval,X] = max_kcut(B,K,solve); 26 | 27 | if (nargin < 3); solve = 0; end; 28 | if ~isreal(B); error('only real B allowed'); end; 29 | 30 | n = length(B); e = ones(n,1); 31 | n2 = n*(n-1)/2; 32 | C{1} = -(1-1/K)/2*(spdiags(B*e,0,n,n)-B); 33 | b = e; 34 | blk{1,1} = 's'; blk{1,2} = n; 35 | blk{2,1} = 'l'; blk{2,2} = n2; 36 | 37 | A = cell(1,n); 38 | for j = 1:n; A{j} = sparse(j,j,1,n,n); end; 39 | Avec = svec(blk(1,:),A,1); 40 | tmp = speye(n*(n+1)/2); 41 | idx = cumsum([1:n]); 42 | Atmp = tmp(:,setdiff([1:n*(n+1)/2],idx)); 43 | Avec{1,1} = [Avec{1,1}, Atmp/sqrt(2)]; 44 | Avec{2,1} = [sparse(n2,n), -speye(n2,n2)]; 45 | b = [b; -1/(K-1)*ones(n2,1)]; 46 | C{2,1} = zeros(n2,1); 47 | %% 48 | if (solve) 49 | [obj,X,y,Z] = sqlp(blk,Avec,C,b); 50 | objval = obj(1); 51 | else 52 | objval = []; X = []; 53 | end 54 | %%******************************************************* 55 | -------------------------------------------------------------------------------- /Examples/maxcut.m: -------------------------------------------------------------------------------- 1 | %%******************************************************* 2 | %% maxcut: MAXCUT problem. 3 | %% 4 | %% (primal problem) min Tr C*X 5 | %% s.t. diag(X) = b; 6 | %% 7 | %% Here, b = e, C = -(diag(B*e)-B)/4. 8 | %% 9 | %% (dual problem) max b'*y 10 | %% s.t. diag(y) + Z = C. 11 | %%------------------------------------------------------- 12 | %% [blk,Avec,C,b,X0,y0,Z0,objval,X] = maxcut(B,feas,solve); 13 | %% 14 | %% B: weighted adjacency matrix of a graph. 15 | %% feas = 1 if want feasible starting point 16 | %% = 0 if otherwise. 17 | %% solve = 0 just to initialize 18 | %% = 1 if want to solve the problem. 19 | %% 20 | %% See graph.m --- generate random adjacency matrix. 21 | %%***************************************************************** 22 | %% SDPT3: version 4.0 23 | %% Copyright (c) 1997 by 24 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 25 | %% Last Modified: 16 Sep 2004 26 | %%***************************************************************** 27 | 28 | function [blk,Avec,C,b,X0,y0,Z0,objval,X] = maxcut(B,feas,solve) 29 | 30 | if nargin < 2; feas = 0; end; 31 | if nargin < 3; solve = 0; end; 32 | if ~isreal(B); error('only real B allowed'); end; 33 | 34 | n = length(B); e = ones(n,1); 35 | C{1} = -(spdiags(B*e,0,n,n)-B)/4; 36 | b = e; 37 | blk{1,1} = 's'; blk{1,2} = n; 38 | 39 | A = cell(1,n); 40 | for k = 1:n; A{k} = sparse(k,k,1,n,n); end; 41 | 42 | Avec = svec(blk,A,ones(size(blk,1),1)); 43 | if (feas) 44 | y0 = -1.1*abs(C{1})*e; 45 | Z0{1} = C{1} - spdiags(y0,0,n,n); 46 | X0{1} = spdiags(b,0,n,n); 47 | else 48 | [X0,y0,Z0] = infeaspt(blk,Avec,C,b); 49 | end 50 | if (solve) 51 | [obj,X,y,Z] = sqlp(blk,Avec,C,b,[],X0,y0,Z0); 52 | objval = obj(1); 53 | else 54 | objval = []; X = []; 55 | end 56 | %%******************************************************* 57 | -------------------------------------------------------------------------------- /Examples/ToeplitzApprox.m: -------------------------------------------------------------------------------- 1 | %%************************************************************************* 2 | %% ToeplitzApprox: find the nearest symmetric positive definite Toeplitz 3 | %% matrix to a given symmetric matrix F. 4 | %% 5 | %% max -y(n+1) 6 | %% s.t. T(y(1:n)) + y(n+1)*B >= 0 7 | %% [I 0 ] + sum_{k=1}^n y(k) [0 gam(k)*e_k ] + y(n+1)*B >= 0 8 | %% [0 -beta] [gam(k)*e_k' -2q(k) ] 9 | %% 10 | %% where B = diag([zeros(n,1); 1]) 11 | %% q(1) = - Tr(F); q(k+1) = -sum of upper and lower kth diagonals of F 12 | %% gam(1) = sqrt(n); gam(k) = sqrt(2*(n-k+1)) for k=2:n 13 | %% beta = norm(F,'fro')^2 14 | %%***************************************************************** 15 | %% SDPT3: version 4.0 16 | %% Copyright (c) 1997 by 17 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 18 | %% Last Modified: 16 Sep 2004 19 | %%***************************************************************** 20 | 21 | function [blk,At,C,b] = ToeplitzApprox(F) 22 | 23 | n = length(F); 24 | gam = sqrt([n, 2*(n-1:-1:1)]); 25 | q = zeros(n,1); 26 | q(1) = -sum(diag(F)); 27 | for k=1:n-1 28 | q(k+1) = -2*sum(diag(F,k)); 29 | end 30 | beta = norm(F,'fro')^2; 31 | 32 | blk{1,1} = 's'; blk{1,2} = n+1; 33 | blk{2,1} = 's'; blk{2,2} = n+1; 34 | 35 | b = [zeros(n,1); -1]; 36 | C{1,1} = sparse(n+1,n+1); 37 | C{2,1} = spdiags([ones(n,1); -beta],0,n+1,n+1); 38 | 39 | Acell = cell(1,n+1); 40 | Acell{1} = -spdiags([ones(n,1); 0],0,n+1,n+1); 41 | for k = 1:n-1 42 | tmp = -spdiags([ones(n,1); 0],k,n+1,n+1); 43 | Acell{k+1} = tmp + tmp'; 44 | end 45 | Acell{n+1} = -spconvert([n+1,n+1,1]); 46 | At(1,1) = svec(blk(1,:),Acell,1); 47 | 48 | for k = 1:n 49 | Acell{k} = -spconvert([k, n+1, gam(k); n+1, k, gam(k); n+1, n+1, -2*q(k)]); 50 | end 51 | Acell{n+1} = -spconvert([n+1,n+1,1]); 52 | At(2,1) = svec(blk(2,:),Acell,1); 53 | %%*********************************************************************** 54 | -------------------------------------------------------------------------------- /Solver/NTdirfun.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% NTdirfun: compute (dX,dZ), given dy, for the NT direction. 3 | %%***************************************************************** 4 | %% SDPT3: version 4.0 5 | %% Copyright (c) 1997 by 6 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 7 | %% Last Modified: 16 Sep 2004 8 | %%***************************************************************** 9 | 10 | function [dX,dy,dZ] = NTdirfun(blk,At,par,Rd,EinvRc,xx,m); 11 | 12 | global solve_ok 13 | 14 | dX = cell(size(blk,1),1); dZ = cell(size(blk,1),1); dy = []; 15 | if (any(isnan(xx)) | any(isinf(xx))) 16 | solve_ok = 0; 17 | fprintf('\n linsysolve: solution contains NaN or inf.'); 18 | return; 19 | end 20 | %% 21 | dy = xx(1:m); 22 | count = m; 23 | %% 24 | for p=1:size(blk,1) 25 | pblk = blk(p,:); 26 | if strcmp(pblk{1},'l') 27 | %%dZ{p} = Rd{p} - At{p}*dy; 28 | dZ(p) = ops(Rd(p),'-',Atyfun(pblk,At(p,:),[],[],dy)); 29 | tmp = par.dd{p}.*dZ{p}; 30 | dX{p} = EinvRc{p} - tmp; 31 | elseif strcmp(pblk{1},'q') 32 | %%dZ{p} = Rd{p} - At{p}*dy; 33 | dZ(p) = ops(Rd(p),'-',Atyfun(pblk,At(p,:),[],[],dy)); 34 | tmp = par.dd{p}.*dZ{p} + qops(pblk,qops(pblk,dZ{p},par.ee{p},1),par.ee{p},3); 35 | dX{p} = EinvRc{p} - tmp; 36 | elseif strcmp(pblk{1},'s') 37 | %%dZ{p} = Rd{p} - smat(pblk,At{p}*dy(par.permA(p,:)),par.isspAy(p)); 38 | dZ(p) = ops(Rd(p),'-',Atyfun(pblk,At(p,:),par.permA(p,:),par.isspAy(p),dy)); 39 | tmp = Prod3(pblk,par.W{p},dZ{p},par.W{p},1); 40 | dX{p} = EinvRc{p}-tmp; 41 | elseif strcmp(pblk{1},'u'); 42 | n = sum(pblk{2}); 43 | dZ{p} = zeros(n,1); 44 | dX{p} = xx(count+[1:n]); 45 | count = count + n; 46 | end 47 | end 48 | %%******************************************************************* 49 | -------------------------------------------------------------------------------- /Examples/Asum.m: -------------------------------------------------------------------------------- 1 | %%************************************************************* 2 | %% Asum: compute the matrix 3 | %% 4 | %% Ay = Asum(blk,A,y) 5 | %% 6 | %% input: A = a CELL ARRAY with m columns. 7 | %% y = mx1 vector. 8 | %% permAy = a permutation of [1:m] coding the order to 9 | %% sum the matrices y(k)*Ak, k = 1,...m. 10 | %% iscmp = 1, if Ay is complex 11 | %% 0, otherwise. 12 | %% 13 | %% output: Ay = sum_{k=1}^m y(k)*Ak, a column CELL ARRAY 14 | %% with the same structure as A{:,1}. 15 | %%***************************************************************** 16 | %% SDPT3: version 4.0 17 | %% Copyright (c) 1997 by 18 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 19 | %% Last Modified: 16 Sep 2004 20 | %%***************************************************************** 21 | 22 | function Ay = Asum(blk,A,y) 23 | 24 | Ay = cell(size(blk,1),1); 25 | m = length(y); 26 | for p = 1:size(blk,1) 27 | n = sum(blk{p,2}); 28 | blktmp = blk{p,2}; 29 | if strcmp(blk{p,1},'s'); 30 | tmp = sparse(n,n); 31 | for k = 1:m; tmp = tmp + A{p,k}*y(k); end; 32 | if (length(blktmp) == 1) 33 | if (nnz(tmp) > 0.15*n*n); 34 | if issparse(tmp); tmp = full(tmp); end; 35 | else; 36 | if ~issparse(tmp); tmp = sparse(tmp); end; 37 | end; 38 | elseif (length(blktmp) > 1); 39 | if ~issparse(tmp); tmp = sparse(tmp); end; 40 | end; 41 | elseif strcmp(blk{p,1},'l'); 42 | tmp = zeros(n,1); 43 | for k = 1:m; tmp = tmp + A{p,k}*y(k); end; 44 | if (nnz(tmp) > 0.15*n); 45 | if issparse(tmp); tmp = full(tmp); end; 46 | else; 47 | if ~issparse(tmp); tmp = sparse(tmp); end; 48 | end; 49 | end; 50 | Ay{p} = tmp; 51 | end; 52 | %%------------------------------------------------------------- 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Solver/Prod3.m: -------------------------------------------------------------------------------- 1 | %%************************************************************ 2 | %% Prod3: compute the entries of Q = A*B*C specified in 3 | %% nzlistQ. 4 | %% 5 | %% Q = Prod3(blk,A,B,C,sym,nzlistQ) 6 | %% Important: (a) A is assumed to be symmetric if nzlistQ 7 | %% has 2 columns (since mexProd2nz computes A'*B). 8 | %% (b) The 2nd column of nzlistQ must be sorted in 9 | %% ascending order. 10 | %% 11 | %% (optional) sym = 1, if Q is symmetric. 12 | %% = 0, otherwise. 13 | %% (optional) nzlistQ = list of non-zero elements of Q to be 14 | %% computed. 15 | %%***************************************************************** 16 | %% SDPT3: version 4.0 17 | %% Copyright (c) 1997 by 18 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 19 | %% Last Modified: 16 Sep 2004 20 | %%***************************************************************** 21 | 22 | function Q = Prod3(blk,A,B,C,sym,nzlistQ) 23 | 24 | if (nargin<5); sym = 0; end; 25 | checkcell = [iscell(A) iscell(B) iscell(C)]; 26 | if (nargin==6) 27 | checkcell(1,4) = iscell(nzlistQ); 28 | else 29 | nzlistQ = inf; 30 | end 31 | %% 32 | if any(checkcell-1) 33 | if (size(blk,1) > 1) 34 | error('Prod3: blk and A,B,C are not compatible'); 35 | end 36 | if strcmp(blk{1},'s') 37 | [len,len2] = size(nzlistQ); 38 | if (len == 0); nzlistQ = inf; len2 = 1; end; 39 | if (len2 == 1) & (nzlistQ == inf) 40 | tmp = Prod2(blk,A,B,0); 41 | Q = Prod2(blk,tmp,C,sym); 42 | else 43 | tmp = Prod2(blk,B,C,0); 44 | Q = mexProd2nz(blk,A,tmp,nzlistQ); 45 | if sym; Q = 0.5*(Q+Q'); end; 46 | end 47 | elseif strcmp(blk{1},'q') | strcmp(blk{1},'l') | strcmp(blk{1},'u') 48 | Q = A.*B.*C; 49 | end 50 | else 51 | error('Prod3: A,B,C,nzlistQ must all be matrices'); 52 | end 53 | %%************************************************************ 54 | -------------------------------------------------------------------------------- /Solver/Mexfun/mexfun71/mexexpand_71.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * mexexpand.c : C mex file 3 | * 4 | * z = mexexpand(blk,x); 5 | * 6 | * Input: blk = [n1, n2, ..., nk] 7 | * 8 | * Output: [x1 x1...x1 x2 x2 ... x2 .... xk xk ...xk]' 9 | * n1 n2 nk 10 | * 11 | * SDPT3: version 3.0 12 | * Copyright (c) 1997 by 13 | * K.C. Toh, M.J. Todd, R.H. Tutuncu 14 | * Last Modified: 2 Feb 01 15 | ***********************************************************************/ 16 | 17 | #include 18 | #include 19 | 20 | #if !defined(MAX) 21 | #define MAX(A, B) ((A) > (B) ? (A) : (B)) 22 | #endif 23 | 24 | /********************************************************** 25 | * 26 | ***********************************************************/ 27 | void mexFunction( 28 | int nlhs, mxArray *plhs[], 29 | int nrhs, const mxArray *prhs[] ) 30 | 31 | { 32 | double *blksize, *x, *z; 33 | int k, l, blkdim, numblk, cols, idx; 34 | 35 | /* CHECK FOR PROPER NUMBER OF ARGUMENTS */ 36 | 37 | if (nrhs != 2){ 38 | mexErrMsgTxt("mexexpand: requires 2 input arguments."); } 39 | if (nlhs > 1){ 40 | mexErrMsgTxt("mexexpand: requires 1 output argument."); } 41 | 42 | /* CHECK THE DIMENSIONS */ 43 | 44 | numblk = MAX(mxGetM(prhs[0]),mxGetN(prhs[0])); 45 | blksize = mxGetPr(prhs[0]); 46 | cols = 0; 47 | for (k=0; k 18 | #include 19 | 20 | #if !defined(MAX) 21 | #define MAX(A, B) ((A) > (B) ? (A) : (B)) 22 | #endif 23 | 24 | /********************************************************** 25 | * 26 | ***********************************************************/ 27 | void mexFunction( 28 | int nlhs, mxArray *plhs[], 29 | int nrhs, const mxArray *prhs[] ) 30 | 31 | { 32 | double *blksize, *x, *z; 33 | int k, l, blkdim, numblk, cols, idx; 34 | 35 | /* CHECK FOR PROPER NUMBER OF ARGUMENTS */ 36 | 37 | if (nrhs != 2){ 38 | mexErrMsgTxt("mexexpand: requires 2 input arguments."); } 39 | if (nlhs > 1){ 40 | mexErrMsgTxt("mexexpand: requires 1 output argument."); } 41 | 42 | /* CHECK THE DIMENSIONS */ 43 | 44 | numblk = MAX(mxGetM(prhs[0]),mxGetN(prhs[0])); 45 | blksize = mxGetPr(prhs[0]); 46 | cols = 0; 47 | for (k=0; k 13 | #include 14 | 15 | /********************************************************** 16 | * 17 | ***********************************************************/ 18 | void mexFunction( 19 | int nlhs, mxArray *plhs[], 20 | int nrhs, const mxArray *prhs[] ) 21 | 22 | { double *A, *nnz; 23 | int *irA, *jcA; 24 | 25 | int NZmax, m, n, isspA, j, k, jm, nnztmp; 26 | 27 | /* CHECK FOR PROPER NUMBER OF ARGUMENTS */ 28 | 29 | if (nrhs != 1){ 30 | mexErrMsgTxt("mexnnz: requires 1 input arguments."); } 31 | else if (nlhs>1){ 32 | mexErrMsgTxt("mexnnz: requires 1 output argument."); } 33 | 34 | /* CHECK THE DIMENSIONS */ 35 | 36 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 37 | nnz = mxGetPr(plhs[0]); 38 | if (mxGetPr(prhs[0]) == NULL) { 39 | nnz[0] = 0.0; 40 | return; 41 | } 42 | m = mxGetM(prhs[0]); 43 | n = mxGetN(prhs[0]); 44 | A = mxGetPr(prhs[0]); 45 | isspA = mxIsSparse(prhs[0]); 46 | if (isspA) { 47 | irA = mxGetIr(prhs[0]); 48 | jcA = mxGetJc(prhs[0]); 49 | NZmax = jcA[n]; 50 | } 51 | /***** main body *****/ 52 | nnztmp = 0; 53 | if (isspA) { 54 | for (k=0; k= 0, sum_{i=1}^p lambda_i = 1. 7 | %% 8 | %% Note: const = n. 9 | %% V: nxp matrix with n <= p. 10 | %% lambda: lambda_i is the fraction of the experiments 11 | %% allocated to test vector v_i. 12 | %% S: = V*diag(lambda)*V'. 13 | %%***************************************************************** 14 | %% SDPT3: version 4.0 15 | %% Copyright (c) 1997 by 16 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 17 | %% Last Modified: 16 Sep 2004 18 | %%***************************************************************** 19 | 20 | function [blk,At,C,b,OPTIONS,lambda,bblk,AAt] = Doptdesign(V,solve); 21 | 22 | if (nargin == 1); solve = 0; end 23 | 24 | [n,p] = size(V); 25 | if (n > p); 26 | error(' size(V,1) > size(V,2)'); 27 | end 28 | %% 29 | %% form blk, At, C, b 30 | %% 31 | b = zeros(p,1); 32 | 33 | blk{1,1} = 's'; blk{1,2} = n; 34 | F = cell(1,p); 35 | for k = 1:p 36 | F{1,k} = -V(:,k)*V(:,k)'; 37 | end 38 | At(1) = svec(blk(1,:),F,1); 39 | C{1,1} = sparse(n,n); 40 | 41 | blk{2,1} = 'l'; blk{2,2} = p; 42 | At{2,1} = -speye(p,p); 43 | C{2,1} = zeros(p,1); 44 | 45 | blk{3,1} = 'u'; blk{3,2} = 1; 46 | At{3,1} = ones(1,p); 47 | C{3,1} = 1; 48 | 49 | OPTIONS.parbarrier{1,1} = 1; 50 | OPTIONS.parbarrier{2,1} = 0; 51 | OPTIONS.parbarrier{3,1} = 0; 52 | %% 53 | %% form bblk, AAt to take into account of 54 | %% low-rank constraint matrices of the form: -vk*vk'. 55 | %% 56 | bblk = blk; AAt = At; 57 | bblk{1,1} = 's'; bblk{1,2} = n; bblk{1,3} = ones(1,p); 58 | AAt{1,1} = []; AAt{1,2} = V; AAt{1,3} = -ones(p,1); 59 | %% 60 | if (solve) 61 | [obj,X,y,Z] = sqlp(blk,At,C,b,OPTIONS); 62 | lambda = -y; 63 | else 64 | lambda = []; 65 | end 66 | %%******************************************************* 67 | -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexfun71/mexnnz_71.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * mexnnz.c: get number of non-zero elements of a matrix M 3 | * 4 | * nnz = mexnnzt(M); 5 | * 6 | * SDPT3: version 3.0 7 | * Copyright (c) 1997 by 8 | * K.C. Toh, M.J. Todd, R.H. Tutuncu 9 | * Last Modified: 2 Feb 01 10 | ***********************************************************************/ 11 | 12 | #include 13 | #include 14 | 15 | /********************************************************** 16 | * 17 | ***********************************************************/ 18 | void mexFunction( 19 | int nlhs, mxArray *plhs[], 20 | int nrhs, const mxArray *prhs[] ) 21 | 22 | { double *A, *nnz; 23 | int *irA, *jcA; 24 | 25 | int NZmax, m, n, isspA, j, k, jm, nnztmp; 26 | 27 | /* CHECK FOR PROPER NUMBER OF ARGUMENTS */ 28 | 29 | if (nrhs != 1){ 30 | mexErrMsgTxt("mexnnz: requires 1 input arguments."); } 31 | else if (nlhs>1){ 32 | mexErrMsgTxt("mexnnz: requires 1 output argument."); } 33 | 34 | /* CHECK THE DIMENSIONS */ 35 | 36 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 37 | nnz = mxGetPr(plhs[0]); 38 | if (mxGetPr(prhs[0]) == NULL) { 39 | nnz[0] = 0.0; 40 | return; 41 | } 42 | m = mxGetM(prhs[0]); 43 | n = mxGetN(prhs[0]); 44 | A = mxGetPr(prhs[0]); 45 | isspA = mxIsSparse(prhs[0]); 46 | if (isspA) { 47 | irA = mxGetIr(prhs[0]); 48 | jcA = mxGetJc(prhs[0]); 49 | NZmax = jcA[n]; 50 | } 51 | /***** main body *****/ 52 | nnztmp = 0; 53 | if (isspA) { 54 | for (k=0; k 13 | #include 14 | #include 15 | #include "header.h" 16 | 17 | /********************************************************** 18 | * 19 | ***********************************************************/ 20 | void mexFunction(int nlhs, mxArray *plhs[], 21 | int nrhs, const mxArray *prhs[] ) 22 | 23 | { double *A, *nnz; 24 | mwIndex *irA, *jcA; 25 | 26 | mwSize NZmax, m, n, isspA, j, k, jm, nnztmp; 27 | 28 | /* CHECK FOR PROPER NUMBER OF ARGUMENTS */ 29 | 30 | if (nrhs != 1){ 31 | mexErrMsgTxt("mexnnz: requires 1 input arguments."); } 32 | else if (nlhs>1){ 33 | mexErrMsgTxt("mexnnz: requires 1 output argument."); } 34 | 35 | /* CHECK THE DIMENSIONS */ 36 | 37 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 38 | nnz = mxGetPr(plhs[0]); 39 | if (mxGetPr(prhs[0]) == NULL) { 40 | nnz[0] = 0.0; 41 | return; 42 | } 43 | m = mxGetM(prhs[0]); 44 | n = mxGetN(prhs[0]); 45 | A = mxGetPr(prhs[0]); 46 | isspA = mxIsSparse(prhs[0]); 47 | if (isspA) { 48 | irA = mxGetIr(prhs[0]); 49 | jcA = mxGetJc(prhs[0]); 50 | NZmax = jcA[n]; 51 | } 52 | /***** main body *****/ 53 | nnztmp = 0; 54 | if (isspA) { 55 | for (k=0; k, k = 1:m 3 | %% 4 | %% AX = AXfun(blk,At,permA,X); 5 | %% 6 | %% Note: permA may be set to [] if no permutation is neccessary. 7 | %% 8 | %%***************************************************************** 9 | %% SDPT3: version 4.0 10 | %% Copyright (c) 1997 by 11 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 12 | %% Last Modified: 16 Sep 2004 13 | %%***************************************************************** 14 | 15 | function AX = AXfun(blk,At,permA,X); 16 | 17 | if isempty(permA); ismtpermA = 1; else; ismtpermA = 0; end 18 | 19 | for p = 1:size(blk,1); 20 | pblk = blk(p,:); 21 | if strcmp(pblk{1},'s') 22 | m1 = size(At{p,1},2); 23 | if (p==1) 24 | if (length(pblk) > 2); m2 = length(pblk{3}); else; m2 = 0; end 25 | m = m1 + m2; 26 | AX = zeros(m,1); tmp = zeros(m,1); 27 | end 28 | if (~isempty(At{p,1})) 29 | if (ismtpermA) 30 | tmp = (svec(pblk,X{p})'*At{p,1})'; 31 | %%tmp = mexinprod(blk,At,svec(pblk,X{p}),m1,p); 32 | else 33 | tmp(permA(p,1:m1),1) = (svec(pblk,X{p})'*At{p,1})'; 34 | %%tmp(permA(p,1:m1),1) = mexinprod(blk,At,svec(pblk,X{p}),m1,p); 35 | end 36 | end 37 | if (length(pblk) > 2) %% for low rank constraints 38 | m2 = length(pblk{3}); 39 | dd = At{p,3}; 40 | len = sum(pblk{3}); 41 | DD = spconvert([dd(:,2:4); len,len,0]); 42 | XVD = X{p}*At{p,2}*DD; 43 | if (length(X{p}) > 1) 44 | tmp2 = sum(At{p,2}.*XVD)'; 45 | else 46 | tmp2 = (At{p,2}.*XVD)'; 47 | end 48 | tmp(m1+[1:m2]) = mexqops(pblk{3},tmp2,ones(length(tmp2),1),1); 49 | end 50 | AX = AX + tmp; 51 | else 52 | if (p==1); m = size(At{p,1},2); AX = zeros(m,1); tmp = zeros(m,1); end 53 | AX = AX + (X{p}'*At{p,1})'; 54 | end 55 | end 56 | %%************************************************************************* 57 | -------------------------------------------------------------------------------- /Solver/Mexfun/mexexpand.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * mexexpand.c : C mex file 3 | * 4 | * z = mexexpand(blk,x); 5 | * 6 | * Input: blk = [n1, n2, ..., nk] 7 | * 8 | * Output: [x1 x1...x1, x2 x2...x2, ...., xk xk...xk]' 9 | * n1 n2 nk 10 | * 11 | * SDPT3: version 3.0 12 | * Copyright (c) 1997 by 13 | * K.C. Toh, M.J. Todd, R.H. Tutuncu 14 | * Last Modified: 2 Feb 01 15 | ***********************************************************************/ 16 | 17 | #include 18 | #include 19 | #include 20 | #include "header.h" 21 | 22 | #if !defined(MAX) 23 | #define MAX(A, B) ((A) > (B) ? (A) : (B)) 24 | #endif 25 | 26 | /********************************************************** 27 | * 28 | ***********************************************************/ 29 | void mexFunction(int nlhs, mxArray *plhs[], 30 | int nrhs, const mxArray *prhs[] ) 31 | 32 | { double *blksize, *x, *z; 33 | mwSize k, l, blkdim, numblk, cols, idx; 34 | 35 | /* CHECK FOR PROPER NUMBER OF ARGUMENTS */ 36 | 37 | if (nrhs != 2){ 38 | mexErrMsgTxt("mexexpand: requires 2 input arguments."); } 39 | if (nlhs > 1){ 40 | mexErrMsgTxt("mexexpand: requires 1 output argument."); } 41 | 42 | /* CHECK THE DIMENSIONS */ 43 | 44 | numblk = MAX(mxGetM(prhs[0]),mxGetN(prhs[0])); 45 | blksize = mxGetPr(prhs[0]); 46 | cols = 0; 47 | for (k=0; k 13 | #include 14 | #include 15 | 16 | #if !defined(MX_API_VER) || ( MX_API_VER < 0x07030000 ) 17 | typedef int mwIndex; 18 | typedef int mwSize; 19 | #endif 20 | 21 | /********************************************************** 22 | * 23 | ***********************************************************/ 24 | void mexFunction(int nlhs, mxArray *plhs[], 25 | int nrhs, const mxArray *prhs[] ) 26 | 27 | { double *A, *nnz; 28 | mwIndex *irA, *jcA; 29 | 30 | int NZmax, m, n, isspA, j, k, jm, nnztmp; 31 | 32 | /* CHECK FOR PROPER NUMBER OF ARGUMENTS */ 33 | 34 | if (nrhs != 1){ 35 | mexErrMsgTxt("mexnnz: requires 1 input arguments."); } 36 | else if (nlhs>1){ 37 | mexErrMsgTxt("mexnnz: requires 1 output argument."); } 38 | 39 | /* CHECK THE DIMENSIONS */ 40 | 41 | plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); 42 | nnz = mxGetPr(plhs[0]); 43 | if (mxGetPr(prhs[0]) == NULL) { 44 | nnz[0] = 0.0; 45 | return; 46 | } 47 | m = mxGetM(prhs[0]); 48 | n = mxGetN(prhs[0]); 49 | A = mxGetPr(prhs[0]); 50 | isspA = mxIsSparse(prhs[0]); 51 | if (isspA) { 52 | irA = mxGetIr(prhs[0]); 53 | jcA = mxGetJc(prhs[0]); 54 | NZmax = jcA[n]; 55 | } 56 | /***** main body *****/ 57 | nnztmp = 0; 58 | if (isspA) { 59 | for (k=0; k 0); 20 | if ~isempty(idx) 21 | vpsub = vp(idx); 22 | if size(vpsub,1) < size(vpsub,2); vpsub = vpsub'; end 23 | if strcmp(pblk{1},'s') 24 | ss = [0, cumsum(pblk{2})]; 25 | logdetX = 2*log(diag(Xchol{p})); 26 | logdetZ = 2*log(diag(Zchol{p})); 27 | logdetXsub = zeros(length(idx),1); 28 | logdetZsub = zeros(length(idx),1); 29 | for k = 1:length(idx) 30 | idxtmp = [ss(idx(k))+1:ss(idx(k)+1)]; 31 | logdetXsub(k) = sum(logdetX(idxtmp)); 32 | logdetZsub(k) = sum(logdetZ(idxtmp)); 33 | end 34 | tmp(1) = -sum(vpsub.*logdetXsub); 35 | tmp(2) = sum(vpsub.*logdetZsub + (pblk{2}(idx)').*vpsub.*(1-log(vpsub))); 36 | elseif strcmp(pblk{1},'q') 37 | gamX = sqrt(qops(pblk,X{p},X{p},2)); 38 | gamZ = sqrt(qops(pblk,Z{p},Z{p},2)); 39 | tmp(1) = -sum(vpsub.*log(gamX(idx))); 40 | tmp(2) = sum(vpsub.*log(gamZ(idx)) + vpsub); 41 | elseif strcmp(pblk{1},'l') 42 | logX = log(X{p}); logZ = log(Z{p}); 43 | tmp(1) = -sum(vpsub.*logX(idx)); 44 | tmp(2) = sum(vpsub.*logZ(idx) + vpsub.*(1-log(vpsub))); 45 | end 46 | objadd = objadd + tmp; 47 | end 48 | end 49 | %%******************************************************************** 50 | -------------------------------------------------------------------------------- /Solver/Prod2.m: -------------------------------------------------------------------------------- 1 | %%******************************************************************* 2 | %% Prod2: compute the block diagonal matrix A*B 3 | %% 4 | %% C = Prod2(blk,A,B,options); 5 | %% 6 | %% INPUT: blk = a cell array describing the block structure of A and B 7 | %% A,B = square matrices or column vectors. 8 | %% 9 | %% options = 0 if no special structure 10 | %% 1 if C is symmetric 11 | %%***************************************************************** 12 | %% SDPT3: version 4.0 13 | %% Copyright (c) 1997 by 14 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 15 | %% Last Modified: 16 Sep 2004 16 | %%***************************************************************** 17 | 18 | function C = Prod2(blk,A,B,options); 19 | 20 | global spdensity 21 | 22 | if (nargin == 3); options = 0; end; 23 | iscellA = iscell(A); iscellB = iscell(B); 24 | %% 25 | if (~iscellA & ~iscellB) 26 | if (size(blk,1) > 1); 27 | error('Prod2: blk and A,B are not compatible'); 28 | end; 29 | if strcmp(blk{1},'s') 30 | numblk = length(blk{2}); 31 | isspA = issparse(A); isspB = issparse(B); 32 | if (numblk > 1) 33 | if ~isspA; A=sparse(A); isspA=1; end 34 | if ~isspB; B=sparse(B); isspB=1; end 35 | end 36 | %%use_matlab = (options==0 & ~isspA & ~isspB) | (isspA & isspB); 37 | use_matlab = (~isspA & ~isspB) | (isspA & isspB); 38 | if (use_matlab) 39 | C = A*B; 40 | if (options==1); C = 0.5*(C+C'); end; 41 | else 42 | C = mexProd2(blk,A,B,options); 43 | end 44 | checksparse = (numblk==1) & (isspA | isspB); 45 | if (checksparse) 46 | n2 = sum(blk{2}.*blk{2}); 47 | if (mexnnz(C) <= spdensity*n2); 48 | if ~issparse(C); C = sparse(C); end; 49 | else 50 | if issparse(C); C = full(C); end; 51 | end 52 | end 53 | elseif (strcmp(blk{1},'q') | strcmp(blk{1},'l') | strcmp(blk{1},'u')) 54 | C = A.*B; 55 | end 56 | else 57 | error(['Prod2: A,B must be matrices']); 58 | end 59 | %%******************************************************************* 60 | -------------------------------------------------------------------------------- /Solver/Mexfun_old/mexexpand.c: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * mexexpand.c : C mex file 3 | * 4 | * z = mexexpand(blk,x); 5 | * 6 | * Input: blk = [n1, n2, ..., nk] 7 | * 8 | * Output: [x1 x1...x1, x2 x2...x2, ...., xk xk...xk]' 9 | * n1 n2 nk 10 | * 11 | * SDPT3: version 3.0 12 | * Copyright (c) 1997 by 13 | * K.C. Toh, M.J. Todd, R.H. Tutuncu 14 | * Last Modified: 2 Feb 01 15 | ***********************************************************************/ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #if !defined(MX_API_VER) || ( MX_API_VER < 0x07030000 ) 22 | typedef int mwIndex; 23 | typedef int mwSize; 24 | #endif 25 | 26 | #if !defined(MAX) 27 | #define MAX(A, B) ((A) > (B) ? (A) : (B)) 28 | #endif 29 | 30 | /********************************************************** 31 | * 32 | ***********************************************************/ 33 | void mexFunction(int nlhs, mxArray *plhs[], 34 | int nrhs, const mxArray *prhs[] ) 35 | 36 | { double *blksize, *x, *z; 37 | int k, l, blkdim, numblk, cols, idx; 38 | 39 | /* CHECK FOR PROPER NUMBER OF ARGUMENTS */ 40 | 41 | if (nrhs != 2){ 42 | mexErrMsgTxt("mexexpand: requires 2 input arguments."); } 43 | if (nlhs > 1){ 44 | mexErrMsgTxt("mexexpand: requires 1 output argument."); } 45 | 46 | /* CHECK THE DIMENSIONS */ 47 | 48 | numblk = MAX(mxGetM(prhs[0]),mxGetN(prhs[0])); 49 | blksize = mxGetPr(prhs[0]); 50 | cols = 0; 51 | for (k=0; k m. 9 | %% 10 | %% e.g. p = 20; m = 5; B = rand(p,m); f = rand(p,1); 11 | %%-------------------------------------------------------------- 12 | %% [blk,At,C,b,objval,x] = logchebyRcone(B,f,solve); 13 | %% 14 | %% B = pxm matrix (p > m). 15 | %% f = px1 vector, [B(:,j)./f must be positive for each j] 16 | %% solve = 0 if just want initialization. 17 | %% = 1 if want to solve the problem. 18 | %%***************************************************************** 19 | %% SDPT3: version 4.0 20 | %% Copyright (c) 1997 by 21 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 22 | %% Last Modified: 16 Sep 2004 23 | %%***************************************************************** 24 | 25 | function [blk,At,C,b,objval,x] = logchebyRcone(B,f,solve); 26 | 27 | if (nargin < 3); solve = 0; end; 28 | if ~isreal(B); error('B must be real'); end; 29 | 30 | [p,m] = size(B); 31 | E = zeros(p,m); 32 | for j = [1:m]; E(:,j) = B(:,j)./f; end; 33 | if any(E < 1e-10); 34 | error(' B(:,j)./f must have all entry positive'); 35 | end 36 | %% 37 | blk{1,1} = 'l'; blk{1,2} = p; 38 | blk{2,1} = 'l'; blk{2,2} = p; 39 | blk{3,1} = 'r'; blk{3,2} = 3; 40 | blk{4,1} = 'u'; blk{4,2} = 1; 41 | At{1,1} = [B, -f, zeros(p,2)]; 42 | At{2,1} = [-B, zeros(p,1), f, zeros(p,1)]; 43 | At{3,1} = [sparse(3,m), -speye(3,3)]; 44 | At{4,1} = [sparse(1,m+2), 1]; 45 | C{1,1} = zeros(p,1); 46 | C{2,1} = zeros(p,1); 47 | C{3,1} = zeros(3,1); 48 | C{4,1} = sqrt(2); 49 | b = [zeros(m,1); -1; 0; 0]; 50 | %% 51 | %% convert rotated cone to socp cone 52 | %% 53 | [blk,At,C,b] = convertRcone(blk,At,C,b); 54 | %% 55 | if (solve) 56 | [obj,X,y,Z] = sqlp(blk,At,C,b); 57 | objval = -mean(obj); 58 | x = y(1:m); 59 | else 60 | objval = []; x = []; 61 | end 62 | %%*************************************************************** 63 | -------------------------------------------------------------------------------- /Solver/NTscaling.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% NTscaling: Compute NT scaling matrix 3 | %% 4 | %% compute SVD of Xchol*Zchol via eigenvalue decompostion of 5 | %% Zchol * X * Zchol' = V * diag(sv2) * V'. 6 | %% compute W satisfying W*Z*W = X. 7 | %% W = G'*G, where G = diag(sqrt(sv)) * (invZchol*V)' 8 | %% important to keep W symmertic. 9 | %%***************************************************************** 10 | %% SDPT3: version 4.0 11 | %% Copyright (c) 1997 by 12 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 13 | %% Last Modified: 16 Sep 2004 14 | %%***************************************************************** 15 | 16 | function [W,G,sv,gamx,gamz,dd,ee,ff] = ... 17 | NTscaling(blk,X,Z,Zchol,invZchol); 18 | 19 | numblk = size(blk,1); 20 | W = cell(numblk,1); G = cell(numblk,1); sv = cell(numblk,1); 21 | gamx = cell(numblk,1); gamz = cell(numblk,1); 22 | dd = cell(numblk,1); ee = cell(numblk,1); ff = cell(numblk,1); 23 | %% 24 | for p = 1:size(blk,1) 25 | pblk = blk(p,:); 26 | numblk = length(pblk{2}); 27 | n = sum(pblk{2}); 28 | if strcmp(pblk{1},'l') 29 | dd{p} = X{p}./Z{p}; %% do not add perturbation, it badly affects cre-a 30 | elseif strcmp(pblk{1},'q'); 31 | gamx{p} = sqrt(qops(pblk,X{p},X{p},2)); 32 | gamz{p} = sqrt(qops(pblk,Z{p},Z{p},2)); 33 | w2 = gamz{p}./gamx{p}; w = sqrt(w2); 34 | dd{p} = qops(pblk,1./w2,ones(n,1),4); 35 | tt = qops(pblk,1./w,Z{p},3) - qops(pblk,w,X{p},4); 36 | gamtt = sqrt(qops(pblk,tt,tt,2)); 37 | ff{p} = qops(pblk,1./gamtt,tt,3); 38 | ee{p} = qops(pblk,sqrt(2)./w,ff{p},4); 39 | elseif strcmp(pblk{1},'s') 40 | tmp = Prod2(pblk,Zchol{p},X{p},0); 41 | tmp = Prod2(pblk,tmp,Zchol{p}',1); 42 | [sv2,V] = blkeig(pblk,tmp); 43 | sv2 = max(1e-20,sv2); 44 | sv{p} = sqrt(sv2); 45 | tmp = Prod2(pblk,invZchol{p},V); 46 | G{p} = Prod2(pblk,spdiags(sqrt(sv{p}),0,n,n),tmp'); 47 | W{p} = Prod2(pblk,G{p}',G{p},1); 48 | end 49 | end 50 | %%********************************************************************** 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Examples/thetaproblem.m: -------------------------------------------------------------------------------- 1 | %%******************************************************* 2 | %% thetaproblem: Lovasz theta number. 3 | %% 4 | %% (primal) min Tr C*X 5 | %% s.t. X(i,j) = 0 if (i,j) is an edge of G, 6 | %% Tr(X) = 1. 7 | %% b = e1, 8 | %% C = -ones(n), 9 | %% A1 = eye(n), Ak = ei*ej' + ej*ei', if (i,j) is an edge. 10 | %%------------------------------------------------------- 11 | %% 12 | %% [blk,Avec,C,b,X0,y0,Z0,objval,X] = thetaproblem(G,feas,solve); 13 | %% 14 | %% G: adjacency matrix of a graph. 15 | %% feas = 1 if want feasible starting point 16 | %% = 0 if otherwise. 17 | %% solve = 0 just to initialize 18 | %% = 1 if want to solve the problem. 19 | %% 20 | %% See graph.m --- generate random adjacency matrix. 21 | %%***************************************************************** 22 | %% SDPT3: version 4.0 23 | %% Copyright (c) 1997 by 24 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 25 | %% Last Modified: 16 Sep 2004 26 | %%***************************************************************** 27 | 28 | function [blk,Avec,C,b,X0,y0,Z0,objval,X] = thetaproblem(G,feas,solve); 29 | 30 | if (nargin < 2); feas = 0; end 31 | if (nargin < 3); solve = 0; end 32 | if isempty(feas); feas = 0; end 33 | if ~isreal(G); error('only real G allowed'); end; 34 | 35 | n = length(G); 36 | m = sum(sum(triu(G,1))) + 1; 37 | e1 = [1 zeros(1,m-1)]'; 38 | C{1} = -ones(n); 39 | b = e1; 40 | blk{1,1} = 's'; blk{1,2} = n; 41 | 42 | A = cell(1,m); A{1} = speye(n); 43 | cnt = 2; 44 | for i = 1:n 45 | idx = find(G(i,i+1:n)); 46 | idx = idx+i; %% adjust index. 47 | for j = 1:length(idx) 48 | A{1,cnt} = sparse([i idx(j)],[idx(j) i],[1 1],n,n); 49 | cnt = cnt + 1; 50 | end 51 | end 52 | 53 | Avec = svec(blk,A,ones(size(blk,1),1)); 54 | if (feas == 1) 55 | y0 = -2*n*e1; 56 | Z0 = 2*n*eye(n)+C{1}; 57 | X0 = eye(n)/n; 58 | elseif (feas == 0); 59 | [X0,y0,Z0] = infeaspt(blk,Avec,C,b); 60 | end 61 | if (solve) 62 | [obj,X,y,Z] = sqlp(blk,Avec,C,b,[],X0,y0,Z0); 63 | objval = obj(1); 64 | else 65 | objval = []; X = []; 66 | end 67 | %%======================================================= 68 | 69 | -------------------------------------------------------------------------------- /Solver/blktrace.m: -------------------------------------------------------------------------------- 1 | %%****************************************************************** 2 | %% blktrace: compute + ... + 3 | %% 4 | %%***************************************************************** 5 | %% SDPT3: version 4.0 6 | %% Copyright (c) 1997 by 7 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 8 | %% Last Modified: 16 Sep 2004 9 | %%***************************************************************** 10 | 11 | function trXZ = blktrace(blk,X,Z,parbarrier); 12 | 13 | if (nargin == 3) 14 | trXZ = 0; 15 | for p = 1:size(blk,1) 16 | pblk = blk(p,:); 17 | if strcmp(pblk{1},'s') 18 | if (length(pblk{2}) == 1) 19 | trXZ = trXZ + sum(sum(X{p}.*Z{p})); 20 | else 21 | xx = mexsvec(pblk,X{p},0); 22 | zz = mexsvec(pblk,Z{p}); 23 | trXZ = trXZ + xx'*zz; 24 | end 25 | else 26 | trXZ = trXZ + sum(X{p}.*Z{p}); 27 | end 28 | end 29 | elseif (nargin == 4) 30 | trXZ = 0; 31 | for p = 1:size(blk,1) 32 | pblk = blk(p,:); 33 | if (norm(parbarrier{p}) == 0) 34 | if strcmp(pblk{1},'s') 35 | if (length(pblk{2}) == 1) 36 | trXZ = trXZ + sum(sum(X{p}.*Z{p})); 37 | else 38 | xx = mexsvec(pblk,X{p},0); 39 | zz = mexsvec(pblk,Z{p}); 40 | trXZ = trXZ + xx'*zz; 41 | end 42 | else 43 | trXZ = trXZ + sum(X{p}.*Z{p}); 44 | end 45 | else 46 | idx = find(parbarrier{p} == 0); 47 | if ~isempty(idx) 48 | if strcmp(pblk{1},'s') 49 | sumXZ = sum(X{p}.*Z{p}); 50 | ss = [0,cumsum(pblk{2})]; 51 | for k = 1:length(idx) 52 | idxtmp = [ss(idx(k))+1:ss(idx(k)+1)]; 53 | trXZ = trXZ + sum(sumXZ(idxtmp)); 54 | end 55 | elseif strcmp(pblk{1},'q') 56 | tmp = qops(pblk,X{p},Z{p},1); 57 | trXZ = trXZ + sum(tmp(idx)); 58 | elseif strcmp(pblk{1},'l') 59 | trXZ = trXZ + sum(X{p}(idx).*Z{p}(idx)); 60 | end 61 | end 62 | end 63 | end 64 | end 65 | %%********************************************************************** 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /Examples/gpp.m: -------------------------------------------------------------------------------- 1 | %%******************************************************* 2 | %% gpp: pgraph partitioning problem. 3 | %% 4 | %% (primal problem) min Tr C*X 5 | %% s.t. Tr(ee'*X) = alpha, 6 | %% diag(X) = e, 7 | %% 8 | %% C = -(diag(B*e)-B). 9 | %% 10 | %% (dual problem) max alpha*y1 + e'*y 11 | %% s.t. y1*e*e^T + diag(y) + Z = C. 12 | %%------------------------------------------------------- 13 | %% 14 | %% [blk,Avec,C,b,X0,y0,Z0,objval,X] = gpp(B,alpha,feas,solve); 15 | %% 16 | %% B: weighted adjacency matrix of a graph with n nodes. 17 | %% alpha: any real number, 18 | %% for alpha in (0,n^2), primal problem is strictly feasible. 19 | %% in {0,n^2}, primal problem is feasible but not strictly. 20 | %% outside [0,n^2], primal problem is infeasible. 21 | %% [default = 1]. 22 | %% feas = 1 if want feasible starting point 23 | %% = 0 if otherwise. 24 | %% solve = 0 just to initialize 25 | %% = 1 if want to solve the problem. 26 | %% 27 | %% See graph.m --- generate random adjacency matrix. 28 | %% 29 | %%***************************************************************** 30 | %% SDPT3: version 4.0 31 | %% Copyright (c) 1997 by 32 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 33 | %% Last Modified: 16 Sep 2004 34 | %%***************************************************************** 35 | 36 | function [blk,Avec,C,b,X0,y0,Z0,objval,X] = gpp(B,alpha,feas,solve); 37 | 38 | if nargin < 2; alpha = 1; end; 39 | if nargin < 3; feas = 0; end; 40 | if nargin < 4; solve = 0; end; 41 | if ~isreal(B); error('only real B allowed'); end; 42 | 43 | n = length(B); e = ones(n,1); 44 | C = -(spdiags(B*e,0,n,n)-B); 45 | b = [alpha; e]; 46 | blk{1,1} = 's'; blk{1,2} = n; 47 | 48 | A = cell(1,n+1); 49 | A{1} = e*e'; 50 | for k = 1:n; A{k+1} = sparse(k,k,1,n,n); end; 51 | 52 | Avec = svec(blk,A,ones(size(blk,1),1)); 53 | if (feas == 1); 54 | error('feas = 1, this option is not avaliable'); 55 | elseif (feas == 0); 56 | [X0,y0,Z0] = infeaspt(blk,Avec,C,b); 57 | end 58 | if (solve) 59 | [obj,X,y,Z] = sqlp(blk,Avec,C,b,[],X0,y0,Z0); 60 | objval = obj(1); 61 | else 62 | objval = []; X = []; 63 | end 64 | %%======================================================= 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /Solver/SDPvalBounds.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% compute lower and upper bounds for the exact primal 3 | %% optimal value. 4 | %% 5 | %% LB <= true optimal dual value = true optimal primal value <= UB. 6 | %% 7 | %%***************************************************************** 8 | %% SDPT3: version 4.0 9 | %% Copyright (c) 1997 by 10 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 11 | %% Last Modified: 16 Sep 2004 12 | %%***************************************************************** 13 | 14 | function [LB,UB] = SDPvalBounds(blk,At,C,b,X,y,mu); 15 | 16 | if (nargin < 7); mu = 1.1; end 17 | Aty = Atyfun(blk,At,[],[],y); 18 | Znew = ops(C,'-',Aty); 19 | %% 20 | eigX = cell(size(blk,1),1); 21 | for p = 1:size(blk,1) 22 | pblk = blk(p,:); 23 | if strcmp(pblk{1},'s') 24 | eigX{p} = eig(full(X{p})); 25 | elseif strcmp(pblk{1},'l') 26 | eigX{p} = X{p}; 27 | end 28 | end 29 | %% 30 | %% compute lower bound 31 | %% 32 | pert = 0; 33 | for p = 1:size(blk,1) 34 | pblk = blk(p,:); 35 | if strcmp(pblk{1},'s') 36 | eigtmp = eig(full(Znew{p})); 37 | idx = find(eigtmp < 0); 38 | Xbar = mu*max(eigX{p}); 39 | elseif strcmp(pblk{1},'l') 40 | eigtmp = Znew{p}; 41 | idx = find(eigtmp < 0); 42 | Xbar = mu*max(eigX{p}); 43 | end 44 | numneg = length(idx); 45 | if (numneg) 46 | mineig = min(eigtmp(idx)); 47 | pert = pert + Xbar*sum(eigtmp(idx)); 48 | %%fprintf('\n numneg = %3.0d, mineigZnew = %- 3.2e',numneg,mineig); 49 | end 50 | end 51 | LB0 = b'*y; 52 | LB = b'*y + pert; 53 | fprintf('\n = %-10.9e, LB = %-10.9e\n',LB0,LB); 54 | %% 55 | %% compute upper bound 56 | %% 57 | Xbar = X; 58 | %% construct Xbar that is positive semidefinite 59 | for p = 1:size(blk,1) 60 | pblk = blk(p,:); 61 | n = sum(pblk{2}); 62 | eigXp = eigX{p}; 63 | if strcmp(pblk{1},'s') 64 | Xbar{p} = Xbar{p} - min(eigXp)*speye(n,n); 65 | elseif strcmp(pblk{1},'l') 66 | Xbar{p} = Xbar{p} - min(eigXp)*ones(n,1); 67 | end 68 | end 69 | Rp = b-AXfun(blk,At,[],Xbar); 70 | UB = blktrace(blk,C,Xbar) + mu*abs(y)'*abs(Rp); 71 | UB0 = blktrace(blk,C,X); 72 | fprintf('\n = %-10.9e, UB = %-10.9e\n',UB0,UB); 73 | %%***************************************************************** 74 | 75 | -------------------------------------------------------------------------------- /Solver/Oldmfiles/Installmex.m: -------------------------------------------------------------------------------- 1 | %% 2 | %% Run this script in Matlab command window 3 | %% 4 | 5 | function Installmex 6 | 7 | curdir = pwd; 8 | fprintf(' current directory is: %s\n',curdir); 9 | %% 10 | %% generate mex files in Mexfun 11 | %% 12 | if strcmp(computer,'PCWIN64') | strcmp(computer,'GLNXA64') 13 | computer_model = 64; 14 | else 15 | computer_model = 32; 16 | end 17 | matlabversion = sscanf(version,'%f'); 18 | matlabversion = matlabversion(1); 19 | fsp = filesep; 20 | %% 21 | %% 22 | %% 23 | src = [curdir,fsp,'Solver',fsp,'Mexfun']; 24 | eval(['cd ','Solver',fsp,'Mexfun']); 25 | fprintf ('\n Now compiling the mexFunctions in:\n'); 26 | fprintf (' %s\n',src); 27 | 28 | fname{1} = 'mexProd2'; 29 | fname{2} = 'mexProd2nz'; 30 | fname{3} = 'mexinprod'; 31 | fname{4} = 'mexmat'; 32 | fname{5} = 'mexsmat'; 33 | fname{6} = 'mexsvec'; 34 | fname{7} = 'mexschur'; 35 | fname{8} = 'mexqops'; 36 | fname{9} = 'mexexpand'; 37 | fname{10} = 'mexskron'; 38 | fname{11} = 'mexnnz'; 39 | fname{12} = 'mexschurfun'; 40 | fname{13} = 'mexMatvec'; 41 | fname{14} = 'mextriang'; 42 | fname{15} = 'mextriangsp'; 43 | 44 | if (matlabversion < 7.3) 45 | mexcmd = 'mex -O '; 46 | else 47 | mexcmd = 'mex -O -largeArrayDims '; 48 | end 49 | for k = 1:length(fname) 50 | cmd([mexcmd,fname{k},'.c']); 51 | end 52 | cd .. 53 | cd .. 54 | %% 55 | %% generate mex files in spchol 56 | %% 57 | if (matlabversion < 7.3) 58 | clear fname 59 | src = [curdir,fsp,'Linsysolver',fsp,'spchol']; 60 | eval(['cd ','Linsysolver',fsp,'spchol']); 61 | fprintf ('\n Now compiling the mexFunctions in:\n'); 62 | fprintf (' %s\n',src); 63 | 64 | fname{1} = 'mexordmmd.c ordmmd.c'; 65 | fname{2} = 'mexsymbfct.c symbfct.c'; 66 | fname{3} = 'choltmpsiz.c'; 67 | fname{4} = 'cholsplit.c'; 68 | fname{5} = 'mexsparchol.c sparchol2.c sdmauxFill.c sdmauxScalarmul.c'; 69 | fname{6} = 'mexfwblkslv.c sdmauxScalarmul.c'; 70 | fname{7} = 'mexbwblkslv.c sdmauxFill.c sdmauxRdot.c'; 71 | mexcmd = 'mex -O '; 72 | for k = 1:length(fname) 73 | cmd([mexcmd,fname{k}]); 74 | end 75 | cd .. 76 | cd .. 77 | end 78 | %%*********************************************** 79 | function cmd(s) 80 | 81 | fprintf(' %s\n',s); 82 | eval(s); 83 | %%*********************************************** 84 | -------------------------------------------------------------------------------- /Solver/svec.m: -------------------------------------------------------------------------------- 1 | %****************************************************************** 2 | %% svec: compute the vector svec(M), 3 | %% 4 | %% x = svec(blk,M,isspx); 5 | %%***************************************************************** 6 | %% SDPT3: version 4.0 7 | %% Copyright (c) 1997 by 8 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 9 | %% Last Modified: 16 Sep 2004 10 | %%***************************************************************** 11 | 12 | function x = svec(blk,M,isspx); 13 | 14 | if iscell(M) 15 | if (size(blk,1) ~= size(M,1)) 16 | error('svec: number of rows in blk and M not equal'); 17 | end 18 | if (nargin == 2) 19 | %%if (size(M,2) == 1) 20 | %% isspx = zeros(size(blk,1),1); 21 | %%else 22 | %% isspx = ones(size(blk,1),1); 23 | %%end 24 | isspx = ones(size(blk,1),1); 25 | else 26 | if (length(isspx) < size(blk,1)) 27 | isspx = ones(size(blk,1),1); 28 | end 29 | end 30 | x = cell(size(blk,1),1); 31 | for p=1:size(blk,1) 32 | pblk = blk(p,:); 33 | n = sum(pblk{2}); m = size(M,2); 34 | if strcmp(pblk{1},'s') 35 | n2 = sum(pblk{2}.*(pblk{2}+1))/2; 36 | if (isspx(p)); 37 | x{p} = sparse(n2,m); 38 | else 39 | x{p} = zeros(n2,m); 40 | end 41 | numblk = length(pblk{2}); 42 | if (pblk{2} > 0) 43 | for k = 1:m 44 | if (numblk > 1) & ~issparse(M{p,k}); 45 | x{p}(:,k) = mexsvec(pblk,sparse(M{p,k}),isspx(p)); 46 | else 47 | x{p}(:,k) = mexsvec(pblk,M{p,k},isspx(p)); 48 | end 49 | end 50 | end 51 | else 52 | if (isspx(p)) 53 | x{p} = sparse(n,m); 54 | else 55 | x{p} = zeros(n,m); 56 | end 57 | for k = 1:m 58 | x{p}(:,k) = M{p,k}; 59 | end 60 | end 61 | end 62 | else 63 | if strcmp(blk{1},'s') 64 | numblk = length(blk{2}); 65 | if (numblk > 1) & ~issparse(M); 66 | x = mexsvec(blk,sparse(M),1); 67 | else 68 | x = mexsvec(blk,sparse(M)); 69 | end 70 | else 71 | x = M; 72 | end 73 | end 74 | %%********************************************************** 75 | 76 | -------------------------------------------------------------------------------- /Solver/NTpred.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% NTpred: Compute (dX,dy,dZ) for NT direction. 3 | %% 4 | %% compute SVD of Xchol*Zchol via eigenvalue decompostion of 5 | %% Zchol * X * Zchol' = V * diag(sv2) * V'. 6 | %% compute W satisfying W*Z*W = X. 7 | %% W = G'*G, where G = diag(sqrt(sv)) * (invZchol*V)' 8 | %%***************************************************************** 9 | %% SDPT3: version 4.0 10 | %% Copyright (c) 1997 by 11 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 12 | %% Last Modified: 16 Sep 2004 13 | %%***************************************************************** 14 | 15 | function [par,dX,dy,dZ,coeff,L,hRd] = ... 16 | NTpred(blk,At,par,rp,Rd,sigmu,X,Z,Zchol,invZchol); 17 | 18 | global schurfun schurfun_par 19 | %% 20 | %% compute NT scaling matrix 21 | %% 22 | [par.W,par.G,par.sv,par.gamx,par.gamz,par.dd,par.ee,par.ff] = ... 23 | NTscaling(blk,X,Z,Zchol,invZchol); 24 | %% 25 | %% compute schur matrix 26 | %% 27 | m = length(rp); 28 | schur = sparse(m,m); 29 | UU = []; EE = []; Afree = []; 30 | dX = cell(size(blk,1),1); dy = []; dZ = cell(size(blk,1),1); 31 | %% 32 | for p = 1:size(blk,1) 33 | pblk = blk(p,:); 34 | if strcmp(pblk{1},'l') 35 | [schur,UU,EE] = schurmat_lblk(blk,At,par,schur,UU,EE,p,par.dd); 36 | elseif strcmp(pblk{1},'q'); 37 | [schur,UU,EE] = schurmat_qblk(blk,At,par,schur,UU,EE,p,par.dd,par.ee); 38 | elseif strcmp(pblk{1},'s') 39 | if isempty(schurfun{p}) 40 | schur = schurmat_sblk(blk,At,par,schur,p,par.W); 41 | elseif isstr(schurfun{p}) 42 | schurtmp = sparse(m,m); 43 | if ~isempty(par.permZ{p}) 44 | Wp = par.W{p}(par.permZ{p},par.permZ{p}); 45 | else 46 | Wp = par.W{p}; 47 | end 48 | eval(['schurtmp = ',schurfun{p},'(Wp,Wp,schurfun_par(p,:));']); 49 | schur = schur + schurtmp; 50 | end 51 | elseif strcmp(pblk{1},'u') 52 | Afree = [Afree, At{p}']; 53 | end 54 | end 55 | %% 56 | %% compute rhs 57 | %% 58 | [rhs,EinvRc,hRd] = NTrhsfun(blk,At,par,X,Z,rp,Rd,sigmu); 59 | %% 60 | %% solve linear system 61 | %% 62 | [xx,coeff,L] = linsysolve(par,schur,UU,Afree,EE,rhs); 63 | %% 64 | %% compute (dX,dZ) 65 | %% 66 | [dX,dy,dZ] = NTdirfun(blk,At,par,Rd,EinvRc,xx,m); 67 | %%********************************************************************** 68 | -------------------------------------------------------------------------------- /Examples/etp.m: -------------------------------------------------------------------------------- 1 | %%*********************************************************** 2 | %% etp: Education testing problem. 3 | %% 4 | %% (dual problem) maximize e'*d 5 | %% subject to B - diag(d) >= 0 6 | %% d >= 0 7 | %% 8 | %% (primal problem) minimize Tr B*X 9 | %% subject to X >= 0 10 | %% diag(X) >= e 11 | %% 12 | %% Ref: M.T. Chu, J.W. Wright, IMA J. of Numerical Anal., 13 | %% 15 (1995), pp. 141--160. 14 | %%----------------------------------------------------------- 15 | %% [blk,Avec,C,b,X0,y0,Z0,objval,d] = etp(B,feas,solve); 16 | %% 17 | %% B = nxn positive definite. 18 | %% feas = 1 if want feasible starting point 19 | %% = 0 if otherwise. 20 | %% solve = 0 just to initialize 21 | %% = 1 if want to solve the problem. 22 | %%***************************************************************** 23 | %% SDPT3: version 4.0 24 | %% Copyright (c) 1997 by 25 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 26 | %% Last Modified: 16 Sep 2004 27 | %%***************************************************************** 28 | 29 | function [blk,Avec,C,b,X0,y0,Z0,objval,d] = etp(B,feas,solve); 30 | 31 | if (nargin < 2); feas = 0; end 32 | if (nargin < 3); solve = 0; end 33 | if isempty(feas); feas = 0; end 34 | if (~isreal(B)) 35 | error('only real B allowed'); 36 | elseif (norm(B-B','fro') > 1e-13); 37 | error(' B must be symmetric'); 38 | end; 39 | %% 40 | %% validate B 41 | %% 42 | n = length(B); 43 | d = eig(B); d = real(d); 44 | if (min(d) < 0); 45 | error('B must be positive def'); 46 | end; 47 | %% 48 | %% 49 | blk{1,1} = 's'; blk{1,2} = n; 50 | blk{2,1} = 'l'; blk{2,2} = n; 51 | b = ones(n,1); 52 | C{1,1} = B; 53 | C{2,1} = zeros(n,1); 54 | 55 | A = cell(2,n); 56 | for k = 1:n 57 | A{1,k} = sparse(k,k,1,n,n); 58 | A{2,k} = [zeros(k-1,1); -1; zeros(n-k,1)]; 59 | end; 60 | 61 | Avec = svec(blk,A,ones(size(blk,1),1)); 62 | if (feas == 1); 63 | y0 = 0.9*min(d)*ones(n,1); 64 | Z0 = ops(C,'-',Atyfun(blk,Avec,[],[],y0)); 65 | X0{1,1} = 1.1*eye(n); 66 | X0{2,1} = 0.1*ones(n,1); 67 | elseif (feas == 0); 68 | [X0,y0,Z0] = infeaspt(blk,Avec,C,b); 69 | end; 70 | if (solve) 71 | [obj,X,y,Z] = sqlp(blk,Avec,C,b,[],X0,y0,Z0); 72 | objval = obj(2); 73 | d = y; 74 | else 75 | objval = []; d = []; 76 | end 77 | %%=========================================================== 78 | 79 | -------------------------------------------------------------------------------- /HSDSolver/HSDNTpred.m: -------------------------------------------------------------------------------- 1 | %%********************************************************************** 2 | %% HSDNTpred: Compute (dX,dy,dZ) for NT direction. 3 | %% 4 | %% compute SVD of Xchol*Zchol via eigenvalue decompostion of 5 | %% Zchol * X * Zchol' = V * diag(sv2) * V'. 6 | %% compute W satisfying W*Z*W = X. 7 | %% W = G'*G, where G = diag(sqrt(sv)) * (invZchol*V)' 8 | %% 9 | %% SDPT3: version 3.1 10 | %% Copyright (c) 1997 by 11 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 12 | %% Last Modified: 16 Sep 2004 13 | %%********************************************************************** 14 | 15 | function [par,dX,dy,dZ,coeff,L,hRd] = ... 16 | HSDNTpred(blk,At,par,rp,Rd,sigmu,X,Z,Zchol,invZchol); 17 | 18 | global schurfun schurfun_par 19 | %% 20 | %% compute NT scaling matrix 21 | %% 22 | [par.W,par.G,par.sv,par.gamx,par.gamz,par.dd,par.ee,par.ff] = ... 23 | NTscaling(blk,X,Z,Zchol,invZchol); 24 | %% 25 | %% compute schur matrix 26 | %% 27 | m = par.m; 28 | schur = sparse(m+2,m+2); 29 | UU = []; EE = []; 30 | dX = cell(size(blk,1),1); dy = []; dZ = cell(size(blk,1),1); 31 | %% 32 | for p = 1:size(blk,1) 33 | pblk = blk(p,:); 34 | if strcmp(pblk{1},'l') 35 | [schur,UU,EE] = schurmat_lblk(blk,At,par,schur,UU,EE,p,par.dd); 36 | elseif strcmp(pblk{1},'q'); 37 | [schur,UU,EE] = schurmat_qblk(blk,At,par,schur,UU,EE,p,par.dd,par.ee); 38 | elseif strcmp(pblk{1},'s') 39 | if isempty(schurfun{p}) 40 | schur = schurmat_sblk(blk,At,par,schur,p,par.W); 41 | elseif isstr(schurfun{p}) 42 | schurtmp = sparse(m,m); 43 | if ~isempty(par.permZ{p}) 44 | Wp = par.W{p}(par.permZ{p},par.permZ{p}); 45 | else 46 | Wp = par.W{p}; 47 | end 48 | eval(['schurtmp = ',schurfun{p},'(Wp,Wp,schurfun_par(p,:));']); 49 | schur = schur + schurtmp; 50 | end 51 | end 52 | end 53 | %% 54 | %% compute rhs 55 | %% 56 | [rhs,EinvRc,hRd] = HSDNTrhsfun(blk,At,par,X,Z,rp,Rd,sigmu); 57 | %% 58 | %% solve linear system 59 | %% 60 | par.addschur = par.kap/par.tau; 61 | schur(m+1,m+1) = schur(m+1,m+1) + par.kap/par.tau; 62 | schur(m+2,m+2) = schur(m+2,m+2) + par.addschur; 63 | [xx,coeff,L] = HSDlinsysolve(par,schur,UU,EE,par.Umat,rhs); 64 | %% 65 | %% compute (dX,dZ) 66 | %% 67 | [par,dX,dy,dZ] = HSDNTdirfun(blk,At,par,Rd,EinvRc,xx); 68 | %%********************************************************************** 69 | -------------------------------------------------------------------------------- /Solver/Mexfun/Oldfiles/mexschurfun_old.c: -------------------------------------------------------------------------------- 1 | /************************************************************************ 2 | * mexschurfun(X,dd,options) 3 | * options = 1, add dd to the diagonal of X (a square matrix) 4 | * options = 2, add the scalar dd to X. 5 | ************************************************************************/ 6 | 7 | #include "mex.h" 8 | #include 9 | 10 | /******************************************************************** 11 | PROCEDURE mexFunction - Entry for Matlab 12 | *********************************************************************/ 13 | void mexFunction(const int nlhs, mxArray *plhs[], 14 | const int nrhs, const mxArray *prhs[]) 15 | { 16 | int n; 17 | double *X, *dd; 18 | int *irX, *jcX; 19 | int isspX, j, jn, k, kstart, kend, r; 20 | int options; 21 | double tmp, tmp2, ddtmp; 22 | 23 | if(nrhs < 2) 24 | mexErrMsgTxt("mexschurfun: requires at least 2 input arguments."); 25 | if(nlhs > 0) 26 | mexErrMsgTxt("mexschurfun: requires no output argument."); 27 | 28 | X = mxGetPr(prhs[0]); 29 | isspX = mxIsSparse(prhs[0]); 30 | if (isspX) { 31 | irX = mxGetIr(prhs[0]); 32 | jcX = mxGetJc(prhs[0]); 33 | } 34 | n = mxGetM(prhs[0]); 35 | if ( n != mxGetN(prhs[0]) ) 36 | mexErrMsgTxt("X should be square."); 37 | dd = mxGetPr(prhs[1]); 38 | if (mxIsSparse(prhs[1])) 39 | mexErrMsgTxt("Sparse dd not supported by mexschurfun."); 40 | if (nrhs == 2) { 41 | options = 1; 42 | } else { 43 | options = (int) (*mxGetPr(prhs[2])); 44 | ddtmp = dd[0]; 45 | } 46 | /********************************************************/ 47 | if (options==1) { 48 | if (isspX) { 49 | for (j=0; j 9 | 10 | /******************************************************************** 11 | PROCEDURE mexFunction - Entry for Matlab 12 | *********************************************************************/ 13 | void mexFunction(const int nlhs, mxArray *plhs[], 14 | const int nrhs, const mxArray *prhs[]) 15 | { 16 | int n; 17 | double *X, *dd; 18 | int *irX, *jcX; 19 | int isspX, j, jn, k, kstart, kend, r; 20 | int options; 21 | double tmp, tmp2, ddtmp; 22 | 23 | if(nrhs < 2) 24 | mexErrMsgTxt("mexschurfun: requires at least 2 input arguments."); 25 | if(nlhs > 0) 26 | mexErrMsgTxt("mexschurfun: requires no output argument."); 27 | 28 | X = mxGetPr(prhs[0]); 29 | isspX = mxIsSparse(prhs[0]); 30 | if (isspX) { 31 | irX = mxGetIr(prhs[0]); 32 | jcX = mxGetJc(prhs[0]); 33 | } 34 | n = mxGetM(prhs[0]); 35 | if ( n != mxGetN(prhs[0]) ) 36 | mexErrMsgTxt("X should be square."); 37 | dd = mxGetPr(prhs[1]); 38 | if (mxIsSparse(prhs[1])) 39 | mexErrMsgTxt("Sparse dd not supported by mexschurfun."); 40 | if (nrhs == 2) { 41 | options = 1; 42 | } else { 43 | options = (int) (*mxGetPr(prhs[2])); 44 | ddtmp = dd[0]; 45 | } 46 | /********************************************************/ 47 | if (options==1) { 48 | if (isspX) { 49 | for (j=0; j 2) %% for low rank constraints 28 | dd = At{p,3}; 29 | m2 = m-m1; 30 | ss = [0,cumsum(pblk{3})]; 31 | for k=1:m2 32 | idx = [ss(k)+1:ss(k+1)]; 33 | V = At{p,2}(:,idx); 34 | ii = dd(idx,1)-ss(k); %% undo cumulative indexing 35 | jj = dd(idx,2)-ss(k); 36 | len = pblk{3}(k); 37 | D = spconvert([ii,jj,dd(idx,3); len,len,0]); 38 | normA(m1+k) = normA(m1+k) + norm(V'*V*D,'fro'); 39 | end 40 | end 41 | else 42 | normA = normA + sqrt(sum(At{p,1}.*At{p,1}))'; 43 | end 44 | end 45 | normA = max(1,normA); 46 | %% 47 | for p=1:numblk 48 | pblk = blk(p,:); 49 | if strcmp(pblk{1},'s') 50 | m1 = size(At{p,1},2); 51 | m2 = m - m1; 52 | At{p,1} = At{p,1}*spdiags(1./normA(1:m1),0,m1,m1); 53 | if (m2 > 0) %% for low rank constaints 54 | yy2 = mexexpand(pblk{3},normA(m1+[1:m2])); 55 | At{p,3}(:,3) = At{p,3}(:,3)./yy2; 56 | end 57 | else 58 | At{p,1} = At{p,1}*spdiags(1./normA,0,m,m); 59 | end 60 | end 61 | b = b./normA; normb = max(1,norm(b)); 62 | b = b/normb; 63 | 64 | normC = 0; 65 | for p=1:numblk 66 | normC = normC + sum(sum(C{p}.*C{p})); 67 | end 68 | normC = sqrt(normC); 69 | normC = max(1,normC); 70 | y0 = y0.*normA/normC; 71 | for p=1:numblk 72 | C{p} = C{p}/normC; 73 | X0{p} = X0{p}/normb; 74 | Z0{p} = Z0{p}/normC; 75 | end 76 | %%******************************************************************** 77 | -------------------------------------------------------------------------------- /Solver/scaling.m: -------------------------------------------------------------------------------- 1 | %%******************************************************************** 2 | %% scaling: scale the SDP data so that A_k,C,b have unit norm. 3 | %% 4 | %% [At,C,b,normA,normC,normb,X0,y0,Z0] = scaling(blk,At,C,b,X0,y0,Z0); 5 | %% 6 | %% The linear objective function value is unchanged under 7 | %% the scaling. 8 | %%***************************************************************** 9 | %% SDPT3: version 4.0 10 | %% Copyright (c) 1997 by 11 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 12 | %% Last Modified: 16 Sep 2004 13 | %%***************************************************************** 14 | 15 | function [At,C,b,normA,normC,normb,X0,y0,Z0] = scaling(blk,At,C,b,X0,y0,Z0); 16 | 17 | m = length(b); 18 | numblk = size(blk,1); 19 | 20 | normA = cell(numblk,1); 21 | for p = 1:numblk 22 | pblk = blk(p,:); 23 | if strcmp(pblk{1},'s') 24 | m1 = size(At{p,1},2); 25 | if (m1 > 0) 26 | normAp2 = sum(sum(At{p,1}.*At{p,1})); 27 | else 28 | normAp2 = 0; 29 | end 30 | if (length(pblk) > 2) %% for low rank constraints 31 | dd = At{p,3}; 32 | m2 = m-m1; 33 | ss = [0,cumsum(pblk{3})]; 34 | for k=1:m2 35 | idx = [ss(k)+1:ss(k+1)]; 36 | V = At{p,2}(:,idx); 37 | ii = dd(idx,1)-ss(k); %% undo cumulative indexing 38 | jj = dd(idx,2)-ss(k); 39 | len = pblk{3}(k); 40 | D = spconvert([ii,jj,dd(idx,3); len,len,0]); 41 | tmp = V'*V*D; 42 | normAp2 = normAp2 + sum(sum(tmp.*tmp')); 43 | end 44 | end 45 | else 46 | normAp2 = sum(sum(At{p,1}.*At{p,1})); 47 | end 48 | normAp = sqrt(normAp2); 49 | normA{p} = max(1,sqrt(normAp)); 50 | end 51 | %% 52 | normb = max(1,norm(b)); 53 | normC = 0; 54 | for p = 1:numblk 55 | normC = max(normC,norm(C{p},'fro')); 56 | end 57 | normC = max(1,normC); 58 | %% 59 | for p = 1:numblk 60 | pblk = blk(p,:); 61 | if strcmp(pblk{1},'s') 62 | m1 = size(At{p,1},2); 63 | m2 = m - m1; 64 | At{p,1} = At{p,1}/normA{p}; 65 | if (m2 > 0) %% for low rank constaints 66 | At{p,3}(:,3) = At{p,3}(:,3)/normA{p}; 67 | end 68 | else 69 | At{p,1} = At{p,1}/normA{p}; 70 | end 71 | C{p} = C{p}/(normC*normA{p}); 72 | if (nargin == 7) 73 | X0{p} = X0{p}*normA{p}; 74 | Z0{p} = Z0{p}/(normC*normA{p}); 75 | end 76 | end 77 | b = b/normb; 78 | %%******************************************************************** 79 | -------------------------------------------------------------------------------- /HSDSolver/etc/HSDgmres.m: -------------------------------------------------------------------------------- 1 | %%**************************************************************** 2 | %% GMRES 3 | %% 4 | %%**************************************************************** 5 | 6 | function [x,resnrm,flag] = HSDgmres(A,b,M,tol,maxit,printlevel) 7 | 8 | N = length(b); 9 | if (nargin < 6); printlevel = 1; end 10 | if (nargin < 5) | isempty(maxit); maxit = min(20,max(5,length(A.mat22))); end; 11 | if (nargin < 4) | isempty(tol); tol = 1e-8; end; 12 | tolb = min(1e-4,tol*norm(b)); 13 | flag = 1; 14 | 15 | m = maxit; 16 | V = zeros(N,m+1); 17 | H = zeros(m+1,m); 18 | V(:,1) = b/norm(b); 19 | resnrm(1) = norm(b); 20 | %% 21 | for k = 1:m 22 | tmp = precond(A,M,V(:,k)); 23 | if isstruct(A); v = matvec(A,tmp); else; v = mexMatvec(A,tmp); end; 24 | for j = 1:k 25 | H(j,k) = (V(:,j))'*v; 26 | v = v - H(j,k)*V(:,j); 27 | end; 28 | H(k+1,k) = norm(v); 29 | V(:,k+1) = v/H(k+1,k); 30 | 31 | d = norm(b)*eye(k+1,1); 32 | y = H(1:k+1,1:k)\d; 33 | err = norm(H(1:k+1,1:k)*y - d); 34 | resnrm(k+1) = err; 35 | if (err < tolb); break; end; 36 | end; 37 | x = precond(A,M,V(:,1:k)*y); 38 | %% 39 | %%************************************************************************* 40 | %% matvec: matrix-vector multiply. 41 | %% matrix = [A.mat11, A.mat12; A.mat12', A.mat22] 42 | %%************************************************************************* 43 | 44 | function Ax = matvec(A,x); 45 | 46 | m = length(A.mat11); m2 = length(x)-m; 47 | if (m2 > 0) 48 | x1 = full(x(1:m)); 49 | else 50 | x1 = full(x); 51 | end 52 | Ax = mexMatvec(A.mat11,x1); 53 | if (m2 > 0) 54 | x2 = full(x(m+[1:m2])); 55 | Ax = Ax + mexMatvec(A.mat12,x2); 56 | Ax2 = mexMatvec(A.mat12,x1,1) + mexMatvec(A.mat22,x2); 57 | Ax = [Ax; Ax2]; 58 | end 59 | %%************************************************************************* 60 | %% precond: 61 | %%************************************************************************* 62 | 63 | function Mx = precond(A,L,x) 64 | 65 | m = length(L.perm); m2 = length(x)-m; 66 | if (m2 > 0) 67 | x1 = full(x(1:m)); 68 | else 69 | x1 = full(x); 70 | end 71 | if (m2 > 0) 72 | x2 = x(m+[1:m2]); 73 | w = linsysolvefun(L,x1); 74 | z = mexMatvec(A.mat12,w,1) -x2; 75 | z = L.Mu \ (L.Ml \ (L.Mp*z)); 76 | x1 = x1 - mexMatvec(A.mat12,z); 77 | end 78 | %% 79 | Mx = linsysolvefun(L,x1); 80 | %% 81 | if (m2 > 0) 82 | Mx = [Mx; z]; 83 | end 84 | %%************************************************************************* 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /HSDSolver/HSDsqlpCpert.m: -------------------------------------------------------------------------------- 1 | %%***************************************************************** 2 | %% HSDsqlpCpert: perturb C. 3 | %%***************************************************************** 4 | %% SDPT3: version 4.0 5 | %% Copyright (c) 1997 by 6 | %% Kim-Chuan Toh, Michael J. Todd, Reha H. Tutuncu 7 | %% Last Modified: 16 Sep 2004 8 | %%***************************************************************** 9 | 10 | function [At,Cpert] = HSDsqlpCpert(blk,At,par,C,X,Cpert,runhist) 11 | 12 | iter = length(runhist.pinfeas); 13 | prim_infeas = runhist.pinfeas(iter); 14 | dual_infeas = runhist.dinfeas(iter); 15 | relgap = runhist.relgap(iter); 16 | infeas = runhist.infeas(iter); 17 | theta = runhist.theta(iter); 18 | %% 19 | Cpertold = Cpert; 20 | err = max(relgap,infeas); 21 | for p = 1:size(blk,1) 22 | pblk = blk(p,:); 23 | n = sum(pblk{2}); 24 | tmp = max(1,norm(C{p},'fro'))/sqrt(n); 25 | if (err < 1e-6) 26 | if (norm(X{p},'fro') < 1e2); const=0.2; else; const=0.3; end 27 | Cpert(p) = max(const*Cpert(p),1e-10*tmp); 28 | elseif (err < 1e-2) 29 | if (norm(X{p},'fro') < 1e2); const=0.4; else; const=0.5; end 30 | Cpert(p) = max(const*Cpert(p),1e-8*tmp); 31 | else 32 | Cpert(p) = max(0.9*Cpert(p),1e-6*tmp); 33 | end 34 | Cpert = min(Cpert,Cpertold); 35 | if (prim_infeas < min([0.1*dual_infeas, 1e-7*runhist.pinfeas(1)])) ... 36 | & (iter > 1 & dual_infeas > 0.8*runhist.dinfeas(iter-1) & relgap < 1e-4) 37 | Cpert(p) = 0.5*Cpert(p); 38 | elseif (dual_infeas < min([0.1*prim_infeas, 1e-7*runhist.dinfeas(1)])) ... 39 | & (iter > 1 & prim_infeas > 0.8*runhist.pinfeas(iter-1) & relgap < 1e-4) 40 | Cpert(p) = 0.5*Cpert(p); 41 | elseif (max(relgap,1e-2*infeas) < 1e-6 & relgap < 0.1*infeas) 42 | Cpert(p) = 0.5*Cpert(p); 43 | end 44 | if (prim_infeas < min([1e-4*dual_infeas,1e-7]) & theta < 1e-6) ... 45 | | (prim_infeas < 1e-4 & theta < 1e-10) 46 | Cpert(p) = 0.1*Cpert(p); 47 | elseif (dual_infeas < min([1e-4*prim_infeas,1e-7]) & theta < 1e-6) ... 48 | | (dual_infeas < 1e-4 & theta < 1e-10) 49 | Cpert(p) = 0.1*Cpert(p); 50 | elseif (iter > 1 & theta > 0.9*runhist.theta(iter-1) & infeas < 1e-3) 51 | Cpert(p) = 0.1*Cpert(p); 52 | end 53 | if strcmp(pblk{1},'s') 54 | Cnew = C{p} + Cpert(p)*speye(n); 55 | At{p}(:,par.invpermA(p,end-1)) = -svec(pblk,Cnew,1); 56 | else 57 | Cnew = C{p} + Cpert(p)*ones(n,1); 58 | At{p}(:,par.invpermA(p,end-1)) = -Cnew; 59 | end 60 | end 61 | %%***************************************************************************** 62 | -------------------------------------------------------------------------------- /Solver/combine_blk.m: -------------------------------------------------------------------------------- 1 | %%****************************************************************** 2 | %% combine_blk: combine small SDP blocks together, 3 | %% combine all SOCP blocks together, etc 4 | %% 5 | %% [blk2,At2,C2,blkinfo] = combine_blk(blk,At,C); 6 | %% 7 | %%***************************************************************** 8 | %% SDPT3: version 4.0 9 | %% Copyright (c) 1997 by 10 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 11 | %% Last Modified: 16 Sep 2004 12 | %%***************************************************************** 13 | 14 | function [blk2,At2,C2,blkinfo] = combine_blk(blk,At,C); 15 | 16 | blkinfo = zeros(size(blk,1),1); 17 | for p = 1:size(blk,1) 18 | pblk = blk(p,:); 19 | if strcmp(pblk{1},'s') 20 | if (sum(pblk{2}) < 100) 21 | blkinfo(p) = 1; 22 | end 23 | elseif strcmp(pblk{1},'q') 24 | blkinfo(p) = 2; 25 | elseif strcmp(pblk{1},'r') 26 | blkinfo(p) = 3; 27 | elseif strcmp(pblk{1},'l') 28 | blkinfo(p) = 4; 29 | elseif strcmp(pblk{1},'u') 30 | blkinfo(p) = 5; 31 | end 32 | end 33 | numblk0 = length(find(blkinfo == 0)); 34 | numblk = numblk0 + length(union(blkinfo(blkinfo > 0),[])); 35 | blk2 = cell(numblk,2); At2 = cell(numblk,1); C2 = cell(numblk,1); 36 | cnt = 0; 37 | idx = find(blkinfo==0); %% larger SDP blocks 38 | if ~isempty(idx) 39 | len = length(idx); 40 | blk2(1:len,:) = blk(idx,:); 41 | At2(1:len) = At(idx); C2(1:len) = C(idx); 42 | cnt = len; 43 | end 44 | idx = find(blkinfo==1); %% smaller SDP blocks 45 | Ctmp = []; idxstart = 0; 46 | if ~isempty(idx) 47 | cnt = cnt + 1; 48 | blk2{cnt,1} = 's'; blk2{cnt,2} = []; 49 | len = length(idx); 50 | for k = 1:len 51 | blk2{cnt,2} = [blk2{cnt,2}, blk{idx(k),2}]; 52 | At2{cnt} = [At2{cnt}; At{idx(k)}]; 53 | [ii,jj,vv] = find(C{idx(k)}); 54 | Ctmp = [Ctmp; [idxstart+ii,idxstart+jj,vv]]; 55 | idxstart = idxstart + sum(blk{idx(k),2}); 56 | end 57 | end 58 | n = sum(blk2{cnt,2}); 59 | C2{cnt} = spconvert([Ctmp; n,n,0]); 60 | %% 61 | for L = [2:5] 62 | idx = find(blkinfo==L); 63 | if ~isempty(idx) 64 | cnt = cnt + 1; 65 | if (L==2) 66 | blk2{cnt,1} = 'q'; 67 | elseif (L==3) 68 | blk2{cnt,1} = 'r'; 69 | elseif (L==4) 70 | blk2{cnt,1} = 'l'; 71 | elseif (L==5) 72 | blk2{cnt,1} = 'u'; 73 | end 74 | blk2{cnt,2} = []; 75 | len = length(idx); 76 | for k = 1:len 77 | blk2{cnt,2} = [blk2{cnt,2}, blk{idx(k),2}]; 78 | At2{cnt} = [At2{cnt}; At{idx(k)}]; 79 | C2{cnt} = [C2{cnt}; C{idx(k)}]; 80 | end 81 | end 82 | end 83 | %%******************************************************************* 84 | -------------------------------------------------------------------------------- /Solver/Oldmfiles/schurmat_sblkold.m: -------------------------------------------------------------------------------- 1 | %%******************************************************************* 2 | %% schurmat_sblk: compute Schur complement matrix corresponding to 3 | %% SDP blocks. 4 | %% 5 | %% symm = 0, HKM 6 | %% = 1, NT 7 | %% 8 | %% SDPT3: version 3.0 9 | %% Copyright (c) 1997 by 10 | %% K.C. Toh, M.J. Todd, R.H. Tutuncu 11 | %% Last modified: 2 Feb 01 12 | %%******************************************************************* 13 | 14 | function schur = schurmat_sblk(blk,At,par,schur,p,X,Y); 15 | 16 | global smallblkdim 17 | 18 | if (nargin == 7); symm = 0; else; symm = 1; Y = X; end; 19 | m = length(schur); 20 | pblk = blk(p,:); 21 | %% 22 | if (max(pblk{2}) > smallblkdim) 23 | %% 24 | %% compute schur for matrices that are very sparse. 25 | %% 26 | if issparse(schur); schur = full(schur); end; 27 | J = max(find(par.nzlistA{p,1} < inf)) -1; 28 | if (J > 0) 29 | if issparse(X{p}) & ~issparse(Y{p}); X{p} = full(X{p}); end 30 | if ~issparse(X{p}) & issparse(Y{p}); Y{p} = full(Y{p}); end 31 | nnzspschur = mexschur(pblk,At{p},par.nzlistA{p,1},... 32 | par.nzlistA{p,2},par.permA(p,:),Y{p},X{p},J,symm,schur); 33 | end 34 | %% 35 | %% compute schur for matrices that are not so sparse or dense. 36 | %% 37 | L = max(find(par.nzlistAsum{p,1} < inf)) -1; 38 | if (J < L) 39 | len = par.nzlistAsum{p,1}(J+1); list = par.nzlistAsum{p,2}(1:len,:); 40 | end 41 | for k = J+1:m 42 | isspAk = par.isspA(p,k); 43 | Ak = mexsmat(blk,At,isspAk,p,k); 44 | if (k <= L) 45 | idx1 = par.nzlistAsum{p,1}(k)+1; idx2 = par.nzlistAsum{p,1}(k+1); 46 | list = [list; par.nzlistAsum{p,2}(idx1:idx2,:)]; 47 | list = sortrows(list,[2 1]); 48 | tmp = Prod3(pblk,X{p},Ak,Y{p},symm,list); 49 | else 50 | tmp = Prod3(pblk,X{p},Ak,Y{p},symm); 51 | end 52 | if ~symm 53 | tmp = 0.5*(mexsvec(pblk,tmp) + mexsvec(pblk,tmp,[],1)); 54 | else 55 | tmp = mexsvec(pblk,tmp); 56 | end 57 | permk = par.permA(p,k); 58 | idx = par.permA(p,1:k); 59 | tmp2 = schur(idx,permk) + mexinprod(blk,At,tmp,k,p); 60 | schur(idx,permk) = tmp2; 61 | schur(permk,idx) = tmp2'; 62 | end 63 | else 64 | if issparse(X{p}) & ~issparse(Y{p}); Y{p} = sparse(Y{p}); end 65 | if ~issparse(X{p}) & issparse(Y{p}); X{p} = sparse(X{p}); end 66 | tmp = mexskron(pblk,X{p},Y{p}); 67 | Perm = spconvert([(1:m)' par.permA(p,:)' ones(m,1)]); 68 | schurtmp = At{p}'*tmp*At{p}; 69 | schurtmp = 0.5*(schurtmp + schurtmp'); 70 | schur = schur + Perm'*schurtmp*Perm; 71 | end 72 | %%******************************************************************* 73 | --------------------------------------------------------------------------------