Skip to content
Snippets Groups Projects
Commit 29ad06ab authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

Vložení SDPA - solveru na semidef. programování

Staženo z: https://sourceforge.net/projects/sdpa/files/sdpa-c/sdpa-c.7.3.8.src.20180125.tar.gz/download
https://sdpa.sourceforge.net/download.html#sdpa

Z jejich stránky:

> Thank you very much for your consideration to refer our papers. When you refer our papers in your papers, please cite the following papers.
>
> SDPA Family
> "Latest developments in the SDPA Family for solving large-scale SDPs,"
> Makoto Yamashita, Katsuki Fujisawa, Mituhiro Fukuda, Kazuhiro Kobayashi, Kazuhide Nakta, Maho Nakata,
> In Handbook on Semidefinite, Cone and Polynomial Optimization: Theory, Algorithms, Software and Applications ,
> edited by Miguel F. Anjos and Jean B. Lasserre, , Springer, NY, USA, Chapter 24, pp. 687--714 (2011)
> > SDPA
> "Implementation and evaluation of SDPA 6.0 (SemiDefinite Programming Algorithm 6.0),"
> Makoto Yamashita, Katsuki Fujisawa, and Masakazu Kojima,
> Optimization Methods and Software 18, 491-505, 2003.
> "A high-performance software package for semidefinite programs: SDPA 7,"
> Makoto Yamashita, Katsuki Fujisawa, Kazuhide Nakata, Maho Nakata, Mituhiro Fukuda, Kazuhiro Kobayashi, and Kazushige Goto,
> Research Report B-460 Dept. of Mathematical and Computing Science, Tokyo Institute of Technology, Tokyo, Japan, September, 2010.
parent 7776ddce
No related branches found
No related tags found
No related merge requests found
Showing
with 1713 additions and 0 deletions
--------------------------------------------------
Copyright (C) 1995-2011 SDPA Project
--------------------------------------------------
We appreciate your comments, suggestions, and questions about SDP
and/or the SDPA software. We also consider questions such as "I can
not install the SDPA on my computer," "I can not formulate my problem
in SDPA format," "I found a bug in the software," etc.
To contact SDPA project, refer the following Web page.
https://sdpa.sourceforge.net/contact.html
The member list of SDPA project is available there.
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
SDPA-C 7.3.8 from SDPA-C 6 / 2013-10-21 Makoto Yamashita
* Based on SDPA 7.3.8
* Employ CHOLMOD for sparse Cholesky factoization
to the variable matrices
* Efficient computation for the Schur complement matrix
* New callable library
* New Matlab/Octave interface
* Multiple-threaded computation
SDPA-C 7.3.X Install Manual
[Copyright (C) 2004-2013 SDPA Project]
This text explains how to install SDPA-C.
If you have questions on the installation,
please contact us from
http://sdpa.sourceforge.net/contact.html
The user-manual of SDPA is available for SDPA-C, and can be downloaded at
https://sourceforge.net/projects/sdpa/files/sdpa/sdpa.7.1.1.manual.20080618.pdf/download
--- index ------------------------------------
1. Install the SDPA-C
2. Compile callable-library example [optional]
3. Compile Matlab Interface [optional]
4. Difference from SDPA
5. If you have some trouble
----------------------------------------------
1. Install the SDPA-C
(1) Check your environment
Requirement: wget, git
Recommendation: gcc (>= 4.2), g++ (>= 4.2), gfortran (>=4.2)
We have checked the compilation on RedHat Linux (version 6)
and Debian (wheezy).
Other C/C++/Fortran compilers than gcc/g++/gfortran may be
available, but we have not tested them.
(2) Download the SDPA from the SDPA Homepage
http://sdpa.sourceforge.net/download.html
You can get the sdpa-c_7.3.X.tar.gz, then unpack the file
$ tar xzf sdpa-c_7.3.X.tar.gz
You will find the directory 'sdpa-c'.
$ cd sdpa-c
(3) Edit make.inc
At least you should check 'sdpac_dir'.
In the default setting, sdpac_dir is $(HOME)/sdpa-c.
In other words, the default setting assumes
you unpacked the downloaded file in your home directory.
(4) Compile SDPA-C
$ make all
will compile SuiteSparse, MUMPS, OpenBLAS, then SDPA-C.
If you want compile them step by step,
$ make SuiteSparse
$ make MUMPS
$ make OpenBLAS
$ make sdpa-c
(5) Test SDPA-C
Try the following command to execute sdpa
$ cd $HOME/sdpa-c
$ ./sdpa-c
Then you will see message from SDPA and can check command line options.
To solve input dat-s and write its result,
$ ./sdpa example1.dat-s example1.result
If you specify the number of threads with the SDPA-C,
set OMP_NUM_THREADS environment variable(ex. export OMP_NUM_THREADS=4).
----------------------------------------------
2. Compile callable-library example (optional)
To compile callable-library example, use 'make' command
in 'libexample' directory
$ cd $HOME/sdpa-c/libexample
$ make
The details of callable-library can be found in SDPA user manual.
----------------------------------------------
3. Compile Matlab Interface (optional)
To compile the Matlab interface, use 'make matlab' command.
$ cd $HOME/sdpa-c
$ make matlab
If you use Octave instead of Matlab, then
$ cd $HOME/sdpa-c
$ make octave
Since the usage of this Matlab Interface as SDPA-M 6.2.0,
SDPA-M 6.2.0 manual is very useful.
(https://sourceforge.net/projects/sdpa/files/sdpa-m/sdpamManual.pdf/download)
In addition, the file 'mex/CommandList.txt' summarizes
each command.
When you have trouble with SDPA-M(Matlab environment),
the following command will display useful messages.
$ matlab -Dgdb
[On gdb environment]
(gdb) run -nodisplay
[On Matlab environment]
>> (Call SDPA-M by sdpam or sedumiwrap)
If Matlab aborts, try the following command in gdb environment.
(gdb) where
The command 'where' will display what happened.
To exit gdb environment,
(gdb) quit
In some case, the segmentation fault may be avoided by
$ export LD_PRELOAD=/usr/lib/gcc/x86_64-linux-gnu/4.4/libgfortran.so:$LD_PRELOAD
$ export LD_PRELOAD=/usr/lib/gcc/x86_64-linux-gnu/4.4/libstdc++.so:$LD_PRELOAD
$ export LD_PRELOAD=/usr/lib/gcc/x86_64-linux-gnu/4.4/libgcc_s.so:$LD_PRELOAD
$ matlab
In particular, when the gcc version is higher than the version Matlab
assumes, Matlab sometimes can not load appropriate shared libraries.
The command above load the libraries before Matlab launches.
-------------------------------------------------------
4. Deference from SDPA
(1) Since SDPA-C employs the completion method, which extensively
uses the structural sparsity, the SDPA dense format is not acceptable.
More precisely, example1.dat-s is available while example1.dat is not.
(2) In the callable library, some function mainly related to the dense
input file are not available.
In addition, the function SDPA::terminate() is renamed as
SDPA::finalize().
In libexample directory, the difference in example1,2,5.cpp from SDPA
is only terminate() to finalize().
However, the example3,4,6.cpp in SDPA contained the functions
which are not available in SDPA-C. We removed these examples
from the SDPA-C package.
(3) param.sdpa is renamed as param.sdpaC.
(4) The matlab interface only contains the mex functions of SDPA-C.
If you want to read the SDPA sparse format, you should employ
such routines from SDPA. We suggest you add the paths of both SDPA
and SDPA-C to the Matlab search path.
-------------------------------------------------------
5. If you have some trouble
If some bugs are found or you encounter some trouble
when you are compiling SDPA, please let us know from
http://sdpa.sourceforge.net/contact.html
In particular, attaching error messages and/or 'config.log' file
is very useful to let us understand your situation.
## This is Makefile for SDPA-C
## Requirement :: wget, git
## Recommendation :: gcc (>= 4.2), g++ (>=4.2), gfortran (>= 4.2),
## Before the compilation, examine the file 'make.inc'
## To compile SDPA-C, 'make all'
## This will compile SuiteSparse, MUMPS, OpenBLAS, then SDPA-C
## To compile mex, 'make matlab' or 'make octave'
-include make.inc
-include make.obj
.PHONY: SuiteSparse MUMPS OpenBLAS
all: $(sdpac_exe)
matlab: all
(cd mex; make DEVELOPEMENT_STAGE=1)
@echo === Add "$(sdpac_dir)/mex" to your Matlab path. ===
octave: all
(cd mex; make DEVELOPEMENT_STAGE=1 COMPILE_ENVIRONMENT=octave)
@echo === Add "$(sdpac_dir)/mex" to your octave path. ===
$(sdpac_exe): SuiteSparse MUMPS OpenBLAS $(sdpac_lib) sdpa_exe.o
$(CXX) $(CXXFLAGS) -o $@ sdpa_exe.o $(sdpac_lib) $(sdpac_all_lib)
$(sdpac_lib): $(OBJ)
rm -f $@
ar r $@ $(OBJ)
ranlib $@
.cpp.o:
$(CXX) $(CXXFLAGS) -c -o $@ -I. $(sdpac_all_include) \
-DVERSION=$(SDPAC_VERSION) $<
SuiteSparse:$(suitesparse_lib)
$(suitesparse_lib):
(cd $(sdpac_dir); \
rm -rf SuiteSparse; \
wget http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-$(suitesparse_ver).tar.gz; \
tar xzf SuiteSparse-$(suitesparse_ver).tar.gz; \
rm -f SuiteSparse-$(suitesparse_ver).tar.gz; )
(cd $(suitesparse_dir); \
cd $(suitesparse_dir)/metis-5.1.0; \
make config cc=$(CC); \
make ; \
cp build/*/libmetis/libmetis.a . )
( cd $(suitesparse_dir); \
echo CC = $(CC) >> $(suitesparse_dir)/SuiteSparse_config/SuiteSparse_config.mk; \
echo CF = $(CFLAGS) -fexceptions >> $(suitesparse_dir)/SuiteSparse_config/SuiteSparse_config.mk; \
echo CC = $(CC) >> $(suitesparse_dir)/CSparse/Lib/Makefile; \
cd $(suitesparse_dir); \
make)
MUMPS:$(mumps_lib)
$(mumps_lib):
(cd $(sdpac_dir); \
rm -rf mumps; \
wget wget http://ftp.de.debian.org/debian/pool/main/m/mumps/$(mumps_tar_file); \
tar xzf $(mumps_tar_file); \
rm -f $(mumps_tar_file); \
mv -f MUMPS_$(mumps_ver)/ $(mumps_dir); \
cd $(mumps_dir); \
cp Make.inc/Makefile.inc.generic.SEQ Makefile.inc; \
echo "CC = " $(CC) >> Makefile.inc; \
echo "FC = " $(FC) >> Makefile.inc; \
echo "FL = " $(FC) >> Makefile.inc; \
echo "OPTC = " $(CFLAGS) >> Makefile.inc; \
echo "OPTF = " $(FCFLAGS) >> Makefile.inc; \
echo "OPTL = " $(FCFLAGS) >> Makefile.inc; \
echo "LPORDDIR = "`pwd`"/PORD/lib/" >> Makefile.inc; \
echo "IPORDDIR = "`pwd`"/PORD/include/" >> Makefile.inc; \
make d;)
OpenBLAS:$(openblas_lib)
$(openblas_lib):
(cd $(sdpac_dir); \
rm -rf OpenBLAS; \
git clone git://github.com/xianyi/OpenBLAS; \
mv -f OpenBLAS $(openblas_dir); \
cd $(openblas_dir); \
make NO_WARMUP=1 USE_THREAD=1 USE_OPENMP=1 FC=$(FC) CC=$(CC) libs netlib)
clean:
rm -rf *~ *.o
@echo "## If you want to clean SuiteSparse, MUMPS, OpenBLAS,"
@echo "## then use 'make dist-clean'"
dist-clean: clean
rm -f $(sdpac_lib) $(sdpac_exe)
(cd $(sdpac_dir); \
rm -rf SuiteSparse; rm -rf mumps; rm -rf OpenBLAS)
(cd mex; make dist-clean)
# -include make.head must be the bottom
# otherwise, you need to assign make 'all'.
-include make.head
CC = gcc
OPTFLAGS = -O3 -fPIC
CC = gcc
OPTFLAGS = -O3 -fPIC
CC = gcc
OPTFLAGS = -O3 -fPIC
CC = gcc
OPTFLAGS = -O3 -fPIC
CC = gcc
OPTFLAGS = -O3 -fPIC
CC = gcc
OPTFLAGS = -O3 -fPIC
CC = gcc
OPTFLAGS = -O3 -fPIC
CC = gcc
OPTFLAGS = -O3 -fPIC
CC = gcc
OPTFLAGS = -O3 -fPIC
CC = gcc
OPTFLAGS = -O3 -fPIC
CC = gcc
OPTFLAGS = -O3 -fPIC
CC = gcc
OPTFLAGS = -O3 -fPIC
CC = gcc
FC = gfortran
FL = gfortran
OPTC = -O3 -fPIC
OPTF = -O3 -fPIC
OPTL = -O3 -fPIC
LPORDDIR = /home/makoto/sdpa-c/PORD/lib/
IPORDDIR = /home/makoto/sdpa-c/PORD/include/
For the latest news on SDPA, please refer to
http://sdpa.sourceforge.net/
"Example 1: mDim = 3, nBLOCK = 1, {2}"
3 = mDIM
1 = nBLOCK
2 = bLOCKsTRUCT
48, -8, 20
0 1 1 1 -11
0 1 2 2 23
1 1 1 1 10
1 1 1 2 4
2 1 2 2 -8
3 1 1 2 -8
3 1 2 2 -2
5
1
7
1.1 -10.0 6.6 19.0 4.1
0 1 1 1 1.8
0 1 2 2 -4.0
0 1 3 3 -1.4
0 1 3 4 -3.2
0 1 4 4 -28.0
0 1 5 5 15.0
0 1 5 6 -12.0
0 1 5 7 2.1
0 1 6 6 16.0
0 1 6 7 -3.8
0 1 7 7 15.0
1 1 1 1 -4.5
1 1 2 2 -3.5
1 1 3 3 0.5
1 1 3 4 5.2
1 1 4 4 -5.3
1 1 5 5 7.8
1 1 5 6 -2.4
1 1 5 7 6.0
1 1 6 6 4.2
1 1 6 7 6.5
1 1 7 7 2.1
2 1 1 1 -0.2
2 1 2 2 -3.7
2 1 3 3 1.7
2 1 3 4 7.0
2 1 4 4 -9.3
2 1 5 5 -1.9
2 1 5 6 -0.9
2 1 5 7 -1.3
2 1 6 6 -0.8
2 1 6 7 -2.1
2 1 7 7 4.0
3 1 1 1 -3.3
3 1 2 2 -4.0
3 1 3 3 6.3
3 1 3 4 -7.5
3 1 4 4 -3.3
3 1 5 5 0.2
3 1 5 6 8.8
3 1 5 7 5.4
3 1 6 6 3.4
3 1 6 7 -0.4
3 1 7 7 7.5
4 1 1 1 4.8
4 1 2 2 9.7
4 1 3 3 -2.4
4 1 3 4 -2.5
4 1 4 4 -2.9
4 1 5 5 3.4
4 1 5 6 -3.2
4 1 5 7 -4.5
4 1 6 6 3.0
4 1 6 7 -4.8
4 1 7 7 3.6
5 1 1 1 6.1
5 1 2 2 -1.5
5 1 3 3 -6.5
5 1 3 4 -5.4
5 1 4 4 -6.6
5 1 5 5 6.7
5 1 5 6 -7.2
5 1 5 7 -3.6
5 1 6 6 7.3
5 1 6 7 -3.0
5 1 7 7 -1.4
*Example 2:
*mDim = 5, nBLOCK = 3, {2,3,-2}
5 = mDIM
3 = nBLOCK
2 3 -2 = bLOCKsTRUCT
{1.1, -10, 6.6 , 19 , 4.1}
{
{ { -1.4, -3.2 },
{ -3.2,-28 } }
{ { 15, -12, 2.1 },
{-12, 16, -3.8 },
{ 2.1, -3.8, 15 } }
{ 1.8, -4.0 }
}
{
{ { 0.5, 5.2 },
{ 5.2, -5.3 } }
{ { 7.8, -2.4, 6.0 },
{ -2.4, 4.2, 6.5 },
{ 6.0, 6.5, 2.1 } }
{ -4.5, -3.5 }
}
{
{ { 1.7, 7.0 },
{ 7.0, -9.3 } }
{ {-1.9, -0.9, -1.3 },
{-0.9, -0.8, -2.1 },
{-1.3, -2.1, 4.0 } }
{-0.2, -3.7 }
}
{
{ { 6.3, -7.5 },
{-7.5, -3.3 } }
{ { 0.2, 8.8, 5.4 },
{ 8.8, 3.4, -0.4 },
{ 5.4, -0.4, 7.5 } }
{-3.3, -4.0 }
}
{
{ { -2.4, -2.5 },
{ -2.5, -2.9 } }
{ { 3.4, -3.2, -4.5 },
{ -3.2, 3.0, -4.8 },
{ -4.5, -4.8, 3.6 } }
{ 4.8 , 9.7 }
}
{
{ { -6.5, -5.4 },
{ -5.4, -6.6 } }
{ { 6.7, -7.2, -3.6 },
{ -7.2, 7.3, -3.0 },
{ -3.6, -3.0, -1.4 } }
{ 6.1, -1.5 }
}
*Example 2:
*mDim = 5, nBLOCK = 3, {2,3,-2}
5 = mDIM
3 = nBLOCK
2 3 -2 = bLOCKsTRUCT
1.1, -10, 6.6 , 19 , 4.1
0 1 1 1 -1.4
0 1 1 2 -3.2
0 1 2 2 -28
0 2 1 1 15
0 2 1 2 -12
0 2 1 3 2.1
0 2 2 2 16
0 2 2 3 -3.8
0 2 3 3 15
0 3 1 1 1.8
0 3 2 2 -4.0
1 1 1 1 0.5
1 1 1 2 5.2
1 1 2 2 -5.3
1 2 1 1 7.8
1 2 1 2 -2.4
1 2 1 3 6.0
1 2 2 2 4.2
1 2 2 3 6.5
1 2 3 3 2.1
1 3 1 1 -4.5
1 3 2 2 -3.5
2 1 1 1 1.7
2 1 1 2 7.0
2 1 2 2 -9.3
2 2 1 1 -1.9
2 2 1 2 -0.9
2 2 1 3 -1.3
2 2 2 2 -0.8
2 2 2 3 -2.1
2 2 3 3 4.0
2 3 1 1 -0.2
2 3 2 2 -3.7
3 1 1 1 6.3
3 1 1 2 -7.5
3 1 2 2 -3.3
3 2 1 1 0.2
3 2 1 2 8.8
3 2 1 3 5.4
3 2 2 2 3.4
3 2 2 3 -0.4
3 2 3 3 7.5
3 3 1 1 -3.3
3 3 2 2 -4.0
4 1 1 1 -2.4
4 1 1 2 -2.5
4 1 2 2 -2.9
4 2 1 1 3.4
4 2 1 2 -3.2
4 2 1 3 -4.5
4 2 2 2 3.0
4 2 2 3 -4.8
4 2 3 3 3.6
4 3 1 1 4.8
4 3 2 2 9.7
5 1 1 1 -6.5
5 1 1 2 -5.4
5 1 2 2 -6.6
5 2 1 1 6.7
5 2 1 2 -7.2
5 2 1 3 -3.6
5 2 2 2 7.3
5 2 2 3 -3.0
5 2 3 3 -1.4
5 3 1 1 6.1
5 3 2 2 -1.5
#############################################################
# List of examples for callable-library
#
# example1.cpp: Solve example1.dat-s using inputElements
# example2.cpp: Solve example2.dat using inputElements
# example5.cpp: Solve problems reading from file
#
#############################################################
.PHONY: all lib clean cleanall distclean
.SUFFIXES: .exe
# after "make install", you can find
# 'make.inc' in 'share/sdpa' sub-directory under the installed directory
# For example
# make MAKE_INCLUDE_DIR=/usr/share/sdpa
# or
# make MAKE_INCLUDE_DIR=/usr/local/share/sdpa
MAKE_INCLUDE_DIR=..
-include ${MAKE_INCLUDE_DIR}/make.inc
# after "make install", you can find
# 'make.inc' in 'share/sdpa' sub-directory under the installed directory
# For example
# make MAKE_INCLUDE_DIR=/usr/share/sdpa
# or
# make MAKE_INCLUDE_DIR=/usr/local/share/sdpa
SRC = $(wildcard example?.cpp)
EXE = $(subst .cpp,.exe,$(SRC))
all: ${EXE}
%.exe: %.o
${CXX} ${CXXFLAGS} -o $@ $< ${sdpac_dir}/${sdpac_lib} ${sdpac_all_lib}
.cpp.o:
${CXX} -c ${CXXFLAGS} \
-I${sdpac_dir} ${sdpac_all_include} \
-o $@ $<
clean:
rm -f *.o *~
cleanall: clean
rm -f *.exe
dist-clean: cleanall
/* -------------------------------------------------------------
This file is a component of SDPA
Copyright (C) 2004-2013 SDPA Project
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
------------------------------------------------------------- */
// Here is the start of ``example1.cpp''
#include <cstdio>
#include <cstdlib>
#include <sdpa_call.h>
/*
example1.dat:
"Example 1: mDim = 3, nBLOCK = 1, {2}"
3 = mDIM
1 = nBLOCK
2 = bLOCKsTRUCT
{48, -8, 20}
{ {-11, 0}, { 0, 23} }
{ { 10, 4}, { 4, 0} }
{ { 0, 0}, { 0, -8} }
{ { 0, -8}, {-8, -2} }
*/
void printVector(double* ele, int dim, char* printFormat,
FILE* fpout);
void printMatrix(double* ele, int dim, char* printFormat,
FILE* fpout);
void printDimacsError(double dimacs_error[7],char* printFormat,
FILE* fpout);
int main ()
{
SDPA::printSDPAVersion(stdout);
SDPA Problem1;
Problem1.setDisplay(stdout);
// All parameteres are renewed
Problem1.setParameterType(SDPA::PARAMETER_DEFAULT);
// If necessary, each parameter can be set independently
// Problem1.setParameterMaxIteration(100);
// Problem1.setParameterEpsilonStar(1.0e-7);
// Problem1.setParameterLambdaStar(1.0e+2);
// Problem1.setParameterOmegaStar(2.0);
// Problem1.setParameterLowerBound(-1.0e+5);
// Problem1.setParameterUppwerBound(1.0e+5);
// Problem1.setParameterBetaStar(0.1);
// Problem1.setParameterBetaBar(0.2);
// Problem1.setParameterGammaStar(0.9);
// Problem1.setParameterEpsilonDash(1.0e-7);
// Problem1.setParameterPrintXVec((char*)"%+8.3e" );
// Problem1.setParameterPrintXMat((char*)"%+8.3e" );
// Problem1.setParameterPrintYMat((char*)"%+8.3e" );
// Problem1.setParameterPrintInformation((char*)"%+10.16e");
Problem1.printParameters(stdout);
int mDIM = 3;
int nBlock = 1;
Problem1.inputConstraintNumber(mDIM);
Problem1.inputBlockNumber(nBlock);
Problem1.inputBlockSize(1,2);
Problem1.inputBlockType(1,SDPA::SDP);
Problem1.initializeUpperTriangleSpace();
Problem1.inputCVec(1,48);
Problem1.inputCVec(2,-8);
Problem1.inputCVec(3,20);
Problem1.inputElement(0, 1, 1, 1, -11);
Problem1.inputElement(0, 1, 2, 2, 23);
Problem1.inputElement(1, 1, 1, 1, 10);
Problem1.inputElement(1, 1, 1, 2, 4);
Problem1.inputElement(2, 1, 2, 2, -8);
Problem1.inputElement(3, 1, 1, 2, -8);
Problem1.inputElement(3, 1, 2, 2, -2);
Problem1.initializeUpperTriangle();
Problem1.initializeSolve();
// if necessary, dump input data and initial point
// Problem1.writeInputSparse((char*)"tmp.dat-s",(char*)"%+8.3e");
// Problem1.writeInitSparse((char*)"tmp.ini-s",(char*)"%+8.3e");
Problem1.solve();
fprintf(stdout, "\nStop iteration = %d\n",
Problem1.getIteration());
char phase_string[30];
Problem1.getPhaseString(phase_string);
fprintf(stdout, "Phase = %s\n", phase_string);
fprintf(stdout, "objValPrimal = %+10.6e\n",
Problem1.getPrimalObj());
fprintf(stdout, "objValDual = %+10.6e\n",
Problem1.getDualObj());
fprintf(stdout, "p. feas. error = %+10.6e\n",
Problem1.getPrimalError());
fprintf(stdout, "d. feas. error = %+10.6e\n\n",
Problem1.getDualError());
fprintf(stdout, "xVec = \n");
// Problem1.printResultXVec();
printVector(Problem1.getResultXVec(),
Problem1.getConstraintNumber(), (char*)"%+8.3e",
stdout);
fprintf(stdout, "xMat = \n");
// Problem1.printResultXMat();
for (int l=0; l<Problem1.getBlockNumber(); ++l) {
if (Problem1.getBlockType(l+1) == SDPA::SDP) {
printMatrix(Problem1.getResultXMat(l+1),
Problem1.getBlockSize(l+1), (char*)"%+8.3e",
stdout);
}
else if (Problem1.getBlockType(l+1) == SDPA::SOCP) {
printf("current version does not support SOCP\n");
}
if (Problem1.getBlockType(l+1) == SDPA::LP) {
printVector(Problem1.getResultXMat(l+1),
Problem1.getBlockSize(l+1), (char*)"%+8.3e",
stdout);
}
}
fprintf(stdout, "yMat = \n");
// Problem1.printResultYMat();
for (int l=0; l<Problem1.getBlockNumber(); ++l) {
if (Problem1.getBlockType(l+1) == SDPA::SDP) {
printMatrix(Problem1.getResultYMat(l+1),
Problem1.getBlockSize(l+1), (char*)"%+8.3e",
stdout);
}
else if (Problem1.getBlockType(l+1) == SDPA::SOCP) {
printf("current version does not support SOCP\n");
}
if (Problem1.getBlockType(l+1) == SDPA::LP) {
printVector(Problem1.getResultYMat(l+1),
Problem1.getBlockSize(l+1), (char*)"%+8.3e",
stdout);
}
}
double dimacs_error[7];
Problem1.getDimacsError(dimacs_error);
printDimacsError(dimacs_error,(char*)"%+8.3e",stdout);
// Problem1.printComputationTime(stdout);
Problem1.finalize();
exit(0);
};
void printVector(double* ele, int dim, char* printFormat, FILE* fpout)
{
fprintf(fpout,"[ ");
for (int k=0; k<dim-1; ++k) {
fprintf(fpout,printFormat,ele[k]);
fprintf(fpout," ");
}
fprintf(fpout,printFormat,ele[dim-1]);
fprintf(fpout,"]; \n");
}
void printMatrix(double* ele, int dim, char* printFormat, FILE* fpout)
{
fprintf(fpout,"[\n");
for (int i=0; i<dim; ++i) {
fprintf(fpout,"[ ");
for (int j=0; j<dim-1; ++j) {
fprintf(fpout,printFormat,ele[i+dim*j]);
fprintf(fpout," ");
}
fprintf(fpout,printFormat,ele[i+dim*(dim-1)]);
fprintf(fpout,"]; \n");
}
fprintf(fpout,"]; \n");
}
void printDimacsError(double dimacs_error[7],char* printFormat,
FILE* fpout)
{
fprintf(fpout, "\n");
fprintf(fpout, "* DIMACS_ERRORS * \n");
fprintf(fpout, "err1 = ");
fprintf(fpout, printFormat, dimacs_error[1]);
fprintf(fpout, " [||Ax-b|| / (1+||b||_1)]\n");
fprintf(fpout, "err2 = ");
fprintf(fpout, printFormat, dimacs_error[2]);
fprintf(fpout, " [max(0, -lambda(x)/(1+||b||_1))]\n");
fprintf(fpout, "err3 = ");
fprintf(fpout, printFormat, dimacs_error[3]);
fprintf(fpout, " [||A^Ty + z - c || / (1+||c||_1)]\n");
fprintf(fpout, "err4 = ");
fprintf(fpout, printFormat, dimacs_error[4]);
fprintf(fpout, " [max(0, -lambda(z)/(1+||c||_1))]\n");
fprintf(fpout, "err5 = ");
fprintf(fpout, printFormat, dimacs_error[5]);
fprintf(fpout, " [(<c,x> - <b,y>) / (1 + |<c,x>| + |<b,y>|)]\n");
fprintf(fpout, "err6 = ");
fprintf(fpout, printFormat, dimacs_error[6]);
fprintf(fpout, " [<x,z> / (1 + |<c,x>| + |<b,y>|)]\n");
fprintf(fpout, "\n");
}
/* -------------------------------------------------------------
This file is a component of SDPA
Copyright (C) 2004-2013 SDPA Project
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
------------------------------------------------------------- */
// Here is the start of ``example1.cpp''
#include <cstdio>
#include <cstdlib>
#include <sdpa_call.h>
/*
*Example 2:
*mDim = 5, nBLOCK = 3, {2,3,-2}
5 = mDIM
3 = nBLOCK
2 3 -2 = bLOCKsTRUCT
{1.1, -10, 6.6 , 19 , 4.1}
{
{ { -1.4, -3.2 },
{ -3.2,-28 } }
{ { 15, -12, 2.1 },
{-12, 16, -3.8 },
{ 2.1, -3.8, 15 } }
{ 1.8, -4.0 }
}
{
{ { 0.5, 5.2 },
{ 5.2, -5.3 } }
{ { 7.8, -2.4, 6.0 },
{ -2.4, 4.2, 6.5 },
{ 6.0, 6.5, 2.1 } }
{ -4.5, -3.5 }
}
{
{ { 1.7, 7.0 },
{ 7.0, -9.3 } }
{ {-1.9, -0.9, -1.3 },
{-0.9, -0.8, -2.1 },
{-1.3, -2.1, 4.0 } }
{-0.2, -3.7 }
}
{
{ { 6.3, -7.5 },
{-7.5, -3.3 } }
{ { 0.2, 8.8, 5.4 },
{ 8.8, 3.4, -0.4 },
{ 5.4, -0.4, 7.5 } }
{-3.3, -4.0 }
}
{
{ { -2.4, -2.5 },
{ -2.5, -2.9 } }
{ { 3.4, -3.2, -4.5 },
{ -3.2, 3.0, -4.8 },
{ -4.5, -4.8, 3.6 } }
{ 4.8 , 9.7 }
}
{
{ { -6.5, -5.4 },
{ -5.4, -6.6 } }
{ { 6.7, -7.2, -3.6 },
{ -7.2, 7.3, -3.0 },
{ -3.6, -3.0, -1.4 } }
{ 6.1, -1.5 }
}
*/
void printVector(double* ele, int dim, char* printFormat,
FILE* fpout);
void printMatrix(double* ele, int dim, char* printFormat,
FILE* fpout);
void printDimacsError(double dimacs_error[7],char* printFormat,
FILE* fpout);
int main ()
{
SDPA::printSDPAVersion(stdout);
SDPA Problem1;
Problem1.setDisplay(stdout);
// All parameteres are renewed
Problem1.setParameterType(SDPA::PARAMETER_DEFAULT);
// Problem1.printParameters(stdout);
int mDIM = 5;
int nBlock = 3;
Problem1.inputConstraintNumber(mDIM);
Problem1.inputBlockNumber(nBlock);
// bLOCKsTRUCT :: 2(SDP) 3(SDP) -2(LP)
Problem1.inputBlockSize(1,2);
Problem1.inputBlockSize(2,3);
Problem1.inputBlockSize(3,-2);
Problem1.inputBlockType(1,SDPA::SDP);
Problem1.inputBlockType(2,SDPA::SDP);
Problem1.inputBlockType(3,SDPA::LP);
Problem1.initializeUpperTriangleSpace();
//cVECT = {1.1, -10, 6.6 , 19 , 4.1}
Problem1.inputCVec(1,1.1);
Problem1.inputCVec(2,-10);
Problem1.inputCVec(3,6.6);
Problem1.inputCVec(4,19);
Problem1.inputCVec(5,4.1);
// --------- Input F_0 --------------------
// 1st block
// { { -1.4, -3.2},
// { -3.2, -28} }
Problem1.inputElement(0, 1, 1, 1, -1.4);
Problem1.inputElement(0, 1, 1, 2, -3.2);
Problem1.inputElement(0, 1, 2, 2, -28);
// 2nd block
// { { 15, -12, 2.1 },
// {-12, 16, -3.8 },
// { 2.1, -3.8, 15 } }
Problem1.inputElement(0, 2, 1, 1, 15);
Problem1.inputElement(0, 2, 1, 2, -12);
Problem1.inputElement(0, 2, 1, 3, 2.1);
Problem1.inputElement(0, 2, 2, 2, 16);
Problem1.inputElement(0, 2, 2, 3,-3.8);
Problem1.inputElement(0, 2, 3, 3, 15);
// 3rd block
// { 1.8, -4.0 }
Problem1.inputElement(0, 3, 1, 1, 1.8);
Problem1.inputElement(0, 3, 2, 2,-4.0);
// --------- Input F_1 --------------------
// 1st block
// { { 0.5, 5.2},
// { 5.2, -5.3} }
Problem1.inputElement(1, 1, 1, 1, 0.5);
Problem1.inputElement(1, 1, 1, 2, 5.2);
Problem1.inputElement(1, 1, 2, 2,-5.3);
// 2nd block
// { { 7.8, -2.4, 6.0 },
// {-2.4, 4.2, 6.5 },
// { 6.0, 6.5, 2.1 } }
Problem1.inputElement(1, 2, 1, 1, 7.8);
Problem1.inputElement(1, 2, 1, 2,-2.4);
Problem1.inputElement(1, 2, 1, 3, 6.0);
Problem1.inputElement(1, 2, 2, 2, 4.2);
Problem1.inputElement(1, 2, 2, 3, 6.5);
Problem1.inputElement(1, 2, 3, 3, 2.1);
// 3rd block
// { -4.5, -3.5 }
Problem1.inputElement(1, 3, 1, 1, -4.5);
Problem1.inputElement(1, 3, 2, 2, -3.5);
// --------- Input F_2 --------------------
// 1st block
// { { 1.7, 7.0},
// { 7.0,-9.3} }
Problem1.inputElement(2, 1, 1, 1, 1.7);
Problem1.inputElement(2, 1, 1, 2, 7.0);
Problem1.inputElement(2, 1, 2, 2, -9.3);
// 2nd block
// { {-1.9, -0.9, -1.3 },
// {-0.9, -0.8, -2.1 },
// {-1.3, -2.1, 4.0 } }
Problem1.inputElement(2, 2, 1, 1, -1.9);
Problem1.inputElement(2, 2, 1, 2, -0.9);
Problem1.inputElement(2, 2, 1, 3, -1.3);
Problem1.inputElement(2, 2, 2, 2, -0.8);
Problem1.inputElement(2, 2, 2, 3, -2.1);
Problem1.inputElement(2, 2, 3, 3, 4.0);
// 3rd block
// { -0.2, -3.7 }
Problem1.inputElement(2, 3, 1, 1, -0.2);
Problem1.inputElement(2, 3, 2, 2, -3.7);
// --------- Input F_3 --------------------
// 1st block
// { { 6.3, -7.5},
// { -7.5, -3.3} }
Problem1.inputElement(3, 1, 1, 1, 6.3);
Problem1.inputElement(3, 1, 1, 2, -7.5);
Problem1.inputElement(3, 1, 2, 2, -3.3);
// 2nd block
// { { 0.2, 8.8, 5.4 },
// { 8.8, 3.4, -0.4 },
// { 5.4, -0.4, 7.5 } }
Problem1.inputElement(3, 2, 1, 1, 0.2);
Problem1.inputElement(3, 2, 1, 2, 8.8);
Problem1.inputElement(3, 2, 1, 3, 5.4);
Problem1.inputElement(3, 2, 2, 2, 3.4);
Problem1.inputElement(3, 2, 2, 3, -0.4);
Problem1.inputElement(3, 2, 3, 3, 7.5);
// 3rd block
// { -3.3, -4.0 }
Problem1.inputElement(3, 3, 1, 1, -3.3);
Problem1.inputElement(3, 3, 2, 2, -4.0);
// --------- Input F_4 --------------------
// 1st block
// { { -2.4, -2.5},
// { -2.5, -2.9} }
Problem1.inputElement(4, 1, 1, 1, -2.4);
Problem1.inputElement(4, 1, 1, 2, -2.5);
Problem1.inputElement(4, 1, 2, 2, -2.9);
// 2nd block
// { { 3.4, -3.2, -4.5 },
// { -3.2, 3.0, -4.8 },
// { -4.5, -4.8, 3.6 } }
Problem1.inputElement(4, 2, 1, 1, 3.4);
Problem1.inputElement(4, 2, 1, 2, -3.2);
Problem1.inputElement(4, 2, 1, 3, -4.5);
Problem1.inputElement(4, 2, 2, 2, 3.0);
Problem1.inputElement(4, 2, 2, 3, -4.8);
Problem1.inputElement(4, 2, 3, 3, 3.6);
// 3rd block
// { 4.8, 9.7 }
Problem1.inputElement(4, 3, 1, 1, 4.8);
Problem1.inputElement(4, 3, 2, 2, 9.7);
// --------- Input F_5 --------------------
// 1st block
// { { -6.5, -5.4},
// { -5.4, -6.6} }
Problem1.inputElement(5, 1, 1, 1, -6.5);
Problem1.inputElement(5, 1, 1, 2, -5.4);
Problem1.inputElement(5, 1, 2, 2, -6.6);
// 2nd block
// { { 6.7, -7.2, -3.6 },
// { -7.2, 7.3, -3.0 },
// { -3.6, -3.0, -1.4 } }
Problem1.inputElement(5, 2, 1, 1, 6.7);
Problem1.inputElement(5, 2, 1, 2, -7.2);
Problem1.inputElement(5, 2, 1, 3, -3.6);
Problem1.inputElement(5, 2, 2, 2, 7.3);
Problem1.inputElement(5, 2, 2, 3, -3.0);
Problem1.inputElement(5, 2, 3, 3, -1.4);
// 3rd block
// { 6.1, -1.5 }
Problem1.inputElement(5, 3, 1, 1, 6.1);
Problem1.inputElement(5, 3, 2, 2,-1.5);
Problem1.initializeUpperTriangle();
Problem1.initializeSolve();
// if necessary, dump input data and initial point
// Problem1.writeInputSparse((char*)"tmp.dat-s",(char*)"%+8.3e");
// Problem1.writeInitSparse((char*)"tmp.ini-s",(char*)"%+8.3e");
Problem1.solve();
fprintf(stdout, "\nStop iteration = %d\n",
Problem1.getIteration());
char phase_string[30];
Problem1.getPhaseString(phase_string);
fprintf(stdout, "Phase = %s\n", phase_string);
fprintf(stdout, "objValPrimal = %+10.6e\n",
Problem1.getPrimalObj());
fprintf(stdout, "objValDual = %+10.6e\n",
Problem1.getDualObj());
fprintf(stdout, "p. feas. error = %+10.6e\n",
Problem1.getPrimalError());
fprintf(stdout, "d. feas. error = %+10.6e\n\n",
Problem1.getDualError());
fprintf(stdout, "xVec = \n");
// Problem1.printResultXVec();
printVector(Problem1.getResultXVec(),
Problem1.getConstraintNumber(), (char*)"%+8.3e",
stdout);
fprintf(stdout, "xMat = \n");
// Problem1.printResultXMat();
for (int l=0; l<Problem1.getBlockNumber(); ++l) {
if (Problem1.getBlockType(l+1) == SDPA::SDP) {
printMatrix(Problem1.getResultXMat(l+1),
Problem1.getBlockSize(l+1), (char*)"%+8.3e",
stdout);
}
else if (Problem1.getBlockType(l+1) == SDPA::SOCP) {
printf("current version does not support SOCP\n");
}
if (Problem1.getBlockType(l+1) == SDPA::LP) {
printVector(Problem1.getResultXMat(l+1),
Problem1.getBlockSize(l+1), (char*)"%+8.3e",
stdout);
}
}
fprintf(stdout, "yMat = \n");
// Problem1.printResultYMat();
for (int l=0; l<Problem1.getBlockNumber(); ++l) {
if (Problem1.getBlockType(l+1) == SDPA::SDP) {
printMatrix(Problem1.getResultYMat(l+1),
Problem1.getBlockSize(l+1), (char*)"%+8.3e",
stdout);
}
else if (Problem1.getBlockType(l+1) == SDPA::SOCP) {
printf("current version does not support SOCP\n");
}
if (Problem1.getBlockType(l+1) == SDPA::LP) {
printVector(Problem1.getResultYMat(l+1),
Problem1.getBlockSize(l+1), (char*)"%+8.3e",
stdout);
}
}
double dimacs_error[7];
Problem1.getDimacsError(dimacs_error);
printDimacsError(dimacs_error,(char*)"%+8.3e",stdout);
// Problem1.printComputationTime(stdout);
Problem1.finalize();
exit(0);
};
void printVector(double* ele, int dim, char* printFormat, FILE* fpout)
{
fprintf(fpout,"[ ");
for (int k=0; k<dim-1; ++k) {
fprintf(fpout,printFormat,ele[k]);
fprintf(fpout," ");
}
fprintf(fpout,printFormat,ele[dim-1]);
fprintf(fpout,"]; \n");
}
void printMatrix(double* ele, int dim, char* printFormat, FILE* fpout)
{
fprintf(fpout,"[\n");
for (int i=0; i<dim; ++i) {
fprintf(fpout,"[ ");
for (int j=0; j<dim-1; ++j) {
fprintf(fpout,printFormat,ele[i+dim*j]);
fprintf(fpout," ");
}
fprintf(fpout,printFormat,ele[i+dim*(dim-1)]);
fprintf(fpout,"]; \n");
}
fprintf(fpout,"]; \n");
}
void printDimacsError(double dimacs_error[7],char* printFormat,
FILE* fpout)
{
fprintf(fpout, "\n");
fprintf(fpout, "* DIMACS_ERRORS * \n");
fprintf(fpout, "err1 = ");
fprintf(fpout, printFormat, dimacs_error[1]);
fprintf(fpout, " [||Ax-b|| / (1+||b||_1)]\n");
fprintf(fpout, "err2 = ");
fprintf(fpout, printFormat, dimacs_error[2]);
fprintf(fpout, " [max(0, -lambda(x)/(1+||b||_1))]\n");
fprintf(fpout, "err3 = ");
fprintf(fpout, printFormat, dimacs_error[3]);
fprintf(fpout, " [||A^Ty + z - c || / (1+||c||_1)]\n");
fprintf(fpout, "err4 = ");
fprintf(fpout, printFormat, dimacs_error[4]);
fprintf(fpout, " [max(0, -lambda(z)/(1+||c||_1))]\n");
fprintf(fpout, "err5 = ");
fprintf(fpout, printFormat, dimacs_error[5]);
fprintf(fpout, " [(<c,x> - <b,y>) / (1 + |<c,x>| + |<b,y>|)]\n");
fprintf(fpout, "err6 = ");
fprintf(fpout, printFormat, dimacs_error[6]);
fprintf(fpout, " [<x,z> / (1 + |<c,x>| + |<b,y>|)]\n");
fprintf(fpout, "\n");
}
/* -------------------------------------------------------------
This file is a component of SDPA
Copyright (C) 2004-2013 SDPA Project
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
------------------------------------------------------------- */
// Here is the start of ``example5.cpp''
#include <cstdio>
#include <cstdlib>
#include <sdpa_call.h>
int main(int argc, char** argv)
{
if (argc != 4) {
fprintf(stderr, "%s [Input] [Output] [Param] \n", argv[0]);
exit(EXIT_FAILURE);
}
SDPA Problem1;
FILE* fpresult;
if ((fpresult = fopen(argv[2],"w")) == NULL) {
fprintf(stderr, "Cannot Open %s \n", argv[2]);
}
Problem1.setResultFile(fpresult);
// fpresult records which file is read from argv[3]
Problem1.readParameter(argv[3],fpresult);
// Note that readParameter should be called before readInput
// Otherwise initial point cannot be decided by lambdaStar
Problem1.readInput(argv[1],fpresult);
Problem1.initializeSolve();
// All results and intermediate log are written into fpresult
Problem1.solve();
fclose(fpresult);
Problem1.finalize();
exit(0);
}
File added
100 unsigned int maxIteration;
1.0E-7 double 0.0 < epsilonStar;
1.0E2 double 0.0 < lambdaStar;
2.0 double 1.0 < omegaStar;
-1.0E5 double lowerBound;
1.0E5 double upperBound;
0.1 double 0.0 <= betaStar < 1.0;
0.3 double 0.0 <= betaBar < 1.0, betaStar <= betaBar;
0.9 double 0.0 < gammaStar < 1.0;
1.0E-7 double 0.0 < epsilonDash;
%+8.3e char* xPrint (default %+8.3e, NOPRINT skips printout)
%+8.3e char* XPrint (default %+8.3e, NOPRINT skips printout)
%+8.3e char* YPrint (default %+8.3e, NOPRINT skips printout)
%+10.16e char* infPrint (default %+10.16e, NOPRINT skips printout)
sdpa_block.o: sdpa_block.cpp sdpa_block.h sdpa_include.h sdpa_right.h \
sdpa_tool.h
sdpa_call.o: sdpa_call.cpp sdpa_call.h sdpa_io.h sdpa_block.h \
sdpa_include.h sdpa_right.h sdpa_tool.h sdpa_parts.h sdpa_dataset.h \
sdpa_struct.h sdpa_linear.h
sdpa_chordal.o: sdpa_chordal.cpp sdpa_chordal.h sdpa_dataset.h \
sdpa_include.h sdpa_right.h sdpa_tool.h sdpa_struct.h sdpa_block.h
sdpa_dataset.o: sdpa_dataset.cpp sdpa_dataset.h sdpa_include.h \
sdpa_right.h sdpa_tool.h sdpa_struct.h sdpa_block.h sdpa_parts.h \
sdpa_linear.h sdpa_newton.h sdpa_chordal.h
sdpa_dpotrf.o: sdpa_dpotrf.cpp sdpa_include.h sdpa_right.h sdpa_tool.h \
sdpa_algebra.h
sdpa_exe.o: sdpa_exe.cpp
sdpa_io.o: sdpa_io.cpp sdpa_io.h sdpa_block.h sdpa_include.h sdpa_right.h \
sdpa_tool.h sdpa_parts.h sdpa_dataset.h sdpa_struct.h sdpa_linear.h
sdpa_linear.o: sdpa_linear.cpp sdpa_linear.h sdpa_struct.h sdpa_include.h \
sdpa_right.h sdpa_tool.h sdpa_block.h sdpa_dataset.h sdpa_dpotrf.h \
sdpa_algebra.h
sdpa_newton.o: sdpa_newton.cpp sdpa_newton.h sdpa_chordal.h \
sdpa_dataset.h sdpa_include.h sdpa_right.h sdpa_tool.h sdpa_struct.h \
sdpa_block.h sdpa_parts.h sdpa_linear.h sdpa_algebra.h
sdpa_parts.o: sdpa_parts.cpp sdpa_parts.h sdpa_include.h sdpa_right.h \
sdpa_tool.h sdpa_dataset.h sdpa_struct.h sdpa_block.h sdpa_linear.h \
sdpa_newton.h sdpa_chordal.h
sdpa_solve.o: sdpa_solve.cpp sdpa_call.h sdpa_linear.h sdpa_struct.h \
sdpa_include.h sdpa_right.h sdpa_tool.h sdpa_block.h sdpa_io.h \
sdpa_parts.h sdpa_dataset.h
sdpa_struct.o: sdpa_struct.cpp sdpa_struct.h sdpa_include.h sdpa_right.h \
sdpa_tool.h sdpa_block.h sdpa_algebra.h sdpa_linear.h sdpa_dataset.h
sdpa_tool.o: sdpa_tool.cpp sdpa_tool.h sdpa_right.h
#########################################################
# Edit below accordingly your environment
#########################################################
# The base directory of SDPA-C
sdpac_dir = $(HOME)/sdpa-c
# The compilers
CC = gcc
CXX = g++
FC = gfortran
# The compiler options
# To generate mex files, you should not remove '-fPIC' from FLAGS
# When you use OpenBLAS, you should not remove '-DOPENBLAS' from CXXFLAGS
CFLAGS = -O3 -fPIC
CXXFLAGS = -O3 -fPIC -DOPENBLAS
FCFLAGS = -O3 -fPIC
#########################################################
# Usually, you do not have to edit below
#########################################################
SDPAC_VERSION = \"7.3.8\"
sdpac_lib = libsdpa-c.a
sdpac_exe = sdpa-c
## do not add '/' to the end of suitesparse_dir
suitesparse_dir = $(sdpac_dir)/SuiteSparse
suitesparse_include = -I$(suitesparse_dir)/CHOLMOD/Include \
-I$(suitesparse_dir)/SuiteSparse_config
suitesparse_lib = $(suitesparse_dir)/CHOLMOD/Lib/libcholmod.a \
$(suitesparse_dir)/CCOLAMD/Lib/libccolamd.a \
$(suitesparse_dir)/COLAMD/Lib/libcolamd.a \
$(suitesparse_dir)/CAMD/Lib/libcamd.a \
$(suitesparse_dir)/AMD/Lib/libamd.a \
$(suitesparse_dir)/metis-5.1.0/libmetis.a \
$(suitesparse_dir)/SuiteSparse_config/libsuitesparseconfig.a
suitesparse_ver = 5.1.2
## do not add '/' to the end of mumps_dir
mumps_dir = $(sdpac_dir)/mumps
mumps_include = -I$(mumps_dir)/include
mumps_lib = $(mumps_dir)/lib/libdmumps.a \
$(mumps_dir)/lib/libmumps_common.a \
$(mumps_dir)/lib/libpord.a \
$(mumps_dir)/libseq/libmpiseq.a
mumps_ver = 5.1.2
mumps_tar_file = mumps_${mumps_ver}.orig.tar.gz
## do not add '/' to the end of openblas_dir
openblas_dir = $(sdpac_dir)/OpenBLAS
openblas_lib = $(openblas_dir)/libopenblas.a
openmp_lib = -lgomp -lpthread
fortran_lib = -lgfortran
realtime_lib = -lrt
sdpac_all_include = $(suitesparse_include) $(mumps_include)
sdpac_all_lib = $(suitesparse_lib) $(mumps_lib) $(openblas_lib) \
$(openmp_lib) $(fortran_lib) $(realtime_lib)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment