From 9e1e4076f0c14f9fcee982389dbaaeab3570ce9a Mon Sep 17 00:00:00 2001 From: Dynamitos Date: Wed, 1 Feb 2023 22:13:04 +0100 Subject: [PATCH] New game interface --- CMakeLists.txt | 2 +- external/sdpa/AUTHORS | 15 - external/sdpa/COPYING | 340 -- external/sdpa/ChangeLog | 10 - external/sdpa/INSTALL | 160 - external/sdpa/Makefile | 100 - external/sdpa/Makefile.in | 24 - external/sdpa/Makefile.inc | 8 - external/sdpa/NEWS | 2 - external/sdpa/example1.dat-s | 12 - external/sdpa/example2-1.dat-s | 70 - external/sdpa/example2.dat | 54 - external/sdpa/example2.dat-s | 72 - external/sdpa/libexample/Makefile | 46 - external/sdpa/libexample/example1.cpp | 227 - external/sdpa/libexample/example2.cpp | 411 -- external/sdpa/libexample/example5.cpp | 55 - external/sdpa/libexample/gmon.out | Bin 2341806 -> 0 bytes external/sdpa/libexample/param.sdpaC | 15 - external/sdpa/make.head | 30 - external/sdpa/make.inc | 62 - external/sdpa/mex/CommandList.txt | 60 - external/sdpa/mex/Makefile | 131 - external/sdpa/mex/mexFprintf.c | 116 - external/sdpa/mex/mexSedumiWrapC.cpp | 655 --- external/sdpa/mex/mexsdpaC.cpp | 842 ---- external/sdpa/mex/paramC.m | 233 -- external/sdpa/mex/sdpamC.m | 81 - external/sdpa/mex/sedumiwrapC.m | 382 -- external/sdpa/param.sdpaC | 15 - external/sdpa/sdpa_algebra.h | 153 - external/sdpa/sdpa_block.cpp | 140 - external/sdpa/sdpa_block.h | 52 - external/sdpa/sdpa_call.cpp | 901 ---- external/sdpa/sdpa_call.h | 256 -- external/sdpa/sdpa_chordal.cpp | 557 --- external/sdpa/sdpa_chordal.h | 84 - external/sdpa/sdpa_dataset.cpp | 557 --- external/sdpa/sdpa_dataset.h | 135 - external/sdpa/sdpa_dpotrf.cpp | 274 -- external/sdpa/sdpa_dpotrf.h | 43 - external/sdpa/sdpa_exe.cpp | 360 -- external/sdpa/sdpa_include.h | 51 - external/sdpa/sdpa_io.cpp | 1155 ------ external/sdpa/sdpa_io.h | 118 - external/sdpa/sdpa_linear.cpp | 2959 ------------- external/sdpa/sdpa_linear.h | 331 -- external/sdpa/sdpa_newton.cpp | 1889 --------- external/sdpa/sdpa_newton.h | 253 -- external/sdpa/sdpa_parts.cpp | 1314 ------ external/sdpa/sdpa_parts.h | 269 -- external/sdpa/sdpa_right.h | 45 - external/sdpa/sdpa_solve.cpp | 259 -- external/sdpa/sdpa_struct.cpp | 3642 ----------------- external/sdpa/sdpa_struct.h | 574 --- external/sdpa/sdpa_tool.cpp | 71 - external/sdpa/sdpa_tool.h | 147 - res/shaders/Skybox.slang | 40 +- src/Editor/Platform/Windows/GameInterface.cpp | 11 +- src/Editor/Platform/Windows/GameInterface.h | 5 +- src/Editor/Window/GameView.cpp | 8 +- src/Editor/Window/GameView.h | 2 +- src/Editor/Window/InspectorView.cpp | 5 +- src/Editor/Window/SceneView.cpp | 2 +- src/Editor/main.cpp | 12 +- src/Engine/Asset/Asset.cpp | 4 +- src/Engine/Asset/AssetRegistry.cpp | 64 +- src/Engine/Asset/AssetRegistry.h | 16 +- src/Engine/Asset/FontAsset.cpp | 1 - src/Engine/Asset/FontAsset.h | 4 +- src/Engine/Asset/FontLoader.cpp | 12 +- src/Engine/Asset/FontLoader.h | 9 +- src/Engine/Asset/MaterialLoader.cpp | 17 +- src/Engine/Asset/MaterialLoader.h | 9 +- src/Engine/Asset/MeshLoader.cpp | 30 +- src/Engine/Asset/MeshLoader.h | 9 +- src/Engine/Asset/TextureLoader.cpp | 30 +- src/Engine/Asset/TextureLoader.h | 15 +- src/Engine/Component/Skybox.h | 1 - src/Engine/Containers/Map.h | 3 +- src/Engine/Game.h | 4 +- src/Engine/Graphics/GraphicsResources.h | 2 + .../Graphics/RenderPass/SkyboxRenderPass.cpp | 89 +- .../Graphics/RenderPass/SkyboxRenderPass.h | 1 + .../Graphics/Vulkan/VulkanGraphicsResources.h | 1 + src/Engine/Graphics/Vulkan/VulkanTexture.cpp | 19 +- src/Engine/Math/Vector.h | 2 +- src/Engine/Scene/Scene.cpp | 12 + src/Engine/Scene/Scene.h | 2 + src/Engine/Serialization/ArchiveBuffer.h | 13 + src/Engine/Serialization/CMakeLists.txt | 9 + 91 files changed, 268 insertions(+), 21014 deletions(-) delete mode 100644 external/sdpa/AUTHORS delete mode 100644 external/sdpa/COPYING delete mode 100644 external/sdpa/ChangeLog delete mode 100644 external/sdpa/INSTALL delete mode 100644 external/sdpa/Makefile delete mode 100644 external/sdpa/Makefile.in delete mode 100644 external/sdpa/Makefile.inc delete mode 100644 external/sdpa/NEWS delete mode 100644 external/sdpa/example1.dat-s delete mode 100644 external/sdpa/example2-1.dat-s delete mode 100644 external/sdpa/example2.dat delete mode 100644 external/sdpa/example2.dat-s delete mode 100644 external/sdpa/libexample/Makefile delete mode 100644 external/sdpa/libexample/example1.cpp delete mode 100644 external/sdpa/libexample/example2.cpp delete mode 100644 external/sdpa/libexample/example5.cpp delete mode 100644 external/sdpa/libexample/gmon.out delete mode 100644 external/sdpa/libexample/param.sdpaC delete mode 100644 external/sdpa/make.head delete mode 100644 external/sdpa/make.inc delete mode 100644 external/sdpa/mex/CommandList.txt delete mode 100644 external/sdpa/mex/Makefile delete mode 100644 external/sdpa/mex/mexFprintf.c delete mode 100644 external/sdpa/mex/mexSedumiWrapC.cpp delete mode 100644 external/sdpa/mex/mexsdpaC.cpp delete mode 100644 external/sdpa/mex/paramC.m delete mode 100644 external/sdpa/mex/sdpamC.m delete mode 100644 external/sdpa/mex/sedumiwrapC.m delete mode 100644 external/sdpa/param.sdpaC delete mode 100644 external/sdpa/sdpa_algebra.h delete mode 100644 external/sdpa/sdpa_block.cpp delete mode 100644 external/sdpa/sdpa_block.h delete mode 100644 external/sdpa/sdpa_call.cpp delete mode 100644 external/sdpa/sdpa_call.h delete mode 100644 external/sdpa/sdpa_chordal.cpp delete mode 100644 external/sdpa/sdpa_chordal.h delete mode 100644 external/sdpa/sdpa_dataset.cpp delete mode 100644 external/sdpa/sdpa_dataset.h delete mode 100644 external/sdpa/sdpa_dpotrf.cpp delete mode 100644 external/sdpa/sdpa_dpotrf.h delete mode 100644 external/sdpa/sdpa_exe.cpp delete mode 100644 external/sdpa/sdpa_include.h delete mode 100644 external/sdpa/sdpa_io.cpp delete mode 100644 external/sdpa/sdpa_io.h delete mode 100644 external/sdpa/sdpa_linear.cpp delete mode 100644 external/sdpa/sdpa_linear.h delete mode 100644 external/sdpa/sdpa_newton.cpp delete mode 100644 external/sdpa/sdpa_newton.h delete mode 100644 external/sdpa/sdpa_parts.cpp delete mode 100644 external/sdpa/sdpa_parts.h delete mode 100644 external/sdpa/sdpa_right.h delete mode 100644 external/sdpa/sdpa_solve.cpp delete mode 100644 external/sdpa/sdpa_struct.cpp delete mode 100644 external/sdpa/sdpa_struct.h delete mode 100644 external/sdpa/sdpa_tool.cpp delete mode 100644 external/sdpa/sdpa_tool.h create mode 100644 src/Engine/Serialization/ArchiveBuffer.h create mode 100644 src/Engine/Serialization/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index c9902a5..fb16994 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,7 +88,7 @@ endif() add_executable(Editor "") target_link_libraries(Editor PRIVATE Engine) target_include_directories(Editor PRIVATE src/Editor) -target_compile_definitions(Editor PRIVATE EDITOR) +#target_compile_definitions(Editor PRIVATE EDITOR) target_precompile_headers(Engine PUBLIC diff --git a/external/sdpa/AUTHORS b/external/sdpa/AUTHORS deleted file mode 100644 index bb17bec..0000000 --- a/external/sdpa/AUTHORS +++ /dev/null @@ -1,15 +0,0 @@ --------------------------------------------------- -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. - diff --git a/external/sdpa/COPYING b/external/sdpa/COPYING deleted file mode 100644 index 623b625..0000000 --- a/external/sdpa/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - 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. - - - Copyright (C) - - 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. - - , 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. diff --git a/external/sdpa/ChangeLog b/external/sdpa/ChangeLog deleted file mode 100644 index a56684d..0000000 --- a/external/sdpa/ChangeLog +++ /dev/null @@ -1,10 +0,0 @@ -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 - - diff --git a/external/sdpa/INSTALL b/external/sdpa/INSTALL deleted file mode 100644 index bb1a856..0000000 --- a/external/sdpa/INSTALL +++ /dev/null @@ -1,160 +0,0 @@ - -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. - diff --git a/external/sdpa/Makefile b/external/sdpa/Makefile deleted file mode 100644 index 466d551..0000000 --- a/external/sdpa/Makefile +++ /dev/null @@ -1,100 +0,0 @@ - -## 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 diff --git a/external/sdpa/Makefile.in b/external/sdpa/Makefile.in deleted file mode 100644 index 7ac3cee..0000000 --- a/external/sdpa/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -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 diff --git a/external/sdpa/Makefile.inc b/external/sdpa/Makefile.inc deleted file mode 100644 index c0742b5..0000000 --- a/external/sdpa/Makefile.inc +++ /dev/null @@ -1,8 +0,0 @@ -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/ diff --git a/external/sdpa/NEWS b/external/sdpa/NEWS deleted file mode 100644 index c9256a8..0000000 --- a/external/sdpa/NEWS +++ /dev/null @@ -1,2 +0,0 @@ -For the latest news on SDPA, please refer to -http://sdpa.sourceforge.net/ diff --git a/external/sdpa/example1.dat-s b/external/sdpa/example1.dat-s deleted file mode 100644 index 58bc643..0000000 --- a/external/sdpa/example1.dat-s +++ /dev/null @@ -1,12 +0,0 @@ -"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 diff --git a/external/sdpa/example2-1.dat-s b/external/sdpa/example2-1.dat-s deleted file mode 100644 index 9fb3f4f..0000000 --- a/external/sdpa/example2-1.dat-s +++ /dev/null @@ -1,70 +0,0 @@ -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 diff --git a/external/sdpa/example2.dat b/external/sdpa/example2.dat deleted file mode 100644 index bc09281..0000000 --- a/external/sdpa/example2.dat +++ /dev/null @@ -1,54 +0,0 @@ -*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 } -} diff --git a/external/sdpa/example2.dat-s b/external/sdpa/example2.dat-s deleted file mode 100644 index cdf8bf3..0000000 --- a/external/sdpa/example2.dat-s +++ /dev/null @@ -1,72 +0,0 @@ -*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 diff --git a/external/sdpa/libexample/Makefile b/external/sdpa/libexample/Makefile deleted file mode 100644 index a7af784..0000000 --- a/external/sdpa/libexample/Makefile +++ /dev/null @@ -1,46 +0,0 @@ - -############################################################# -# 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 diff --git a/external/sdpa/libexample/example1.cpp b/external/sdpa/libexample/example1.cpp deleted file mode 100644 index 9512d60..0000000 --- a/external/sdpa/libexample/example1.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/* ------------------------------------------------------------- - -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 -#include -#include - -/* -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 - ) / (1 + || + ||)]\n"); - fprintf(fpout, "err6 = "); - fprintf(fpout, printFormat, dimacs_error[6]); - fprintf(fpout, " [ / (1 + || + ||)]\n"); - fprintf(fpout, "\n"); -} - diff --git a/external/sdpa/libexample/example2.cpp b/external/sdpa/libexample/example2.cpp deleted file mode 100644 index 4c36415..0000000 --- a/external/sdpa/libexample/example2.cpp +++ /dev/null @@ -1,411 +0,0 @@ -/* ------------------------------------------------------------- - -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 -#include -#include - -/* -*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 - ) / (1 + || + ||)]\n"); - fprintf(fpout, "err6 = "); - fprintf(fpout, printFormat, dimacs_error[6]); - fprintf(fpout, " [ / (1 + || + ||)]\n"); - fprintf(fpout, "\n"); -} - diff --git a/external/sdpa/libexample/example5.cpp b/external/sdpa/libexample/example5.cpp deleted file mode 100644 index c43173a..0000000 --- a/external/sdpa/libexample/example5.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* ------------------------------------------------------------- - -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 -#include -#include - -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); -} diff --git a/external/sdpa/libexample/gmon.out b/external/sdpa/libexample/gmon.out deleted file mode 100644 index cc2191dda9ed5dcc16b4461b7c973528d4517a20..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2341806 zcmeI&eXOKcUBL0VtJW@P9iSp>luWA7u0k?`Y0^J1w_4FnpiUY?(oo4H)WroUgNV9` zCSy%Vs{{wc#??}Wf-5VeT$|DtU+RFRX0^s~DYb2c3|pu!2o7|+WL1cF&iNfV&&`Sd z`p<`i4D-Fe=RD8znP*;?*S+ygH*EFx{AYCOm8snO>YLK-_x;1Ode`s%uebdCYu|Lk z^=~QD|NB2ma7%yy0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72y6tlFc2U>fB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ;Qv)%Ykk?3 z=>YEfp?tfwdv9xeFyA@z(kf0Pp1-<^^N7Ft$|~+eJo?2SPit>&)-3Vlx)BdQRmDZw z(bH92mH3a1c*oCFdmqP{Jik7pMcg^|SJmdri1$5E#Z|5szK>6W`qXxD}@n&)idOK8tvwR@#Yp{?pZQ zE+QUURdH3;tm8W3vD4LL??rj92R~QEe#9&4$9)v>Gd1!wE|&u}@*?8JpQz4g8FBky z^>CDUb3M6=$vf+~j(GUJ)tV*tUR`z`yQ`0Uq!rVeO5Hul%X}Xr{Q1*qQ9zk|)dcnI?x3JCh~e_>?)B2lC_vn{yvU9R76`ml2O$P_4O& zxc|4RIE`0?Yg@7Z?bYNgCcpaIRa{0aYhJiHq~1KAQCTy^e#EkQit~6%pSr1Db5G1` z-k#Silbv|-=Dc}|!_t!Kbj{>Ol!{K&8hQ@o44Xl z#K$hG)?BpWvK3dYxNgPXU*_ZN?5N+0gH{~2;&wAG@{Y=-n4X5?h!=lXb($p}dv+Bk zt;rHQlhf8@iJi$=YqG@7!{K6Sp=`nRzSj?1^d3(WCi{j(#P-ex}XGkLP&jLscBc zr-~<^SzR{ch=;GQ;^bfR=Ku8CeEV&iLt6b?zSBFBZ})HF_zU^Yo$<1kV*iUdmY1Lu zcfOS4pPkLO2R56}zMSuz_)^~c57zO>x{CAv$djkfR>!$4@pl^WRd26if8E_Yz1nO? zER!jY%4DpWV*kSIxc|rUn%|wy{aHD7-p(cww_lRq%F`R)v^6<>Zr*(Goq5ePx&6W% z%R53Rp1H7^9JMA(>`abZlO=X0C#}g6JCoDaWQm>0S!=Sy&gA&geD3$ho9Sg6o)~(6@ zhx3}(#IreFOC=t9MgC)ogP82BSz_mqrZIV4ylkY+7ZE#?>yI?fsJD}2XGg<38>T{4 z71t5p91ly{ymxPF&4_mgVVWG4$$&|5J7Q<=C3fVeF&H`c#gc7uDV;bG$8H8Pew45zDJhild0-H6+Dx z#PSlNQ6(c}soplZaQx`+VB_EaFA=uW<8-$KO_+(IR5!_qq~a zb}XN6T5}bXFNrTtDXt?Ph{r$0-qVc-t{?GSeK8DLlf#IeM{_&kq54O>QN(NStIlW~ z@xDK=;w0jM&s1kLjd=2O73UGlrI^mB#Qkxd=F>daIL$%Cr%zRTpGGYI;*c)yoz~`y zh@Ep^N9>$t?`wJQw_a5pd_Urubrt6kkDaa#sl>P6-S#w6*3=#NYg6rc1}Ui1?~^S8*Nj&O1z-&s%G*A{O~HxsF)mQ|x^suT_v!>_;pQM~Z`pMLxx0#3G;K zc8MXM;y7ZFPjS@G?*!%Z((YH8-A~l038({+c{lK5nJhJDlT#@#SvcW^x_B z?6o|q1P z@mOB#*FRRRId~%9DUVT_+-}8DE6yVR?C(}<&RcP(6&I~Ik9XGc2{0)wKc9C{;s-Yu z!{py{eEEarYti{!bCAH_O9j?G`1H}AyJt8dyp++OeCrB|lgw0Vi=U)YEz oTk%*c9%;oZT5*3XKK6pf-cPjR(N;XviU(Tpy7+$qY|j0E0FZAFzW@LL diff --git a/external/sdpa/libexample/param.sdpaC b/external/sdpa/libexample/param.sdpaC deleted file mode 100644 index a9ec655..0000000 --- a/external/sdpa/libexample/param.sdpaC +++ /dev/null @@ -1,15 +0,0 @@ -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) - diff --git a/external/sdpa/make.head b/external/sdpa/make.head deleted file mode 100644 index 7d745a3..0000000 --- a/external/sdpa/make.head +++ /dev/null @@ -1,30 +0,0 @@ -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 diff --git a/external/sdpa/make.inc b/external/sdpa/make.inc deleted file mode 100644 index 1bdb9ef..0000000 --- a/external/sdpa/make.inc +++ /dev/null @@ -1,62 +0,0 @@ -######################################################### -# 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) diff --git a/external/sdpa/mex/CommandList.txt b/external/sdpa/mex/CommandList.txt deleted file mode 100644 index b62cf21..0000000 --- a/external/sdpa/mex/CommandList.txt +++ /dev/null @@ -1,60 +0,0 @@ -This is a short list for SDPA-M command. - -(1) read_data.m ->> [mDIM,nBLOCK,bLOCKsTRUCT,c,F] = read_data('example1.dat-s'); -will read 'example1.dat-s' into the SDPA-M structures. - -(2) paramC.m ->> OPTION=paramC; -will prepare default parameter. You can change the parameter -by this OPTION structure. - -(3) sdpam.m ->> [objVal,x,X,Y,INFO] = sdpam(mDIM,nBLOCK,bLOCKsTRUCT,c,F); -or ->> [objVal,x,X,Y,INFO] = sdpam(mDIM,nBLOCK,bLOCKsTRUCT,c,F,OPTION); -will solve the SDP. - -(4) gensdpafile.m ->> gensdpafile('myexample.dat-s',mDIM,nBLOCK,bLOCKsTRUCT,c,F); -will output the SDPA-M structure into 'myexample.dat-s'. - -(5) initial_point.m ->> [x0,X0,Y0] = initial_point('example1.ini-s', mDIM, nBLOCK, bLOCKsTRUCT); -will read an initial point from 'example1.ini-s'. -You need to prepare mDIM, nBLOCK, bLOCKsTRUCT by read_data.m - -(6) SDPAToSedumi.m ->> [At,b,c,K,blockStruct] = SDPAToSedumi('example1.dat-s'); -will read 'example1.dat-s' into SeDuMi structures with -an additional structure 'blockStruct'. - -(7) sedumiwrap.m ->> [x,y,info]=sedumiwrap(A,b,c,K,pars,OPTION); -will solve the SDP given in SeDuMi strucutres. -The 5th argument 'pars' will be ignored -and the 6th argument can be prepared by param.m - -(8) SedumiToSDPA.m ->> SedumiToSDPA('myexample.dat-s',A,b,c,K,'%8.16e'); -will output SeDuMi structures into 'myexample.dat-s'. -'%8.16' determines the output style by printf-format. - -(9) read_output.m ->> [objVal,x,X,Y,INFO] = read_output('example1.result',mDIM,nBLOCK,bLOCKsTRUCT); -will read the result file generated by SDPA. -If you solve 'example1.dat-s' by -$ ./sdpa example1.dat-s example1.result -then this result can be read by ->> [mDIM,nBLOCK,bLOCKsTRUCT,c,F] = read_data('example1.dat-s'); ->> [objVal,x,X,Y,INFO] = read_output('example1.result',mDIM,nBLOCK,bLOCKsTRUCT); - -(10) read_outputSedumi.m ->> [x,y,info] = read_outputSedumi('example1.result',m,K); -will read the result file generated by SDPA. -If you solve 'example1.dat-s' by -$ ./sdpa example1.dat-s example1.result -then this result can be read by ->> [At,b,c,K,blockStruct] = SDPAToSedumi('example1.dat-s'); ->> [x,y,info] = read_outputSedumi('example1.result',m,K); - diff --git a/external/sdpa/mex/Makefile b/external/sdpa/mex/Makefile deleted file mode 100644 index bfb4d0c..0000000 --- a/external/sdpa/mex/Makefile +++ /dev/null @@ -1,131 +0,0 @@ -# -# SDPA-M: $Revision: 7.3 $ -# -# For Matlab -# $ make -# For Octave -# $ make COMPILE_ENVIRONMENT=octave - -# 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 -# In addition, for Octave, you should try -# make MAKE_INCLUDE_DIR=/usr/local/share/sdpa COMPILE_ENVIRONMENT=octave - - -# To compile with mingw, the following command is a sample. -# Your need to modify directory names and compiler names. -# make MEX="i586-mingw32msvc-g++ -shared" COMPILE_ENVIRONMENT=octave \ -# PRINTF_INT_STYLE=-DPRINTF_INT_STYLE=\\\"%zd\\\" \ -# OUTPUT_FORMAT="-o \$@.mexw32" \ -# MATLAB_INCLUDE="-Imatlab-extern/include" \ -# MATLAB_LIBS="-I/matlab-extern/microsoft/libmx.lib -I/matlab-extern/microsoft/libmex.lib" \ - - -# for only SDPA-Project members -# set DEVELOPEMENT_STAGE=1 to compile without 'make install' -# For example -# make MAKE_INCLUDE_DIR=../etc DEVELOPEMENT_STAGE=1 -# In addition, for Octave, you should try -# make MAKE_INCLUDE_DIR=../etc DEVELOPEMENT_STAGE=1 COMPILE_ENVIRONMENT=octave - -# 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 - -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 - -MEX = mex -DEF_FPIC = -fPIC - -CXXFLAGSOPTIONS = CXXFLAGS="-Wall -fPIC" -O -DNDEBUG CC=${CC} CXX=${CXX} -LARGEARRAYOPTION = -largeArrayDims - -SDPA_INCLUDE = -I${SDPA_DIR}/include -ifeq ($(DEVELOPEMENT_STAGE),1) - SDPA_INCLUDE = -I.. - SDPA_LIB = ../libsdpa-c.a -endif - -PRINTF_INT_STYLE = -DPRINTF_INT_STYLE=\\\"%zd\\\" -# Output format is usually automatically set by mex command. -OUTPUT_FORMAT = - -ifeq ($(COMPILE_ENVIRONMENT),octave) - MEX = CC=${CC} CXX=${CXX} mkoctfile --mex - CXXFLAGSOPTIONS = - LARGEARRAYOPTION = - PRINTF_INT_STYLE = -DPRINTF_INT_STYLE=\\\"%d\\\" -endif - -ALL_OPTION = ${CXXFLAGSOPTIONS} ${LARGEARRAYOPTION} ${PRINTF_INT_STYLE} - -all: mexsdpaC mexSedumiWrapC -# all: mexSedumiWrap - -mexBinaryCheck: - @echo "---------------------------------------------" - @echo "Mex Compilation Start " - @echo "---------------------------------------------" - @if [ -f $(MEX) ]; then \ - echo "---------------------------------------------" ;\ - echo " We use " ;\ - echo " " $(MEX) ;\ - echo " for Mex compilaton " ;\ - echo "---------------------------------------------" ;\ - else \ - echo "---------------------------------------------" ;\ - echo "Automatic search is failed, " ;\ - echo " Set the full path for mex command mannually " ;\ - echo " in "`pwd`"/Makekefile" ;\ - echo " and try 'make' in `pwd` " ;\ - echo "---------------------------------------------" ;\ - false ;\ - fi - -mexsdpaC: - ${MEX} ${ALL_OPTION} \ - ${OUTPUT_FORMAT} \ - ${SDPA_INCLUDE} ${sdpac_all_include} \ - mexsdpaC.cpp mexFprintf.c \ - ${SDPA_LIB} ${sdpac_all_lib} - -mexSedumiWrapC: - ${MEX} ${ALL_OPTION} \ - ${OUTPUT_FORMAT} \ - ${SDPA_INCLUDE} ${sdpac_all_include} \ - mexSedumiWrapC.cpp mexFprintf.c \ - ${SDPA_LIB} ${sdpac_all_lib} - -# clean all generated files -clean: - rm -f *~ *.o -dist-clean: clean - rm -f mexsdpaC.mex* mexSedumiWrapC.mex* - -# -# End of File -# diff --git a/external/sdpa/mex/mexFprintf.c b/external/sdpa/mex/mexFprintf.c deleted file mode 100644 index 7d57758..0000000 --- a/external/sdpa/mex/mexFprintf.c +++ /dev/null @@ -1,116 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ - -#include -#include -#include -#include - -#include - - -#define BUF_LENGTH 4096 - -int fprintf(FILE *stream, const char *format, ...) -{ - va_list arg; - va_start(arg,format); - int return_size = 0; - if (stream == stdout) { - char tmp_buf[BUF_LENGTH]; - vsprintf(tmp_buf,format,arg); - #if 0 - printf("tmp_buf = %s",tmp_buf); - #endif - mexPrintf(tmp_buf); - mexEvalString("drawnow;"); /* to dump string.*/ - return_size = strlen(tmp_buf); - if ( return_size >= BUF_LENGTH ) { - mexPrintf("Too Long Message To PrintOut " - "(some part might be truncated)"); - } - } - else { - return_size = vfprintf(stream,format,arg); - } - va_end(arg); - return return_size; -} - -static int internal_fprintf(FILE *stream, const char *format, ...) -{ - va_list arg; - va_start(arg,format); - int return_size = 0; - return_size = vfprintf(stream,format,arg); - va_end(arg); - return return_size; -} - -size_t fwrite(const void *ptr, size_t size, size_t nmemb, - FILE *stream) -{ - #if 1 - fprintf(stream,"%s",(const char*)ptr); - #else - // internal_fprintf does not work well here - internal_fprintf(stream, (const char*) internal_fprintf); - #endif - return 1; -} - -int fputc(int c, FILE* fp) -{ - if (fp == stdout) { - mexPrintf("%c",(unsigned char)c); - } - else { - internal_fprintf(fp,"%c",c); - /* fprintf(fp,"%c ",c);*/ - } - return c; -} - -#ifdef __GNUC__ -/*Only GNU, to avoid - warning: 'noreturn' function does return -*/ -static void internal_exit() __attribute__ ((noreturn)); -extern void mexErrMsgTxt(const char*) __attribute__ ((noreturn)); - void exit() __attribute__ ((noreturn)); - void abort() __attribute__ ((noreturn)); -#endif - -static void internal_exit() -{ - mexWarnMsgTxt("SDPA-C exits with some error."); - mexWarnMsgTxt("Matlab should be reboot to clear up memory space."); - mexErrMsgTxt("SDPA-C exits with some error."); -} - -void exit(int status) -{ - internal_exit(); -} -void abort(void) -{ - internal_exit(); -} diff --git a/external/sdpa/mex/mexSedumiWrapC.cpp b/external/sdpa/mex/mexSedumiWrapC.cpp deleted file mode 100644 index ce5d073..0000000 --- a/external/sdpa/mex/mexSedumiWrapC.cpp +++ /dev/null @@ -1,655 +0,0 @@ -/* - * 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 - * - * SDPA-M: 7.3 - * mexsdpa.cpp - */ - -#include -/* - * SDPA header files - */ -#include -#include -using namespace sdpa; - -extern void _main(); - -void sdpasolver(mxArray* At_ptr, mxArray* b_ptr, mxArray* c_ptr, - mxArray* K_ptr, mxArray* OPTION_ptr, - mxArray* x_ptr, mxArray* y_ptr, - mxArray* info_ptr) -{ - time_t ltime; - time(<ime); - char string_time[1024]; - strcpy(string_time,ctime(<ime)); - string_time[strlen(string_time)-1]='\0'; - - SDPA sdpa; - - int maxIteration = 0; - double param = 0.0; - /* mxArray pointer */ - mxArray *field_ptr = NULL; - int nSymmChk = 0; - int nDimacs = 0; - - /* strings for phase value */ - const char *szPhase[] = { - "noINFO", "pFEAS", "dFEAS", "pdFEAS", "pdINF", - "pFEAS_dINF", "pINF_dFEAS", "pdOPT", "pUNBD", "dUNBD"}; - - /* output file */ - char *outfile = NULL; - FILE *fp = NULL; - FILE *fpResult = NULL; - int nOutfile = 0; - - mwSize mDIM; - mwSize nBLOCK; - - /* temporary variables */ - mwIndex k; - int size; - mwSize mwsize; - double *tmp_ptr = NULL; - char* tmpPrint = NULL; - - TimeStart(SDPA_START); - TimeStart(SDPA_CONVERT_START); - - /*** Set SDPA parameters by OPTIONS ***/ - /* Max Iteration */ - field_ptr = mxGetField(OPTION_ptr, 0, "maxIteration"); - if( field_ptr != NULL ){ - maxIteration = (int)mxGetScalar(field_ptr); - // mexPrintf("maxIteration = %d\n",maxIteration); - sdpa.setParameterMaxIteration(maxIteration); - } - /* epsilonStar */ - field_ptr = mxGetField(OPTION_ptr, 0, "epsilonStar"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterEpsilonStar(param); - } - /* lambdaStar */ - field_ptr = mxGetField(OPTION_ptr, 0, "lambdaStar"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterLambdaStar(param); - } - /* omegaStar */ - field_ptr = mxGetField(OPTION_ptr, 0, "omegaStar"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterOmegaStar(param); - } - /* lowerBound */ - field_ptr = mxGetField(OPTION_ptr, 0, "lowerBound"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterLowerBound(param); - } - /* upperBound */ - field_ptr = mxGetField(OPTION_ptr, 0, "upperBound"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterUpperBound(param); - } - /* betaStar */ - field_ptr = mxGetField(OPTION_ptr, 0, "betaStar"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterBetaStar(param); - } - /* betaBar */ - field_ptr = mxGetField(OPTION_ptr, 0, "betaBar"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterBetaBar(param); - } - /* gammaStar */ - field_ptr = mxGetField(OPTION_ptr, 0, "gammaStar"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterGammaStar(param); - } - /* epsilonDash */ - field_ptr = mxGetField(OPTION_ptr, 0, "epsilonDash"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterEpsilonDash(param); - } - /* xPrint */ - field_ptr = mxGetField(OPTION_ptr, 0, "xPrint"); - if( field_ptr != NULL ){ - mwsize = mxGetM(field_ptr) * mxGetN(field_ptr) + 1; - tmpPrint = (char*)mxCalloc(mwsize, sizeof(char)); - mxGetString(field_ptr, tmpPrint, mwsize); - sdpa.setParameterPrintXVec(tmpPrint); - mxFree(tmpPrint); - } - /* XPrint */ - field_ptr = mxGetField(OPTION_ptr, 0, "XPrint"); - if( field_ptr != NULL ){ - mwsize = mxGetM(field_ptr) * mxGetN(field_ptr) + 1; - tmpPrint = (char*)mxCalloc(mwsize, sizeof(char)); - mxGetString(field_ptr, tmpPrint, mwsize); - sdpa.setParameterPrintXMat(tmpPrint); - mxFree(tmpPrint); - } - /* YPrint */ - field_ptr = mxGetField(OPTION_ptr, 0, "YPrint"); - if( field_ptr != NULL ){ - mwsize = mxGetM(field_ptr) * mxGetN(field_ptr) + 1; - tmpPrint = (char*)mxCalloc(mwsize, sizeof(char)); - mxGetString(field_ptr, tmpPrint, mwsize); - sdpa.setParameterPrintYMat(tmpPrint); - mxFree(tmpPrint); - } - /* infPrint */ - field_ptr = mxGetField(OPTION_ptr, 0, "infPrint"); - if( field_ptr != NULL ){ - mwsize = mxGetM(field_ptr) * mxGetN(field_ptr) + 1; - tmpPrint = (char*)mxCalloc(mwsize, sizeof(char)); - mxGetString(field_ptr, tmpPrint, mwsize); - sdpa.setParameterPrintInformation(tmpPrint); - mxFree(tmpPrint); - } - - - /* isSymmetric */ - field_ptr = mxGetField(OPTION_ptr, 0, "isSymmetric"); - if( field_ptr != NULL ){ - nSymmChk = (int)mxGetScalar(field_ptr); - } - /* isDimacs */ - field_ptr = mxGetField(OPTION_ptr, 0, "isDimacs"); - if( field_ptr != NULL ){ - nDimacs = (int)mxGetScalar(field_ptr); - } - /* print */ - field_ptr = mxGetField(OPTION_ptr, 0, "print"); - if( field_ptr != NULL ){ - mwsize = mxGetM(field_ptr) * mxGetN(field_ptr) + 1; - if (mwsize == 1) { - // mexPrintf("display is NULL\n"); - fp = NULL; - } - else { - outfile = (char*)mxCalloc(mwsize, sizeof(char)); - mxGetString(field_ptr, outfile, mwsize); - if( strncmp("display", outfile, mwsize - 1) == 0 ){ - fp = stdout; - } else if( strncmp("no", outfile, mwsize - 1) == 0 ){ - fp = NULL; - } else { - fp = fopen(outfile, "at"); - if( fp == NULL ){ - mexPrintf("Failed to open %s\n", outfile); - fp = stdout; - } else { - nOutfile = 1; - } - } - mxFree(outfile); - } - } else { - /* default setting is displaying information to stdout */ - fp = stdout; - } - sdpa.setDisplay(fp); - - /* resultFile */ - field_ptr = mxGetField(OPTION_ptr, 0, "resultFile"); - if( field_ptr != NULL ){ - mwsize = mxGetM(field_ptr) * mxGetN(field_ptr) + 1; - if (mwsize == 1) { - // mexPrintf("resultFile is NULL\n"); - } - else { - outfile = (char*)mxCalloc(mwsize, sizeof(char)); - mxGetString(field_ptr, outfile, mwsize); - if ( strncmp("no", outfile, mwsize - 1) == 0 ) { - mexPrintf("resultFile is NULL\n"); - } - else { - fpResult = fopen(outfile, "w"); - if ( fpResult == NULL ) { - mexPrintf("Failed to open %s\n", outfile); - mexPrintf("Skip the detail file\n"); - } else { - sdpa.setResultFile(fpResult); - } - } - mxFree(outfile); - } - } - - if (fp) { - fprintf(fp,"SDPA-C start at [%s]\n",string_time); - } - if (fpResult) { - fprintf(fpResult,"SDPA-C start at [%s]\n",string_time); - } - - if (nDimacs != 0) { - if (sdpa.judgeDimacsAvailability() == false) { - if (fp) { - fprintf(fp, "Dimacs will be skipped by XPrint and YPrint parameter.\n"); - } - if (fpResult) { - fprintf(fpResult, "Dimacs will be skipped by XPrint and YPrint parameter.\n"); - } - nDimacs = 0; - } - } - - /* NumThreads */ - field_ptr = mxGetField(OPTION_ptr, 0, "NumThreads"); - if( field_ptr != NULL ){ - sdpa.setNumThreads((int)mxGetScalar(field_ptr)); - } - - /*** initialize SDPA class members ***/ - /* mDIM */ - mDIM = mxGetN(At_ptr); - sdpa.inputConstraintNumber(mDIM); - /* nBLOCK */ - nBLOCK = 0; - mwSize K_l = 0; - int isK_l = 0; // 1 (K_l > 0) or 0 (K_l == 0) - field_ptr = mxGetField(K_ptr, 0, "l"); - if (field_ptr != NULL) { - K_l = (mwSize)((mxGetPr(field_ptr))[0]); - #if 0 - mexPrintf("K_l = %zd\n", K_l); - #endif - if (K_l > 0) { - isK_l = 1; - nBLOCK++; - } - } - mwSize* K_s = NULL; - mwSize* K_sdpConeStart = NULL; - int K_sdpNoCones = 0; - field_ptr = mxGetField(K_ptr, 0, "s"); - if (field_ptr != NULL) { - K_sdpNoCones = (int) mxGetM(field_ptr); - K_s = (mwSize*) mxCalloc(K_sdpNoCones, sizeof(mwSize)); - K_sdpConeStart = (mwSize*) mxCalloc(K_sdpNoCones+1, sizeof(mwSize)); - K_sdpConeStart[0] = 0; - for (int l=0; l 0) { - sdpa.inputBlockSize(1, K_l); - sdpa.inputBlockType(1, SDPA::LP); - } - for (int l=0; l 0) { - size = sdpa.getBlockSize(1); - tmp_ptr = sdpa.getResultYMat(1); - for (int index = 0; index < size; ++index) { - x[index] = tmp_ptr[index]; - } - } - for (int l=0; l -/* - * SDPA header files - */ -#include - -extern void _main(); - -void sdpasolver(double *mDIM_ptr, - double *nBLOCK_ptr, - double *bLOCKsTRUCT_ptr, - double *c_ptr, - mxArray *F_ptr, - double *x0_ptr, - mxArray *X0_ptr, - mxArray *Y0_ptr, - mxArray *OPTION_ptr, - int IniPt, - double *objVal_ptr, - double *x_ptr, - mxArray *X_ptr, - mxArray *Y_ptr, - mxArray *INFO_ptr) -{ - time_t ltime; - time(<ime); - char string_time[1024]; - strcpy(string_time,ctime(<ime)); - string_time[strlen(string_time)-1]='\0'; - - SDPA sdpa; - - int maxIteration = 0; - double param = 0.0; - /* mxArray pointer */ - mxArray *field_ptr = NULL; - mxArray *cell_ptr = NULL; - - int nSymmChk = 0; - int nDimacs = 0; - - /* strings for phase value */ - const char *szPhase[] = { - "noINFO", "pFEAS", "dFEAS", "pdFEAS", "pdINF", - "pFEAS_dINF", "pINF_dFEAS", "pdOPT", "pUNBD", "dUNBD"}; - - /* output file */ - char *outfile = NULL; - FILE *fp = NULL; - FILE *fpResult = NULL; - int nOutfile = 0; - - mwSize mDIM; - mwSize nBLOCK; - - /* temporary variables */ - mwIndex i,j,k,l; - int size; - mwSize mwsize; - mwIndex idx, startidx, endidx; - mwSize sizeM, sizeN; - mwIndex *subscript = NULL; - mwIndex *dims = NULL; - int cell_index = 0; - mwIndex *ir_ptr = NULL; - mwIndex *jc_ptr = NULL; - double *tmp_ptr = NULL; - double *result_ptr = NULL; - char* tmpPrint = NULL; - - /*** Set SDPA parameters by OPTIONS ***/ - /* Max Iteration */ - field_ptr = mxGetField(OPTION_ptr, 0, "maxIteration"); - if( field_ptr != NULL ){ - maxIteration = (int)mxGetScalar(field_ptr); - sdpa.setParameterMaxIteration(maxIteration); - } - /* epsilonStar */ - field_ptr = mxGetField(OPTION_ptr, 0, "epsilonStar"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterEpsilonStar(param); - } - /* lambdaStar */ - field_ptr = mxGetField(OPTION_ptr, 0, "lambdaStar"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterLambdaStar(param); - } - /* omegaStar */ - field_ptr = mxGetField(OPTION_ptr, 0, "omegaStar"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterOmegaStar(param); - } - /* lowerBound */ - field_ptr = mxGetField(OPTION_ptr, 0, "lowerBound"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterLowerBound(param); - } - /* upperBound */ - field_ptr = mxGetField(OPTION_ptr, 0, "upperBound"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterUpperBound(param); - } - /* betaStar */ - field_ptr = mxGetField(OPTION_ptr, 0, "betaStar"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterBetaStar(param); - } - /* betaBar */ - field_ptr = mxGetField(OPTION_ptr, 0, "betaBar"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterBetaBar(param); - } - /* gammaStar */ - field_ptr = mxGetField(OPTION_ptr, 0, "gammaStar"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterGammaStar(param); - } - /* epsilonDash */ - field_ptr = mxGetField(OPTION_ptr, 0, "epsilonDash"); - if( field_ptr != NULL ){ - param = *mxGetPr(field_ptr); - sdpa.setParameterEpsilonDash(param); - } - /* xPrint */ - field_ptr = mxGetField(OPTION_ptr, 0, "xPrint"); - if( field_ptr != NULL ){ - mwsize = mxGetM(field_ptr) * mxGetN(field_ptr) + 1; - tmpPrint = (char*)mxCalloc(mwsize, sizeof(char)); - mxGetString(field_ptr, tmpPrint, mwsize); - sdpa.setParameterPrintXVec(tmpPrint); - mxFree(tmpPrint); - } - /* XPrint */ - field_ptr = mxGetField(OPTION_ptr, 0, "XPrint"); - if( field_ptr != NULL ){ - mwsize = mxGetM(field_ptr) * mxGetN(field_ptr) + 1; - tmpPrint = (char*)mxCalloc(mwsize, sizeof(char)); - mxGetString(field_ptr, tmpPrint, mwsize); - sdpa.setParameterPrintXMat(tmpPrint); - mxFree(tmpPrint); - } - /* YPrint */ - field_ptr = mxGetField(OPTION_ptr, 0, "YPrint"); - if( field_ptr != NULL ){ - mwsize = mxGetM(field_ptr) * mxGetN(field_ptr) + 1; - tmpPrint = (char*)mxCalloc(mwsize, sizeof(char)); - mxGetString(field_ptr, tmpPrint, mwsize); - sdpa.setParameterPrintYMat(tmpPrint); - mxFree(tmpPrint); - } - /* infPrint */ - field_ptr = mxGetField(OPTION_ptr, 0, "infPrint"); - if( field_ptr != NULL ){ - mwsize = mxGetM(field_ptr) * mxGetN(field_ptr) + 1; - tmpPrint = (char*)mxCalloc(mwsize, sizeof(char)); - mxGetString(field_ptr, tmpPrint, mwsize); - sdpa.setParameterPrintInformation(tmpPrint); - mxFree(tmpPrint); - } - - /* isSymmetric */ - field_ptr = mxGetField(OPTION_ptr, 0, "isSymmetric"); - if( field_ptr != NULL ){ - nSymmChk = (int)mxGetScalar(field_ptr); - } - /* isDimacs */ - field_ptr = mxGetField(OPTION_ptr, 0, "isDimacs"); - if( field_ptr != NULL ){ - nDimacs = (int)mxGetScalar(field_ptr); - } - /* print */ - field_ptr = mxGetField(OPTION_ptr, 0, "print"); - if( field_ptr != NULL ){ - mwsize = mxGetM(field_ptr) * mxGetN(field_ptr) + 1; - if (mwsize == 1) { - // mexPrintf("display is NULL\n"); - fp = NULL; - } - else { - outfile = (char*)mxCalloc(mwsize, sizeof(char)); - mxGetString(field_ptr, outfile, mwsize); - if( strncmp("display", outfile, mwsize - 1) == 0 ){ - fp = stdout; - } else if( strncmp("no", outfile, mwsize - 1) == 0 ){ - fp = NULL; - } else { - fp = fopen(outfile, "at"); - if( fp == NULL ){ - mexPrintf("Failed to open %s\n", outfile); - fp = stdout; - } else { - nOutfile = 1; - } - } - mxFree(outfile); - } - } else { - /* default setting is displaying information to stdout */ - fp = stdout; - } - sdpa.setDisplay(fp); - - /* resultFile */ - field_ptr = mxGetField(OPTION_ptr, 0, "resultFile"); - if( field_ptr != NULL ){ - mwsize = mxGetM(field_ptr) * mxGetN(field_ptr) + 1; - if (mwsize == 1) { - // mexPrintf("resultFile is NULL\n"); - } - else { - outfile = (char*)mxCalloc(mwsize, sizeof(char)); - mxGetString(field_ptr, outfile, mwsize); - fpResult = fopen(outfile, "w"); - if( fpResult == NULL ){ - mexPrintf("Failed to open %s\n", outfile); - mexPrintf("Skip the detail file\n"); - } else { - sdpa.setResultFile(fpResult); - } - mxFree(outfile); - } - } - - if (fp) { - fprintf(fp,"SDPA-C start at [%s]\n",string_time); - } - if (fpResult) { - fprintf(fpResult,"SDPA-C start at [%s]\n",string_time); - } - - if (nDimacs) { - if (sdpa.judgeDimacsAvailability() == false) { - if (fp) { - fprintf(fp, "Dimacs will be skipped by XPrint and YPrint parameter.\n"); - } - if (fpResult) { - fprintf(fpResult, "Dimacs will be skipped by XPrint and YPrint parameter.\n"); - } - } - } - - - /* NumThreads */ - field_ptr = mxGetField(OPTION_ptr, 0, "NumThreads"); - if( field_ptr != NULL ){ - sdpa.setNumThreads((int)mxGetScalar(field_ptr)); - } - - /*** initialize SDPA class members ***/ - /* mDIM */ - mDIM = (mwSize)(*mDIM_ptr); - sdpa.inputConstraintNumber(mDIM); - /* nBLOCK */ - nBLOCK = (mwSize)(*nBLOCK_ptr); - sdpa.inputBlockNumber(nBLOCK); - /* bLOCKsTRUCT */ - for(i = 0; i < nBLOCK; i++){ - int bs = (int)(bLOCKsTRUCT_ptr[i]); - sdpa.inputBlockSize(i+1,bs); - if (bs < 0 || bs == 1) { - sdpa.inputBlockType(i+1,SDPA::LP); - } - else { - sdpa.inputBlockType(i+1,SDPA::SDP); - } - } - /* Execute initializeUpperTriangleSpace() */ - sdpa.initializeUpperTriangleSpace(); - /* cVECT */ - for(i = 0; i < mDIM; i++){ - sdpa.inputCVec(i+1, c_ptr[i]); - } - - /*** Count NonZeroNumber in coefficience matrices ***/ - // Do nothing for SDPA 7 - - /*** Set coefficience matrices value ***/ - subscript = (mwIndex*)mxCalloc(2,sizeof(mwIndex)); - dims = (mwIndex*)mxGetDimensions(F_ptr); - for(l = 0; l < dims[0]; l++){ - for(k = 0; k < dims[1]; k++){ - subscript[0]=l; subscript[1]=k; - cell_index = mxCalcSingleSubscript(F_ptr, 2, subscript); - cell_ptr = mxGetCell(F_ptr, cell_index); - // mxGetDimensions at the next line is redundant, - // but this is necessary to octave - dims = (mwIndex*)mxGetDimensions(F_ptr); - if( cell_ptr == NULL || mxIsEmpty(cell_ptr) ){ - /* If the cell is empty, we assume this cell as zero matrix */ - continue; - } - sizeM = mxGetM(cell_ptr); - sizeN = mxGetN(cell_ptr); - tmp_ptr = mxGetPr(cell_ptr); - if( mxIsSparse(cell_ptr) ){ - /* Sparse Matrix */ - ir_ptr = mxGetIr(cell_ptr); - jc_ptr = mxGetJc(cell_ptr); - if( sizeM == 1 && sizeN != 1 ){ - /* Row Vector Case */ - for(j = 0; j < sizeN; j++){ - startidx = jc_ptr[j]; - endidx = jc_ptr[j+1]; - if( startidx == endidx ){ continue; } - sdpa.inputElement( k, l+1, j+1, j+1, tmp_ptr[startidx]); - } - } else if( sizeM != 1 && sizeN == 1 ){ - /* Column Vector Case */ - endidx = jc_ptr[sizeN]; - for(idx = 0; idx < endidx; idx++){ - i = ir_ptr[idx]; - sdpa.inputElement( k, l+1, i+1, i+1, tmp_ptr[idx]); - } - } else { - /* Matrix Case */ - for(j = 0; j < sizeN; j++){ - startidx = jc_ptr[j]; - endidx = jc_ptr[j+1]; - if( startidx == endidx ){ continue; } - for(idx = startidx; idx < endidx; idx++){ - i = ir_ptr[idx]; - if( i <= j ){ - sdpa.inputElement( k, l+1, i+1, j+1, tmp_ptr[idx]); - } - } - } - } - } else { - /* Dense Matrix */ - if( sdpa.getBlockType(l+1)==SDPA::SDP ){ - /* Full Matrix */ - for(j = 0; j < sizeN; j++){ - for(i = 0; i < sizeM; i++){ - if( i <= j ){ - if( tmp_ptr[j * sizeN + i] != 0 ){ - sdpa.inputElement(k, l+1, i+1, j+1, - tmp_ptr[j * sizeN + i]); - } - } - } - } - } else { - /* Diagonal Matrix */ - if( sizeM == 1 && sizeN != 1 ){ - /* Row Vector Case */ - for(j = 0; j < sizeN; j++){ - if( tmp_ptr[j] != 0 ){ - sdpa.inputElement( k, l+1, j+1, j+1, tmp_ptr[j]); - } - } - } else if( sizeM != 1 && sizeN == 1 ){ - /* Column Vector Case */ - for(i = 0; i < sizeM; i++){ - if( tmp_ptr[i] != 0 ){ - sdpa.inputElement( k, l+1, i+1, i+1, tmp_ptr[i]); - } - } - } else { - /* Matrix Case */ - for(j = 0; j < sizeN; j++){ - if( tmp_ptr[j * sizeN + j] != 0 ){ - sdpa.inputElement( k, l+1, j+1, j+1, - tmp_ptr[j * sizeN + j]); - } - } - } - } - } - } - } - - /*** Check the consistence of F, c ***/ - if( nSymmChk ){ - sdpa.initializeUpperTriangle(true); - } - else { - sdpa.initializeUpperTriangle(false); - } - - /*** Check initial point ***/ - if( IniPt == 1 ){ - rMessage("Initial point is ignored in SDPA-C."); - #if 0 - sdpa.setInitPoint(true); - /* initial value for xVec */ - for(k = 0; k < mDIM; k++){ - sdpa.inputInitXVec( k+1, x0_ptr[k]); - } - /* initial value for XMat */ - cell_index = 0; - for(l = 0; l < nBLOCK; l++){ - cell_ptr = mxGetCell(X0_ptr, cell_index); - if( cell_ptr == NULL || mxIsEmpty(cell_ptr) ){ - /* If the cell is empty, we assume this cell as zero matrix */ - continue; - } - sizeM = mxGetM(cell_ptr); - sizeN = mxGetN(cell_ptr); - tmp_ptr = mxGetPr(cell_ptr); - if( mxIsSparse(cell_ptr) ){ - /* Sparse Matrix */ - ir_ptr = mxGetIr(cell_ptr); - jc_ptr = mxGetJc(cell_ptr); - if( sizeM == 1 && sizeN != 1 ){ - /* Row Vector Case */ - for(j = 0; j < sizeN; j++){ - startidx = jc_ptr[j]; - endidx = jc_ptr[j+1]; - if( startidx == endidx ){ continue; } - sdpa.inputInitXMat(l+1, j+1, j+1, tmp_ptr[startidx]); - } - } else if( sizeM != 1 && sizeN == 1 ){ - /* Column Vector Case */ - endidx = jc_ptr[sizeN]; - for(idx = 0; idx < endidx; idx++){ - i = ir_ptr[idx]; - sdpa.inputInitXMat(l+1, i+1, i+1, tmp_ptr[idx]); - } - } else { - /* Matrix Case */ - for(j = 0; j < sizeN; j++){ - startidx = jc_ptr[j]; - endidx = jc_ptr[j+1]; - if( startidx == endidx ){ continue; } - for(idx = startidx; idx < endidx; idx++){ - i = ir_ptr[idx]; - if( i <= j ){ - sdpa.inputInitXMat( l+1, i+1, j+1, tmp_ptr[idx]); - } - } - } - } - } else { - /* Dense Matrix */ - if( sdpa.getBlockType(l+1) == SDPA::SDP ){ - /* Full Matrix */ - for(j = 0; j < sizeN; j++){ - for(i = 0; i < sizeM; i++){ - if( i <= j ){ - if( tmp_ptr[j * sizeN + i] != 0 ){ - sdpa.inputInitXMat( l+1, i+1, j+1, - tmp_ptr[j * sizeN + i]); - } - } - } - } - } else { - /* Diagonal Matrix */ - if( sizeM == 1 && sizeN != 1 ){ - /* Row Vector Case */ - for(j = 0; j < sizeN; j++){ - if( tmp_ptr[j] != 0 ){ - sdpa.inputInitXMat( l+1, j+1, j+1, tmp_ptr[j]); - } - } - } else if( sizeM != 1 && sizeN == 1 ){ - /* Column Vector Case */ - for(i = 0; i < sizeM; i++){ - if( tmp_ptr[i] != 0 ){ - sdpa.inputInitXMat( l+1, i+1, i+1, tmp_ptr[i]); - } - } - } else { - /* Matrix Case */ - for(j = 0; j < sizeN; j++){ - if( tmp_ptr[j * sizeN + j] != 0 ){ - sdpa.inputInitXMat( l+1, j+1, j+1, - tmp_ptr[j * sizeN + j]); - } - } - } - } - } - cell_index++; - } - /* initial value for YMat */ - cell_index = 0; - for(l = 0; l < nBLOCK; l++){ - cell_ptr = mxGetCell(Y0_ptr, cell_index); - if( cell_ptr == NULL || mxIsEmpty(cell_ptr) ){ - /* If the cell is empty, we assume this cell as zero matrix */ - continue; - } - sizeM = mxGetM(cell_ptr); - sizeN = mxGetN(cell_ptr); - tmp_ptr = mxGetPr(cell_ptr); - if( mxIsSparse(cell_ptr) ){ - /* Sparse Matrix */ - ir_ptr = mxGetIr(cell_ptr); - jc_ptr = mxGetJc(cell_ptr); - if( sizeM == 1 && sizeN != 1 ){ - /* Row Vector Case */ - for(j = 0; j < sizeN; j++){ - startidx = jc_ptr[j]; - endidx = jc_ptr[j+1]; - if( startidx == endidx ){ continue; } - sdpa.inputInitYMat( l+1, j+1, j+1, tmp_ptr[startidx]); - } - } else if( sizeM != 1 && sizeN == 1 ){ - /* Column Vector Case */ - endidx = jc_ptr[sizeN]; - for(idx = 0; idx < endidx; idx++){ - i = ir_ptr[idx]; - sdpa.inputInitYMat( l+1, i+1, i+1, tmp_ptr[idx]); - } - } else { - /* Matrix Case */ - for(j = 0; j < sizeN; j++){ - startidx = jc_ptr[j]; - endidx = jc_ptr[j+1]; - if( startidx == endidx ){ continue; } - for(idx = startidx; idx < endidx; idx++){ - i = ir_ptr[idx]; - if( i <= j ){ - sdpa.inputInitYMat( l+1, i+1, j+1, tmp_ptr[idx]); - } - } - } - } - } else { - /* Dense Matrix */ - if( sdpa.getBlockType(l+1) == SDPA::SDP ){ - /* Full Matrix */ - for(j = 0; j < sizeN; j++){ - for(i = 0; i < sizeM; i++){ - if( i <= j ){ - if( tmp_ptr[j * sizeN + i] != 0 ){ - sdpa.inputInitYMat( l+1, i+1, j+1, - tmp_ptr[j * sizeN + i]); - } - } - } - } - } else { - /* Diagonal Matrix */ - if( sizeM == 1 && sizeN != 1 ){ - /* Row Vector Case */ - for(j = 0; j < sizeN; j++){ - if( tmp_ptr[j] != 0 ){ - sdpa.inputInitYMat( l+1, j+1, j+1, tmp_ptr[j]); - } - } - } else if( sizeM != 1 && sizeN == 1 ){ - /* Column Vector Case */ - for(i = 0; i < sizeM; i++){ - if( tmp_ptr[i] != 0 ){ - sdpa.inputInitYMat( l+1, i+1, i+1, tmp_ptr[i]); - } - } - } else { - /* Matrix Case */ - for(j = 0; j < sizeN; j++){ - if( tmp_ptr[j * sizeN + j] != 0 ){ - sdpa.inputInitYMat( l+1, j+1, j+1, - tmp_ptr[j * sizeN + j]); - } - } - } - } - } - cell_index++; - } - #endif - } - /*** Solve SDP ***/ - sdpa.initializeSolve(); - sdpa.solve(); - /*** Dimacs Error Information ****/ - if (nDimacs != 0) { - field_ptr = mxCreateNumericMatrix(6,1,mxDOUBLE_CLASS,mxREAL); - double dimacs_error[7]; - sdpa.getDimacsError(dimacs_error); - double* dimacs_store = mxGetPr(field_ptr); - if (sdpa.judgeDimacsAvailability() == false) { - for (int i=0; i<=6; i++) { - dimacs_store[i] = 0.0; - } - } - else { - for (int i=1; i<=6; i++) { - dimacs_store[i-1] = dimacs_error[i]; - } - } - mxSetField(INFO_ptr, 0, "dimacs", field_ptr); - } - /**** Set output values to arguments ****/ - /* Optimal value of Primal objective */ - objVal_ptr[0] = sdpa.getPrimalObj(); - /* Optimal value of Dual objective */ - objVal_ptr[1] = sdpa.getDualObj(); - /* Optimal value for xVec */ - tmp_ptr = sdpa.getResultXVec(); - if( tmp_ptr != NULL ){ - for(k = 0; k < mDIM; k++){ - x_ptr[k] = tmp_ptr[k]; - } - } - /* Optimal value for XMat */ - cell_index = 0; - result_ptr = sdpa.getResultXMat(1); - if (result_ptr == NULL) { - rMessage("XMat is not computed by XPrint, and XMat will be empty matrix."); - } - for(l = 0; l < nBLOCK; l++){ - result_ptr = sdpa.getResultXMat(l+1); - if (result_ptr == NULL) { - cell_ptr = mxCreateDoubleMatrix(0, 0, mxREAL); - mxSetCell(X_ptr, cell_index++, mxDuplicateArray(cell_ptr)); - continue; - } - size = sdpa.getBlockSize(l+1); - if( sdpa.getBlockType(l+1) == SDPA:: SDP){ - sizeM = size; - sizeN = size; - } else { - sizeM = 1; - sizeN = abs(size); - } - cell_ptr = mxCreateDoubleMatrix(sizeM, sizeN, mxREAL); - tmp_ptr = mxGetPr(cell_ptr); - idx = 0; - result_ptr = sdpa.getResultXMat(l+1); - if( size >= 0 ){ - for(j = 0; j < sizeN; j++){ - for(i = 0; i < sizeM; i++){ - tmp_ptr[idx++] = result_ptr[j + sizeN * i]; - } - } - } else { - for(idx = 0; idx < sizeN; idx++){ - tmp_ptr[idx] = result_ptr[idx]; - } - } - mxSetCell(X_ptr, cell_index++, mxDuplicateArray(cell_ptr)); - } - /* Optimal value for YMat */ - result_ptr = sdpa.getResultYMat(1); - if (result_ptr == NULL) { - rMessage("YMat is not computed by YPrint, and YMat will be empty matrix."); - } - cell_index = 0; - for(l = 0; l < nBLOCK; l++){ - result_ptr = sdpa.getResultYMat(l+1); - if (result_ptr == NULL) { - cell_ptr = mxCreateDoubleMatrix(0, 0, mxREAL); - mxSetCell(Y_ptr, cell_index++, mxDuplicateArray(cell_ptr)); - continue; - } - size = sdpa.getBlockSize(l+1); - if( sdpa.getBlockType(l+1) == SDPA:: SDP){ - sizeM = size; - sizeN = size; - } else { - sizeM = 1; - sizeN = abs(size); - } - cell_ptr = mxCreateDoubleMatrix(sizeM, sizeN, mxREAL); - tmp_ptr = mxGetPr(cell_ptr); - idx = 0; - result_ptr = sdpa.getResultYMat(l+1); - if( size >= 0 ){ - for(j = 0; j < sizeN; j++){ - for(i = 0; i < sizeM; i++){ - tmp_ptr[idx++] = result_ptr[j + sizeN * i]; - } - } - } else { - for(idx = 0; idx < sizeN; idx++){ - tmp_ptr[idx] = result_ptr[idx]; - } - } - mxSetCell(Y_ptr, cell_index++, mxDuplicateArray(cell_ptr)); - } - /* Phase information */ - field_ptr = mxCreateString(szPhase[sdpa.getPhaseValue()]); - mxSetField(INFO_ptr, 0, "phasevalue", field_ptr); - /* Iteration */ - field_ptr = mxCreateNumericMatrix(1,1,mxDOUBLE_CLASS,mxREAL); - *mxGetPr(field_ptr) = (double)sdpa.getIteration(); - mxSetField(INFO_ptr, 0, "iteration", field_ptr); - /* close output file */ - time(<ime); - strcpy(string_time,ctime(<ime)); - string_time[strlen(string_time)-1]='\0'; - if (fp) { - fprintf(fp,"SDPA-C end at [%s]\n",string_time); - } - if (fpResult) { - fprintf(fpResult,"SDPA-C end at [%s]\n",string_time); - } - - if( nOutfile ){ - fclose(fp); - } - if (fpResult != NULL) { - fclose(fpResult); - } - /*** Free allocated memory ****/ - mxFree(subscript); - sdpa.finalize(); - - return; -} - -/* - * Matlab gateway function - */ -void mexFunction(int nlhs, mxArray *plhs[], - int nrhs, const mxArray *prhs[]) -{ - /* Decleration of variables */ - - double - *mDIM_ptr, - *nBLOCK_ptr, - *bLOCKsTRUCT_ptr, - *c_ptr, - *x_ptr, - *objVal_ptr, - *x0_ptr; - - mxArray - *F_ptr, - *X_ptr, - *Y_ptr, - *X0_ptr, - *Y0_ptr, - *OPTION_ptr, - *INFO_ptr; - - int IniPt; - - const char *fnames[] = { - "phasevalue", - "iteration", - "dimacs", - "cpusec" - }; - - /* - * check arguments - */ - if( nrhs != 9 ){ - mexErrMsgTxt("Input arguments must be 9."); - } - - /* Get the pointer of input variables */ - mDIM_ptr = mxGetPr(prhs[0]); - nBLOCK_ptr = mxGetPr(prhs[1]); - bLOCKsTRUCT_ptr = mxGetPr(prhs[2]); - c_ptr = mxGetPr(prhs[3]); - F_ptr = (mxArray*)prhs[4]; - x0_ptr = mxGetPr(prhs[5]); - X0_ptr = (mxArray*)prhs[6]; - Y0_ptr = (mxArray*)prhs[7]; - OPTION_ptr = (mxArray*)prhs[8]; - - if( mxIsEmpty(prhs[5]) /* x0 */ - || mxIsEmpty(prhs[6]) /* X0 */ - || mxIsEmpty(prhs[7]) /* Y0 */ - ){ - /* nouse of Initial Point*/ - IniPt = 0; - } else { - /* use of Initial Point */ - IniPt = 1; - /* check of argument dimensions */ - /* if(*mDIM_ptr != mxGetM(prhs[5]) || !mxIsDouble(prhs[5])) - mexErrMsgTxt("x0 must be (mDIM x 1) column vector of double"); - if( *nBLOCK_ptr != sizeM_X0 || 1 != sizeN_X0 || !mxIsCell(prhs[6])) - mexErrMsgTxt("X0 must be (nBLOCK x 1) cell array"); - if( *nBLOCK_ptr != sizeM_Y0 || 1 != sizeN_Y0 || !mxIsCell(prhs[7])) - - mexErrMsgTxt("Y0 must be (nBLOCK x 1) cell array");*/ - } - /* Create cellarrays for the output variables */ - plhs[0] = mxCreateDoubleMatrix(1,2,mxREAL); - plhs[1] = mxCreateDoubleMatrix((int) *mDIM_ptr,1,mxREAL); - plhs[2] = mxCreateCellMatrix((int) *nBLOCK_ptr,1); - plhs[3] = mxCreateCellMatrix((int) *nBLOCK_ptr,1); - plhs[4] = mxCreateStructMatrix(1,1,4,fnames); - - //Get the pointer of output variables - objVal_ptr = mxGetPr(plhs[0]); - x_ptr = mxGetPr(plhs[1]); - X_ptr = plhs[2]; - Y_ptr = plhs[3]; - INFO_ptr = plhs[4]; - - /* Call sdpasolver here */ - sdpasolver(mDIM_ptr, - nBLOCK_ptr, - bLOCKsTRUCT_ptr, - c_ptr, - F_ptr, - x0_ptr, - X0_ptr, - Y0_ptr, - OPTION_ptr, - IniPt, - objVal_ptr, - x_ptr, - X_ptr, - Y_ptr, - INFO_ptr); - - return; -} - -/* - * End of File - */ diff --git a/external/sdpa/mex/paramC.m b/external/sdpa/mex/paramC.m deleted file mode 100644 index 1242c13..0000000 --- a/external/sdpa/mex/paramC.m +++ /dev/null @@ -1,233 +0,0 @@ -function OPTION=paramC(OPTION) -% -% Create SDPA-C parameters. -% If there is no argument, default parameters are returned. -% -% OPTION=paramC % for default parameter -% or -% OPTION=paramC(field1,value1,field2,value2,....) -% -% -% - field?: string : field name -% - value?: numeric or string : -% -% -% - OPTION: structure data: each field is as follows: -% * maxIteration : The maximum number of iterations. -% * epsilonStar : The accuracy of an approximate optimal solution -% for primal and dual SDP. -% * lambdaStar : An initial point. -% * omegaStar : The search region for an optimal solution. -% * lowerBound : Lower bound of the minimum objective value of -% the primal SDP. -% * upperBound : Upper bound of the maximum objective value of -% the dual SDP -% * betaStar : The parameter for controlling the search direction -% if the current point is feasible. -% * betaBar : The parameter for controlling the search direction -% if the current point is infeasible. -% * gammaStar : A reduction factor for the primal and dual step -% lengths. -% * epsilonDash : The relative accuracy of an approximate optimal -% solution between primal and dual SDP. -% * isSymmetric : The flag for the checking the symmetricity of input -% matrices. (0 => no check, 1=> check) -% * isDimacs : The flag to compute DIMACS ERROR -% (0 => no computation, 1=> computation) -% * xPrint : (default %+8.3e, NOPRINT skips printout) -% * XPrint : (default %+8.3e, NOPRINT skips printout) -% * YPrint : (default %+8.3e, NOPRINT skips printout) -% * infPrint : (default %+10.16e, NOPRINT skips printout) -% * print : Destination of file output. the default setting is -% stdout by 'display'. -% If print is set 'no' or empty, no message -% is print out -% * resultFile : Destination of detail file output -% * NumThreads : Number of Threads for internal computation - -% 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 -% -% SDPA-M: $Revision: 6.2 $ -% $Id: param.m,v 6.2 2005/05/28 02:36:40 drophead Exp $ - -% create default OPTION -OPTION0.maxIteration = 100; -OPTION0.epsilonStar = 1.0E-7; -OPTION0.lambdaStar = 1.0E2; -OPTION0.omegaStar = 2.0; -OPTION0.lowerBound = -1.0E5; -OPTION0.upperBound = 1.0E5; -OPTION0.betaStar = 0.1; -OPTION0.betaBar = 0.3; -OPTION0.gammaStar = 0.9; -OPTION0.epsilonDash = 1.0E-7; -OPTION0.isSymmetric = 0; -OPTION0.isDimacs = 0; -OPTION0.xPrint = '%+8.3e'; -OPTION0.XPrint = '%+8.3e'; -OPTION0.YPrint = '%+8.3e'; -OPTION0.infPrint = '%+16.10e'; -OPTION0.print = 'display'; -OPTION0.resultFile = ''; -try - OPTION0.NumThreads = maxNumCompThreads; % Max Avialable Number -catch - fprintf(['Function maxNumCompThreads is not found, NumThreads ' ... - 'is set as 1.\n']); - OPTION0.NumThreads = 1; -end - - -OPTION0.aggConeSize = []; - -if (nargin == 0) || isempty(OPTION) - OPTION = OPTION0; - return -else - if ~isfield(OPTION,'maxIteration') - OPTION.maxIteration=OPTION0.maxIteration; - elseif ~isnumeric(OPTION.maxIteration) - error('OPTION.maxIteration must be numeric.'); - end - % - if ~isfield(OPTION,'epsilonStar') - OPTION.epsilonStar=OPTION0.epsilonStar; - elseif ~isnumeric(OPTION.epsilonStar) - error('epsilonStar must be numeric.'); - end - % - if ~isfield(OPTION,'lambdaStar') - OPTION.lambdaStar=OPTION0.lambdaStar; - elseif ~isnumeric(OPTION.lambdaStar) - error('OPTION.lambdaStar must be numeric.'); - end - % - if ~isfield(OPTION,'omegaStar') - OPTION.omegaStar=OPTION0.omegaStar; - elseif ~isnumeric(OPTION.omegaStar) - error('OPTION.omegaStar must be numeric.'); - end - % - if ~isfield(OPTION,'lowerBound') - OPTION.lowerBound=OPTION0.lowerBound; - elseif ~isnumeric(OPTION.lowerBound) - error('OPTION.lowerBound must be numeric.'); - end - % - if ~isfield(OPTION,'upperBound') - OPTION.upperBound=OPTION0.upperBound; - elseif ~isnumeric(OPTION.upperBound) - error('OPTION.upperBound must be numeric.'); - end - % - if ~isfield(OPTION,'betaStar') - OPTION.betaStar=OPTION0.betaStar; - elseif ~isnumeric(OPTION.betaStar) - error('OPTION.beaStar must be numeric.'); - end - % - if ~isfield(OPTION,'betaBar') - OPTION.betaBar=OPTION0.betaBar; - elseif ~isnumeric(OPTION.betaBar) - error('OPTION.betaBar must be numeric.'); - end - % - if ~isfield(OPTION,'gammaStar') - OPTION.gammaStar=OPTION0.gammaStar; - elseif ~isnumeric(OPTION.gammaStar) - error('OPTION.gammaStar must be numeric.'); - end - % - if ~isfield(OPTION,'epsilonDash') - OPTION.epsilonDash=OPTION0.epsilonDash; - elseif ~isnumeric(OPTION.epsilonDash) - error('OPTION.epsilonDash must be numeric.'); - end - % - if isfield(OPTION,'searchDir') - disp('Parameter *searchDir* is no longer supported.'); - disp('HRVW/KSH/M is automatically used.'); - end - % - if ~isfield(OPTION,'isSymmetric') - OPTION.isSymmetric=OPTION0.isSymmetric; - elseif ~isnumeric(OPTION.isSymmetric) || ((OPTION.isSymmetric~=0) && (OPTION.isSymmetric~=1)) - error('OPTION.isSymmetric must be 0 or 1.'); - end - % - if ~isfield(OPTION,'isDimacs') - OPTION.isDimacs=OPTION0.isDimacs; - elseif ~isnumeric(OPTION.isDimacs) || ((OPTION.isDimacs~=0) && (OPTION.isDimacs~=1)) - error('OPTION.isDimacs must be 0 or 1.'); - end - % - if ~isfield(OPTION,'XPrint') - OPTION.XPrint=OPTION0.XPrint; - elseif ~ischar(OPTION.XPrint) - error('OPTION.XPrint must be string.'); - end - % - if ~isfield(OPTION,'YPrint') - OPTION.YPrint=OPTION0.YPrint; - elseif ~ischar(OPTION.YPrint) - error('OPTION.YPrint must be string for printf.'); - end - % - if ~isfield(OPTION,'infPrint') - OPTION.infPrint=OPTION0.infPrint; - elseif ~ischar(OPTION.infPrint) - error('OPTION.infPrint must be string for printf.'); - end - % - if isfield(OPTION,'print') && ... - (isempty(OPTION.print) || length(OPTION.print) == 0) - OPTION.print = 'no'; - end - if ~isfield(OPTION,'print') - OPTION.print=OPTION0.print; - elseif ~ischar(OPTION.print) - disp('*** OPTION.print must be string for FILE. ***'); - disp(' "display" is for stdout.'); - disp(' "no" or empty is for skip message.'); - disp(' filename is filename in which message will be written.'); - error('*** OPTION.print must be string for FILE. ***'); - end - % - if ~isfield(OPTION,'resultFile') || isempty(OPTION.resultFile) - OPTION.resultFile=OPTION0.resultFile; - elseif ~ischar(OPTION.resultFile) - error('OPTION.resultFile must be string.'); - end - % - if ~isfield(OPTION,'NumThreads') - OPTION.NumThreads=OPTION0.NumThreads; - elseif ~isnumeric(OPTION.NumThreads) - error('OPTION.NumThreads must be positive integer.'); - end - - if ~isfield(OPTION,'aggConeSize') - OPTION.aggConeSize = OPTION0.aggConeSize; - elseif (~isempty(OPTION.aggConeSize)) && ... - ((~isnumeric(OPTION.aggConeSize)) || (OPTION.aggConeSize <=0)) - error('OPTION.aggConeSize must be a positive integer.'); - end -end - -return - -% End of File diff --git a/external/sdpa/mex/sdpamC.m b/external/sdpa/mex/sdpamC.m deleted file mode 100644 index 09d9e35..0000000 --- a/external/sdpa/mex/sdpamC.m +++ /dev/null @@ -1,81 +0,0 @@ -function [objVal,x,X,Y,INFO]=sdpamC(mDIM,nBLOCK,bLOCKsTRUCT,c,F,... - x0,X0,Y0,OPTION) -% -% Compute the solution of standard SDP. -% Since some of input arguments are optional, sdpam can be -% overloaded as below. -% -% [objVal,x,X,Y,INFO] = sdpamC(mDIM,nBLOCK,bLOCKsTRUCT,c,F, -% x0,X0,Y0,OPTION); -% -% -% - mDIM : integer ; number of primal variables -% - nBLOCK : integer ; number of blocks of F -% - bLOCKsTRUCT: vector ; represetns the block structure of F -% - c : vector ; coefficient vector -% - F : cell array; coefficient matrices -% - x0,X0,Y0 : cell array; initial point -% (NOTE: In SDPA-C, initial point is ignored.) -% - OPTION : structure ; options -% -% -% - objVal: [objValP objValD]; optimal value of P and D -% - x : vector ; optimal solution -% - X,Y : cell arrray ; optimal solutions -% - INFO : structure ; infomation of the solution -% - -% 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 -% -% SDPA-M: $Revision: 6.2 $ -% $Id: sdpam.m,v 6.2 2005/05/28 02:36:40 drophead Exp $ - -t = cputime; - -if (nargin < 5 || nargin > 9) - error('incorrect number of input arguments') -elseif nargin == 5 - % make initial points empty - x0=[];X0=[];Y0=[]; - % load default parameters - OPTION=paramC; - % solve by SDPA - [objVal,x,X,Y,INFO]=mexsdpaC(mDIM,nBLOCK,bLOCKsTRUCT,... - c,F,x0,X0,Y0,OPTION); -elseif nargin == 6 - % use OPTION given by arguments - OPTION=paramC(x0); - % make initial points empty - x0=[];X0=[];Y0=[]; - [objVal,x,X,Y,INFO]=mexsdpaC(mDIM,nBLOCK,bLOCKsTRUCT,... - c,F,x0,X0,Y0,OPTION); -elseif nargin == 8 - % load default parameters - OPTION=paramC; - %solve by SDPA - [objVal,x,X,Y,INFO]=mexsdpaC(mDIM,nBLOCK,bLOCKsTRUCT,... - c,F,x0,X0,Y0,OPTION); -elseif nargin == 9 - OPTION=paramC(OPTION); - % solve by SDPA - [objVal,x,X,Y,INFO]=mexsdpaC(mDIM,nBLOCK,bLOCKsTRUCT,... - c,F,x0,X0,Y0,OPTION); -end -INFO.cpusec = cputime-t; - -% End of File diff --git a/external/sdpa/mex/sedumiwrapC.m b/external/sdpa/mex/sedumiwrapC.m deleted file mode 100644 index 47431d2..0000000 --- a/external/sdpa/mex/sedumiwrapC.m +++ /dev/null @@ -1,382 +0,0 @@ -function [x,y,info]=sedumiwrapC(A,b,c,K,pars,OPTION); - -% -% SeDuMi wrapper for SDPA -% -% [x,y,info]=sedumiwrapC(A,b,c,K,pars,OPTION); -% or -% [x,y,info]=sedumiwrapC(A,b,c,K); % with SDPA-M default parameter -% -% Note : -% 'A', in each SDP block, only upper triangle part is used. -% 'K' can include only 'f'(free) 'l'(linear) 's'(SDP) cones. -% 'pars' information is NOT used (just for SeDuMi compatibility) -% 'OPTION' is option structure for SDPA-M (for details, try 'help param') -% 'info' information is based on SDPA-M -% -% 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 -% -% SDPA-M: $Revision: 7.3 $ - - -t = cputime; - -fprintf('-SeDuMi Wrapper for SDPA-C Start-\n'); - -if (nargin < 4 || nargin > 6) - error('incorrect number of input arguments') -end -if nargin >= 5 - if isfield(OPTION,'print') && ~isempty(OPTION.print) - fprintf('Note: pars information [5th argument] is not used\n'); - end -end -if nargin < 6 - OPTION = paramC; -else - OPTION = paramC(OPTION); -end - -if isfield(K,'q') && ~isempty(K.q) - error('Current Wrapper cannot handle K.q'); -end - -if isfield(K,'r') && ~isempty(K.r) - error('Current Wrapper cannot handle K.r'); -end - -if size(b,2) ~= 1 - % fprintf('Transposing b to a column vector'); - b = b'; -end -if size(b,2) ~= 1 - error('b must be a vector'); -end - -if size(c,2) ~= 1 - % fprintf('Transposing c to a column vector\n'); - c = c'; -end -if size(c,2) ~= 1 - error('c must be a vector'); -end - -%%%%% -% Constructing at least one SDP cone if necesary -if (~isfield(K,'s')) || (isempty(K.s)) - [K] = LPtoLP_SDP(K); -end -%%%%% - -totalLength = 0; -Kf = 0; -if isfield(K,'f') && ~isempty(K.f) - totalLength = totalLength + K.f; - Kf = K.f; -end -if isfield(K,'l') && ~isempty(K.l) - totalLength = totalLength + K.l; -else - K.l = 0; -end -if isfield(K,'s') && ~isempty(K.s) - if size(K.s,2) ~= 1 - % fprintf('Transposing K.s to a column vector\n'); - K.s = K.s'; - end - Ks = sum(K.s .* K.s); - totalLength = totalLength + Ks; -else - error('Cannot handle empty K.s'); -end -m = size(b,1); -n = size(c,1); - -[mA,nA] = size(A); -if (m~=mA || n~=nA) && (m~=nA || n~=mA) - fprintf('Inconsistent Size of A,b,c\n'); - fprintf('size(A) = [%d,%d], size(b) = %d, size(c) = %d\n',... - mA,nA, m,n); - error('Cannot continue...'); -end - -if (n~=totalLength) - fprintf('Inconsistent Size of c and K\n'); - fprintf('size(c) = %d, totalSize(K) = %d\n',... - n, totalLength); - error('Cannot continue...'); -end - -if ~issparse(A) - if isfield(OPTION,'print') && ~isempty(OPTION.print) - fprintf('Converting A from dense to sparse\n'); - end - A = sparse(A); -end - -if issparse(b) - % fprintf('Converting b from sparse to dense\n'); - b = full(b); -end - -if ~issparse(c) - % fprintf('Converting c from dense to sparse\n'); - c = sparse(c); -end - -if issparse(K.s) - % fprintf('Converting K.s from sparse to dense\n'); - K.s = full(K.s); -end - -if Kf ~= 0 - if isfield(OPTION,'print') && ~isempty(OPTION.print) - fprintf(['Free Variables are divided into positive and ' ... - 'negative part of LP cone\n']); - end - Af = A(:,1:Kf); - Kl = K.l; - Al = A(:,Kf+1:Kf+Kl); - As = A(:,Kf+Kl+1:Kf+Kl+Ks); - Anew = [Af, -Af, Al, As]; - - cf = c(1:Kf); - cl = c(Kf+1:Kf+Kl); - cs = c(Kf+Kl+1:Kf+Kl+Ks); - cnew = [cf; -cf; cl; cs]; - - Knew.l = 2*Kf + Kl; - Knew.s = K.s; - - A = Anew; - c = cnew; - K = Knew; - - clear Af; - clear Al; - clear As; - clear Anew; - clear cf; - clear cl; - clear cs; - clear cnew; - clear Knew; -end - -if isfield(K,'s') && ~isempty(K.s) - if size(K.s,2) ~= 1 - K.s = Ks'; - end -end - -%%%%% -% Aggregating small SDP cones into larger SDP cones -aggSW = 0; -minNoSDPcones = 3; -if (isfield(OPTION,'aggConeSize')) && (~isempty(OPTION.aggConeSize)) && (isnumeric(OPTION.aggConeSize)) && ... - ((OPTION.aggConeSize > 0)) && (length(K.s') > minNoSDPcones) && (length(find(K.s' < OPTION.aggConeSize)) > minNoSDPcones) - fprintf('OPTION.aggConeSize = %d\n',OPTION.aggConeSize) - K0 = K; - aggSW = 1; - [A,c,K1] = aggSDPcones(A,c,K,OPTION.aggConeSize); - A = sparse(A); - c = sparse(c); - K = K1; -end -%%%%% - - -% A should be transposed when passed to mex -[mA,nA] = size(A); -if mA ~= K.l + sum(K.s.*K.s) - A = A'; -end -% fprintf('size(A) = (%d,%d)\n',size(A,2),size(A,1)); -% fprintf('length(K.s) = %d\n',length(K.s)); - -[x,y,info] = mexSedumiWrapC(A,b,c,K,OPTION); - -%%%%% -% Retrieving the origianl primal SDP cone variables -if aggSW == 1 - if (isfield(K,'l')) && (~isempty(K.l)) && (K.l > 0) - xSDP = x(K.l+1:size(x,1),1); - xLP = x(1:K.l,1); - [xSDP] = mexDisAggSDPsol(xSDP,K0.s,K1.s); - x = [xLP; xSDP]; - else - [x] = mexDisAggSDPsol(x,K0.s,K1.s); - end -end -%%%%% - -if Kf ~=0 - xlength = size(x); - xnew = x(1:Kf) - x(Kf+1:Kf+Kf); - xnew = [xnew; x(Kf+Kf+1:xlength)]; - x = xnew; -end - -info.cpusec = cputime-t; -% if isfield(OPTION,'print') && ~isempty(OPTION.print) - fprintf('-SeDuMi Wrapper for SDPA-C End-\n'); -% end - -% End of File - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -function [K] = LPtoLP_SDP(K) - -if isfield(K,'q') && ~isempty(K.q) - error('Current Wrapper cannot handle K.q'); -end - -if isfield(K,'r') && ~isempty(K.r) - error('Current Wrapper cannot handle K.r'); -end - -if isfield(K,'s') && ~isempty(K.s) - return; -elseif ~isfield(K,'l') || isempty(K.l) - error('Both LP and SDP cones are empty, so the problem can not be solved'); -else - K.l = K.l-1; - if K.l == 0 - K.l = []; - end - K.s = 1; -end - -return - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -function [A1,c1,K1] = aggSDPcones(A,c,K0,aggConeSize) -% -% [A1,c1,K1] = aggSDPcones(A,c,K0,aggConeSize) -% Input : SeDuMi format -% aggConeSize : the block size into which small blocks are converted -% Output: Sedumi format with larger SDP cone matrices -% - -if (size(K0.s,2) > 1) - K0.s = K0.s'; -end - -if size(A,1) > size(A,2) - A = A'; -end -% if size(c,1) < size(c,2) -% c = c'; -% end -[m,n] = size(A); -% -if ~isfield(K0,'f') || isempty(K0.f) - fDim = 0; -else - fDim = K0.f; -end -% -if ~isfield(K0,'l') || isempty(K0.l) - ellDim = 0; -else - ellDim = K0.l; -end -% -if ~isfield(K0,'q') - qDim = 0; -else - if size(K0.q,1) > size(K0.q,2) - K0.q = K0.q'; % a row vector - end - qDim = sum(K0.q); -end -% -if ~isfield(K0,'s') || isempty(K0.s) - K1 = K0; - A1 = A; - c1 = c; - return -else - if size(K0.s,2) > size(K0.s,1) - K0.s = K0.s'; % a column vector - end - sDim = sum(K0.s .* K0.s); -end - -nonSDim = fDim+ellDim+qDim; -if nonSDim == 0 - cNonSDP = []; - AnonSDP = []; - c0SDP = c; - A0SDP = A; -else - cNonSDP = c(1:nonSDim,1); - AnonSDP = A(:,1:nonSDim); - c0SDP = c(nonSDim+1:n,1); - A0SDP = A(:,nonSDim+1:n); -end - -K1s = []; -coneSize = 0; -for p=1:length(K0.s) - if (K0.s(p) > aggConeSize) - if coneSize > 0 - K1s = [K1s; coneSize; K0.s(p)]; - coneSize = 0; - else - K1s = [K1s; K0.s(p)]; - coneSize = 0; - end - elseif ((coneSize + K0.s(p) > aggConeSize)) - K1s = [K1s; coneSize]; - coneSize = K0.s(p); - elseif ((coneSize + K0.s(p) == aggConeSize)) - K1s = [K1s; coneSize + K0.s(p)]; - coneSize = 0; - else - coneSize = coneSize + K0.s(p); - end -end -if (coneSize > 0) - K1s = [K1s; coneSize]; -end - -K0s = K0.s; % K0.s is a column vector -K1 = K0; -K1.s = K1s; % K1s is a column vector - -tStart = tic; -% C0SDP, K0s and K1s need to be clolumn vector -[A1SDP,c1SDP] = mexAggSDPcones(A0SDP,c0SDP',K0s,K1s); -tElapsed = toc(tStart); -fprintf('Original SDP: the max cone size, the number of cones = %3d, %3d\n',full(max(K0.s)),length(K0.s)); -fprintf('Transformed SDP: the max cone size, the number of cones = %3d, %3d\n',full(max(K1.s)),length(K1.s)); -% fprintf('Elapsed time for transformation = %6.2e\n',tElapsed); - -c1SDP = c1SDP'; - -A1 = sparse([AnonSDP, A1SDP]); -c1 = sparse([cNonSDP;c1SDP]); - -% checkData(A1,b1,c1,K1); - -% sedumi(A1,b1,c1,K1); - -return - - diff --git a/external/sdpa/param.sdpaC b/external/sdpa/param.sdpaC deleted file mode 100644 index a9ec655..0000000 --- a/external/sdpa/param.sdpaC +++ /dev/null @@ -1,15 +0,0 @@ -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) - diff --git a/external/sdpa/sdpa_algebra.h b/external/sdpa/sdpa_algebra.h deleted file mode 100644 index 72804f2..0000000 --- a/external/sdpa/sdpa_algebra.h +++ /dev/null @@ -1,153 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ -/* sdpa_algebra.h - -LAPACK+BLAS definitions wrapper - -Define macros to mangle the given C identifier (in lower and upper -case), which must not contain underscores, for linking with Fortran. - -*/ - -#ifndef __sdpa_algebra_h__ -#define __sdpa_algebra_h__ - -#define FC_RET_I int -#define FC_RET_D double - -#if defined(__APPLE__) // Dirty... -#define FC_FUNC(name,NAME) name ## _ -#endif - - -#define FC_FUNC(name,NAME) name ## _ // for SDPA-C temporary - -#define dtrsm_fc FC_FUNC (dtrsm, DTRSM) -#define dsyrk_fc FC_FUNC (dsyrk, DSYRK) -#define dcopy_fc FC_FUNC (dcopy, DCOPY) -#define daxpy_fc FC_FUNC (daxpy, DAXPY) -#define dgemm_fc FC_FUNC (dgemm, DGEMM) -#define dgemv_fc FC_FUNC (dgemv, DGEMV) -#define dscal_fc FC_FUNC (dscal, DSCAL) -#define dtrsv_fc FC_FUNC (dtrsv, DTRSV) -#define dtrmv_fc FC_FUNC (dtrmv, DTRMV) -#define ddot_fc FC_FUNC (ddot, DDOT) -#define dtrmm_fc FC_FUNC (dtrmm, DTRMM) -#define ilaenv_fc FC_FUNC (ilaenv, ILAENV) -#define dsteqr_fc FC_FUNC (dsteqr, DSTEQR) -#define dsyev_fc FC_FUNC (dsyev, DSYEV) -#define dpotrf_fc FC_FUNC (dpotrf, DPORTRF) - - -extern "C" -{ -// BLAS - FC_RET_I dtrsm_fc - (char* side, char* uplo, char* trans, char* diag, - int* M, int* N, - double* alpha, - double* A, int* lda, - double* B, int* ldb, int side_len, - int uplo_len, int trans_len, int diag_len); - - FC_RET_I dsyrk_fc - (char* uplo, char* trans, int* N, int* K, - double* alpha, - double* A, int* lda, - double* beta, - double* C, int* ldc, int uplo_len, int trans_len); - - FC_RET_I dcopy_fc - (int* N, - double* X, int* incX, - double* Y, int* incY); - - FC_RET_I daxpy_fc - (int* N, - double* alpha, - double* X, int* incX, - double* Y, int* incY); - - FC_RET_I dgemm_fc - (char* transA, char* transB, int* M, int* N, int* K, - double* alpha, - double* A, int* lda, - double* B, int* ldb, - double* beta, - double* C, int* ldc, int transA_len, int transB_len); - - FC_RET_I dgemv_fc - (char* trans, int* M, int* N, - double* alpha, - double* A, int* lda, - double* X, int* incX, - double* beta, - double* Y, int* incY, int trans_len); - - FC_RET_I dscal_fc - (int* N, - double* alpha, - double* X, int* incX); - - FC_RET_I dtrsv_fc - (char* uplo, char* trans, char* diag, int* N, - double* A, int* lda, - double* X, int* incX, int uplo_len, - int trans_len, int diag_len); - - FC_RET_I dtrmv_fc - (char* uplo, char *trans, char* diag, int *N, - double *A, int *lda, - double *X, int *incX, int uplo_len, int trans_len, int diag_len); - - FC_RET_D ddot_fc - (int* N, double* X, int* incX, double* Y, int* incY); - - FC_RET_I dtrmm_fc - (char* side, char* uplo, char* trans, char* diag, - int* M, int* N, - double* alpha, - double* A, int* lda, - double* B, int* ldb, int side_len, int uplo_len, - int trans_len, int diag_len); - -// LAPACK - - FC_RET_I ilaenv_fc - (int *ispec, char *name, char *opts, int *n1, - int *n2, int *n3, int *n4, int name_len, int opts_len); - - FC_RET_I dsteqr_fc - (char *compz, int *n, double *d, - double *e, double *z, int *ldz, double *work, - int *info, int compz_len); - - FC_RET_I dsyev_fc - (char *jobz, char *uplo, int *n, double *a, - int *lda, double *w, double *work, int *lwork, - int *info, int jobz_len, int uplo_len); - - FC_RET_I dpotrf_fc - (char *uplo, int *n, double *a, int *lda, - int *info, int uplo_len); -} - -#endif // __sdpa_algebra_h__ diff --git a/external/sdpa/sdpa_block.cpp b/external/sdpa/sdpa_block.cpp deleted file mode 100644 index fd44c77..0000000 --- a/external/sdpa/sdpa_block.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ - -#include "sdpa_block.h" - -namespace sdpa { - -BlockStruct::BlockStruct() -{ - nBlock = 0; - blockStruct = NULL; - blockNumber = NULL; - blockType = NULL; - SDP_nBlock = 0; - SDP_blockStruct = NULL; - LP_nBlock = 0; -} - -BlockStruct::~BlockStruct() -{ - finalize(); -} - -void BlockStruct::initialize(int nBlock) -{ - this->nBlock = nBlock; - NewArray(blockStruct,int,nBlock); - NewArray(blockType, BlockType, nBlock); - NewArray(blockNumber,int,nBlock); - SDP_nBlock = 0; - SDP_blockStruct = NULL; - LP_nBlock = 0; -} - -void BlockStruct::finalize() -{ - DeleteArray(blockStruct); - DeleteArray(blockNumber); - DeleteArray(blockType); - DeleteArray(SDP_blockStruct); -} - -void BlockStruct::makeInternalStructure() -{ - SDP_nBlock = 0; - LP_nBlock = 0; - for (int l=0; lDisplay = Display; -} - -void SDPA::setResultFile(FILE* fpout) -{ - this->fpout = fpout; -} - -void SDPA::setNumThreads(int NumThreads) -{ - newton.setNumThreads(Display,fpout,NumThreads); -} - -SDPA::ParameterType SDPA::getParameterType() -{ - return typeParameter; -} - -int SDPA::getParameterMaxIteration() -{ - return param.maxIteration; -} -double SDPA::getParameterEpsilonStar() -{ - return param.epsilonStar; -} -double SDPA::getParameterLambdaStar() -{ - return param.lambdaStar; -} -double SDPA::getParameterOmegaStar() -{ - return param.omegaStar; -} -double SDPA::getParameterLowerBound() -{ - return param.lowerBound; -} -double SDPA::getParameterUpperBound() -{ - return param.upperBound; -} -double SDPA::getParameterBetaStar() -{ - return param.betaStar; -} -double SDPA::getParameterBetaBar() -{ - return param.betaBar; -} -double SDPA::getParameterGammaStar() -{ - return param.gammaStar; -} -double SDPA::getParameterEpsilonDash() -{ - return param.epsilonDash; -} -char* SDPA::getParameterPrintXVec() -{ - return param.xPrint; -} -char* SDPA::getParameterPrintXMat() -{ - return param.XPrint; -} -char* SDPA::getParameterPrintYMat() -{ - return param.YPrint; -} -char* SDPA::getParameterPrintInformation() -{ - return param.infPrint; -} -FILE* SDPA::getDisplay() -{ - return Display; -} -FILE* SDPA::getResultFile() -{ - return fpout; -} -bool SDPA::getInitPoint() -{ - return isInitPoint; -} - -int SDPA::getNumThreads() -{ - return newton.NUM_THREADS; -} - -void SDPA::inputConstraintNumber(int m) -{ - this->m = m; -} - -void SDPA::inputBlockNumber(int nBlock) -{ - this->nBlock = nBlock; - bs.initialize(nBlock); -} - -void SDPA::inputBlockSize(int l, int size) -{ - bs.blockStruct[l-1] = size; -} - -void SDPA::inputBlockType(int l, ConeType coneType) -{ - if (coneType == SDPA::SDP) { - bs.blockType[l-1] = BlockStruct::btSDP; - } - if (coneType == SDPA::LP) { - bs.blockType[l-1] = BlockStruct::btLP; - } -} - -void SDPA::inputCVec(int k, double value) -{ - if (k > m || k <= 0) { - rError("k exceeds ConstraintNumber or " - "k is less than or equal to zero :: m= " - << m << " : k= " << k); - - } - inputData.b.ele[k-1] = value; -} - -void SDPA::inputElement(int k, int l, int i, int j, double value, - bool inputCheck) -{ - if (inputCheck) { - if (k > m || k < 0) { - rError ("k exceeds ConstraintNumber or " - "k is less than zero :: m= " - << m << " : k= " << k << " : l= " << l - << " : i= " << i << " : j= " << j); - } - if (l > nBlock || l <= 0) { - rError ("l exceeds nBlock or " - "l is less than or equal to zero :: nBlock= " - << nBlock << " : k= " << k << " : l= " << l - << " : i= " << i << " : j= " << j); - } - int dim = bs.blockStruct[l-1]; - if (i > dim || i <= 0) { - rError ("i exceeds dimension of the block or " - "i is less than or equal to zero :: dim= " - << dim << " : k= " << k << " : l= " << l - << " : i= " << i << " : j= " << j); - } - if (j > dim || j <= 0) { - rError ("j exceeds dimension of the block or " - "j is less than or equal to zero :: dim= " - << dim << " : k= " << k << " : l= " << l - << " : i= " << i << " : j= " << j); - } - if (bs.blockType[l-1] == BlockStruct::btSDP) { - if (i > j) { - rMessage("Swap i and j [Only Upper Triangle]" - " : k= " << k << " : l= " << l - << " : i= " << i << " : j= " << j); - } - } - if (bs.blockType[l-1] == BlockStruct::btLP) { - if (i!=j) { - rError("i should be j in LP block" - " : k= " << k << " : l= " << l - << " : i= " << i << " : j= " << j); - } - } - } - - if (i > j) { - int tmp = i; i = j; j = tmp; - } - - LIJV* indexLIJv; - NewArray(indexLIJv,LIJV,1); - indexLIJv[0].SDPl = -1; - indexLIJv[0].LPl = -1; - indexLIJv[0].i = i; - indexLIJv[0].j = j; - indexLIJv[0].value = value; - - if (bs.blockType[l-1] == BlockStruct::btSDP) { - int l2 = bs.blockNumber[l-1]; - indexLIJv[0].SDPl = l2; - NonZeroElements[k].push_back(indexLIJv); - } else if (bs.blockType[l-1] == BlockStruct::btLP) { - int l2 = bs.blockNumber[l-1]; - indexLIJv[0].LPl = l2+i-1; - NonZeroElements[k].push_back(indexLIJv); - } - // NonZeroElements[k].push_back(indexLIJv); -} - -void SDPA::inputInitXVec(int k, double value) -{ - rError("This routine is not available in SDPA-C"); -} - -void SDPA::inputInitXMat(int l, int i, int j, double value) -{ - rError("This routine is not available in SDPA-C"); -} - -void SDPA::inputInitYMat(int l, int i, int j, double value) -{ - rError("This routine is not available in SDPA-C"); -} - - -void SDPA::initializeUpperTriangleSpace() -{ - bs.makeInternalStructure(); - NewArray(NonZeroElements,vector,m+1); - inputData.initialize(m, bs); - - // In SDPA-C, currentPt.initialize will be called later - // currentPt.initialize(m, bs, param.lambdaStar, com); -} - - -void SDPA::printNonZeroElements(FILE* fp) -{ - for (int k=0; k<=m; ++k) { - int size = NonZeroElements[k].size(); - for (int index = 0; index= 0) { - fprintf(fp,"%d, %d(S), %d, %d, ",k,SDPl,i,j); - } - if (LPl >= 0) { - fprintf(fp,"%d, %d(L), %d, %d, ",k,LPl,i,j); - } - fprintf(fp,param.infPrint,value); - fprintf(fp,"\n"); - } - } -} - -void SDPA::checkNonZeroElements() -{ - TimeStart(FILE_CHECK_START1); - for (int k=0; k<=m; ++k) { - int size = NonZeroElements[k].size(); - for (int index = 0; indexLP_sp_index[index2]); - } - printf("\n"); - rMessage("SDP blocks = "); - for (int index2 = 0; index2 < SDP_sp_nBlock; ++index2) { - printf(" %d", target->SDP_sp_index[index2]); - } - printf("\n"); - #endif - target->initializeInputVector(); - } - LP_blockCount.clear(); - SDP_blockCount.clear(); -} - -void SDPA::setNonZeroElements() -{ - for (int k=0; k0) { - target = &inputData.A[k-1]; - scale = 1.0; - } - int length = NonZeroElements[k].size(); - for (int index1 = 0; index1 < length; ++index1) { - LIJV* oneData = NonZeroElements[k].at(index1); - if (oneData[0].LPl >= 0) { - target->setElement_LP(oneData[0].LPl, oneData[0].value*scale); - } - if (oneData[0].SDPl >= 0) { - target->setElement_SDP(oneData[0].SDPl, - oneData[0].i-1, oneData[0].j-1, - oneData[0].value*scale); - } - } - } - - double v1 = 0; // dummy initialize - double v2 = 0; // dummy initialize - inputData.C.sortInputVector(); - int check_l = 0, check_i = 0, check_j = 0; - double check_v1 = 0, check_v2 = 0; - inputData.C.checkInputDataStructure(check_l, check_i, check_j, - check_v1, check_v2); - inputData.C.makeInternalStructure(); - if (check_l>=0) { - printf("***** invalid data ******\n"); - printf("F[0]:%d-th SDP block:[%d, %d]-th element has more than one input\n", - check_l+1, check_i+1, check_j+1); - rError("Stop due to input error\n"); - } - for (int k=0; k=0) { - printf("***** invalid data ******\n"); - printf("F[%d]:%d-th SDP block:[%d, %d]-th element has more than one input\n", - k+1, check_l+1, check_i+1, check_j+1); - rError("Stop due to input error\n"); - } - } - - #if 0 - rMessage("************** Read finished, internal data is from here."); - rMessage("C = -------------------------"); - inputData.C.display(); - for (int k=0; k nBlock || l <= 0) { - rError ("l exceeds nBlock or " - "l is less than or equal to zero :: nBlock= " - << nBlock << " : l= " << l); - } - if (bs.blockType[l-1] == BlockStruct::btSDP) { - int l2 = bs.blockNumber[l-1]; - return currentPt.finalZ.SDP_block[l2].de_ele; - } - else if (bs.blockType[l-1] == BlockStruct::btLP) { - int start = bs.blockNumber[l-1]; - return ¤tPt.finalZ.LP_block[start]; - } - return NULL; -} - -double* SDPA::getResultYMat(int l) -{ - if (IO::judgeXmake(param) == false) { - return NULL; - } - if (l > nBlock || l <= 0) { - rError ("l exceeds nBlock or " - "l is less than or equal to zero :: nBlock= " - << nBlock << " : l= " << l); - } - if (bs.blockType[l-1] == BlockStruct::btSDP) { - int l2 = bs.blockNumber[l-1]; - return currentPt.finalX.SDP_block[l2].de_ele; - } - else if (bs.blockType[l-1] == BlockStruct::btLP) { - int start = bs.blockNumber[l-1]; - return ¤tPt.finalX.LP_block[start]; - } - return NULL; -} - -double SDPA::getPrimalObj() -{ - // Note reverse primal-dual - return -solveInfo.objValDual; -} - -double SDPA::getDualObj() -{ - // Note reverse primal-dual - return -solveInfo.objValPrimal; -} - -double SDPA::getPrimalError() -{ - // Note reverse primal-dual - return currentRes.normDual; -} - -double SDPA::getDualError() -{ - // Note reverse primal-dual - return currentRes.normPrimal; -} - -double SDPA::getDigits() -{ - double mean = (fabs(solveInfo.objValPrimal) - + fabs(solveInfo.objValDual)) / 2.0; - double PDgap = getDualityGap(); - double digits = -log10(fabs(PDgap/mean)); - return digits; -} - -int SDPA::getIteration() -{ - return pIteration; -} - -double SDPA::getMu() -{ - return mu.current; -} - -double SDPA::getDualityGap() -{ - double PDgap = fabs(solveInfo.objValPrimal - - solveInfo.objValDual); - return PDgap; -} - -SDPA::PhaseType SDPA::getPhaseValue() -{ - // Note reverse primal-dual - switch (phase.value) { - case SolveInfo::noINFO : return noINFO ; break; - case SolveInfo::pFEAS : return pFEAS ; break; - case SolveInfo::dFEAS : return dFEAS ; break; - case SolveInfo::pdFEAS : return pdFEAS ; break; - case SolveInfo::pdINF : return pdINF ; break; - case SolveInfo::pFEAS_dINF: return pINF_dFEAS; break; - case SolveInfo::pINF_dFEAS: return pFEAS_dINF; break; - case SolveInfo::pdOPT : return pdOPT ; break; - case SolveInfo::pUNBD : return dUNBD ; break; - case SolveInfo::dUNBD : return pUNBD ; break; - default: break; - } - return noINFO; -} - -void SDPA::getPhaseString(char* str) -{ - switch (phase.value) { - case SolveInfo::noINFO : strcpy(str,(char *)"noINFO "); break; - case SolveInfo::pFEAS : strcpy(str,(char *)"pFEAS "); break; - case SolveInfo::dFEAS : strcpy(str,(char *)"dFEAS "); break; - case SolveInfo::pdFEAS : strcpy(str,(char *)"pdFEAS "); break; - case SolveInfo::pdINF : strcpy(str,(char *)"pdINF "); break; - case SolveInfo::pFEAS_dINF: strcpy(str,(char *)"pFEAS_dINF"); break; - case SolveInfo::pINF_dFEAS: strcpy(str,(char *)"pINF_dFEAS"); break; - case SolveInfo::pdOPT : strcpy(str,(char *)"pdOPT "); break; - case SolveInfo::pUNBD : strcpy(str,(char *)"pUNBD "); break; - case SolveInfo::dUNBD : strcpy(str,(char *)"dUNBD "); break; - default: - strcpy(str,(char *)"phase error"); - break; - } - return; -} - -double SDPA::getSolveTime() -{ - return com.TotalTime; -} - -int SDPA::getConstraintNumber() -{ - return m; -} - -int SDPA::getBlockNumber() -{ - return nBlock; -} - -int SDPA::getBlockSize(int l) -{ - if (l<=0 || l>nBlock) { - rMessage("out of range : getBlockSize " - ": l = " << l - << " should be between 1 and nBlock " << nBlock); - } - return bs.blockStruct[l-1]; -} - -SDPA::ConeType SDPA::getBlockType(int l) -{ - if (l<=0 || l>nBlock) { - rMessage("out of range : getBlockSize " - ": l = " << l - << " should be between 1 and nBlock " << nBlock); - } - switch (bs.blockType[l-1]) { - case BlockStruct::btSDP : return SDPA::SDP ; - case BlockStruct::btLP : return SDPA::LP ; - } - rError("Type Error in getBlockType "); - return SDPA::SDP; // dummy return -} - -void SDPA::getDimacsError(double* DimacsError) -{ - if (judgeDimacsAvailability() == false) { - return; - } - IO::computeDimacs(DimacsError, solveInfo, currentRes, - currentPt, inputData); -} - -void SDPA::printDimacsError(double* DimacsError, char* printFormat, - FILE* fpout) -{ - if (judgeDimacsAvailability() == false) { - return; - } - IO::printDimacs(DimacsError,printFormat,fpout); -} - -void SDPA::printDimacsEasy(FILE* fpout) -{ - double dimacs_error[7]; - currentPt.makeFinalSolution(true, true, bs); - getDimacsError(dimacs_error); - printf("Dimacs = "); - for (int dd=1; dd<7; ++dd) { - printf("%.3e ", dimacs_error[dd]); - } - printf("\n"); -} - - -void SDPA::printResultXVec(FILE* fp) -{ - // Note reverse primal-dual - currentPt.cholmodSpace.yVec.display(fp,1.0,param.xPrint); -} - -void SDPA::printResultXMat(FILE* fp) -{ - if (IO::judgeZmake(param) == false) { - fprintf(fp, "Result XMat is not computed.\n"); - return; - } - // Note reverse primal-dual - currentPt.finalZ.displaySolution(bs,fp,param.XPrint); -} - -void SDPA::printResultYMat(FILE* fp) -{ - if (IO::judgeXmake(param) == false) { - fprintf(fp, "Result YMat is not computed.\n"); - return; - } - // Note reverse primal-dual - currentPt.finalX.displaySolution(bs,fp,param.YPrint); -} - -void SDPA::printComputationTime(FILE* fp) -{ - com.display(fp); -} - -void SDPA::printParameters(FILE* fp) -{ - param.display(fp); -} - -bool SDPA::judgeDimacsAvailability() // for only SDPA-C -{ - bool Xmake = IO::judgeXmake(param); - bool Zmake = IO::judgeZmake(param); - if (Xmake == false || Zmake == false) { - return false; - } - return true; -} - -void SDPA::printSDPAVersion(FILE* fp) -{ - if (fp) { - fprintf(fp,"%s\n",(char*)sdpa_right); - } -} - -void SDPA::readInput(char* filename, FILE* fpout) -{ - TimeStart(FILE_READ_START1); - FILE* fpinput = NULL; - if ((fpinput = fopen(filename,"r")) == NULL) { - rError("Cannot Open Data File " << filename); - } - #if 0 - if (fpout){ - fprintf(fpout,"data is %s ", filename); - fprintf(fpout," : sparse\n"); - } - #endif - - char titleAndComment[LengthOfBuffer]; - IO::read(fpinput,fpout,m,titleAndComment); - IO::read(fpinput,nBlock); - bs.initialize(nBlock); - IO::read(fpinput,bs); - bs.makeInternalStructure(); - inputData.initialize(m, bs); - IO::read(fpinput, inputData.b); - IO::read(fpinput, m, bs, inputData); - // inputData.initialize_index(); - fclose(fpinput); - TimeEnd(FILE_READ_END1); - com.FileRead += TimeCal(FILE_READ_START1, - FILE_READ_END1); - com.TotalTime += TimeCal(FILE_READ_START1, - FILE_READ_END1); - return; -} - -void SDPA::readParameter(char* filename, FILE* fpout) -{ - FILE* fp = NULL; - if ((fp=fopen(filename,"r"))==NULL) { - rError("Cannot Open parameter File " << filename); - } - param.readFile(fp); - fclose(fp); - return; -} - -void SDPA::finalize() -{ - bs.finalize(); - inputData.finalize(); - chordal.finalize(); - newton.finalize(); - currentPt.finalize(); - initPt_xMat.finalize(); - initPt_zMat.finalize(); - currentRes.finalize(); - alpha.finalize(); -} - - -void SDPA::copyCurrentToInit() -{ - // This function is only compatibility with SDPA. - rMessage("The function SDPA::copyCurrentToInit() does nothing in SDPA-C"); - return; -} - -void SDPA::setKappa(double KAPPA) -{ - this->KAPPA = KAPPA; -} - diff --git a/external/sdpa/sdpa_call.h b/external/sdpa/sdpa_call.h deleted file mode 100644 index 544d9e6..0000000 --- a/external/sdpa/sdpa_call.h +++ /dev/null @@ -1,256 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ -/*-------------------------------------------------- - sdpa_call.h ---------------------------------------------------*/ - -/*************************************************** - In this header file, - Do NOT use 'using namespace sdpa;'. - Otherwise, if users define their OWN 'sdpa' namespace, - it would be trouble. -***************************************************/ - - -#ifndef __sdpa_call_h__ -#define __sdpa_call_h__ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* The class list is generated by the following command - $ grep class *.h | grep -v \; | grep -v SDPA | tr ':' ' ' | \ - awk '{print $2 " " $3 ";"}' -*/ - -namespace sdpa { - class BlockStruct; - class Chordal; - class Solutions; - class InputData; - class Residuals; - class IO; - class Lal; - class Newton; - class ComputeTime; - class Parameter; - class StepLength; - class DirectionParameter; - class Switch; - class AverageComplementarity; - class RatioInitResCurrentRes; - class SolveInfo; - class Phase; - class Vector; - class BlockVector; - class SparseMatrix; - class DenseMatrix; - class SparseLinearSpace; - class DenseLinearSpace; - class Time; - - class LIJV - { - public: - int SDPl,LPl,i,j; - double value; - }; -}; - -class SDPA -{ -public: - - enum PhaseType {noINFO, pFEAS,dFEAS,pdFEAS,pdINF, - pFEAS_dINF,pINF_dFEAS,pdOPT,pUNBD,dUNBD}; - enum ParameterType {PARAMETER_DEFAULT, - PARAMETER_UNSTABLE_BUT_FAST, - PARAMETER_STABLE_BUT_SLOW}; - - enum ConeType {SDP, SOCP, LP}; - // SOCP is not implemented in the current version. - - enum SparseType {AUTO, SPARSE, DENSE}; - // SparseType is only for compatiblity with SDPA7 - // In SDPA-C, this always must be SPARSE. - // enum SparseType {AUTO, SPARSE, DENSE}; - // when AUTO is set, the type is analyzed by the file extenstion. - - SDPA(); - ~SDPA(); - - void setParameterType(ParameterType type = PARAMETER_DEFAULT); - void setParameterMaxIteration(int maxIteration); - void setParameterEpsilonStar (double epsilonStar); - void setParameterLambdaStar (double lambdaStar); - void setParameterOmegaStar (double omegaStar); - void setParameterLowerBound (double lowerBound); - void setParameterUpperBound (double upperBound); - void setParameterBetaStar (double betaStar); - void setParameterBetaBar (double betaBar); - void setParameterGammaStar (double gammaStar); - void setParameterEpsilonDash (double epsilonDash); - - void setParameterPrintXVec(char* xPrint); - void setParameterPrintXMat(char* XPrint); - void setParameterPrintYMat(char* YPrint); - void setParameterPrintInformation(char* infPrint); - - void setDisplay(FILE* Display = stdout); - void setResultFile(FILE* fpout = stdout); - - void setNumThreads(int NumThreads=0); - - ParameterType getParameterType(); - int getParameterMaxIteration(); - double getParameterEpsilonStar (); - double getParameterLambdaStar (); - double getParameterOmegaStar (); - double getParameterLowerBound (); - double getParameterUpperBound (); - double getParameterBetaStar (); - double getParameterBetaBar (); - double getParameterGammaStar (); - double getParameterEpsilonDash (); - - char* getParameterPrintXVec(); - char* getParameterPrintXMat(); - char* getParameterPrintYMat(); - char* getParameterPrintInformation(); - - FILE* getDisplay(); - FILE* getResultFile(); - bool getInitPoint(); - - int getNumThreads(); - - void inputConstraintNumber(int m); - void inputBlockNumber(int nBlock); - void inputBlockSize(int l, int size); - void inputBlockType(int l, ConeType coneType); - void inputCVec(int k, double value); - void inputElement(int k, int l, int i, int j, double value, - bool inputCheck = false); - void inputInitXVec(int k, double value); - void inputInitXMat(int l, int i, int j, double value); - void inputInitYMat(int l, int i, int j, double value); - - void initializeUpperTriangleSpace(); - void initializeUpperTriangle(bool inputTwiceCheck = false); - void initializeSolve(); - - void solve(); - - double* getResultXVec(); - double* getResultXMat(int l); - double* getResultYMat(int l); - double getPrimalObj(); - double getDualObj(); - double getPrimalError(); - double getDualError(); - double getDigits(); - int getIteration(); - double getMu(); - double getDualityGap(); - PhaseType getPhaseValue(); - void getPhaseString(char* str); - double getSolveTime(); - - int getConstraintNumber(); - int getBlockNumber(); - int getBlockSize(int l); - ConeType getBlockType(int l); - - void getDimacsError(double* DimacsError); - void printDimacsError(double* DimacsError, char* printFormat, - FILE* fp = stdout); - - void printResultXVec(FILE* fp = stdout); - void printResultXMat(FILE* fp = stdout); - void printResultYMat(FILE* fp = stdout); - void printComputationTime(FILE* fp = stdout); - void printParameters(FILE* fp = stdout); - - bool judgeDimacsAvailability(); // for only SDPA-C - - static void printSDPAVersion(FILE* fp = stdout); - - void readInput(char* filename, FILE* fpout = NULL); - void readParameter(char* filename, FILE* fpout = NULL); - void writeInputSparse(char* filename, char* printFormat); - void writeInitSparse(char* filename, char* printFormat); - - void finalize(); - void copyCurrentToInit(); - - // setKappa is for only SDPA developers - void setKappa(double KAPPA); - - // // for debugging, private is replaced by public - // public: -private: - double KAPPA; - int m; - int nBlock; - FILE* Display; - FILE* fpout; - bool isInitPoint; - ParameterType typeParameter; - - int pIteration; - - sdpa::ComputeTime com; - sdpa::Parameter param; - sdpa::BlockStruct bs; - sdpa::InputData inputData; - sdpa::Newton newton; - sdpa::Chordal chordal; - sdpa::Solutions currentPt; - sdpa::DenseLinearSpace initPt_xMat; - sdpa::DenseLinearSpace initPt_zMat; - sdpa::Residuals currentRes; - sdpa::StepLength alpha; - sdpa::DirectionParameter beta; - sdpa::Switch reduction; - sdpa::AverageComplementarity mu; - sdpa::RatioInitResCurrentRes theta; - sdpa::SolveInfo solveInfo; - sdpa::Phase phase; - - - // temporary space to store - // upper trianguler part non-zeros. - vector * NonZeroElements; - void printNonZeroElements(FILE* fpout = stdout); - void checkNonZeroElements(); - void setNonZeroBlockStruct(); - void setNonZeroElements(); - - void printDimacsEasy(FILE* fpout = stdout); // heavy but for each iteration -}; - -#endif // __sdpa_call_h__ diff --git a/external/sdpa/sdpa_chordal.cpp b/external/sdpa/sdpa_chordal.cpp deleted file mode 100644 index 96ea8dd..0000000 --- a/external/sdpa/sdpa_chordal.cpp +++ /dev/null @@ -1,557 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ - -#include - -#define PrintSparsity 1 -#define PLUS_ADJUST_DIAGONAL (1.0e-10) - // #define PLUS_ADJUST_DIAGONAL (m*1.0e-10) - - // For debug -#define FORCE_SCHUR_DENSE 0 -#define FORCE_SCHUR_SPARSE 0 - -#include "sdpa_chordal.h" -#define MUMPS_JOB_INIT -1 -#define MUMPS_JOB_END -2 -#define MUMPS_JOB_ANALYSIS 1 -#define MUMPS_JOB_FACTORIZE 2 -#define MUMPS_JOB_SOLVE 3 -#define MUMPS_USE_COMM_WORLD (-987654) - -namespace sdpa { - -Chordal::Chordal() -{ - mumps_usage = false; - sparse_bMat_ptr = NULL; - best = 0; -} - -Chordal::~Chordal() -{ - finalize(); -} - -void Chordal::initialize(SparseMatrix* sparse_bMat_ptr) -{ - // condition of sparse computation - // m_threshold < mDim, - // b_threshold < nBlock, - // aggregate_threshold >= aggrigated sparsity ratio - // extend_threshold >= extended sparsity ratio - m_threshold = 100; - b_threshold = 5; - aggregate_threshold = 0.70; - extend_threshold = 0.80; - -#if FORCE_SCHUR_DENSE // DENSE computation for debugging - m_threshold = 10000000; - b_threshold = 1000000; - aggregate_threshold = 0.0; - extend_threshold = 0.0; -#endif -#if FORCE_SCHUR_SPARSE // SPARSE computation for debugging - m_threshold = 0; - b_threshold = 0; - aggregate_threshold = 2.0; - extend_threshold = 2.0; -#endif - // initialize by assuming Schur would be DENSE - best = SELECT_DENSE; - - this->sparse_bMat_ptr = sparse_bMat_ptr; - - // initialize MUMPS - mumps_id.job = MUMPS_JOB_INIT; - mumps_id.comm_fortran = MUMPS_USE_COMM_WORLD; - // rank 0 process participates factorizations - mumps_id.par = 1; - // Only symmetric positive definite matricies - mumps_id.sym = 1; - // No OUTPUTS - mumps_id.icntl[1-1] = -1; - mumps_id.icntl[2-1] = -1; - mumps_id.icntl[3-1] = -1; - mumps_id.icntl[4-1] = 0; - - // MUMPS selects ordering automatically - mumps_id.icntl[7-1] = SELECT_MUMPS_BEST; - // for Minumum Degree Ordering - // mumps_id.icntl[7-1] = 0; - - dmumps_c(&mumps_id); - mumps_usage = true; - -} - -void Chordal::finalize() -{ - if (mumps_usage == true) { - mumps_id.job = MUMPS_JOB_END; - dmumps_c(&mumps_id); - mumps_usage = false; - } - if (sparse_bMat_ptr) { - sparse_bMat_ptr->finalize(); - } - sparse_bMat_ptr = NULL; -} - -// merge array1 to array2 -void Chordal::mergeArray(int na1, int* array1, int na2, int* array2) -{ - - int ptr = na1 + na2 - 1; - int ptr1 = na1-1; - int ptr2 = na2-1; - int idx1, idx2; - - while ((ptr1 >= 0) || (ptr2 >= 0)){ - - if (ptr1 >= 0){ - idx1 = array1[ptr1]; - } else { - idx1 = -1; - } - if (ptr2 >= 0 ){ - idx2 = array2[ptr2]; - } else { - idx2 = -1; - } - if (idx1 > idx2){ - array2[ptr] = idx1; - ptr1--; - } else { - array2[ptr] = idx2; - ptr2--; - } - ptr--; - - } - - // error check - if (ptr != -1){ - rMessage("Chordal::mergeArray:: program bug"); - } -} - -void Chordal::catArray(int na1, int* array1, int na2, int* array2) -{ - int ind1 = 0; - for (int index=0; index initialize(m,m,SparseMatrix::SPARSE, - nz,SparseMatrix::DSarrays); - sparse_bMat_ptr -> NonZeroCount = nz; - int indexNZ = 0; - for (j=0; j row_index[indexNZ] = tmp[j][index_i]+1; - sparse_bMat_ptr -> column_index[indexNZ] = j+1; - sparse_bMat_ptr -> sp_ele[indexNZ] = 0.0; - indexNZ++; - } - } - - DeleteArray(counter); - for (j=0; jNonZeroCount; - mumps_id.irn = sparse_bMat_ptr->row_index; - mumps_id.jcn = sparse_bMat_ptr->column_index; - mumps_id.a = sparse_bMat_ptr->sp_ele; - - // sparse_bMat_ptr->display(); - // rMessage("m = " << m); - // rMessage("NonZeroCount = " << sparse_bMat_ptr->NonZeroCount); - - // No OUTPUTS for analysis - mumps_id.icntl[1-1] = -1; - mumps_id.icntl[2-1] = -1; - mumps_id.icntl[3-1] = -1; - mumps_id.icntl[4-1] = 0; - // strcpy(mumps_id.write_problem,"write_problem"); - dmumps_c(&mumps_id); - double lower_nonzeros = (double)mumps_id.infog[20-1]; - // if lower_nonzeros is greater than 1.0e+6, - // the value infog[20-1] is lower_nonzeros*(-1)/(1.0e+6). - // we need to adjust the value. - if (lower_nonzeros < 0) { - lower_nonzeros *= (-1.0e+6); - } - #if 0 - rMessage("lower_nonzeros = " << lower_nonzeros); - rMessage("Schur density = " << lower_nonzeros/((m+1)*m/2)*100 << "%" ); - #endif - - if (mumps_id.infog[1-1] != 0) { - rError("MUMPS ERROR " << mumps_id.infog[1-1]); - } - return lower_nonzeros; -} - -void Chordal::ordering_bMat(int m, int nBlock, - InputData& inputData, - FILE* Display, FILE* fpOut) -{ - best = SELECT_MUMPS_BEST; - #if 0 - if ((m <= m_threshold)||(nBlock <= b_threshold)) { - best = SELECT_DENSE; - return; - } - #else - if (m <= m_threshold) { - best = SELECT_DENSE; - return; - } - #endif - - #if 1 - for (int b=0; b m * sqrt(aggregate_threshold)){ - best = SELECT_DENSE; - return; - } - } - for (int b=0; b m * sqrt(aggregate_threshold)){ - best = SELECT_DENSE; - return; - } - } - #endif - - makeGraph(inputData,m); - // Here, we initialize sparse_bMat - - int NonZeroAggregate = sparse_bMat_ptr->NonZeroCount*2-m; - if (NonZeroAggregate > aggregate_threshold * (double)m * (double) m) { - best = SELECT_DENSE; - return; - } - - double lowerExtended = analysisAndcountLowerNonZero(m); - double NonZeroExtended = lowerExtended*2 - m; - double overM2 = 1.0/((double)m*(double)m)*100.0; -#if PrintSparsity - /* print sparsity information */ - if (Display) { - - #if 0 - fprintf(Display,"dense matrix :\t\t\t%14d elements\n", m*m); - fprintf(Display,"aggregate sparsity pattern :\t\t\t%14d elements\n", - NonZeroAggregate); - fprintf(Display,"extended sparsity pattern :\t\t\t%14d elements\n", - (int)NonZeroExtended); - fprintf(Display,"Schur density = %.8lf%%\n", - (double)NonZeroExtended*overM2); - fprintf(Display,"Fill in = %e%%\n", - (double)(NonZeroExtended-NonZeroAggregate)*overM2); - fprintf(Display, "Estimated FLOPs for elimation process = %e\n", - mumps_id.rinfog[1-1]); - fprintf(Display, - "Maximum Processor Memory Requirement = %d MB = %.2lf GB\n", - mumps_id.infog[16-1],(double)mumps_id.infog[16-1]/1024); - fprintf(Display, - "Total Processors Memory Requirement = %d MB = %.2lf GB\n", - mumps_id.infog[17-1],(double)mumps_id.infog[17-1]/1024); - #else - fprintf(Display, "Full Schur Elements %ld, %.2e\n", - (long int)((double)m*m),(double)m*m); - fprintf(Display, "Agg %d (%.2e%%)->Ext %d (%.2e%%)" - " [Fill %d (%.2e%%)]\n", - NonZeroAggregate, - (double)NonZeroAggregate*overM2, - (int)NonZeroExtended, - (double)NonZeroExtended*overM2, - (int)(NonZeroExtended-NonZeroAggregate), - (double)(NonZeroExtended-NonZeroAggregate)*overM2); - fprintf(Display, "Est FLOPs Elim = %.2e:", - mumps_id.rinfog[1-1]); - fprintf(Display, - "MaxMem = %dMB = %.2lfGB:", - mumps_id.infog[16-1],(double)mumps_id.infog[16-1]/1024); - fprintf(Display, - "TotMem = %dMB = %.2lfGB\n", - mumps_id.infog[17-1],(double)mumps_id.infog[17-1]/1024); - #endif - } - if (fpOut) { - #if 0 - fprintf(fpOut,"dense matrix :\t\t\t%14d elements\n", m*m); - fprintf(fpOut,"aggregate sparsity pattern :\t\t\t%14d elements\n", - NonZeroAggregate); - fprintf(fpOut,"extended sparsity pattern :\t\t\t%14d elements\n", - (int)NonZeroExtended); - fprintf(fpOut,"Schur density = %.8lf%%\n", - (double)NonZeroExtended*overM2); - fprintf(fpOut,"Fill in = %e%%\n", - (double)(NonZeroExtended-NonZeroAggregate)*overM2); - fprintf(fpOut, "Estimated FLOPS for elimation process = %e\n", - mumps_id.rinfog[1-1]); - fprintf(fpOut, - "Maximum Processor Memory Requirement = %d MB = %.2lf GB\n", - mumps_id.infog[16-1],(double)mumps_id.infog[16-1]/1024); - fprintf(fpOut, - "Total Processors Memory Requirement = %d MB = %.2lf GB\n", - mumps_id.infog[17-1],(double)mumps_id.infog[17-1]/1024); - #else - fprintf(fpOut, "Full Schur Elements Number %ld, %.2e\n", - (long int)((double)m*m),(double)m*m); - fprintf(fpOut, "Agg %d (%.2e%%)->Ext %d (%.2e%%)" - " [Fill %d (%.2e%%)]\n", - NonZeroAggregate, - (double)NonZeroAggregate*overM2, - (int)NonZeroExtended, - (double)NonZeroExtended*overM2, - (int)(NonZeroExtended-NonZeroAggregate), - (double)(NonZeroExtended-NonZeroAggregate)*overM2); - fprintf(fpOut, "Est FLOPs Elim = %.2e:", - mumps_id.rinfog[1-1]); - fprintf(fpOut, - "MaxMem = %dMB = %.2lfGB:", - mumps_id.infog[16-1],(double)mumps_id.infog[16-1]/1024); - fprintf(fpOut, - "TotMem = %dMB = %.2lfGB\n", - mumps_id.infog[17-1],(double)mumps_id.infog[17-1]/1024); - #endif - } -#endif - - - - if (NonZeroExtended > extend_threshold * m * m){ - best = SELECT_DENSE; - } - - double sparse_cost = mumps_id.rinfog[1-1] * 1.15; - double dense_cost = 1.0/3.0 * (double)m * (double)m * (double) m; - double sd_ratio = 0.85; - // The ratio of (dense/sparse) - // estimated by BbRosenB10.dat-s - #if 0 - rMessage("sparse_cost = " << sparse_cost - << " : dense_cost = " << dense_cost - << " : dense_cost * sd_ratio = " - << (dense_cost * sd_ratio)); - #endif - - #if !FORCE_SCHUR_SPARSE - if (sparse_cost > dense_cost * sd_ratio) { - best = SELECT_DENSE; - } - #endif -} - -bool Chordal::factorizeSchur(int m, int* diagonalIndex, - FILE* Display, FILE* fpOut) -{ - // I need to adjust Schur before factorization - // to loose Numerical Error Condition - double adjustSize = PLUS_ADJUST_DIAGONAL; - for (int i=0; isp_ele[diagonalIndex[i]] += adjustSize; - } - - mumps_id.job = MUMPS_JOB_FACTORIZE; - mumps_id.a = sparse_bMat_ptr->sp_ele; - dmumps_c(&mumps_id); - bool isSuccess = SDPA_SUCCESS; - while (mumps_id.infog[1-1] == -9) { - #if 0 - rMessage("mumps icntl(14) = " << mumps_id.icntl[14-1]); - rMessage("mumps icntl(23) = " << mumps_id.icntl[23-1]); - #endif - if (Display) { - fprintf(Display,"MUMPS needs more memory space. Trying ANALYSIS phase once more\n"); - } - if (fpOut) { - fprintf(fpOut, "MUMPS needs more memory space. Trying ANALYSIS phase once more\n"); - } - mumps_id.icntl[14-1] += 20; // More 20% working memory space - analysisAndcountLowerNonZero(m); - mumps_id.job = MUMPS_JOB_FACTORIZE; - dmumps_c(&mumps_id); - } - if (mumps_id.infog[1-1] < 0) { - isSuccess = SDPA_FAILURE; - if (mumps_id.infog[1-1] == -10) { - rMessage("Cholesky failed by NUMERICAL ERROR"); - rMessage("There are some possibilities."); - rMessage("1. SDPA finalizes due to inaccuracy of numerical error"); - rMessage("2. The input problem may not have (any) interior-points"); - rMessage("3. Input matrices are linearly dependent"); - } - else { - rMessage("Cholesky failed with Error Code " - << mumps_id.infog[1-1]); - } - } - return isSuccess; -} - -bool Chordal::solveSchur(Vector& rhs) -{ - mumps_id.job = MUMPS_JOB_SOLVE; - mumps_id.rhs = rhs.ele; - dmumps_c(&mumps_id); - return SDPA_SUCCESS; -} - -} // end of namespace 'sdpa' - diff --git a/external/sdpa/sdpa_chordal.h b/external/sdpa/sdpa_chordal.h deleted file mode 100644 index 8febad5..0000000 --- a/external/sdpa/sdpa_chordal.h +++ /dev/null @@ -1,84 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ - -/*----------------------------------------- - sdpa_chordal.h ------------------------------------------*/ - -#ifndef __sdpa_chordal_h__ -#define __sdpa_chordal_h__ - -#include "sdpa_dataset.h" -#include - -#define SELECT_MUMPS_BEST 7 // MUMPS selects automatically when 7 -#define SELECT_DENSE -1 // This value must be minus - -namespace sdpa { - -class Chordal { -public: - - // condition of sparse computation - // m_threshold < mDim, - // b_threshold < nBlock, - // aggregate_threshold >= aggrigated sparsity ratio - // extend_threshold >= extended sparsity ratio - int m_threshold; - int b_threshold; - double aggregate_threshold; - double extend_threshold; - - int best; -/* indicates the used ordering method */ - /* -1: dense computation */ - /* 7: sparse computation by MUMPS */ - - SparseMatrix* sparse_bMat_ptr; - DMUMPS_STRUC_C mumps_id; - bool mumps_usage; - - - Chordal(void); - ~Chordal(); - void initialize(SparseMatrix* sparse_bMat_ptr); - void finalize(); - - // merge array1 to array2 - void mergeArray(int na1, int* array1, int na2, int* array2); - void catArray(int na1, int* array1, int na2, int* array2); - void slimArray(int i, int length, int* array, int& slimedLength); - - void makeGraph(InputData& inputData, int m); - - void ordering_bMat(int m, int nBlock, - InputData& inputData, FILE* Display, - FILE* fpOut); - double analysisAndcountLowerNonZero(int m); - bool factorizeSchur(int m, int* diagonalIndex, - FILE* Display, FILE* fpOut); - bool solveSchur(Vector& rhs); - -}; - -} // end of namespace 'sdpa' - -#endif // __sdpa_chordal_h__ diff --git a/external/sdpa/sdpa_dataset.cpp b/external/sdpa/sdpa_dataset.cpp deleted file mode 100644 index 708f065..0000000 --- a/external/sdpa/sdpa_dataset.cpp +++ /dev/null @@ -1,557 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ - -#include "sdpa_dataset.h" -#include "sdpa_parts.h" -#include "sdpa_linear.h" -#include "sdpa_newton.h" - -namespace sdpa { - -Solutions::Solutions() -{ - initialize(); -} - -Solutions::~Solutions() -{ - finalize(); -} - -void Solutions::initialize() -{ - nDim = 0; - mDim = 0; -} - -void Solutions::initialize(int m, BlockStruct& bs) -{ - mDim = m; - nDim = 0; - for (int l=0; l \n"); - cholmodSpace.display(fpout, printFormat); - fprintf(fpout, "order =========> \n"); - order.display(fpout, printFormat); - rMessage("Solutions @ end @@@@@@@@@@@@@@@@@@@@@@"); -} - -void Solutions::makeFinalSolution(bool Xmake, bool Zmake, - BlockStruct& bs) -{ - if (Xmake == true) { - cholmodSpace.getCholesky(order); - finalX.initialize(bs); - for (int l=0; l ret) { - ret = tmp; - } - } - return ret; -} - -double Residuals::computeMaxNorm(cholmod_sparse* rD) -{ - double ret = 0.0; - for (int index1=0; index1nzmax; ++index1) { - const double tmp = fabs(((double*)rD->x)[index1]); - if (tmp > ret) { - ret = tmp; - } - } - return ret; -} - -void Residuals::update(CholmodSpace& cholmodSpace) -{ - // p[k] = b[k] - A[k].X; - normPrimal = computeMaxNorm(cholmodSpace.rp); - - double tmpNorm = 0.0; - for (int l = 0; l < cholmodSpace.LP_nBlock; ++l) { - double tmp2 = fabs(cholmodSpace.LP_rD[l]); - if (tmp2 > tmpNorm) { - tmpNorm = tmp2; - } - } - for (int l = 0; l < cholmodSpace.SDP_nBlock; ++l) { - double tmp2 = computeMaxNorm(cholmodSpace.SDP_block[l].rD); - if (tmp2 > tmpNorm) { - tmpNorm = tmp2; - } - } - normDual = tmpNorm; -} - -void Residuals::copyToInit() -{ - initNormPrimal = normPrimal; - initNormDual = normDual; - centerNorm = 0.0; -} - -void Residuals::display(FILE* fpout) -{ - if (fpout == NULL) { - return; - } - fprintf(fpout," initial.normPrimal = %8.3e\n", - initNormPrimal); - fprintf(fpout," initial.normDual = %8.3e\n", - initNormDual); - fprintf(fpout," currentRes.normPrimal = %8.3e\n", - normPrimal); - fprintf(fpout," currentRes.normDual = %8.3e\n", - normDual); -} - - - -} // end of namespace 'sdpa' - diff --git a/external/sdpa/sdpa_dataset.h b/external/sdpa/sdpa_dataset.h deleted file mode 100644 index a37786e..0000000 --- a/external/sdpa/sdpa_dataset.h +++ /dev/null @@ -1,135 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ - -#ifndef __sdpa_detaset_h__ -#define __sdpa_detaset_h__ - -#include "sdpa_include.h" -#include "sdpa_struct.h" - -namespace sdpa { - -class Newton; - -class Solutions; -class InputData; -class Residuals; - -class ComputeTime; -class Parameter; -class StepLength; -class DirectionParameter; -class Switch; -class RatioInitResCurrentRes; -class SolveInfo; -class Phase; -class AverageComplementarity; - - -class Solutions -{ -public: - int nDim; - int mDim; - - CholmodSpace cholmodSpace; - OrderingSpace order; - - DenseLinearSpace finalX; - DenseLinearSpace finalZ; - - Solutions(); - ~Solutions(); - void initialize(); - void initialize(int m, BlockStruct& bs); - void finalize(); - - void makeCliques(BlockStruct& bs, InputData& inputData); - void setInitialPoint(BlockStruct&bs, double lambda); - - bool update(StepLength& alpha, ComputeTime& com); - void display(FILE* fpout=stdout, char* printFormat = P_FORMAT); - - void makeFinalSolution(bool Xmake, bool Zmake, - BlockStruct& bs); -}; - -class InputData -{ -public: - Vector b; - CompSpace C; - CompSpace* A; - - // nBLock : number of block - // nConstraint[k]: number of nonzero matrix in k-th block - // When A[i].block[k] is nonzero matrix, for t, - // i <-> constraint[k][t] - // A[i].block[k] <-> A[i].sp_block[blockIndex[k][t]] - int SDP_nBlock; int* SDP_nConstraint; - int** SDP_constraint; int** SDP_blockIndex; - int LP_nBlock; int* LP_nConstraint; - int** LP_constraint; int** LP_blockIndex; - - InputData(); - ~InputData(); - void initialize(int m, BlockStruct& bs); - void finalize(); - void initialize_bVec(int m); - void initialize_index_SDP(); - void initialize_index_LP(); - void initialize_index(); - - void assignAgg(CholmodSpace& cholmodSpace); - void assignBlockIndex(OrderingSpace& order); - - void display(FILE* fpout=stdout); - void display_index(FILE* fpout=stdout); -}; - -class Residuals -{ -public: - double initNormPrimal; - double initNormDual; - double normPrimal; - double normDual; - double centerNorm; - - Residuals(); - ~Residuals(); - - void initialize(); - void finalize(); - - static double computeMaxNorm(Vector& primalVec); - static double computeMaxNorm(cholmod_sparse* rD); - - void update(CholmodSpace& cholmodSpace); - void copyToInit(); - void display(FILE* fpout = stdout); - -}; - - -} // end of namespace 'sdpa' - -#endif // __sdpa_dataset_h__ diff --git a/external/sdpa/sdpa_dpotrf.cpp b/external/sdpa/sdpa_dpotrf.cpp deleted file mode 100644 index 4144881..0000000 --- a/external/sdpa/sdpa_dpotrf.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ -/*----------------------------------------------- - rsdpa_dpotrf.cpp - modification of ATL_dpotrfL - for dealing with numerical error - in diagonal elements. - - int rATL_dpotrfL(int N, double *A,int lda) - - modified by Makoto Yamshita 2002.07.11 ------------------------------------------------*/ -#define POTRF_NONZERO (1.0e-14) -#define POTRF_ASSIGN (1.0e+100) -#define POTRF_LIMIT (-1.0e-6) - -/* - * Automatically Tuned Linear Algebra Software v3.4.0 - * (C) Copyright 1999 R. Clint Whaley - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions, and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the ATLAS group or the names of its contributers may - * not be used to endorse or promote products derived from this - * software without specific written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ATLAS GROUP OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - - - -#include "sdpa_include.h" -#include "sdpa_algebra.h" -#if 0 -#define CHOLESKY_ADJUST(val) rMessage("Choleksy adjust from " << val << " to " << POTRF_NONZERO); -#else -#define CHOLESKY_ADJUST(val) ; -#endif - -namespace sdpa { - -extern "C" { -static int potrf4(double* A,const int n) -{ - double* A1 = A+n+1; - double* A2 = A1+n+1; - double* A3 = A2+n+1; - double L11 = *A; - double L21 = A[1], L22 = *A1; - double L31 = A[2], L32 = A1[1], L33 = *A2; - double L41 = A[3], L42 = A1[2], L43 = A2[1], L44 = *A3; - - if (L11 < POTRF_LIMIT) { - return 1; - } - if (L11 < POTRF_NONZERO) { - CHOLESKY_ADJUST(L11); - L11 = POTRF_ASSIGN; - } - - *A = L11 = sqrt(L11); - L11 = 1.0/L11; - L21 *= L11; - L31 *= L11; - L41 *= L11; - - L22 -= L21*L21; - if (L22 < POTRF_LIMIT) { - return 2; - } - if (L22 < POTRF_NONZERO) { - CHOLESKY_ADJUST(L22); - L22 = POTRF_ASSIGN; - } - *A1 = L22 = sqrt(L22); - L22 = 1.0/L22; - L32 = (L32 - L31*L21)*L22; - L42 = (L42 - L41*L21)*L22; - - L33 -= L31*L31 + L32*L32; - if (L33 < POTRF_LIMIT) { - return 3; - } - if (L33 < POTRF_NONZERO) { - CHOLESKY_ADJUST(L33); - L33 = POTRF_ASSIGN; - } - *A2 = L33 = sqrt(L33); - L43 = (L43-L41*L31-L42*L32)/L33; - L44 -= L41*L41 + L42*L42 + L43*L43; - if (L44 < POTRF_LIMIT) { - return 4; - } - if (L44 < POTRF_NONZERO) { - CHOLESKY_ADJUST(L44); - L44 = POTRF_ASSIGN; - } - *A3 = sqrt(L44); - - A[1] = L21; - A[2] = L31; A1[1] = L32; - A[3] = L41; A1[2] = L42; A2[1] = L43; - return 0; -} - -static int potrf3(double* A,const int n) -{ - double* A1 = A+n+1; - double* A2 = A1+n+1; - double L11 = *A; - double L21 = A[1], L22 = *A1; - double L31 = A[2], L32 = A1[1], L33 = *A2; - - if (L11 < POTRF_LIMIT) { - return 1; - } - if (L11 < POTRF_NONZERO) { - CHOLESKY_ADJUST(L11); - L11 = POTRF_ASSIGN; - } - - *A = L11 = sqrt(L11); - L11 = 1.0/L11; - L21 *= L11; - L31 *= L11; - - L22 -= L21*L21; - if (L22 < POTRF_LIMIT) { - return 2; - } - if (L22 < POTRF_NONZERO) { - CHOLESKY_ADJUST(L22); - L22 = POTRF_ASSIGN; - } - L22 = sqrt(L22); - L32 = (L32 - L31*L21)/L22; - - L33 -= L31*L31 + L32*L32; - if (L33 < POTRF_LIMIT) { - return 3; - } - if (L33 < POTRF_NONZERO) { - CHOLESKY_ADJUST(L33); - L33 = POTRF_ASSIGN; - } - *A2 = sqrt(L33); - - A[1] = L21; *A1 = L22; - A[2] = L31; A1[1] = L32; - return 0; -} - -static int potrf2(double* A,const int n) -{ - double* A1 = A+n+1; - double L11 = *A; - double L21 = A[1], L22 = *A1; - - if (L11 < POTRF_LIMIT) { - return 1; - } - if (L11 < POTRF_NONZERO) { - CHOLESKY_ADJUST(L11); - L11 = POTRF_ASSIGN; - } - - *A = L11 = sqrt(L11); - L21 /= L11; - L22 -= L21*L21; - if (L22 < POTRF_LIMIT) { - return 2; - } - if (L22 < POTRF_NONZERO) { - CHOLESKY_ADJUST(L22); - L22 = POTRF_ASSIGN; - } - *A = L11; - A[1] = L21; *A1 = sqrt(L22); - - return 0; -} - -int rATL_dpotrfL(int N, double *A,int lda) -{ - double *An, *Ar; - int Nleft, Nright, ierr; - - if (N > 4) { - Nleft = N >> 1; -#if 0 - int nb = ilaenv_fc(&IONE, "DPOTRF", "L", &N, - &IMONE,&IONE, &IMONE, strlen("DPOTRF"), strlen("L")); - if (Nleft > nb<<1) Nleft = (Nleft/nb)*nb; -#endif -#if 0 - if (Nleft > 64) { - Nleft = 64; - } -#endif - Nright = N - Nleft; - ierr = rATL_dpotrfL(Nleft, A,lda); - if (!ierr) { - Ar = A + Nleft; - An = Ar + lda * Nleft; - dtrsm_fc ((char *)"R",(char *)"L",(char *)"T",(char *)"N", - &Nright,&Nleft,&DONE,A,&lda, - Ar, &lda, strlen("R"),strlen("L"), - strlen("T"),strlen("N")); - dsyrk_fc ((char *)"L",(char *)"N",&Nright,&Nleft,&DMONE, - Ar, &lda, &DONE,An,&lda,strlen("L"),strlen("N")); - ierr = rATL_dpotrfL(Nright, An,lda); - if (ierr) return(ierr+Nleft); - } - else return(ierr); - } - else if (N==4) return(potrf4(A,lda)); - else if (N==3) return(potrf3(A,lda)); - else if (N==2) return(potrf2(A,lda)); - else if (N==1) { - if (*A < POTRF_LIMIT) { - return 1; - } - if (*A < POTRF_NONZERO) { - CHOLESKY_ADJUST(*A); - *A = POTRF_ASSIGN; - } - *A = sqrt(*A); - } - return(0); -} - -void rdpotrfl_(int* N, double *A,int* lda,int* info) -{ - *info = rATL_dpotrfL(*N,A,*lda); -} - -}; // end of extern "C" - -} // end of namespace 'sdpa' diff --git a/external/sdpa/sdpa_dpotrf.h b/external/sdpa/sdpa_dpotrf.h deleted file mode 100644 index 586887d..0000000 --- a/external/sdpa/sdpa_dpotrf.h +++ /dev/null @@ -1,43 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ -/*----------------------------------------------- - rsdpa_dpotrf.cpp - modification of ATL_dpotrfL - int rATL_dpotrfL(int N, double *A,int lda) - $Id: rsdpa_dpotrf.h,v 1.2 2004/09/01 06:34:12 makoto Exp $ ------------------------------------------------*/ - -#ifndef __sdpa_dpotrf_h__ -#define __sdpa_dpotrf_h__ - -namespace sdpa { - -#ifdef __cplusplus -extern "C" int rATL_dpotrfL(int N, double *A,int lda); -#else -extern int rATL_dpotrfL(int N, double *A,int lda); -#endif - -} // end of namespace 'sdpa' - -#endif // __sdpa_dpotrf_h__ - - diff --git a/external/sdpa/sdpa_exe.cpp b/external/sdpa/sdpa_exe.cpp deleted file mode 100644 index c8c63c3..0000000 --- a/external/sdpa/sdpa_exe.cpp +++ /dev/null @@ -1,360 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ - -#include -#include -#include -using namespace sdpa; - -#define USER_PARAMETER_FILE ((char *)"./param.sdpaC") -#define DEFAULT_PARAMETER_FILE ((char *)"/usr/share/sdpa/param.sdpaC") -// PARAMETER_FILE is decided by the following priority -// 1: The file assigned by '-p' option of 'option type 2'. -// For 'option type1', this is skipped. -// 2: USER_PARAMETER_FILE -// For 'option type2', this is skipped. -// 3: DEFAULT_PARAMETER_FILE -// 4: Default parameter -static void message(char* argv0) -{ - cout << endl; - cout << "*** Please assign data file and output file.***" << endl; - cout << endl; - cout << "---- option type 1 ------------" << endl; - cout << argv0 <<" SparseDataFile OutputFile" - " [-pt parameters] [-dimacs] [-numThreads numThreads]"<< endl; - cout << "parameters = 0 default, 1 fast (unstable)," - " 2 slow (stable)" << endl; - cout << " -dimacs : printout dimacs information incurring additional computation cost " << endl; - cout << " -numThreads: Number of pthreads for internal computation" << endl; - cout << "example1-1: " << argv0 - << " example1.dat-s example1.result" << endl; - cout << "example1-2: " << argv0 - << " example1.dat-s example1.result -pt 2" << endl; - cout << "example1-3: " << argv0 - << " example1.dat-s example1.result -dimacs" << endl; - cout << "example1-4: " << argv0 - << " example1.dat-s example1.result -numThreads 4" << endl; - - cout << endl; - cout << "---- option type 2 ------------" << endl; - cout << argv0 << " [option filename]+ " << endl; - cout << " -ds : data sparse " << endl; - cout << " -o : output :: -p : parameter " << endl; - cout << " -pt : parameters , 0 default, 1 fast (unstable)" << endl; - cout << " 2 slow (stable) " << endl; - cout << " -dimacs : printout dimacs information incurring additional computation cost " << endl; - cout << " -numThreads: Number of pthreads for internal computation" << endl; - cout << "example2-1: " << argv0 - << " -ds example1.dat-s -o example1.result " - << "-p param.sdpaC" << endl; - cout << "example2-2: " << argv0 - << " -ds example1.dat-s -o example1.result " - << "-pt 2" << endl; - cout << "example2-3: " << argv0 - << " -ds example1.dat-s -o example1.result " - << "-dimacs" << endl; - cout << "example2-4: " << argv0 - << " -ds example1.dat-s -o example1.result " - << "-numThreads 4" << endl; - - cout << endl; - cout << "---- option type 3 ------------" << endl; - cout << argv0 << " --version " << endl; - cout << " to print out version and exit." << endl; - - cout << endl << endl; - cout << "PARAMETER_FILE is decided by the following priority" << endl; - cout << " 1: The file assigned by '-p' option of 'option type 2'." << endl; - cout << " For 'option type1', this is skipped." << endl; - cout << " 2: " << USER_PARAMETER_FILE << endl; - cout << " For 'option type2', this is skipped." << endl; - cout << " 3: " << DEFAULT_PARAMETER_FILE << endl; - cout << " 4: Default parameter" << endl; - exit(1); -} - -static void argumentAnalysis(SDPA& Problem1, - int argc, char** argv, - char*& inputFileName, - char*& resultFileName, - char*& paramFileName, - SDPA::ParameterType& parameterType, - bool& isDimacs, int& numThreads) -{ - if (argc == 1) { - message(argv[0]); - } - if (strcmp(argv[1],"--version") == 0) { - fprintf(stdout,"====\n"); - fprintf(stdout,"SDPA-C (SemiDefinite Programming Algorithm with Completion) %s\n",sdpa_version); - fprintf(stdout," %s\n",sdpa_right); - fprintf(stdout,"====\n"); - exit(0); - } - if (argv[1][0] == '-') { - // rsdpa argument - - for (int index = 0; index < argc; ++index) { - char* target = argv[index]; - if (strcmp(target,"-dd")==0 && index+1 < argc) { - fprintf(stdout,"*** Dense Data is NOT supported ***\n"); - inputFileName = argv[index+1]; - inputFileName = NULL; - // isInputSparse = SDPA::DENSE; - index++; - continue; - } - if (strcmp(target,"-ds")==0 && index+1 < argc) { - inputFileName = argv[index+1]; - // isInputSparse = SDPA::SPARSE; - continue; - } - if (strcmp(target,"-o")==0 && index+1 < argc) { - resultFileName = argv[index+1]; - index++; - continue; - } - if (strcmp(target,"-p")==0 && index+1 < argc) { - paramFileName = argv[index+1]; - index++; - continue; - } - if (strcmp(target,"-dimacs")==0) { - isDimacs = true; - continue; - } - if (strcmp(target,"-pt")==0 && index+1 < argc) { - int tmp = atoi(argv[index+1]); - switch (tmp) { - case 0: - parameterType = SDPA::PARAMETER_DEFAULT; - break; - case 1: - parameterType = SDPA::PARAMETER_UNSTABLE_BUT_FAST; - break; - case 2: - parameterType = SDPA::PARAMETER_STABLE_BUT_SLOW; - break; - default: - parameterType = SDPA::PARAMETER_DEFAULT; - } - index++; - paramFileName = NULL; - continue; - } - if (strcmp(target,"-numThreads")==0 && index+1 < argc) { - numThreads = atoi(argv[index+1]); - index++; - continue; - } - } - } - else { // SDPA argument - inputFileName = argv[1]; - int len = strlen(inputFileName); - if (inputFileName[len-1] == 's' - && inputFileName[len-2] == '-') { - } - else { - fprintf(stdout, "File may not be Sparse SDPA format. \n"); - fprintf(stdout, "The file extension must be 'dat-s'. \n"); - inputFileName = NULL; - } - - resultFileName = argv[2]; - - paramFileName = USER_PARAMETER_FILE; - - for (int index=3; index -#include -#include -#include -#include -#include - -using namespace std; - -#define SDPA_SUCCESS true -#define SDPA_FAILURE false - - - -// for CHOLMOD routine -#define TRUE 1 -#define FALSE 0 - -#include "sdpa_tool.h" -// #include "sdpa_algebra.h" - -#endif // __sdpa_include_h__ diff --git a/external/sdpa/sdpa_io.cpp b/external/sdpa/sdpa_io.cpp deleted file mode 100644 index 7974606..0000000 --- a/external/sdpa/sdpa_io.cpp +++ /dev/null @@ -1,1155 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ - -#include "sdpa_io.h" -#include "sdpa_linear.h" -#include -#include - -namespace sdpa { - -void IO::read(FILE* fpData, FILE* fpout, int& m, char* str) -{ - while (true) { - volatile int dummy=0; dummy++;//for gcc-3.3 bug - fgets(str,lengthOfString,fpData); - if (str[0]=='*' || str[0]=='"') { - fprintf(fpout,"%s",str); - } else { - sscanf(str,"%d",&m); - break; - } - } -} - -void IO::read(FILE* fpData, int & nBlock) -{ - fscanf(fpData,"%d",&nBlock); -} - -void IO::read(FILE* fpData, BlockStruct& bs) -{ - for (int l=0; l 0 ) { - bs.blockType[l] = BlockStruct::btSDP; - } - if (bs.blockStruct[l] < 0 ) { - bs.blockType[l] = BlockStruct::btLP; - } - } -} - -void IO::read(FILE* fpData, Vector& b) -{ - for (int k=0; k 0) { - // if y[0] locates the first charcter in fpData - // then we need the following line - yVec.ele[k] = -tmp; - // rMessage("yVec.ele[" << k << "] = " << -tmp); - k++; - } - for (; k* readData; - NewArray(readData, vector, m+1); - - while (true) { - lineNumber++; - if (fscanf(fpData,"%*[^0-9+-]%d",&k)<=0) { - break; - } - if (fscanf(fpData,"%*[^0-9+-]%d",&l)<=0) { - break; - } - if (fscanf(fpData,"%*[^0-9+-]%d",&i)<=0) { - break; - } - if (fscanf(fpData,"%*[^0-9+-]%d",&j)<=0) { - break; - } - if (fscanf(fpData,"%*[^0-9+-]%lf",&value)<=0) { - break; - } - - #if 0 - rMessage("Data " << k << "," << l << "," - << i << "," << j << "," << value); - #endif - - IO::LIJV* oneData; - NewArray(oneData, IO::LIJV, 1); - oneData[0].SDPl = -1; // -1 means empty here - oneData[0].LPl = -1; - oneData[0].i = i-1; - oneData[0].j = j-1; - oneData[0].value = value; - - if (bs.blockType[l-1] == BlockStruct::btSDP) { - int l2 = bs.blockNumber[l-1]; - oneData[0].SDPl = l2; - readData[k].push_back(oneData); - } else if (bs.blockType[l-1] == BlockStruct::btLP) { - if (i!=j) { - printf("******** invalid data line %d, %d, %d, %d, %e ***\n", - k,l,i,j,value); - printf("Line number [%d] in 5-element-lines is invalid\n", lineNumber); - printf("Check your input file\n"); - printf("Note: -1000 may appear in the above invalid report line if the corresponding place is not read correctly.\n"); - - rError("IO::initializeLinearSpace"); - } - int l2 = bs.blockNumber[l-1]; - oneData[0].LPl = l2+i-1; - readData[k].push_back(oneData); - } else { - printf("******** invalid data line %d, %d, %d, %d, %e ***\n", - k,l,i,j,value); - printf("Line number [%d] in 5-element-lines is invalid\n", lineNumber); - printf("Check your input file\n"); - printf("Note: -1000 may appear in the above invalid report line if the corresponding place is not read correctly.\n"); - rError("io::read not valid blockType"); - } - }// end of 'while (true)' - - vector LP_blockCount; - vector SDP_blockCount; - for (int k=0; k= 0) { - LP_blockCount.push_back(oneData[0].LPl); - } - if (oneData[0].SDPl >= 0) { - SDP_blockCount.push_back(oneData[0].SDPl); - } - } - sort(LP_blockCount.begin(), LP_blockCount.end()); - sort(SDP_blockCount.begin(), SDP_blockCount.end()); - int LP_sp_nBlock = 0; - int SDP_sp_nBlock = 0; - int LP_old_block = -1; - int SDP_old_block = -1; - const int LP_length = LP_blockCount.size(); - const int SDP_length = SDP_blockCount.size(); - for (int index1 = 0; index1 < LP_length; ++index1) { - if (LP_blockCount[index1] != LP_old_block) { - LP_old_block = LP_blockCount[index1]; - LP_sp_nBlock++; - } - } - for (int index1 = 0; index1 < SDP_length; ++index1) { - if (SDP_blockCount[index1] != SDP_old_block) { - SDP_old_block = SDP_blockCount[index1]; - SDP_sp_nBlock++; - } - } - - CompSpace* target = &inputData.C; - if (k>0) { - target = &inputData.A[k-1]; - } - target->initialize(LP_sp_nBlock, SDP_sp_nBlock); - int index_t = 0; - LP_old_block = -1; - for (int index1 = 0; index1 < LP_length; ++index1) { - const int current_block = LP_blockCount[index1]; - if (current_block != LP_old_block) { - target->LP_sp_index[index_t] = current_block; - LP_old_block = current_block; - index_t++; - } - } - index_t = 0; - SDP_old_block = -1; - for (int index1 = 0; index1 < SDP_length; ++index1) { - const int current_block = SDP_blockCount[index1]; - if (current_block != SDP_old_block) { - target->SDP_sp_index[index_t] = current_block; - SDP_old_block = current_block; - target->SDP_sp_block[index_t].nRow = bs.SDP_blockStruct[current_block]; - target->SDP_sp_block[index_t].nCol = bs.SDP_blockStruct[current_block]; - index_t++; - } - } - #if 0 - rMessage("LP blocks = "); - for (int index2 = 0; index2 < LP_sp_nBlock; ++index2) { - printf(" %d", target->LP_sp_index[index2]); - } - printf("\n"); - rMessage("SDP blocks = "); - for (int index2 = 0; index2 < SDP_sp_nBlock; ++index2) { - printf(" %d", target->SDP_sp_index[index2]); - } - printf("\n"); - #endif - target->initializeInputVector(); - } - LP_blockCount.clear(); - SDP_blockCount.clear(); - - for (int k=0; k0) { - target = &inputData.A[k-1]; - scale = 1.0; - } - int length = readData[k].size(); - for (int index1 = 0; index1 < length; ++index1) { - IO::LIJV* oneData = readData[k].at(index1); - if (oneData[0].LPl >= 0) { - target->setElement_LP(oneData[0].LPl, oneData[0].value*scale); - } - if (oneData[0].SDPl >= 0) { - target->setElement_SDP(oneData[0].SDPl, - oneData[0].i, oneData[0].j, - oneData[0].value*scale); - } - DeleteArray(oneData); - } - } - DeleteArray(readData); - - double v1 = 0; // dummy initialize - double v2 = 0; // dummy initialize - inputData.C.sortInputVector(); - inputData.C.checkInputDataStructure(l, i, j, v1, v2); - inputData.C.makeInternalStructure(); - if (l>=0) { - printf("***** invalid data ******\n"); - printf("F[0]:%d-th SDP block:[%d, %d]-th element has more than one input\n", - l+1, i+1, j+1); - rError("Stop due to input error\n"); - } - for (int k=0; k=0) { - printf("***** invalid data ******\n"); - printf("F[%d]:%d-th SDP block:[%d, %d]-th element has more than one input\n", - k+1, l+1, i+1, j+1); - rError("Stop due to input error\n"); - } - } - - #if 0 - rMessage("************** Read finished, internal data is from here."); - rMessage("C = -------------------------"); - inputData.C.display(); - for (int k=0; k* SDP_index; - NewArray(SDP_index,vector,m+1); - vector* SOCP_index; - NewArray(SOCP_index,vector,m+1); - vector* LP_index; - NewArray(LP_index,vector,m+1); - - // for SDP - int SDP_sp_nBlock; - int* SDP_sp_index; - int* SDP_sp_blockStruct; - int* SDP_sp_NonZeroNumber; - NewArray(SDP_sp_index,int,bs.SDP_nBlock); - NewArray(SDP_sp_blockStruct,int,bs.SDP_nBlock); - NewArray(SDP_sp_NonZeroNumber,int,bs.SDP_nBlock); - // for SOCP - int SOCP_sp_nBlock; - int* SOCP_sp_blockStruct; - int* SOCP_sp_index; - int* SOCP_sp_NonZeroNumber; - // for LP - int LP_sp_nBlock; - int* LP_sp_index; - NewArray(LP_sp_index,int,bs.LP_nBlock); - - if (isDataSparse) { - int i,j,k,l; - i=j=k=l = -1000; // dummy initialize - double value; - value = -1000; - int lineNumber = 0; - while (true) { - lineNumber++; - if (fscanf(fpData,"%*[^0-9+-]%d",&k)<=0) { - break; - } - if (fscanf(fpData,"%*[^0-9+-]%d",&l)<=0) { - break; - } - if (fscanf(fpData,"%*[^0-9+-]%d",&i)<=0) { - break; - } - if (fscanf(fpData,"%*[^0-9+-]%d",&j)<=0) { - break; - } - if (fscanf(fpData,"%*[^0-9+-]%lf",&value)<=0) { - break; - } - - if (bs.blockType[l-1] == BlockStruct::btSDP) { - int l2 = bs.blockNumber[l-1]; - SDP_index[k].push_back(l2); - } else if (bs.blockType[l-1] == BlockStruct::btLP) { - if (i!=j){ - printf("******** invalid data line %d, %d, %d, %d, %e ***\n", - k,l,i,j,value); - printf("Line number [%d] in 5-element-lines is invalid\n", lineNumber); - printf("Check your input file\n"); - printf("Note: -1000 may appear in the above invalid report line if the corresponding place is not read correctly.\n"); - - rError("IO::initializeLinearSpace"); - } - int l2 = bs.blockNumber[l-1]; - LP_index[k].push_back(l2+i-1); - } else { - printf("******** invalid data line %d, %d, %d, %d, %e ***\n", - k,l,i,j,value); - printf("Line number [%d] in 5-element-lines is invalid\n", lineNumber); - printf("Check your input file\n"); - printf("Note: -1000 may appear in the above invalid report line if the corresponding place is not read correctly.\n"); - rError("io::read not valid blockType"); - } - }// end of 'while (true)' - - } else { // isDataSparse == false - - // constant matrix - for (int l=0; lncol; - for (int j=0; j < ncol; ++j) { - const int start_row = ((int*)rD->p)[j]; - const int end_row = ((int*)rD->p)[j+1]; - for (int i_index = start_row; i_index < end_row; ++i_index) { - const int i = (( int*)rD->i)[i_index]; - const double value = ((double*)rD->x)[i_index]; - if (i==j) { - d_norm += value * value; - } - else { - d_norm += 2.0 * value * value; - } - } - } - } - d_norm = sqrt(d_norm); - - double x_min = 1.0e+50; - double z_min = 1.0e+50; - DenseLinearSpace& finalX = currentPt.finalX; - DenseLinearSpace& finalZ = currentPt.finalZ; - - for (int l=0; l < finalX.LP_nBlock; ++l) { - if (x_min > finalX.LP_block[l]) { - x_min = finalX.LP_block[l]; - } - } - for (int l=0; l < finalZ.LP_nBlock; ++l) { - if (z_min > finalZ.LP_block[l]) { - z_min = finalZ.LP_block[l]; - } - } - - for (int l=0; l < finalX.SDP_nBlock; ++l) { - DenseMatrix& xMat = finalX.SDP_block[l]; - int nDim = xMat.nRow; - DenseMatrix workMatrix; - workMatrix.copyFrom(xMat); - Vector eigenVec; - eigenVec.initialize(nDim); - Vector workVec; - workVec.initialize(3*nDim-1); - Lal::getMinEigenValue(workMatrix, eigenVec, workVec); - - for (int i=0; i eigenVec.ele[i]) { - x_min = eigenVec.ele[i]; - } - } - } - - - for (int l=0; l < finalZ.SDP_nBlock; ++l) { - DenseMatrix& zMat = finalZ.SDP_block[l]; - int nDim = zMat.nRow; - DenseMatrix workMatrix; - workMatrix.copyFrom(zMat); - Vector eigenVec; - eigenVec.initialize(nDim); - Vector workVec; - workVec.initialize(3*nDim-1); - Lal::getMinEigenValue(workMatrix, eigenVec, workVec); - - for (int i=0; i eigenVec.ele[i]) { - z_min = eigenVec.ele[i]; - } - } - } - - - #if 0 - printf("b1:%e\n",b1); - printf("c1:%e\n",c1); - printf("p_norm:%e\n",p_norm); - printf("d_norm:%e\n",d_norm); - printf("x_min:%e\n",x_min); - printf("z_min:%e\n",z_min); - #endif - - double ctx = solveInfo.objValPrimal; - double bty = solveInfo.objValDual; - double xtz = 0.0; - Lal::let(xtz,'=',currentPt.finalX,'.',currentPt.finalZ); - - for (int i=0; i<=6; ++i) { - dimacs_error[i] = 0.0; - } - - rMessage("x_min, z_min"); - printf("x_min = %.2e, z_min = %.2e\n", x_min, z_min); - - dimacs_error[1] = p_norm / (1+b1); - dimacs_error[2] = max( 0.0, - x_min / (1+b1)); - dimacs_error[3] = d_norm / (1+c1); - dimacs_error[4] = max( 0.0, - z_min / (1+c1)); - dimacs_error[5] = (ctx - bty) / (1 + fabs(ctx) + fabs(bty)); - dimacs_error[6] = xtz / (1 + fabs(ctx) + fabs(bty)); -} - -void IO::printDimacs(double* DimacsError,char* printFormat, - FILE* fpout) -{ - if (fpout == NULL) { - return; - } - fprintf(fpout, "\n"); - fprintf(fpout, "* DIMACS_ERRORS * \n"); - fprintf(fpout, "err1 = "); - fprintf(fpout, printFormat, DimacsError[1]); - fprintf(fpout, " [||Ax-b|| / (1+||b||_1)]\n"); - fprintf(fpout, "err2 = "); - fprintf(fpout, printFormat, DimacsError[2]); - fprintf(fpout, " [max(0, -lambda(x)/(1+||b||_1))]\n"); - fprintf(fpout, "err3 = "); - fprintf(fpout, printFormat, DimacsError[3]); - fprintf(fpout, " [||A^Ty + z - c || / (1+||c||_1)]\n"); - fprintf(fpout, "err4 = "); - fprintf(fpout, printFormat, DimacsError[4]); - fprintf(fpout, " [max(0, -lambda(z)/(1+||c||_1))]\n"); - fprintf(fpout, "err5 = "); - fprintf(fpout, printFormat, DimacsError[5]); - fprintf(fpout, " [( - ) / (1 + || + ||)]\n"); - fprintf(fpout, "err6 = "); - fprintf(fpout, printFormat, DimacsError[6]); - fprintf(fpout, " [ / (1 + || + ||)]\n"); - fprintf(fpout, "\n"); -} - - -bool IO::judgeXmake(Parameter& param) -{ -#if REVERSE_PRIMAL_DUAL - if (strcmp(param.YPrint,NO_P_FORMAT) == 0) { - return false; - } -#else - if (strcmp(param.XPrint,NO_P_FORMAT) == 0) { - return false; - } -#endif - return true; -} - -bool IO::judgeZmake(Parameter& param) -{ -#if REVERSE_PRIMAL_DUAL - if (strcmp(param.XPrint,NO_P_FORMAT) == 0) { - return false; - } -#else - if (strcmp(param.YPrint,NO_P_FORMAT) == 0) { - return false; - } -#endif - return true; -} - - -void IO::printSolution(BlockStruct& bs, Solutions& currentPt, - Parameter& param, FILE* fpout, bool Xmake, bool Zmake) -{ - if (fpout != NULL) { - #if REVERSE_PRIMAL_DUAL - fprintf(fpout,"xVec = \n"); - currentPt.cholmodSpace.yVec.display(fpout,1.0,param.xPrint); - fprintf(fpout,"xMat = \n"); - currentPt.finalZ.displaySolution(bs,fpout,param.XPrint); - fprintf(fpout,"yMat = \n"); - currentPt.finalX.displaySolution(bs,fpout,param.YPrint); - #else - fprintf(fpout,"xMat = \n"); - currentPt.finalX.displaySolution(bs,fpout,param.XPrint); - fprintf(fpout,"yVec = \n"); - currentPt.cholmodSpace.yVec.display(fpout,1.0,param.xPrint); - fprintf(fpout,"zMat = \n"); - currentPt.finalZ.displaySolution(bs,fpout,param.YPrint); - #endif - } -} - -} // end of namespace 'sdpa' diff --git a/external/sdpa/sdpa_io.h b/external/sdpa/sdpa_io.h deleted file mode 100644 index 231e205..0000000 --- a/external/sdpa/sdpa_io.h +++ /dev/null @@ -1,118 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ - -#ifndef __sdpa_io_h__ -#define __sdpa_io_h__ - -#define lengthOfString 256 - -#include "sdpa_block.h" -#include "sdpa_parts.h" - -namespace sdpa { - -class IO -{ -public: - static void read(FILE* fpData, FILE* fpout, int& m, char* str); - static void read(FILE* fpData, int& nBlock); - static void read(FILE* fpData, BlockStruct& bs); - static void read(FILE* fpData, Vector& b); - static void read(FILE* fpData, DenseLinearSpace& xMat, - Vector& yVec, DenseLinearSpace& zMat, - BlockStruct& bs, bool inputSparse); - static void read(FILE* fpData, int m, - BlockStruct& bs, - InputData& inputData, bool isDataSparse); - static void read(FILE* fpData, int m, - BlockStruct& bs, InputData& inputData); - - // read data is first introduced into this class - class LIJV - { - public: - int SDPl,LPl,i,j; - double value; - }; - - - // 2008/02/27 kazuhide nakata - // without LP_ANonZeroCount - static void setBlockStruct(FILE* fpData, InputData& inputData, - int m, BlockStruct& bs, - long position, bool isDataSparse); - - // 2008/02/27 kazuhide nakata - // without LP_ANonZeroCount - static void setElement(FILE* fpData, InputData& inputData, int m, - BlockStruct& bs, - long position, bool isDataSparse); - - static void printHeader(FILE* fpout, FILE* Display); - - static void printOneIteration(int pIteration, - AverageComplementarity& mu, - RatioInitResCurrentRes& theta, - SolveInfo& solveInfo, - StepLength& alpha, - DirectionParameter& beta, - FILE* fpout, - FILE* Display); - - static void printLastInfo(int pIteration, - AverageComplementarity& mu, - RatioInitResCurrentRes& theta, - SolveInfo& solveInfo, - StepLength& alpha, - DirectionParameter& beta, - Residuals& currentRes, - Phase & phase, - Solutions& currentPt, - InputData& inputData, - double cputime, - ComputeTime& com, - Parameter& param, - FILE* fpout, - FILE* Display, - bool printTime = true); - - static void computeDimacs(double* dimacs_error, - SolveInfo& solveInfo, - Residuals& currentRes, - Solutions& currentPt, - InputData& inputData); - - static void printDimacs(double* dimacs_error, - char* printFormat, - FILE* fpout); - - static bool judgeXmake(Parameter& param); - static bool judgeZmake(Parameter& param); - - static void printSolution(BlockStruct& bs, Solutions& currentPt, - Parameter& param, FILE* fpout, - bool Xmake, bool Zmake); - -}; - -} // end of namespace 'sdpa' - -#endif // __sdpa_io_h__ diff --git a/external/sdpa/sdpa_linear.cpp b/external/sdpa/sdpa_linear.cpp deleted file mode 100644 index 56531f6..0000000 --- a/external/sdpa/sdpa_linear.cpp +++ /dev/null @@ -1,2959 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ - -#include "sdpa_linear.h" -#include "sdpa_dataset.h" -#include "sdpa_dpotrf.h" -#include "sdpa_algebra.h" - -namespace sdpa { - -double Lal::getMinEigen(DenseMatrix& lMat, - DenseMatrix& xMat, - DenseMatrix& Q, - Vector& out, Vector& b, Vector& r, - Vector& q, Vector& qold, - Vector& w, Vector& tmp, - Vector& diagVec, Vector& diagVec2, - Vector& workVec, char charTranspose) -{ - double alpha,beta,value; - double min = 1.0e+51, min_old = 1.0e+52; - double error = 1.0e+10; - - int nDim = xMat.nRow; - int k = 0, kk = 0; - - diagVec.initialize(1.0e+50); - diagVec2.setZero(); - q.setZero(); - r.initialize(1.0); - beta = sqrt((double)nDim); // norm of "r" - - // nakata 2004/12/12 - while (k 1.0e-16 - && ( k<20 || - fabs(min-min_old) > (1.0e-5)*fabs(min)+(1.0e-8) - // && (fabs(min-min_old) > (1.0e-3)*fabs(min)+(1.0e-6) - || fabs(error*beta) > (1.0e-2)*fabs(min)+(1.0e-6) ) - ) { - // rMessage("k = " << k); - qold.copyFrom(q); - value = 1.0/beta; - Lal::let(q,'=',r,'*',&value); - - if (charTranspose == 'N') { - // w = (lMat^T)*q - w.copyFrom(q); - dtrmv_fc ((char *)"Lower",(char *)"Transpose", - (char *)"NotUnit",&nDim, - lMat.de_ele,&nDim,w.ele,&IONE, - strlen("Lower"), strlen("Transpose"),strlen("NotUnit")); - Lal::let(tmp,'=',xMat,'*',w); - w.copyFrom(tmp); - dtrmv_fc ((char *)"Lower",(char *)"NoTranspose", - (char *)"NotUnit",&nDim, - lMat.de_ele,&nDim,w.ele,&IONE, - strlen("Lower"), strlen("NoTranspose"),strlen("NotUnit")); - // w = lMat*xMat*(lMat^T)*q - // rMessage("w = "); - // w.display(); - } - else if (charTranspose == 'T') { - // w = lMat*q - w.copyFrom(q); - dtrmv_fc ((char *)"Lower",(char *)"NoTranspose", - (char *)"NotUnit",&nDim, - lMat.de_ele,&nDim,w.ele,&IONE, - strlen("Lower"), strlen("NoTranspose"),strlen("NotUnit")); - Lal::let(tmp,'=',xMat,'*',w); - w.copyFrom(tmp); - dtrmv_fc ((char *)"Lower",(char *)"Transpose", - (char *)"NotUnit",&nDim, - lMat.de_ele,&nDim,w.ele,&IONE, - strlen("Lower"), strlen("Transpose"),strlen("NotUnit")); - // w = lMat^T*xMat*lMat*q - // rMessage("w = "); - // w.display(); - } - else { - rError("code bug, charTranspose should be 'N' or 'T'"); - } - - Lal::let(alpha,'=',q,'.',w); - diagVec.ele[k] = alpha; - Lal::let(r,'=',w,'-',q,&alpha); - Lal::let(r,'=',r,'-',qold,&beta); - // rMessage("r = "); - // r.display(); - - if ( kk>=sqrt((double)k) || k==nDim-1 || k>sqrt((double)nDim+9) ) { - kk = 0; - out.copyFrom(diagVec); - b.copyFrom(diagVec2); - out.ele[nDim-1] = diagVec.ele[k]; - b.ele[nDim-1] = 0.0; - - // rMessage("out = "); - // out.display(); - // rMessage("b = "); - // b.display(); - - int info; - int kp1 = k+1; - dsteqr_fc ((char *)"I_withEigenvalues",&kp1,out.ele,b.ele, - Q.de_ele, &Q.nRow, workVec.ele, &info, - strlen("I_withEigenvalues")); - if (info < 0) { - rError(" rLanczos :: bad argument " << -info - << " Q.nRow = " << Q.nRow - << ": nDim = " << nDim - << ": kp1 = " << kp1); - } else if (info > 0) { - rMessage(" rLanczos :: cannot converge " << info); - break; - } - - // rMessage("out = "); - // out.display(); - // rMessage("Q = "); - // Q.display(); - - min_old = min; - #if 0 - min = 1.0e+50; - error = 1.0e+10; - for (int i=0; iout.ele[i]){ - min = out.ele[i]; - error = Q.de_ele[k+Q.nCol*i]; - } - } - #else - // out have eigen values with ascending order. - min = out.ele[0]; - error = Q.de_ele[k]; - #endif - - } // end of 'if ( kk>=sqrt(k) ...)' - // printf("\n"); - - Lal::let(value,'=',r,'.',r); - beta = sqrt(value); - diagVec2.ele[k] = beta; - ++k; - ++kk; - } // end of while - // rMessage("k = " << k); - return min - fabs(error*beta); -} - -double Lal::getMinEigenValue(DenseMatrix& aMat, - Vector& eigenVec, - Vector& workVec) -{ - // aMat is rewritten. - // aMat must be symmetric. - // eigenVec is the space of eigen values - // and needs memory of length aMat.nRow - // workVec is temporary space and needs - // 3*aMat.nRow-1 length memory. - int N = aMat.nRow; - int LWORK, info; - LWORK = 3*N-1; - // "N" means that we need not eigen vectors - // "L" means that we refer only lower triangular. - dsyev_fc((char *)"NonVectors",(char *)"Lower",&N,aMat.de_ele,&N, - eigenVec.ele,workVec.ele,&LWORK,&info, - strlen("NonVectors"), strlen("Lower")); - if (info!=0) { - if (info < 0) { - rMessage("getMinEigenValue:: info is mistaken " << info); - } else { - rMessage("getMinEigenValue:: cannot decomposition"); - } - exit(0); - return 0.0; - } - return eigenVec.ele[0]; -} - -double Lal::getMinEigenValue(CholmodMatrix& cholmodMatrix) -{ - cholmod_factor* Lz = cholmodMatrix.Lz; - cholmod_sparse* dZ = cholmodMatrix.dZ; - cholmod_common& common = cholmodMatrix.common; - const int nDIM = cholmodMatrix.nDim; - Vector rVect(nDIM); - Vector qVect(nDIM); - Vector qoldVect(nDIM); - Vector wVect(nDIM); - Vector diagVect(nDIM); - Vector diag2Vect(nDIM); - - if (nDIM == 1) { - // this block should be handled as an LP block - rError("code bug"); - } - int i,j,k; - double alpha,beta,tmp,min=1.0e51,min_old = 1.0e52; - double sig,max,mid; - - k = 0; - for (i=0; i 1.0e-16) && - ((fabs(min - min_old) > 1.0e-4 * fabs(min) + 1.0e-8))) { - qoldVect.copyFrom(qVect); - tmp = 1.0 / beta; - Lal::let(qVect,'=',rVect,'*',&tmp); - - - // wVect = Lz^{-1} * dZ * Lz^{-T} * qVect - double* b_z_ele = (double*) cholmodMatrix.b_z->x; - for (i=0; ix; - for (i=0; i sqrt((double)nDIM)+20)|| - (beta < 1.0e-16)||(3 * k >= sqrt((double)nDIM+20))) { - min_old = min; - min = diagVect.ele[0] - fabs(diag2Vect.ele[0]); - max = diagVect.ele[0] + fabs(diag2Vect.ele[0]); - for ( i = 1; i < k ; i++ ) { - tmp = diagVect.ele[i] - - fabs(diag2Vect.ele[i-1]) - fabs(diag2Vect.ele[i]); - if (min > tmp) - min = tmp; - tmp = diagVect.ele[i] - + fabs(diag2Vect.ele[i-1]) + fabs(diag2Vect.ele[i]); - if (max < tmp) - max = tmp; - } - tmp = diagVect.ele[k] - fabs(diag2Vect.ele[k-1]); - if (min > tmp) - min = tmp; - tmp = diagVect.ele[k] + fabs(diag2Vect.ele[k-1]); - if (max < tmp) - max = tmp; - - for (i = 0; i < 20;i++) { - // printf("i = %d min = %lf max = %lf\n", i, min, max); - mid = (max + min) / 2.0; - sig = diagVect.ele[0] - mid; - for (j = 1;j <= k;j++) { - if (sig <= 0.0) - break; - tmp = sig; - sig = (diagVect.ele[j] - mid) - diag2Vect.ele[j-1] * diag2Vect.ele[j-1] / tmp; - } - if (sig <= 0.0) - max = mid; - else - min = mid; - } - } - k++; - // printf("%d : %e %e %e\n",k,fabs(min - min_old),fabs(min),beta); - } - return min; -} - - - -double Lal::getOneNorm(Vector& b) -{ - double ret = 0.0; - int nDim = b.nDim; - for (int k=0; k= *n) { - // Here is point. - rdpotf2_(uplo, n, a, lda, info); - } else { - for (int j = 0; j < *n; j += nb) { - int jb = min(nb,*n- j); - dsyrk_fc((char *)"Lower", (char *)"No transpose", &jb, - &j, &DMONE, &a[j], lda, - &DONE, &a[j+nRow*j], lda, - strlen("Lower"), strlen("No transpose")); - // Here is point. - rdpotf2_((char *)"Lower", &jb, &a[j+nRow*j], lda, info); - if (*info != 0) { - *info = *info + j - 1; - return 0; - } - if (j + jb <= *n-1) { - int i = *n - j - jb; - dgemm_fc((char *)"No transpose", (char *)"Transpose", &i, &jb, - &j, &DMONE, &a[j + jb], lda, &a[j], lda, - &DONE, &a[(j + jb)+nRow*j], lda, - strlen("No transpose"), strlen("Transpose")); - dtrsm_fc((char *)"Right", (char *)"Lower", - (char *)"Transpose", (char *)"Non-unit", - &i, &jb, &DONE, &a[j+nRow*j], lda, - &a[(j + jb)+nRow*j], lda, - strlen("Right"), strlen("Lower"), - strlen("Transpose"), strlen("Non-unit")); - } - } - } - return 0; -} - - -bool Lal::choleskyFactorWithAdjust(DenseMatrix& aMat) -{ - int info=0; -#if 1 - // aMat.display(); - TimeStart(START1); - info = rATL_dpotrfL(aMat.nRow, aMat.de_ele,aMat.nRow); - TimeEnd(END1); - // rMessage("Schur colesky ::" << TimeCal(START1,END1)); - // aMat.display(); -#elif 1 - dpotrf_fc("Lower",&aMat.nRow,aMat.de_ele,&aMat.nRow, - &info,strlen("Lower")); -#else - rdpotrf_("Lower",&aMat.nRow,aMat.de_ele,&aMat.nRow,&info); -#endif - if (info < 0) { - rMessage("cholesky argument is wrong " << -info); - } else if (info > 0) { - rMessage("cholesky miss condition :: not positive definite" - << " :: info = " << info); - rMessage("There are some possibilities."); - rMessage("1. SDPA finalizes due to inaccuracy of numerical error"); - rMessage("2. The input problem may not have (any) interior-points"); - rMessage("3. Input matrices are linearly dependent"); - return SDPA_FAILURE; - } - return SDPA_SUCCESS; -#if 0 - double ZERO_DETECT = 1.0e-3; - double NONZERO = 1.0e-7; - // no idea version - // if Cholesky factorization failed, then exit soon. - int info = 1; // info == 0 means success - int start = 0; - while (start NONZERO*mishi) { - // rMessage(" migi*migi > NONZERO*mishi "); - migi = sqrt(NONZERO*mishi) * 0.99; - shita = sqrt(NONZERO*mishi) * 0.99; - } - } - } - rMessage("cholesky adjust position " << start); - } - if (info < 0) { - rError("argument is something wrong " << info); - } - return SDPA_SUCCESS; -#endif -} - -bool Lal::solveSystems(Vector& xVec, - DenseMatrix& aMat, Vector& bVec) -{ - // aMat must have done Cholesky factorized. - if (aMat.nCol!=xVec.nDim || aMat.nRow!=bVec.nDim - || aMat.nRow!=aMat.nCol) { - rError("solveSystems:: different memory size"); - } - xVec.copyFrom(bVec); - dtrsv_fc((char *)"Lower", (char *)"NoTranspose", (char *)"NonUnit", - &aMat.nRow, aMat.de_ele, &aMat.nCol, xVec.ele,&IONE, - strlen("Lower"), strlen("NoTranspose"), strlen("NonUnit")); - dtrsv_fc((char *)"Lower", (char *)"Transpose", (char *)"NonUnit", - &aMat.nRow, aMat.de_ele, &aMat.nCol, xVec.ele,&IONE, - strlen("Lower"), strlen("Transpose"), strlen("NonUnit")); - return SDPA_SUCCESS; -} - -// nakata 2004/12/01 -bool Lal::solveSystems(Vector& xVec, - SparseMatrix& aMat, Vector& bVec) -{ -#define TUNEUP 0 -#if TUNEUP - if (aMat.nCol!=xVec.nDim || aMat.nRow!=bVec.nDim - || aMat.nRow!=aMat.nCol) { - printf("A.row:%d A.col:%d x.row:%d b.row:%d\n", - aMat.nCol,aMat.nRow,xVec.nDim ,bVec.nDim); - rError("solveSystems(sparse):: different memory size"); - } - int length; - int amari,shou,counter; - - switch(aMat.type) { - case SparseMatrix::SPARSE: -#endif - // Attension: in SPARSE case, only half elements - // are stored. And bMat must be DENSE case. - // rMessage("aMat.NonZeroCount == " << aMat.NonZeroCount); - xVec.copyFrom(bVec); -#if TUNEUP - - shou = aMat.NonZeroCount / 4; - amari = aMat.NonZeroCount % 4; - int i,j; - double value; - - for (int index=0; indexx)[agg_index] += value*(*scalar); - } - } -} - -void Lal::plus(CholmodSpace& retMat, - CompSpace& aMat, - double* scalar) -{ - if (scalar == NULL) { - scalar = &DONE; - } - - for (int l_index=0; l_index < aMat.LP_sp_nBlock; ++l_index) { - const double value = aMat.LP_sp_block[l_index]; - const int l = aMat.LP_sp_index[l_index]; - if (l < 0 || l>=retMat.LP_nBlock) { - rError("Code bug"); - } - retMat.LP_Z[l] += value * (*scalar); - } - - for (int l_index=0; l_index < aMat.SDP_sp_nBlock; ++l_index) { - const int l = aMat.SDP_sp_index[l_index]; - Lal::plus(retMat.SDP_block[l], aMat.SDP_sp_block[l_index], scalar); - } -} - -bool Lal::getSymmetrize(DenseLinearSpace& aMat) -{ - bool total_judge = SDPA_SUCCESS; - // for SDP - for (int l=0; lA) = retMat(Cholmod->A) + aMat*(*scalar); - static void plus(CholmodMatrix& retMat, - CompMatrix& aMat, - double* scalar = NULL); - - // retMat(Cholmod->A) = retMat(Cholmod->A) + aMat*(*scalar); - static void plus(CholmodSpace& retMat, - CompSpace& aMat, - double* scalar = NULL); - - // ret = a '*' (*scalar) - static bool let(DenseLinearSpace& retMat, const char eq, - DenseLinearSpace& aMat, const char op, - double* scalar = NULL); - - // ret = a '+' '-' b*(*scalar) - static bool let(DenseLinearSpace& retMat, const char eq, - DenseLinearSpace& aMat, const char op, - DenseLinearSpace& bMat, double* scalar = NULL); - - // ret = a '+' '-' b*(*scalar) - static bool let(DenseLinearSpace& retMat, const char eq, - SparseLinearSpace& aMat, const char op, - DenseLinearSpace& bMat, double* scalar = NULL); - - // ret = a '+' '-' '*' b*(*scalar) - static bool let(DenseLinearSpace& retMat, const char eq, - DenseLinearSpace& aMat, const char op, - SparseLinearSpace& bMat, double* scalar = NULL); - - // ret = inner_product(a,b) // op = '.' - static bool let(double& ret, const char eq, - DenseLinearSpace& aMat, const char op, - DenseLinearSpace& bMat); - - // ret = inner_product(a,b) // op = '.' - static bool let(double& ret, const char eq, - SparseLinearSpace& aMat, const char op, - DenseLinearSpace& bMat); - - // ret = inner_product(a,b) // op = '.' - static bool let(double& ret, const char eq, - DenseLinearSpace& aMat, const char op, - SparseLinearSpace& bMat); - - - //======================================================================= - // for SDPA-C - //======================================================================= - - static void getInnerProduct(double& ret, - CompMatrix& A, - CliqueMatrix& X, - OrderingMatrix& order); - - static void getInnerProduct(double& ret, - cholmod_sparse* Z, - CliqueMatrix& X, - OrderingMatrix& order, - int* Z_blockNumber, int* Z_blockIndex); - - static void getInnerProduct(double& ret, - CompSpace& A, - CliqueSpace& X, - OrderingSpace& order); - - static void getInnerProduct(double& ret, - CompMatrix& A, - double* aVec, - double* bVec); - - static void getInnerProduct(double& ret, - cholmod_sparse* A, - double* aVec, - double* bVec); - - -}; - -} // end of namespace 'sdpa' - -#endif // __sdpa_linear_h__ diff --git a/external/sdpa/sdpa_newton.cpp b/external/sdpa/sdpa_newton.cpp deleted file mode 100644 index 584755f..0000000 --- a/external/sdpa/sdpa_newton.cpp +++ /dev/null @@ -1,1889 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ - -#include "sdpa_newton.h" -#include "sdpa_parts.h" -#include "sdpa_linear.h" -#include "sdpa_algebra.h" - -namespace sdpa { - -pthread_mutex_t Newton::job_mutex = PTHREAD_MUTEX_INITIALIZER; -int Newton::Column_Number = 0; -int Newton::Column_NumberDx = 0; - - -Newton::Newton() -{ - // Caution: if SDPA doesn't use sparse bMat, - // following variables are indefinite. - this->SDP_nBlock = -1; - SDP_number = NULL; SDP_location_sparse_bMat = NULL; - SDP_constraint1 = NULL; SDP_constraint2 = NULL; - SDP_blockIndex1 = NULL; SDP_blockIndex2 = NULL; - this->LP_nBlock = -1; - LP_number = NULL; LP_location_sparse_bMat = NULL; - LP_constraint1 = NULL; LP_constraint2 = NULL; - LP_blockIndex1 = NULL; LP_blockIndex2 = NULL; - - diagonalIndex = NULL; - NUM_THREADS = 1; -} - -Newton::Newton(int m, BlockStruct& bs) -{ - initialize(m, bs); -} - -Newton::~Newton() -{ - finalize(); -} - -void Newton::initialize(int m, BlockStruct& bs) -{ - gVec.initialize(m); - - SDP_nBlock = bs.SDP_nBlock; - LP_nBlock = bs.LP_nBlock; - - bMat_type = DENSE; - // Caution: if SDPA doesn't use sparse bMat, - // following variables are indefinite. - this->SDP_nBlock = -1; - SDP_number = NULL; SDP_location_sparse_bMat = NULL; - SDP_constraint1 = NULL; SDP_constraint2 = NULL; - SDP_blockIndex1 = NULL; SDP_blockIndex2 = NULL; - this->LP_nBlock = -1; - LP_number = NULL; LP_location_sparse_bMat = NULL; - LP_constraint1 = NULL; LP_constraint2 = NULL; - LP_blockIndex1 = NULL; LP_blockIndex2 = NULL; - - diagonalIndex = NULL; -} - -void Newton::finalize() -{ - - if (bMat_type == SPARSE){ - - if (SDP_location_sparse_bMat && SDP_constraint1 && SDP_constraint2 - && SDP_blockIndex1 && SDP_blockIndex2) { - for (int l=0; l 1){ - if (sparse_bMat.row_index[target] < ii+1){ - begin = target; - target = (begin + end) / 2; - } else if (sparse_bMat.row_index[target] > ii+1){ - end = target; - target = (begin + end) / 2; - } else if (sparse_bMat.row_index[target] == ii+1) { - t = target; - break; - } - } - if (t == -1){ - if (sparse_bMat.row_index[begin] == ii+1){ - t = begin; - } else if (sparse_bMat.row_index[end] == ii+1){ - t = end; - } else { - #if 0 - int m = sparse_bMat.nRow; - rMessage("Trouble ii = " << ii << " jj = " << j << " m = " << m); - for (int k = 0; k startTmp; - - for (int k1=0; k1%d ", index1,startTmp[index1]); - } - #endif - } //for l lth block -} - -void Newton::make_aggrigateIndex_LP(InputData& inputData) -{ - LP_nBlock = inputData.LP_nBlock; - NewArray(LP_number,int,LP_nBlock); - - // memory allocate for aggrigateIndex - NewArray(LP_constraint1,int*,LP_nBlock); - NewArray(LP_constraint2,int*,LP_nBlock); - NewArray(LP_blockIndex1,int*,LP_nBlock); - NewArray(LP_blockIndex2,int*,LP_nBlock); - NewArray(LP_location_sparse_bMat,int*,LP_nBlock); - NewArray(LP_nStartIndex2, int, LP_nBlock); - NewArray(LP_startIndex2, int*, LP_nBlock); - - for (int l=0; l startTmp; - - for (int k1=0; k1l; - const int m = targ->m; - const double target_mu = targ->target_mu; - const int thread_num = targ->thread_num; - InputData& inputData = *(targ->addr_inputData); - CholmodMatrix& cholmodMatrix = *(targ->addr_cholmodMatrix); - DenseMatrix& bMat = *(targ->addr_bMat); - Vector& gVec = *(targ->addr_gVec); - Phase& phase = *(targ->addr_phase); - CompSpace* A = inputData.A; - const int nDim = cholmodMatrix.nDim; - cholmod_common& common = cholmodMatrix.common; - - const int SDP_nConstraintl = inputData.SDP_nConstraint[l]; - int* SDP_constraintl = inputData.SDP_constraint[l]; - int* SDP_blockIndexl = inputData.SDP_blockIndex[l]; - - - // for multi-threads computing work space - cholmod_dense* b_x1; - cholmod_dense* b_z1; - b_x1 = cholmod_allocate_dense(nDim,1,nDim,CHOLMOD_REAL, - &common); - b_z1 = cholmod_allocate_dense(nDim,1,nDim,CHOLMOD_REAL, - &common); - double* b_x = (double*)(b_x1->x); - double* b_z = (double*)(b_z1->x); - - cholmod_factor* Lz = cholmodMatrix.Lz; - cholmod_factor* Lx = cholmodMatrix.Lx; - int k1 = 0; // dummy initialize - while (1) { - pthread_mutex_lock(&job_mutex); - k1 = Column_Number; - Column_Number++; - pthread_mutex_unlock(&job_mutex); - if (k1>=SDP_nConstraintl) { - break; - } - - int j = SDP_constraintl[k1]; - int jb = SDP_blockIndexl[k1]; - // rMessage("j = " << j << " : jb = " << jb); - CompMatrix& Aj = A[j].SDP_sp_block[jb]; - - const int nCol = Aj.nzColumn; - double gj1 = 0.0; - double gj2 = 0.0; - for (int k_index = 0; k_index < nCol; ++k_index) { - const int k = Aj.column_index[k_index]; - // rMessage("k = " << k << ", k_index = " << k_index); - // rMessage("j = " << j << " : jb = " << jb); - for (int index1=0;index1 < nDim; ++index1) { - b_z[index1] = 0.0; - } - const int i_start = Aj.column_start[k_index]; - const int i_end = Aj.column_start[k_index+1]; - for (int i_index = i_start; i_index < i_end; ++i_index) { - const int i2 = Aj.row_index[i_index]; - b_z[i2] = Aj.ele[i_index]; - } - - cholmod_dense* b2 = cholmod_solve(CHOLMOD_P, Lz, b_z1, &common); - cholmod_dense* x_z2 = cholmod_solve(CHOLMOD_LDLt, Lz, b2, &common); - cholmod_dense* x_z1 = cholmod_solve(CHOLMOD_Pt, Lz, x_z2, &common); - double* x_z = (double*)(x_z1->x); - - for (int index1=0;index1 < nDim; ++index1) { - b_x[index1] = 0.0; - } - b_x[k] = 1.0; - - cholmod_dense* b_x2 = cholmod_solve(CHOLMOD_P, Lx, b_x1, &common); - cholmod_dense* x_x3 = cholmod_solve(CHOLMOD_L, Lx, b_x2, &common); - cholmod_dense* x_x2 = cholmod_solve(CHOLMOD_Lt,Lx, x_x3, &common); - cholmod_dense* x_x1 = cholmod_solve(CHOLMOD_Pt, Lx, x_x2, &common); - double* x_x = (double*)(x_x1->x); -#if 0 - rMessage("Aj = "); Aj.display(); - rMessage(" b_x = "); - CholmodMatrix::display_dense(cholmodMatrix.b_x1); - rMessage(" x_x = "); - CholmodMatrix::display_dense(cholmodMatrix.x_x1); - rMessage(" b_z = "); - CholmodMatrix::display_dense(cholmodMatrix.b_z1); - rMessage(" x_z = "); - CholmodMatrix::display_dense(cholmodMatrix.x_z1); - // rMessage(" rD = "); - // CholmodMatrix::display_sparse(cholmodMatrix.rD); -#endif - - double gadd = 0.0; - if (phase.value == SolveInfo::pFEAS - || phase.value == SolveInfo::noINFO) { - Lal::getInnerProduct(gadd, cholmodMatrix.rD, x_x, x_z); - } - // rMessage("gj1 = " << gadd << " : gj2 = " << x_z[k] << " : k = " << k); - gj1 += gadd; - gj2 += x_z[k]; - for (int k2=k1; k2l; - const int m = targ->m; - const double target_mu = targ->target_mu; - const int thread_num = targ->thread_num; - InputData& inputData = *(targ->addr_inputData); - CholmodMatrix& cholmodMatrix = *(targ->addr_cholmodMatrix); - SparseMatrix& sparse_bMat = *(targ->addr_sparse_bMat); - Vector& gVec = *(targ->addr_gVec); - Phase& phase = *(targ->addr_phase); - Newton& newton = *(targ->addr_newton); - CompSpace* A = inputData.A; - const int nDim = cholmodMatrix.nDim; - cholmod_common& common = cholmodMatrix.common; - - int* SDP_constraint1l = newton.SDP_constraint1[l]; - int* SDP_blockIndex1l = newton.SDP_blockIndex1[l]; - int* SDP_constraint2l = newton.SDP_constraint2[l]; - int* SDP_blockIndex2l = newton.SDP_blockIndex2[l]; - int* SDP_startIndex2l = newton.SDP_startIndex2[l]; - const int SDP_nStartIndex2l = newton.SDP_nStartIndex2[l]; - int* SDP_location_sparse_bMatl = newton.SDP_location_sparse_bMat[l]; - - // for multi-threads computing work space - cholmod_dense* b_x1; - cholmod_dense* b_z1; - b_x1 = cholmod_allocate_dense(nDim,1,nDim,CHOLMOD_REAL, - &common); - b_z1 = cholmod_allocate_dense(nDim,1,nDim,CHOLMOD_REAL, - &common); - double* b_x = (double*)(b_x1->x); - double* b_z = (double*)(b_z1->x); - - cholmod_factor* Lz = cholmodMatrix.Lz; - cholmod_factor* Lx = cholmodMatrix.Lx; - - int index2 = 0; // dummy initialize - while (1) { - pthread_mutex_lock(&job_mutex); - index2 = Column_Number++; - pthread_mutex_unlock(&job_mutex); - if (index2 >= SDP_nStartIndex2l) { - break; - } - const int start_iter = SDP_startIndex2l[index2]; - const int end_iter = SDP_startIndex2l[index2+1]; - int j = SDP_constraint2l[start_iter]; - int jb = SDP_blockIndex2l[start_iter]; - CompMatrix& Aj = A[j].SDP_sp_block[jb]; - - const int nCol = Aj.nzColumn; - double gj1 = 0.0; - double gj2 = 0.0; - for (int k_index = 0; k_index < nCol; ++k_index) { - const int k = Aj.column_index[k_index]; - for (int index1=0;index1 < nDim; ++index1) { - b_z[index1] = 0.0; - } - const int i_start = Aj.column_start[k_index]; - const int i_end = Aj.column_start[k_index+1]; - for (int i_index = i_start; i_index < i_end; ++i_index) { - const int i2 = Aj.row_index[i_index]; - b_z[i2] = Aj.ele[i_index]; - } - cholmod_dense* b2 = cholmod_solve(CHOLMOD_P, Lz, b_z1, &common); - cholmod_dense* x_z2 = cholmod_solve(CHOLMOD_LDLt, Lz, b2, &common); - cholmod_dense* x_z1 = cholmod_solve(CHOLMOD_Pt, Lz, x_z2, &common); - double* x_z = (double*)(x_z1->x); - for (int index1=0;index1 < nDim; ++index1) { - b_x[index1] = 0.0; - } - b_x[k] = 1.0; - - cholmod_dense* b_x2 = cholmod_solve(CHOLMOD_P, Lx, b_x1, &common); - cholmod_dense* x_x3 = cholmod_solve(CHOLMOD_L, Lx, b_x2, &common); - cholmod_dense* x_x2 = cholmod_solve(CHOLMOD_Lt,Lx, x_x3, &common); - cholmod_dense* x_x1 = cholmod_solve(CHOLMOD_Pt, Lx, x_x2, &common); - double* x_x = (double*)(x_x1->x); - -#if 0 - rMessage(" x_x = "); - CholmodMatrix::display_dense(cholmodMatrix.x_x); - rMessage(" x_z = "); - CholmodMatrix::display_dense(cholmodMatrix.x_z); - rMessage(" rD = "); - CholmodMatrix::display_sparse(cholmodMatrix.rD); -#endif - - double gadd = 0.0; - if (phase.value == SolveInfo:: pFEAS - || phase.value == SolveInfo::noINFO) { - Lal::getInnerProduct(gadd, cholmodMatrix.rD, x_x, x_z); - // rMessage("gj1 = " << gadd << " : gj2 = " << x_z[k] << " : k = " << k); - } - gj1 += gadd; - gj2 += x_z[k]; - - for (int iter = start_iter; iter < end_iter; ++iter) { - int i = SDP_constraint1l[iter]; - int ib = SDP_blockIndex1l[iter]; - CompMatrix& Ai = A[i].SDP_sp_block[ib]; - double Badd = 0.0; - Lal::getInnerProduct(Badd, Ai, x_x, x_z); - sparse_bMat.sp_ele[SDP_location_sparse_bMatl[iter]] += Badd; - } - cholmod_free_dense(&b2,&common); - cholmod_free_dense(&x_z2,&common); - cholmod_free_dense(&b_x2,&common); - cholmod_free_dense(&x_x3,&common); - cholmod_free_dense(&x_x2,&common); - cholmod_free_dense(&x_x1,&common); - cholmod_free_dense(&x_z1,&common); - } // end of 'for (int k_index)' - gVec.ele[j] += (gj1 - target_mu * gj2); - } // end of 'for (int index2, aka j)' - cholmod_free_dense(&b_x1,&common); - cholmod_free_dense(&b_z1,&common); - -} - - - -void Newton::Make_bMatgVec(InputData& inputData, - Solutions& currentPt, - Residuals& currentRes, - AverageComplementarity& mu, - DirectionParameter& beta, - Phase& phase, - ComputeTime& com) -{ - TimeStart(START3); - gVec.copyFrom(inputData.b); - if (bMat_type == SPARSE){ - // set sparse_bMat zero - sdpa_dset(sparse_bMat.NonZeroCount, 0.0, sparse_bMat.sp_ele, 1); - #if 0 - compute_bMatgVec_sparse(inputData, currentPt, currentRes, mu, beta, - phase, com); - #else - compute_bMatgVec_sparse_threads(inputData, currentPt, currentRes, mu, beta, - phase, com); - #endif - } else { - bMat.setZero(); - #if 0 - compute_bMatgVec_dense(inputData, currentPt, currentRes, mu, beta, - phase, com); - #else - compute_bMatgVec_dense_threads(inputData, currentPt, currentRes, mu, beta, - phase, com); - #endif - } - - #if 0 - // display_index(); - rMessage("bMat = "); - if (bMat_type == DENSE) { - bMat.display(); - } - else { - sparse_bMat.display(); - } - rMessage("gVec = "); - gVec.display(); - #endif - TimeEnd(END3); - com.makebMatgVec += TimeCal(START3,END3); -} - -bool Newton::compute_DyVec(Newton::WHICH_DIRECTION direction, - int m, - InputData& inputData, - Chordal& chordal, - Solutions& currentPt, - ComputeTime& com, - FILE* Display, FILE* fpOut) -{ - if (direction == PREDICTOR) { - TimeStart(START3_2); - - if (bMat_type == SPARSE){ - bool ret = chordal.factorizeSchur(m, diagonalIndex, Display, fpOut); - if (ret == SDPA_FAILURE) { - return SDPA_FAILURE; - } - } else { - bool ret = Lal::choleskyFactorWithAdjust(bMat); - if (ret == SDPA_FAILURE) { - return SDPA_FAILURE; - } - } - // rMessage("Cholesky of bMat = "); - // bMat.display(); - // sparse_bMat.display(); - TimeEnd(END3_2); - com.choleskybMat += TimeCal(START3_2,END3_2); - } - // bMat is already cholesky factorized. - - - Vector& DyVec = currentPt.cholmodSpace.dyVec; - - TimeStart(START4); - if (bMat_type == SPARSE){ - DyVec.copyFrom(gVec); - chordal.solveSchur(DyVec); - } else { - Lal::let(DyVec,'=',bMat,'/',gVec); - } - TimeEnd(END4); - com.solve += TimeCal(START4,END4); - // rMessage("DyVec = "); - // DyVec.display(); - return SDPA_SUCCESS; -} - -void Newton::compute_DzMat(InputData& inputData, - Solutions& currentPt, - Residuals& currentRes, - Phase& phase, - ComputeTime& com) -{ - TimeStart(START_SUMDZ); - CholmodSpace& cholmodSpace = currentPt.cholmodSpace; - CompSpace* A = inputData.A; - - for (int l=0; lnzmax; - for (int index1 = 0; index1 < length; ++index1) { - ((double*)(dZ->x))[index1] = 0.0; - } - } - - const int m = cholmodSpace.dyVec.nDim; - for (int k=0; kx))[agg_index] -= Akl.ele[i]*dyk; - } - } - } - } // end of 'for (int k=0; knzmax; - for (int index1 = 0; index1 < length; ++index1) { - ((double*)(dZ->x))[index1] += ((double*)(rD->x))[index1]; - } - } - } - TimeEnd(END_SUMDZ); - com.sumDz += TimeCal(START_SUMDZ,END_SUMDZ); -} - -void Newton::compute_DxMat(Solutions& currentPt, - AverageComplementarity& mu, - DirectionParameter& beta, - ComputeTime& com) -{ - TimeStart(START_DX); - CholmodSpace& cholmodSpace = currentPt.cholmodSpace; - OrderingSpace& orderingSpace = currentPt.order; - const double target_mu = beta.value * mu.current; - for (int l=0; lx); - b_z[k] = 1.0; - cholmodMatrix.solveByZ(); - double* x_z = (double*)(cholmodMatrix.x_z->x); - // x_z is now Zinv[*k] - - double one[2] = {1.0, 0.0}; - double zero[2] = {0.0, 0.0} ; - int transpose = 0; // 0 means no transpose - double* b_x = (double*)(cholmodMatrix.b_x->x); - cholmod_sdmult(dZ, transpose, one, zero, cholmodMatrix.x_z, - cholmodMatrix.b_x, &common); - cholmodMatrix.solveByX(); - double* x_x = (double*)(cholmodMatrix.x_x->x); - - for (int i=0; il; - const int thread_num = tDX->thread_num; - const double target_mu = tDX->target_mu; - CholmodMatrix& cholmodMatrix = *(tDX->addr_cholmodMatrix); - OrderingMatrix& order = *(tDX->addr_order); - - const int nDim = cholmodMatrix.nDim; - cholmod_factor* Lz = cholmodMatrix.Lz; - cholmod_factor* Lx = cholmodMatrix.Lx; - cholmod_sparse* dZ = cholmodMatrix.dZ; - cholmod_common& common = cholmodMatrix.common; - CliqueMatrix& clique_dX = cholmodMatrix.clique_dX; - - cholmod_dense* b_x1; - cholmod_dense* b_z1; - b_x1 = cholmod_allocate_dense(nDim,1,nDim,CHOLMOD_REAL, - &common); - b_z1 = cholmod_allocate_dense(nDim,1,nDim,CHOLMOD_REAL, - &common); - double* b_x = (double*)(b_x1->x); - double* b_z = (double*)(b_z1->x); - - int k = 0; // dummy initialize - - while (1) { - pthread_mutex_lock(&job_mutex); - k = Column_NumberDx; - Column_NumberDx++; - pthread_mutex_unlock(&job_mutex); - if (k >= nDim) { - break; - } - for (int index1=0;index1 < nDim; ++index1) { - b_z[index1] = 0.0; - } - b_z[k] = 1.0; - cholmod_dense* b2 = cholmod_solve(CHOLMOD_P, Lz, b_z1, &common); - cholmod_dense* x_z2 = cholmod_solve(CHOLMOD_LDLt, Lz, b2, &common); - cholmod_dense* x_z1 = cholmod_solve(CHOLMOD_Pt, Lz, x_z2, &common); - double* x_z = (double*)(x_z1->x); - - // x_z is now Zinv[*k] - - double one[2] = {1.0, 0.0}; - double zero[2] = {0.0, 0.0} ; - int transpose = 0; // 0 means no transpose - cholmod_sdmult(dZ, transpose, one, zero, x_z1, - b_x1, &common); - - cholmod_dense* b_x2 = cholmod_solve(CHOLMOD_P, Lx, b_x1, &common); - cholmod_dense* x_x3 = cholmod_solve(CHOLMOD_L, Lx, b_x2, &common); - cholmod_dense* x_x2 = cholmod_solve(CHOLMOD_Lt,Lx, x_x3, &common); - cholmod_dense* x_x1 = cholmod_solve(CHOLMOD_Pt, Lx, x_x2, &common); - double* x_x = (double*)(x_x1->x); - - - for (int i=0; inzmax; - for (int index1 = 0; index1 < length; ++index1) { - ((double*)(rDs[l]->x))[index1] = -((double*)(Z->x))[index1] -((double*)(dZ->x))[index1]; - } - } - for (int l_index=0; l_index < C.SDP_sp_nBlock; ++l_index) { - const int l = C.SDP_sp_index[l_index]; - CompMatrix& Cl = C.SDP_sp_block[l_index]; - cholmod_sparse* rD = rDs[l]; - for (int j_index = 0; j_indexx))[agg_index] += Cl.ele[i]; - } - } - } - for (int k=0; kx))[agg_index] -= Akl.ele[i]*(yk+dyk); - } - } - } - } - for (int l=0; lnzmax; - for (int index1 = 0; index1 < length; ++index1) { - double value = ((double*)(rDs[l]->x))[index1]; - sum += value*value; - } - } - for (int l=0; l - -#define SparseCholesky 1 - -namespace sdpa { - -class Newton; - -class Solutions; -class InputData; -class Residuals; - -class ComputeTime; -class Parameter; -class StepLength; -class DirectionParameter; -class Switch; -class RatioInitResCurrentRes; -class SolveInfo; -class Phase; -class AverageComplementarity; - - - -class Newton -{ -public: - enum bMat_Sp_De {SPARSE, DENSE}; - bMat_Sp_De bMat_type; - - SparseMatrix sparse_bMat; - DenseMatrix bMat; // the coefficent of Schur complement - Vector gVec; // the right hand side of Schur complement - - // Caution: - // if SDPA doesn't use sparse bMat, following variables are indefinite. - // - // nBlock : number of block - // nConstraint[k]: number of combination of nonzero matrices in k-th block - // when A[k].block[i] and A[k].block[j] are nonzero matrices, - // i <-> constraint1[k][t] - // j <-> constraint2[k][t] - // A[k].block[i] <-> A[k].sp_block[blockIndex1[k][t]] - // A[k].block[j] <-> A[k].sp_block[blockIndex2[k][t]] - // B_{ij} <-> sparse_bMat.sp_ele[location_sparse_bMat[k][t]] - int SDP_nBlock; int* SDP_number; - int** SDP_constraint1; int** SDP_constraint2; - int** SDP_blockIndex1; int** SDP_blockIndex2; - int** SDP_location_sparse_bMat; - int* SDP_nStartIndex2; // start new j&jb from this index - int** SDP_startIndex2; // start new j&jb from this index - int LP_nBlock; int* LP_number; - int** LP_constraint1; int** LP_constraint2; - int** LP_blockIndex1; int** LP_blockIndex2; - int** LP_location_sparse_bMat; - int* LP_nStartIndex2; // start new j&jb from this index - int** LP_startIndex2; // start new j&jb from this index - - // from index of aggrigate sparsity pattern to index of sparse_bMat - // B_{ii} <-> sparse_bMat[diagonalIndex[i]] - int* diagonalIndex; - // B_{ij} for all i is between diagonalIndex[j] and rowStartIndex[j+1] - - Newton(); - Newton(int m, BlockStruct& bs); - ~Newton(); - - void initialize(int m, BlockStruct& bs); - - void finalize(); - - void initialize_dense_bMat(int m); - // 2008/03/12 kazuhide nakata - void initialize_sparse_bMat(int m); - // 2008/03/12 kazuhide nakata - void initialize_bMat(int m, Chordal& chordal, InputData& inputData, - FILE* Display, FILE* fpOut); - - int binarySearchIndex(int i, int j); - void make_aggrigateIndex_SDP(InputData& inputData); - void make_aggrigateIndex_LP(InputData& inputData); - void make_aggrigateIndex(InputData& inputData); - - enum WHICH_DIRECTION {PREDICTOR, CORRECTOR}; - - void compute_bMatgVec_dense(InputData& inputData, - Solutions& currentPt, - Residuals& currentRes, - AverageComplementarity& mu, - DirectionParameter& beta, - Phase& phase, - ComputeTime& com); - - static pthread_mutex_t job_mutex; - static int Column_Number; - static int Column_NumberDx; - - void compute_bMatgVec_dense_threads(InputData& inputData, - Solutions& currentPt, - Residuals& currentRes, - AverageComplementarity& mu, - DirectionParameter& beta, - Phase& phase, - ComputeTime& com); - static void* compute_bMatgVec_dense_threads_SDP(void* arg); - - void compute_bMatgVec_sparse(InputData& inputData, - Solutions& currentPt, - Residuals& currentRes, - AverageComplementarity& mu, - DirectionParameter& beta, - Phase& phase, - ComputeTime& com); - - void compute_bMatgVec_sparse_threads(InputData& inputData, - Solutions& currentPt, - Residuals& currentRes, - AverageComplementarity& mu, - DirectionParameter& beta, - Phase& phase, - ComputeTime& com); - - static void* compute_bMatgVec_sparse_threads_SDP(void* arg); - - void Make_bMatgVec(InputData& inputData, - Solutions& currentPt, - Residuals& currentRes, - AverageComplementarity& mu, - DirectionParameter& beta, - Phase& phase, - ComputeTime& com); - - bool compute_DyVec(Newton::WHICH_DIRECTION direction, - int m, - InputData& inputData, - Chordal& chordal, - Solutions& currentPt, - ComputeTime& com, - FILE* Display, FILE* fpOut); - - void compute_DzMat(InputData& inputData, - Solutions& currentPt, - Residuals& currentRes, - Phase& phase, - ComputeTime& com); - - void compute_DxMat(Solutions& currentPt, - AverageComplementarity& mu, - DirectionParameter& beta, - ComputeTime& com); - - void compute_DxMat_threads(Solutions& currentPt, - AverageComplementarity& mu, - DirectionParameter& beta, - ComputeTime& com); - - static void* compute_DxMat_threads_SDP(void* arg); - - bool Mehrotra(WHICH_DIRECTION direction, - int m, - InputData& inputData, - Chordal& chordal, - Solutions& currentPt, - Residuals& currentRes, - AverageComplementarity& mu, - DirectionParameter& beta, - Switch& reduction, - Phase& phase, - ComputeTime& com, - FILE* Display, FILE* fpOut); - - void checkDirection(int m, InputData& inputData, - Solutions& currentPt, - Residuals& currentRes, - AverageComplementarity& mu, - DirectionParameter& beta, - Switch& reduction, - Phase& phase, - ComputeTime& com, - FILE* Display, FILE* fpOut); - - void display(FILE* fpout=stdout); - void display_index(FILE* fpout=stdout); - void display_sparse_bMat(FILE* fpout=stdout); - - int NUM_THREADS; - void setNumThreads(FILE* Display, FILE* fpOut, int NumThreads=0); -}; - -typedef struct _thread_arg { - int l; - int m; - double target_mu; - int thread_num; - InputData* addr_inputData; - CholmodMatrix* addr_cholmodMatrix; - DenseMatrix* addr_bMat; - Vector* addr_gVec; - Phase* addr_phase; - -} thread_arg_t; - -typedef struct _thread_arg_s { - int l; - int m; - double target_mu; - int thread_num; - InputData* addr_inputData; - CholmodMatrix* addr_cholmodMatrix; - SparseMatrix* addr_sparse_bMat; - Vector* addr_gVec; - Phase* addr_phase; - Newton* addr_newton; - -} thread_arg_s; - -typedef struct _thread_DX { - int l; - int thread_num; - double target_mu; - CholmodMatrix* addr_cholmodMatrix; - OrderingMatrix* addr_order; -} thread_DX_t; - - -} // end of namespace 'sdpa' - -#endif // __sdpa_newton_h__ diff --git a/external/sdpa/sdpa_parts.cpp b/external/sdpa/sdpa_parts.cpp deleted file mode 100644 index 1ea8627..0000000 --- a/external/sdpa/sdpa_parts.cpp +++ /dev/null @@ -1,1314 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ - -#include "sdpa_parts.h" -#include "sdpa_linear.h" -#include "sdpa_newton.h" - -namespace sdpa { - -ComputeTime::ComputeTime() -{ - Predictor = 0.0; - Corrector = 0.0; - - StepPredictor = 0.0; - StepCorrector = 0.0; - - xMatTime = 0.0; - zMatTime = 0.0; - xMatzMatTime = 0.0; - invzMatTime = 0.0; - - EigxMatTime = 0.0; - EigzMatTime = 0.0; - EigxMatzMatTime = 0.0; - - makebMat = 0.0; - B_DIAG = 0.0; - B_F1 = 0.0; - B_F2 = 0.0; - B_F3 = 0.0; - B_PRE = 0.0; - - makebMatgVec = 0.0; - makerMat = 0.0; - choleskybMat = 0.0; - - solve = 0.0; - sumDz = 0.0; - makedX = 0.0; - symmetriseDx = 0.0; - makedXdZ = 0.0; - updateRes = 0.0; - - MainLoop = 0.0; - FileRead = 0.0; - FileCheck = 0.0; - FileChange= 0.0; - TotalTime = 0.0; -} - -ComputeTime::~ComputeTime() -{ - // Nothing needs. -} - - -void ComputeTime::display(FILE* fpout) -{ - if (fpout == NULL) { - return; - } - fprintf(fpout,"\n"); - #if 0 - if (TotalTime <= 0.0) { - return; - } - #endif - fprintf(fpout, " Time(sec) "); - fprintf(fpout," Ratio(%% : MainLoop) \n"); - fprintf(fpout, " Predictor time = %f, %f\n", - Predictor, Predictor/MainLoop*100.0); - fprintf(fpout, " Corrector time = %f, %f\n", - Corrector, Corrector/MainLoop*100.0); - fprintf(fpout, " Make bMat time = %f, %f\n", - makebMat, makebMat/MainLoop*100.0); - fprintf(fpout, " Make bDia time = %f, %f\n", - B_DIAG,B_DIAG/MainLoop*100.0); - fprintf(fpout, " Make bF1 time = %f, %f\n", - B_F1,B_F1/MainLoop*100.0); - fprintf(fpout, " Make bF2 time = %f, %f\n", - B_F2,B_F2/MainLoop*100.0); - fprintf(fpout, " Make bF3 time = %f, %f\n", - B_F3,B_F3/MainLoop*100.0); - fprintf(fpout, " Make bPRE time = %f, %f\n", - B_PRE,B_PRE/MainLoop*100.0); - fprintf(fpout, " Make rMat time = %f, %f\n", - makerMat, makerMat/MainLoop*100.0); - fprintf(fpout, " Make bMatgVec = %f, %f\n", - makebMatgVec, makebMatgVec/MainLoop*100.0); - fprintf(fpout, " Cholesky bMat = %f, %f\n", - choleskybMat, choleskybMat/MainLoop*100.0); - fprintf(fpout, " Ste Pre time = %f, %f\n", - StepPredictor, StepPredictor/MainLoop*100.0); - fprintf(fpout, " Ste Cor time = %f, %f\n", - StepCorrector, StepCorrector/MainLoop*100.0); - fprintf(fpout, " solve = %f, %f\n", - solve, solve/MainLoop*100.0); - fprintf(fpout, " sumDz = %f, %f\n", - sumDz, sumDz/MainLoop*100.0); - fprintf(fpout, " makedX = %f, %f\n", - makedX, makedX/MainLoop*100.0); - fprintf(fpout, " symmetriseDx = %f, %f\n", - symmetriseDx, symmetriseDx/MainLoop*100.0); - fprintf(fpout, " makedXdZ = %f, %f\n", - makedXdZ, makedXdZ/MainLoop*100.0); - fprintf(fpout, " xMatTime = %f, %f\n", - xMatTime, xMatTime/MainLoop*100.0); - fprintf(fpout, " zMatTime = %f, %f\n", - zMatTime, zMatTime/MainLoop*100.0); - fprintf(fpout, " invzMatTime = %f, %f\n", - invzMatTime, invzMatTime/MainLoop*100.0); - fprintf(fpout, " xMatzMatTime = %f, %f\n", - xMatzMatTime, xMatzMatTime/MainLoop*100.0); - fprintf(fpout, " EigxMatTime = %f, %f\n", - EigxMatTime, EigxMatTime/MainLoop*100.0); - fprintf(fpout, " EigzMatTime = %f, %f\n", - EigzMatTime, EigzMatTime/MainLoop*100.0); - fprintf(fpout, " EigxMatzMatTime = %f, %f\n", - EigxMatzMatTime, EigxMatzMatTime/MainLoop*100.0); - fprintf(fpout, " updateRes = %f, %f\n", - updateRes, updateRes/MainLoop*100.0); - double total_eigen = EigxMatTime + EigzMatTime + EigxMatzMatTime; - fprintf(fpout, " EigTime = %f, %f\n", - total_eigen, total_eigen/MainLoop*100.0); - double sub_total_bMat = MainLoop - makebMat; - fprintf(fpout, " sub_total_bMat = %f, %f\n", - sub_total_bMat, sub_total_bMat/MainLoop*100.0); - fprintf(fpout, " Main Loop = %f, %f\n", - MainLoop, MainLoop/MainLoop*100.0); - fprintf(fpout, " File Check = %f, %f\n", - FileCheck, FileCheck/MainLoop*100.0); - fprintf(fpout, " File Change = %f, %f\n", - FileChange, FileChange/MainLoop*100.0); - fprintf(fpout, " File Read = %f, %f\n", - FileRead, FileRead/MainLoop*100.0); - fprintf(fpout, " Total = %f, %f\n", - TotalTime, TotalTime/MainLoop*100.0); - fprintf(fpout, "\n"); - - return; -} - -//------------------------------------------------------------- - -Parameter::Parameter() -{ - // setDefaultParameter(); -} -Parameter::Parameter(FILE* parameterFile) -{ - readFile(parameterFile); -} - -Parameter::~Parameter() -{ - // Nothings needs. -} - -void Parameter::setDefaultParameter(Parameter::parameterType type) -{ - if (type == PARAMETER_STABLE_BUT_SLOW) { - maxIteration = 1000; - epsilonStar = 1.0e-7; - lambdaStar = 1.0e+4; - omegaStar = 2.0; - lowerBound = -1.0e+5; - upperBound = 1.0e+5; - betaStar = 0.1; - betaBar = 0.5; - gammaStar = 0.8; - epsilonDash = 1.0e-7; - } - else if (type == PARAMETER_UNSTABLE_BUT_FAST) { - maxIteration = 100; - epsilonStar = 1.0e-7; - lambdaStar = 1.0e+2; - omegaStar = 2.0; - lowerBound = -1.0e+5; - upperBound = 1.0e+5; - betaStar = 0.01; - betaBar = 0.02; - gammaStar = 0.95; - epsilonDash = 1.0e-7; - } - else { - maxIteration = 100; - epsilonStar = 1.0e-7; - lambdaStar = 1.0e+2; - omegaStar = 2.0; - lowerBound = -1.0e+5; - upperBound = 1.0e+5; - betaStar = 0.1; - betaBar = 0.3; - gammaStar = 0.9; - epsilonDash = 1.0e-7; - } - strcpy(xPrint,xPRINT_DEFAULT); - strcpy(XPrint,XPRINT_DEFAULT); - strcpy(YPrint,YPRINT_DEFAULT); - strcpy(infPrint,infPRINT_DEFAULT); -} - -char Parameter::xPRINT_DEFAULT[PRINT_DEFAULT_LENGTH] = "%+8.3e"; -char Parameter::XPRINT_DEFAULT[PRINT_DEFAULT_LENGTH] = "%+8.3e"; -char Parameter::YPRINT_DEFAULT[PRINT_DEFAULT_LENGTH] = "%+8.3e"; -char Parameter::infPRINT_DEFAULT[PRINT_DEFAULT_LENGTH] = "%+10.16e"; - -void Parameter::readFile(FILE* parameterFile) -{ - fscanf(parameterFile,"%d%*[^\n]",&maxIteration); - fscanf(parameterFile,"%lf%*[^\n]",&epsilonStar); - fscanf(parameterFile,"%lf%*[^\n]",&lambdaStar); - fscanf(parameterFile,"%lf%*[^\n]",&omegaStar); - fscanf(parameterFile,"%lf%*[^\n]",&lowerBound); - fscanf(parameterFile,"%lf%*[^\n]",&upperBound); - fscanf(parameterFile,"%lf%*[^\n]",&betaStar); - fscanf(parameterFile,"%lf%*[^\n]",&betaBar); - fscanf(parameterFile,"%lf%*[^\n]",&gammaStar); - fscanf(parameterFile,"%lf%*[^\n]",&epsilonDash); - fscanf(parameterFile,"%s %*[^\n]",xPrint); - fscanf(parameterFile,"%s %*[^\n]",XPrint); - fscanf(parameterFile,"%s %*[^\n]",YPrint); - fscanf(parameterFile,"%s %*[^\n]",infPrint); - if (strcmp(xPrint,NO_P_FORMAT)!=0 && xPrint[0]!='%') { - rMessage("Strange xPrint[" << xPrint << "]" - " migh cause trouble when printing x"); - } - if (strcmp(XPrint,NO_P_FORMAT)!=0 && XPrint[0]!='%') { - rMessage("Strange XPrint[" << XPrint << "]" - " migh cause trouble when printing X."); - } - if (strcmp(YPrint,NO_P_FORMAT)!=0 && YPrint[0]!='%') { - rMessage("Strange YPrint[" << YPrint << "]" - " migh cause trouble when printing Y."); - } - if (strcmp(infPrint,NO_P_FORMAT)!=0 && infPrint[0]!='%') { - rMessage("Strange infPrint[" << infPrint << "]" - " migh cause trouble when printing information."); - } -} - - -void Parameter::display(FILE* fpout, char* printFormat) -{ - if (fpout == NULL) { - return; - } - if (strcmp(printFormat,NO_P_FORMAT) == 0) { - fprintf(fpout,"%s\n",NO_P_FORMAT); - return; - } - fprintf(fpout, "** Parameters **\n"); - fprintf(fpout, "maxIteration = %d\n",maxIteration); - fprintf(fpout, "epsilonStar = "); - fprintf(fpout, printFormat, epsilonStar ); - fprintf(fpout, "\n"); - fprintf(fpout, "lambdaStar = "); - fprintf(fpout, printFormat, lambdaStar ); - fprintf(fpout, "\n"); - fprintf(fpout, "omegaStar = "); - fprintf(fpout, printFormat, omegaStar ); - fprintf(fpout, "\n"); - fprintf(fpout, "lowerBound = "); - fprintf(fpout, printFormat, lowerBound); - fprintf(fpout, "\n"); - fprintf(fpout, "upperBound = "); - fprintf(fpout, printFormat, upperBound); - fprintf(fpout, "\n"); - fprintf(fpout, "betaStar = "); - fprintf(fpout, printFormat, betaStar ); - fprintf(fpout, "\n"); - fprintf(fpout, "betaBar = "); - fprintf(fpout, printFormat, betaBar ); - fprintf(fpout, "\n"); - fprintf(fpout, "gammaStar = "); - fprintf(fpout, printFormat, gammaStar ); - fprintf(fpout, "\n"); - fprintf(fpout, "epsilonDash = "); - fprintf(fpout, printFormat, epsilonDash ); - fprintf(fpout, "\n"); - #if 1 - fprintf(fpout, "xPrint = %s \n", xPrint ); - fprintf(fpout, "XPrint = %s \n", XPrint ); - fprintf(fpout, "YPrint = %s \n", YPrint ); - fprintf(fpout, "infPrint = %s \n", infPrint ); - #endif - return; -} - -//---------------------------------------------------------- - -StepLength::StepLength() -{ - primal = 0.0; - dual = 0.0; - -} - -StepLength::~StepLength() -{ - finalize(); -} - - -void StepLength::initialize(double alphaP, double alphaD) -{ - primal = alphaP; - dual = alphaD; -} - -void StepLength::finalize() -{ - // Nothing needs. -} - -double StepLength::minBlockVector(BlockVector& aVec) -{ - int nBlock = aVec.nBlock; - double ret = aVec.ele[0].ele[0]; - double tmp; - int size = aVec.ele[0].nDim; - for (int j=1; j1.0) { - primal = 1.0; - } - if (dual>1.0) { - dual = 1.0; - } - - -} - - -void StepLength::display(FILE* fpout) -{ - if (fpout == NULL) { - return; - } - - fprintf(fpout,"alpha.primal = %8.3e\n",primal); - fprintf(fpout,"alpha.dual = %8.3e\n",dual); -} - -//------------------------------------------------- -DirectionParameter::DirectionParameter(double betaStar) -{ - initialize(betaStar); -} - -DirectionParameter::~DirectionParameter() -{ - // Nothing needs. -} - -void DirectionParameter::initialize(double betaStar) -{ - value = betaStar; -} - -void DirectionParameter::Predictor(Phase& phase, - Switch& reduction, - Parameter& param) -{ - const double nu = 2.0; - if (phase.value == SolveInfo::pdFEAS) { - value = param.betaStar; - } else { - value = param.betaBar; - if (reduction.switchType==Switch::AFFINE) { - value = nu; - } - } -} - -void DirectionParameter::Centering() -{ - value = 1.0; -} - -void DirectionParameter:: -MehrotraCorrector(Phase& phase, StepLength& alpha, - Solutions& currentPt, - AverageComplementarity& mu, Parameter& param) -{ - int nDim = currentPt.nDim; - CholmodSpace& cholmodSpace = currentPt.cholmodSpace; - - // Lal::let(uMatzMat,'=',newton.DxMat,'.',currentPt.zMat); - // Lal::let(xMatvMat,'=',currentPt.xMat,'.',newton.DzMat); - // Lal::let(uMatvMat,'=',newton.DxMat,'.',newton.DzMat); - double uMatzMat = 0.0; - double xMatvMat = 0.0; - double uMatvMat = 0.0; - for (int l=0; l 1.0) { - value = 1.0; - } - } else { - if (value < param.betaBar) { - value = param.betaBar; - } - } - // rMessage("MehrotraCorrector : " << value); -} - -void DirectionParameter::display(FILE* fpout) -{ - if (fpout == NULL) { - return; - } - fprintf(fpout,"beta.value = %8.3e\n",value); -} - -//--------------------------------------------------- - -Switch::Switch(SwitchType switchType) -{ - initialize(switchType); -} - -Switch::~Switch() -{ - // Nothing needs. -} - -void Switch::initialize(SwitchType switchType) -{ - this->switchType = switchType; -} - -void Switch::MehrotraPredictor(Phase& phase) -{ - if (phase.value==SolveInfo::noINFO - || phase.value==SolveInfo::pFEAS - || phase.value==SolveInfo::dFEAS) { - // At least one of primal or dual is infeasible. - switchType = CENTERING; - } else { - switchType = AFFINE; - } -} - -void Switch::display(FILE* fpout) -{ - if (fpout == NULL) { - return; - } - - if (switchType == CENTERING) { - fprintf(fpout,"reduction.switchType == CENTERING\n"); - } else { - fprintf(fpout,"reduction.switchType == AFFINE\n"); - } -} - -// ---------------------------------------- - -AverageComplementarity::AverageComplementarity(double lambdaStar) -{ - initialize(lambdaStar); -} - -AverageComplementarity::~AverageComplementarity() -{ - // Nothing needs. -} - -void AverageComplementarity::initialize(double lambdaStar) -{ - initial = lambdaStar*lambdaStar; - current = initial; - // rMessage("initial average = " << initial); -} - -void AverageComplementarity::update(Solutions& currentPt) -{ - CholmodSpace& cholmodSpace = currentPt.cholmodSpace; - int nDim = cholmodSpace.LP_nBlock; - current = 0.0; - for (int l=0; l param.epsilonDash * 1.0e-2) { - primal = currentRes.normPrimal / currentRes.initNormPrimal; - } - else { - primal = 0.0; - } - if (currentRes.initNormDual - > param.epsilonDash * 1.0e-2) { - dual = currentRes.normDual / currentRes.initNormDual; - } - else { - dual = 0.0; - } -} - -void RatioInitResCurrentRes::display(FILE* fpout) -{ - if (fpout == NULL) { - return; - } - - fprintf(fpout,"theta.primal = %8.3e\n",primal); - fprintf(fpout,"theta.dual = %8.3e\n",dual); -} - -//--------------------------------------------------- - -SolveInfo::SolveInfo() -{ - rho = 0.0; - etaPrimal = 0.0; - etaDual = 0.0; - objValPrimal = 0.0; - objValDual = 0.0; -} - -SolveInfo::SolveInfo(InputData& inputData, Solutions& currentPt, - double mu0, double omegaStar) -{ - initialize(inputData,currentPt,mu0,omegaStar); -} - -SolveInfo::~SolveInfo() -{ - // Nothing needs. -} - -void SolveInfo::initialize(InputData& inputData, Solutions& currentPt, - double mu0, double omegaStar) -{ - int nDim = currentPt.nDim; - Vector& b = inputData.b; - CompSpace& C = inputData.C; - CholmodSpace& cholmodSpace = currentPt.cholmodSpace; - - rho = 1.0; - etaPrimal = omegaStar * nDim * mu0; - etaDual = omegaStar * nDim * mu0; - cholmodSpace.getInnerProductAX(objValPrimal, C, currentPt.order); - #if 0 - C.display(); - cholmodSpace.display(); - rMessage("objValPrimal = " << objValPrimal); - #endif - Lal::let(objValDual,'=',b,'.',cholmodSpace.yVec); -} - -void SolveInfo::update(InputData& inputData, - Solutions& currentPt, - Residuals& currentRes, - AverageComplementarity& mu, - RatioInitResCurrentRes& theta, - Parameter& param) -{ - CholmodSpace& cholmodSpace = currentPt.cholmodSpace; - - // Lal::let(objValPrimal,'=',C,'.',currentPt.xMat); - objValPrimal = 0.0; - cholmodSpace.getInnerProductAX(objValPrimal, inputData.C, currentPt.order); - Lal::let(objValDual,'=',inputData.b,'.',cholmodSpace.yVec); - - int nDim = cholmodSpace.LP_nBlock; - for (int l=0; lncol; - for (int j=0; j < ncol; ++j) { - const int diag_row = ((int*)Z->p)[j]; - x0zMat += ((double*)Z->x)[diag_row]; - } - } - x0zMat *= lambda; - - // Lal::let(xMatz0,'=',currentPt.xMat,'.',initPt_zMat); - double xMatz0 = 0.0; - for (int l=0; l accuracy - && currentRes.normDual <= accuracy) { - rho = primal*x0zMat - / ((primal+(1.0-primal)*omega)*etaDual + xMatzMat); - } - - // primal is feasible and dual is infeasible - if (currentRes.normPrimal <= accuracy - && currentRes.normDual > accuracy) { - rho = dual*xMatz0 - / ((dual+(1.0-dual)*omega)* etaPrimal + xMatzMat); - } - - // primal and dual are infeasible - if (currentRes.normPrimal > accuracy - && currentRes.normDual > accuracy) { - rho = (dual*xMatz0+primal*x0zMat) - / ((primal*dual - + omega *(primal*(1.0-dual) + (1.0-primal)*dual))* x0z0 - + xMatzMat); - } - // rMessage("eta Primal = " << etaPrimal); - // rMessage("eta Dual = " << etaDual); -} - -// 2007/09/13 kazuhide nakata -// print information of ObjVal, residual, gap, complementarity -// b^T y + R \bullet X = value, norm(r), norm(Z) -// C \bullet X + r^T y = value, norm(R), norm(X) -// gap gap, mu * nDim -void SolveInfo::check(InputData& inputData, - Solutions& currentPt, - Residuals& currentRes, - AverageComplementarity& mu, - RatioInitResCurrentRes& theta, - Parameter& param) -{ - rMessage("This function is not implemented in SDPA-C"); - #if 0 - double tmp,tmp1p,tmp1d,tmp2p,tmp2d,tmp3p,tmp3d,tmp4,tmp5p,tmp5d; - - Lal::let(tmp,'=',inputData.b,'.',currentPt.yVec); - tmp1p = - tmp; - printf("Primal: %9.1e",tmp1p); - Lal::let(tmp,'=',currentRes.dualMat,'.',currentPt.xMat); - tmp2p = -tmp; - printf(" + %9.1e",tmp2p); - tmp3p = tmp1p + tmp2p; - printf(" = %9.1e",tmp3p); - printf(", residual:%-9.1e",currentRes.normDualMat); - tmp5p = currentRes.computeMaxNorm(currentPt.zMat); - printf(" norm:%-9.1e\n",tmp5p); - - Lal::let(tmp,'=',inputData.C,'.',currentPt.xMat); - tmp1d = - tmp; - printf("Dual: %9.1e",tmp1d); - Lal::let(tmp,'=',currentRes.primalVec,'.',currentPt.yVec); - tmp2d = -tmp; - printf(" + %9.1e",tmp2d); - tmp3d = tmp1d + tmp2d; - printf(" = %9.1e",tmp3d); - printf(", residual:%-9.1e", currentRes.normPrimalVec); - tmp5d = currentRes.computeMaxNorm(currentPt.xMat); - printf(" norm:%-9.1e\n",tmp5d); - - tmp4 = tmp1p - tmp1d; - printf("P-D: %9.1e",tmp4); - tmp4 = tmp3p - tmp3d; - printf(" %9.1e",tmp4); - tmp4 = mu.current * currentPt.nDim; - printf(", mu * n:%-9.1e\n",tmp4); - - #endif -} - - -void SolveInfo::display(FILE* fpout) -{ - if (fpout == NULL) { - return; - } - - fprintf(fpout,"rSolveInfo.rho = %8.3e\n",rho); - fprintf(fpout,"rSolveInfo.etaPrimal = %8.3e\n",etaPrimal); - fprintf(fpout,"rSolveInfo.etaDual = %8.3e\n",etaDual); - fprintf(fpout,"rSolveInfo.objValPrimal = %8.3e\n",objValPrimal); - fprintf(fpout,"rSolveInfo.objValDual = %8.3e\n",objValDual); -} - -// ---------------------------------------------------- - -Phase::Phase() -{ - nDim = 0; - value = SolveInfo::noINFO; -} - -Phase::~Phase() -{ - // Nothing needs. -} - -bool Phase::initialize(Residuals& currentRes, - SolveInfo& solveInfo, - Parameter& param, int nDim) -{ - this->nDim = nDim; - return updateCheck(currentRes, solveInfo, param); -} - -bool Phase::updateCheck(Residuals& currentRes, - SolveInfo& solveInfo, - Parameter& param) -{ - const double NONZERO = 1.0e-6; - double accuracy = param.epsilonDash; - value = SolveInfo::noINFO; - - if (currentRes.normPrimal <= accuracy) { - if (currentRes.normDual <= accuracy) { - value = SolveInfo::pdFEAS; - } else { - value = SolveInfo::pFEAS; - } - } - if (value==SolveInfo::noINFO - && currentRes.normDual <= accuracy) { - value = SolveInfo::dFEAS; - } - if (value==SolveInfo::pdFEAS) { - double mean = (fabs(solveInfo.objValPrimal)+ - fabs(solveInfo.objValDual)) / 2.0; - double PDgap = fabs(solveInfo.objValPrimal - solveInfo.objValDual); - - double dominator; - if (mean < 1.0) { - dominator = 1.0; - } else { - dominator = mean; - } - #if 0 - rMessage("PDgap = " << PDgap); - rMessage("dominator = " << dominator); - rMessage("PDgap/dominator = " << PDgap/dominator); - #endif - if (PDgap/dominator <= param.epsilonStar) { - value = SolveInfo::pdOPT; - return false; - } - } - if (value == SolveInfo::noINFO - && solveInfo.rho > 1.0+NONZERO) { - rMessage("pdINF criteria"); - value = SolveInfo::pdINF; - return false; - } - if (value == SolveInfo::pFEAS) { - #if REVERSE_PRIMAL_DUAL - if (solveInfo.objValPrimal<=-param.upperBound) { - rMessage("pUNBD criteria"); - value = SolveInfo::pUNBD; - return false; - } - #else - if (solveInfo.objValPrimal<=param.lowerBound) { - rMessage("pdINF criteria"); - value = SolveInfo::pUNBD; - return false; - } - #endif - if (solveInfo.rho > 1.0+NONZERO) { - rMessage("pFEAS_dINF criteria"); - value = SolveInfo::pFEAS_dINF; - return false; - } - } - - if (value == SolveInfo::dFEAS) { - #if REVERSE_PRIMAL_DUAL - if (solveInfo.objValDual>=-param.lowerBound) { - rMessage("dUNBD criteria"); - value = SolveInfo::dUNBD; - return false; - } - #else - if (solveInfo.objValDual>=param.upperBound) { - rMessage("dUNBD criteria"); - value = SolveInfo::dUNBD; - return false; - } - #endif - if (solveInfo.rho > 1.0+NONZERO) { - rMessage("pINF_dFEAD criteria"); - value = SolveInfo::pINF_dFEAS; - return false; - } - } - #if 0 - rMessage("phase ="); - display(); - #endif - return true; -} - -void Phase::reverse() -{ - #if REVERSE_PRIMAL_DUAL - switch (value) { - case SolveInfo::noINFO : ; break; - case SolveInfo::pFEAS : value = SolveInfo::dFEAS ; break; - case SolveInfo::dFEAS : value = SolveInfo::pFEAS ; break; - case SolveInfo::pdFEAS : ; break; - case SolveInfo::pdINF : ; break; - case SolveInfo::pFEAS_dINF: value = SolveInfo::pINF_dFEAS; break; - case SolveInfo::pINF_dFEAS: value = SolveInfo::pFEAS_dINF; break; - case SolveInfo::pdOPT : ; break; - case SolveInfo::pUNBD : value = SolveInfo::dUNBD ; break; - case SolveInfo::dUNBD : value = SolveInfo::pUNBD ; break; - default: break; - } - #else - // do nothing - #endif -} - - -void Phase::display(FILE* fpout) -{ - if (fpout == NULL) { - return; - } - char* str; - switch (value) { - case SolveInfo::noINFO : str = (char *)"noINFO "; break; - case SolveInfo::pFEAS : str = (char *)"pFEAS "; break; - case SolveInfo::dFEAS : str = (char *)"dFEAS "; break; - case SolveInfo::pdFEAS : str = (char *)"pdFEAS "; break; - case SolveInfo::pdINF : str = (char *)"pdINF "; break; - case SolveInfo::pFEAS_dINF: str = (char *)"pFEAS_dINF"; break; - case SolveInfo::pINF_dFEAS: str = (char *)"pINF_dFEAS"; break; - case SolveInfo::pdOPT : str = (char *)"pdOPT "; break; - case SolveInfo::pUNBD : str = (char *)"pUNBD "; break; - case SolveInfo::dUNBD : str = (char *)"dUNBD "; break; - default: - str = (char *)"phase error"; - rMessage("rPhase:: phase error"); - break; - } - fprintf(fpout,"phase.value = %s\n",str); -} - -} // end of namespace 'sdpa' - diff --git a/external/sdpa/sdpa_parts.h b/external/sdpa/sdpa_parts.h deleted file mode 100644 index 6bd91f8..0000000 --- a/external/sdpa/sdpa_parts.h +++ /dev/null @@ -1,269 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ - -#ifndef __sdpa_parts_h__ -#define __sdpa_parts_h__ - -#include "sdpa_include.h" -#include "sdpa_dataset.h" - -namespace sdpa { - -class Newton; - -class Solutions; -class InputData; -class Residuals; - -class ComputeTime; -class Parameter; -class StepLength; -class DirectionParameter; -class Switch; -class RatioInitResCurrentRes; -class SolveInfo; -class Phase; -class AverageComplementarity; - - -class ComputeTime -{ -public: - double Predictor; - double Corrector; - double StepPredictor; - double StepCorrector; - double xMatTime; - double zMatTime; - double invzMatTime; - double xMatzMatTime; - double EigxMatTime; - double EigzMatTime; - double EigxMatzMatTime; - double makerMat; - double makebMat; - double B_DIAG; - double B_F1; - double B_F2; - double B_F3; - double B_PRE; - double makebMatgVec; - double choleskybMat; - double solve; - double sumDz; - double makedX; - double symmetriseDx; - double makedXdZ; - double updateRes; - double MainLoop; - double FileRead; - double FileCheck; - double FileChange; - double TotalTime; - ComputeTime(); - ~ComputeTime(); - void display(FILE* fpout=stdout); -}; - -class Parameter -{ -public: - enum parameterType {PARAMETER_DEFAULT, - PARAMETER_UNSTABLE_BUT_FAST, - PARAMETER_STABLE_BUT_SLOW}; - int maxIteration; - double epsilonStar; - double lambdaStar; - double omegaStar; - double lowerBound; - double upperBound; - double betaStar; - double betaBar; - double gammaStar; - double epsilonDash; - #define PRINT_DEFAULT_LENGTH 30 - static char xPRINT_DEFAULT[PRINT_DEFAULT_LENGTH]; - static char XPRINT_DEFAULT[PRINT_DEFAULT_LENGTH]; - static char YPRINT_DEFAULT[PRINT_DEFAULT_LENGTH]; - static char infPRINT_DEFAULT[PRINT_DEFAULT_LENGTH]; - char xPrint[PRINT_DEFAULT_LENGTH]; - char XPrint[PRINT_DEFAULT_LENGTH]; - char YPrint[PRINT_DEFAULT_LENGTH]; - char infPrint[PRINT_DEFAULT_LENGTH]; - Parameter(); - Parameter(FILE* parameterFile); - ~Parameter(); - void setDefaultParameter(parameterType type - = PARAMETER_DEFAULT); - void readFile(FILE* parameterFile); - void display(FILE* fpout=stdout, char* printFormat=infPRINT_DEFAULT); -}; - -class StepLength -{ -public: - - double primal; - double dual; - StepLength(); - StepLength(double alphaP, double alphaD, int nBlock, - int* blockStruct); - ~StepLength(); - void initialize(double alphaP, double alphaD); - void finalize(); - - static double minBlockVector(BlockVector& aVec); - - void computeStepLength(Solutions& currentPt, - ComputeTime& com); - void MehrotraPredictor(InputData& inputData, - Solutions& currentPt, - Phase& phase, - Switch& reduction, - AverageComplementarity& mu, - RatioInitResCurrentRes& theta, - Parameter& param, - ComputeTime& com); - void Centering(Solutions& currentPt, - Parameter& param, - ComputeTime& com); - void display(FILE* fpout = stdout); -}; - -class DirectionParameter -{ -public: - double value; - DirectionParameter(double betaStar=0.0); - ~DirectionParameter(); - void initialize(double betaStar=0.0); - - void Predictor(Phase& phase, Switch& reduction, - Parameter& param); - void Centering(); - void MehrotraCorrector(Phase& phase, StepLength& alpha, - Solutions& currentPt, - AverageComplementarity& mu, - Parameter& param); - void display(FILE* fpout = stdout); -}; - -class Switch -{ -public: - enum SwitchType {CENTERING,AFFINE}; // {ON,OFF} - SwitchType switchType; - - Switch(SwitchType switchType=CENTERING); - ~Switch(); - void initialize(SwitchType switchType=CENTERING); - - void MehrotraPredictor(Phase& phase); - void display(FILE* fpout = stdout); - -}; - -class AverageComplementarity -{ -public: - double initial; - double current; - AverageComplementarity(double lambdaStar = 0.0); - ~AverageComplementarity(); - void initialize(double lambdaStar = 0.0); - void update(Solutions& currentPt); - void display(FILE* fpout = stdout); -}; - -class RatioInitResCurrentRes -{ -public: - double primal; - double dual; - - RatioInitResCurrentRes(); - ~RatioInitResCurrentRes(); - - void initialize(Parameter& param, Residuals& currentRes); - - void update(Switch& reduction, StepLength& alpha); - void update_exact(Residuals& currentRes, Parameter& param); - void display(FILE* fpout = stdout); -}; - -class SolveInfo -{ -public: - enum phaseType { noINFO,pFEAS,dFEAS,pdFEAS,pdINF,pFEAS_dINF, - pINF_dFEAS,pdOPT,pUNBD,dUNBD}; - - double rho; - double etaPrimal; - double etaDual; - double objValPrimal; - double objValDual; - - SolveInfo(); - SolveInfo(InputData& inputData, Solutions& currentPt, - double mu0, double omegaStar); - ~SolveInfo(); - - void initialize(InputData& inputData, Solutions& currentPt, - double mu0, double omegaStar); - - void update(InputData& inputData, - Solutions& currentPt, - Residuals& currentRes, - AverageComplementarity& mu, - RatioInitResCurrentRes& theta, - Parameter& param); - // check mu, gap, feasibility 2007/09/13 - void check(InputData& inputData, - Solutions& currentPt, - Residuals& currentRes, - AverageComplementarity& mu, - RatioInitResCurrentRes& theta, - Parameter& param); - void display(FILE* fpout = stdout); -}; - -class Phase -{ -public: - int nDim; - SolveInfo::phaseType value; - - Phase(); - ~Phase(); - - bool initialize(Residuals& currentRes, - SolveInfo& solveInfo, - Parameter& param, int nDim); - bool updateCheck(Residuals& currentRes, - SolveInfo& solveInfo, - Parameter& param); - void reverse(); - void display(FILE* fpout = stdout); -}; - -} // end of namespace 'sdpa' - -#endif // __sdpa_parts_h__ diff --git a/external/sdpa/sdpa_right.h b/external/sdpa/sdpa_right.h deleted file mode 100644 index bf1ccd0..0000000 --- a/external/sdpa/sdpa_right.h +++ /dev/null @@ -1,45 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ -/*-------------------------------------------------- - sdpa_right.h ---------------------------------------------------*/ - -#ifndef __sdpa_right_h__ -#define __sdpa_right_h__ - -/*------------------------------------------ - Version Code Name - - SDPA 6 : Rosemary/2003Aug - SDPA 7 : Margaret/2008Feb - -------------------------------------------*/ - -static const char sdpa_right[] = - "SDPA7 (Margaret/since 2008Feb) has been developed by SDPA Project."; -#ifdef VERSION -// VERSION is set by configure script -static const char sdpa_version[] = VERSION; -#else -// static const char sdpa_version[] = "7"; -#endif - -#endif // __sdpa_right_h__ diff --git a/external/sdpa/sdpa_solve.cpp b/external/sdpa/sdpa_solve.cpp deleted file mode 100644 index a9c9ce8..0000000 --- a/external/sdpa/sdpa_solve.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ -/*-------------------------------------------------- - sdpa_solve.cpp ---------------------------------------------------*/ - -#include "sdpa_call.h" -#include "sdpa_linear.h" -#include "sdpa_io.h" -using namespace sdpa; - -void SDPA::initializeSolve() -{ - TimeStart(FILE_CHANGE_START1); - TimeEnd(FILE_CHANGE_END1); - com.FileChange += TimeCal(FILE_CHANGE_START1, - FILE_CHANGE_END1); - com.TotalTime += TimeCal(FILE_CHANGE_START1, - FILE_CHANGE_END1); - inputData.initialize_index(); - // rMessage("inputData = "); inputData.display(); - currentPt.initialize(m, bs); - currentPt.makeCliques(bs, inputData); - // rMessage("order = "); currentPt.order.display(); - currentPt.order.displayStatistics(Display, currentPt.cholmodSpace); - currentPt.order.displayStatistics(fpout, currentPt.cholmodSpace); - currentPt.setInitialPoint(bs, param.lambdaStar); - inputData.assignAgg(currentPt.cholmodSpace); - inputData.assignBlockIndex(currentPt.order); - currentPt.cholmodSpace.assignBlockIndex(currentPt.order); - // rMessage("currentPt.initial = "); currentPt.display(); - newton.initialize(m,bs); - int nBlock2 = bs.SDP_nBlock + bs.LP_nBlock; - chordal.initialize(&newton.sparse_bMat); - chordal.ordering_bMat(m, nBlock2, inputData, Display, fpout); - newton.initialize_bMat(m, chordal, inputData, Display, fpout); - - mu.initialize(param.lambdaStar); - TimeStart(UPDATE_START); - currentPt.cholmodSpace.computeResiduals(inputData, currentPt.order); - TimeEnd(UPDATE_END); - com.updateRes += TimeCal(UPDATE_START,UPDATE_END); - // currentPt.cholmodSpace.display(); - // inputData.display(); - currentRes.initialize(); - currentRes.update(currentPt.cholmodSpace); - currentRes.copyToInit(); - // rMessage("currentRes = "); currentRes.display(); - beta.initialize(param.betaStar); - theta.initialize(param, currentRes); - solveInfo.initialize(inputData, currentPt, mu.initial, - param.omegaStar); - phase.initialize(currentRes, solveInfo, param, currentPt.nDim); - // writeInputSparse((char*)"tmp.dat-s",(char*)"%+8.3e"); -} - -void SDPA::solve() -{ - pIteration = 0; - TimeStart(MAIN_LOOP_START1); - IO::printHeader(fpout,Display); - while (phase.updateCheck(currentRes, solveInfo, param) - && pIteration < param.maxIteration) { - // Mehrotra's Predictor - TimeEnd(THIS_ITERATION_TIME); - #if 0 - rMessage("++ " << pIteration << " turn ++ with " - << TimeCal(MAIN_LOOP_START1, THIS_ITERATION_TIME) - << " seconds in main loop"); - #endif - - TimeStart(MEHROTRA_PREDICTOR_START1); - // set variable of Mehrotra - reduction.MehrotraPredictor(phase); - beta.Predictor(phase, reduction, param); - // rMessage("reduction = "); reduction.display(); - // rMessage("phase = "); phase.display(); - // rMessage("beta.predictor.value = " << beta.value); - // rMessage(" mu = " << mu.current); - // rMessage("currentPt = "); currentPt.display(); - // rMessage("currentRes = "); currentRes.display(); - // inputData.display(); - - bool isSuccessCholesky; - isSuccessCholesky = newton.Mehrotra(Newton::PREDICTOR, - m, inputData, chordal, - currentPt, currentRes, - mu, beta, reduction, - phase, com, - Display, fpout); - if (isSuccessCholesky == false) { - break; - } - #if 0 - newton.checkDirection(m, inputData, currentPt, currentRes, - mu, beta, reduction, phase, com, Display, fpout); - #endif - // rMessage("order = "); currentPt.order.display(); - // rMessage("currentPt.cholmodSpace = "); currentPt.cholmodSpace.display(); - - TimeEnd(MEHROTRA_PREDICTOR_END1); - com.Predictor += TimeCal(MEHROTRA_PREDICTOR_START1, - MEHROTRA_PREDICTOR_END1); - - TimeStart(STEP_PRE_START1); - - alpha.MehrotraPredictor(inputData, currentPt, phase, reduction, - mu, theta, param, com); - // rMessage("alpha predictor = "); alpha.display(); - - TimeStart(STEP_PRE_END1); - com.StepPredictor += TimeCal(STEP_PRE_START1,STEP_PRE_END1); - - // rMessage("alphaStar = " << param.alphaStar); - IO::printOneIteration(pIteration, mu, theta, solveInfo, - alpha, beta, fpout, Display); - - if (currentPt.update(alpha,com)==false) { - // if step length is too short, - // we finish algorithm - rMessage("cannot move"); - pIteration++; - break; - } - // rMessage("currentPt = "); - // currentPt.display(); - - // rMessage("updated"); - const double old_mu = mu.current; - theta.update(reduction,alpha); - // rMessage("theta = "); theta.display(); - // rMessage("Before mu update"); - mu.update(currentPt); - // rMessage("mu = "); mu.display(); - currentPt.cholmodSpace.computeResiduals(inputData, currentPt.order); - currentRes.update(currentPt.cholmodSpace); - // rMessage("currentPt = "); currentPt.display(); - theta.update_exact(currentRes, param); - // rMessage("theta.exact = "); theta.display(); - solveInfo.update(inputData, currentPt, currentRes, mu, theta, param); - - // printDimacsEasy(); - pIteration++; - // rMessage("currentPt = "); currentPt.display(); - // rMessage("No Centering"); continue; - // Centering - if ((alpha.primal < 0.3) - ||(alpha.dual < 0.3) - ||((phase.value == SolveInfo::pdFEAS) - &&(old_mu * 0.5 < mu.current))) { - - TimeStart(CORRECTOR_START1); - reduction.MehrotraPredictor(phase); - #if 1 - beta.Centering(); - #else - beta.MehrotraCorrector(phase, alpha, currentPt, mu, param); - rMessage("beta = "); beta.display(); - #endif - isSuccessCholesky = newton.Mehrotra(Newton::PREDICTOR, - m, inputData, chordal, - currentPt, currentRes, - mu, beta, reduction, - phase, com, - Display, fpout); - if (isSuccessCholesky == false) { - break; - } - TimeEnd(CORRECTOR_END1); - com.Corrector += TimeCal(CORRECTOR_START1, CORRECTOR_END1); - TimeStart(CORRECTOR_STEP_START1); - #if 0 - newton.checkDirection(m, inputData, currentPt, currentRes, - mu, beta, reduction, phase, com, Display, fpout); - #endif - alpha.Centering(currentPt, param, com); - TimeEnd(CORRECTOR_STEP_END1); - com.StepCorrector += TimeCal(CORRECTOR_STEP_START1, - CORRECTOR_STEP_END1); - - IO::printOneIteration(pIteration, mu, theta, solveInfo, - alpha, beta, fpout, Display); - - if (currentPt.update(alpha,com)==false) { - // if step length is too short, - // we finish algorithm - rMessage("cannot move"); - pIteration++; - break; - } - - theta.update(reduction,alpha); - mu.update(currentPt); - currentPt.cholmodSpace.computeResiduals(inputData, currentPt.order); - currentRes.update(currentPt.cholmodSpace); - theta.update_exact(currentRes, param); - solveInfo.update(inputData, currentPt, currentRes, mu, theta, param); - // printDimacsEasy(); - pIteration++; - } - } // end of MAIN_LOOP - - if (pIteration == param.maxIteration) { - rMessage("maxIteration is reached"); - } - TimeEnd(MAIN_LOOP_END1); - - com.MainLoop = TimeCal(MAIN_LOOP_START1, - MAIN_LOOP_END1); - com.TotalTime += com.MainLoop; - currentRes.update(currentPt.cholmodSpace); -#if REVERSE_PRIMAL_DUAL - Lal::let(currentPt.cholmodSpace.yVec, - '=',currentPt.cholmodSpace.yVec,'*',&DMONE); - phase.reverse(); -#endif - IO::printLastInfo(pIteration, mu, theta, solveInfo, alpha, beta, - currentRes, phase, currentPt, - inputData, com.TotalTime, com, - param, fpout, Display); - bool Xmake = IO::judgeXmake(param); - bool Zmake = IO::judgeZmake(param); - currentPt.makeFinalSolution(Xmake, Zmake, bs); - IO::printSolution(bs, currentPt, param, fpout, Xmake, Zmake); - // com.display(fpout); - - if (Display) { - fprintf(Display, " main loop time = %.6f\n",com.MainLoop); - fprintf(Display, " total time = %.6f\n",com.TotalTime); - fprintf(Display, "file check time = %.6f\n",com.FileCheck); - fprintf(Display, "file change time = %.6f\n",com.FileChange); - fprintf(Display, "file read time = %.6f\n",com.FileRead); - } - if (fpout) { - fprintf(fpout, " main loop time = %.6f\n",com.MainLoop); - fprintf(fpout, " total time = %.6f\n",com.TotalTime); - fprintf(fpout, " file check time = %.6f\n",com.FileCheck); - fprintf(fpout, " file change time = %.6f\n",com.FileChange); - fprintf(fpout, " file read time = %.6f\n",com.FileRead); - } -} diff --git a/external/sdpa/sdpa_struct.cpp b/external/sdpa/sdpa_struct.cpp deleted file mode 100644 index 0e1d13f..0000000 --- a/external/sdpa/sdpa_struct.cpp +++ /dev/null @@ -1,3642 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ - -#include "sdpa_struct.h" -#include "sdpa_algebra.h" -#include "sdpa_linear.h" -#include "sdpa_dataset.h" - -#include - -namespace sdpa{ - -Vector::Vector() -{ - initialize(); -} - -Vector::Vector(int nDim, double value) -{ - initialize(); - initialize(nDim,value); -} - -Vector::~Vector() -{ - finalize(); -} - -void Vector::initialize() -{ - nDim = 0; - ele = NULL; -} - -void Vector::initialize(int nDim, double value) -{ - // rMessage("Vector initialize"); - if (nDim<=0) { - rError("Vector:: nDim is nonpositive"); - } - - if (this->nDim!=nDim && ele != NULL) { - DeleteArray(ele); - } - this->nDim = nDim; - if (ele == NULL) { - NewArray(ele,double,nDim); - } - sdpa_dset(nDim,value,ele,IONE); -} - -void Vector::initialize(double value) -{ - if (ele==NULL) { - NewArray(ele,double,nDim); - } - sdpa_dset(nDim,value,ele,IONE); -} - -void Vector::finalize() -{ - DeleteArray(ele); -} - -void Vector::setZero() -{ - initialize(0.0); -} - -void Vector::display(FILE* fpout, char* printFormat) -{ - if (fpout == NULL) { - return; - } - if (strcmp(printFormat,NO_P_FORMAT) == 0) { - fprintf(fpout,"%s\n",NO_P_FORMAT); - return; - } - fprintf(fpout,"{"); - for (int j=0; j0) { - fprintf(fpout,printFormat,ele[nDim-1]); - fprintf(fpout,"}\n"); - } else { - fprintf(fpout," }\n"); - } -} - -void Vector::display(FILE* fpout,double scalar, char* printFormat) -{ - if (fpout == NULL) { - return; - } - if (strcmp(printFormat,NO_P_FORMAT) == 0) { - fprintf(fpout,"%s\n",NO_P_FORMAT); - return; - } - fprintf(fpout,"{"); - for (int j=0; j0) { - fprintf(fpout,printFormat,ele[nDim-1]*scalar); - fprintf(fpout,"}\n"); - } else { - fprintf(fpout," }\n"); - } -} - -bool Vector::copyFrom(Vector& other) -{ - if (this == &other) { - return SDPA_SUCCESS; - } - if (other.nDim<=0) { - rError("Vector:: nDim is nonpositive"); - } - if (nDim != other.nDim) { - DeleteArray(ele); - } - nDim = other.nDim; - if (ele==NULL) { - NewArray(ele,double,nDim); - } - dcopy_fc(&nDim,other.ele,&IONE,ele,&IONE); - return SDPA_SUCCESS; -} - -BlockVector::BlockVector() -{ - nBlock = 0; - blockStruct = NULL; - ele = NULL; -} - -BlockVector::BlockVector(BlockStruct& bs, double value) -{ - initialize(bs.SDP_nBlock,bs.SDP_blockStruct,value); -} - -BlockVector::BlockVector(int nBlock, int* blockStruct, - double value) -{ - initialize(nBlock,blockStruct,value); -} - -BlockVector::~BlockVector() -{ - finalize(); -} - -void BlockVector::initialize(BlockStruct& bs, double value) -{ - initialize(bs.SDP_nBlock,bs.SDP_blockStruct,value); -} - -void BlockVector::initialize(int nBlock, int* blockStruct, - double value) -{ - // rMessage("BlockVector initialize"); - if (nBlock<=0) { - rError("BlockVector:: nBlock is nonpositive"); - } - this->nBlock = nBlock; - NewArray(this->blockStruct,int,nBlock); - for (int l=0; lblockStruct[l] = blockStruct[l]; - } - - NewArray(ele,Vector,nBlock); - for (int l=0; l0 && blockStruct && ele) { - for (int l=0; l=0) { - for (int l=0; l0 && blockStruct && ele) { - for (int l=0; l0 && blockStruct && ele) { - for (int l=0; lnRow = nRow; - this->nCol = nCol; - this->type = type; - this->DataStruct = DataStruct; - - int length; - switch(type) { - case SPARSE: - this->NonZeroNumber = NonZeroNumber; - this->NonZeroCount = 0; - this->NonZeroEffect = 0; - if (NonZeroNumber > 0) { - if (DataStruct == DSarrays) { - NewArray(row_index,int,NonZeroNumber); - NewArray(column_index,int,NonZeroNumber); - NewArray(sp_ele,double,NonZeroNumber); - if (row_index==NULL || column_index==NULL - || sp_ele==NULL) { - rError("SparseMatrix:: memory exhausted"); - } - } - else { - NewArray(DataS, SparseElement, NonZeroNumber); - if (DataS == NULL) { - rError("SparseElement:: memory exhausted"); - } - } - } - break; - case DENSE: - this->NonZeroNumber = nRow*nCol; - this->NonZeroCount = nRow*nCol; - this->NonZeroEffect = nRow*nCol; - NewArray(de_ele,double,NonZeroNumber); - if (de_ele==NULL) { - rError("SparseMatrix:: memory exhausted"); - } - length = nRow*nCol; - sdpa_dset(length,DZERO,de_ele,IONE); - // all elements are 0. - break; - } -} - -void SparseMatrix::finalize() -{ - DeleteArray(de_ele); - if (DataStruct == DSarrays) { - DeleteArray(row_index); - DeleteArray(column_index); - DeleteArray(sp_ele); - } - else { - DeleteArray(DataS); - } -} - -void SparseMatrix::display(FILE* fpout, char* printFormat) -{ - int i, j; - double value; - if (fpout == NULL) { - return; - } - if (strcmp(printFormat,NO_P_FORMAT) == 0) { - fprintf(fpout,"%s\n",NO_P_FORMAT); - return; - } - switch(type) { - case SPARSE: - fprintf(fpout,"{"); - for (int index=0; index1) { - fprintf(fpout," {"); - } - for (int j=0; j1) { - fprintf(fpout," }\n"); - } else { - fprintf(fpout,"\n"); - } - break; - } -} - -bool SparseMatrix::copyFrom(SparseMatrix& other) -{ - if (type != other.type || nRow != other.nRow - || nCol != other.nCol) { - this->~SparseMatrix(); - initialize(other.nRow,other.nCol,other.type, - NonZeroNumber); - NonZeroCount = other.NonZeroCount; - NonZeroEffect = other.NonZeroEffect; - int length; - switch(type) { - case SPARSE: - for (int index = 0; index NonZeroNumber) { - rError("SparseMatrix:: cannot store over NonZeroNumber"); - // the number of Diagonal elements equals nCol. - } - NonZeroCount = nCol; - NonZeroEffect = nCol; - for (int index=0; index< NonZeroCount; ++index) { - #if DATA_CAPSULE - DataS[index].vRow = index; - DataS[index].vCol = index; - DataS[index].vEle = scalar; - #else - row_index[index] = index; - column_index[index] = index; - sp_ele[index] = scalar; - #endif - } - break; - case DENSE: - length = nRow*nCol; - sdpa_dset(length,DZERO,de_ele,IONE); - step = nCol+1; - sdpa_dset(nCol,scalar,de_ele,step); - // only diagonal elements are set the value of scalar. - break; - } -} - -bool SparseMatrix::sortSparseIndex(int& i, int& j) -{ - // if this matrix is not symmetric, - // return the index(i,j) whose values are not symmetric. - i = -1; - j = -1; - const double tolerance = 1.0e-8; - switch(type) { - case SPARSE: - // Make matrix as Upper Triangluar - for (int i1=0; i1tmpj) { - DataS[i1].vRow = tmpj; - DataS[i1].vCol = tmpi; - } -#else - int tmpi = row_index[i1]; - int tmpj = column_index[i1]; - if (tmpi>tmpj) { - row_index [i1] = tmpj; - column_index[i1] = tmpi; - } -#endif - } - // simple sort - for (int i1=0; i1 tolerance) { - // Here must not be symmetric - if (i<0 || j<0) { - i = DataS[i1].vRow; - j = DataS[i1].vCol; - } - } - // remove redudunt - for (int i2 = i1+1; i2 tolerance) { - // Here must not be symmetric - if (i<0 || j<0) { - i = row_index [i1]; - j = column_index[i1]; - } - } - // remove redudunt - for (int i2 = i1+1; i2 tolerance) { - return SDPA_FAILURE; - } - } - } - break; - } - return SDPA_SUCCESS; -} - -DenseMatrix::DenseMatrix() -{ - initialize(); -} - -void DenseMatrix::initialize() -{ - nRow = 0; - nCol = 0; - de_ele = NULL; -} - -DenseMatrix::~DenseMatrix() -{ - finalize(); -} - -void DenseMatrix::initialize(int nRow, int nCol) -{ - // rMessage("DenseMatrix::initialize"); - - DenseMatrix(); - if (nRow<=0 || nCol<=0) { - rError("DenseMatrix:: Dimensions are nonpositive"); - } - int old_length = this->nRow*this->nCol; - this->nRow = nRow; - this->nCol = nCol; - - int length; - length = nRow*nCol; - if (de_ele != NULL && old_length!=length) { - DeleteArray(de_ele); - } - if (de_ele==NULL) { - NewArray(de_ele,double,length); - } - sdpa_dset(length,DZERO,de_ele,IONE); -} - -void DenseMatrix::finalize() -{ - DeleteArray(de_ele); -} - -void DenseMatrix::display(FILE* fpout, char* printFormat) -{ - if (fpout == NULL) { - return; - } - fprintf(fpout,"{"); - for (int i=0; i1) { - fprintf(fpout," {"); - } - for (int j=0; j1) { - fprintf(fpout," }\n"); - } else { - fprintf(fpout,"\n"); - } -} - -bool DenseMatrix::copyFrom(SparseMatrix& other) -{ - int length; - switch(other.type) { - case SparseMatrix::SPARSE: - DeleteArray(de_ele); - nRow = other.nRow; - nCol = other.nCol; - NewArray(de_ele,double,nRow*nCol); - length = nRow*nCol; - sdpa_dset(length,DZERO,de_ele,IONE); - for (int index = 0; index 0){ - SDP_sp_nBlock++; - } - } - if (SDP_sp_nBlock > 0){ - NewArray(SDP_sp_index,int,SDP_sp_nBlock); - NewArray(SDP_sp_block,SparseMatrix,SDP_sp_nBlock); - } - counter = 0; - for (int l=0; l 0){ - SDP_sp_index[counter] = l; - int size = SDP_blockStruct[l]; - SDP_sp_block[counter].initialize(size,size,SparseMatrix::SPARSE, - SDP_NonZeroNumber[l]); - counter++; - } - } - - - // for SOCP -#if 0 - for (int l=0; l 0){ - SOCP_sp_nBlock++; - } - } - if (SOCP_sp_nBlock > 0){ - NewArray(SOCP_sp_index,int,SOCP_sp_nBLock); - NewArray(SOCP_sp_block,SparseMatrix,SOCP_sp_nBLock); - } - counter = 0; - for (int l=0; l 0){ - SOCP_sp_index[counter] = l; - int size = SOCP_blockStruct[l]; - SOCP_sp_block[counter].initialize(size,size,SparseMatrix::SPARSE, - SOCP_NonZeroNumber[l]); - counter++; - } - } -#endif - - // for LP - for (int l=0; l 0){ - NewArray(LP_sp_index,int,LP_sp_nBlock); - NewArray(LP_sp_block,double,LP_sp_nBlock); - } - counter = 0; - for (int l=0; lSDP_sp_nBlock = SDP_sp_nBlock; - if (SDP_sp_nBlock > 0){ - NewArray(this->SDP_sp_index,int,SDP_sp_nBlock); - NewArray(this->SDP_sp_block,SparseMatrix,SDP_sp_nBlock); - } - for (int l=0; lSDP_sp_index[l] = SDP_sp_index[l]; - int size = SDP_sp_blockStruct[l]; - SDP_sp_block[l].initialize(size,size,SparseMatrix::SPARSE, - SDP_sp_NonZeroNumber[l]); - } - - // for SOCP -#if 0 - this->SOCP_sp_nBlock = SOCP_sp_nBlock; - if (SOCP_sp_nBlock > 0){ - NewArray(this->SOCP_sp_index,int,SOCP_sp_nBlock); - NewArray(this->SOCP_sp_block,SparseMatrix,SOCP_sp_nBlock); - } - for (int l=0; lSOCP_sp_index[l] = SOCP_sp_index[l]; - int size = SOCP_sp_blockStruct[l]; - SOCP_sp_block[l].initialize(size,size,SparseMatrix::SPARSE, - SOCP_sp_NonZeroNumber[l]); - } -#endif - - // for LP - this->LP_sp_nBlock = LP_sp_nBlock; - if (LP_sp_nBlock > 0){ - NewArray(this->LP_sp_index,int,LP_sp_nBlock); - NewArray(this->LP_sp_block,double,LP_sp_nBlock); - } - for (int l=0; lLP_sp_index[l] = LP_sp_index[l]; - } -} - -void SparseLinearSpace::finalize() -{ - // for SDP - if (SDP_sp_block && SDP_sp_index && SDP_sp_nBlock>=0) { - for (int l=0; l=0) { - for (int l=0; l=0) { - DeleteArray(LP_sp_block); - DeleteArray(LP_sp_index); - } -} - -void SparseLinearSpace::changeToDense(bool forceChange) -{ - if (SDP_sp_nBlock>0 && SDP_sp_index && SDP_sp_block) { - for (int l=0; l0 && SOCP_sp_index && SOCP_sp_block) { - for (int l=0; l0 && SDP_sp_index && SDP_sp_block) { - fprintf(fpout,"SDP part{\n"); - for (int l=0; l0 && SOCP_sp_index && SOCP_sp_block) { - fprintf(fpout,"SOCP part{\n"); - for (int l=0; l0 && LP_sp_index && LP_sp_block) { - fprintf(fpout,"LP part{\n"); - for (int l=0; l 0 && SDP_sp_index==NULL ) { - NewArray(SDP_sp_index,int,SDP_sp_nBlock); - for (int l=0; l 0 && SDP_sp_block==NULL ) { - NewArray(SDP_sp_block,SparseMatrix,SDP_sp_nBlock); - } - total_judge = SDPA_SUCCESS; - for (int l=0; l 0 && SOCP_sp_index==NULL) { - NewArray(SOCP_sp_index,int,SOCP_sp_nBlock); - for (int l=0; l 0 && SOCP_sp_block==NULL) { - NewArray(SOCP_sp_block,SparseMatrix,SOCP_sp_nBlock); - } - total_judge = SDPA_SUCCESS; - for (int l=0; l 0 && LP_sp_index==NULL) { - NewArray(LP_sp_index,int,LP_sp_nBlock); - for (int l=0; l 0 && LP_sp_block==NULL) { - NewArray(LP_sp_block,double,LP_sp_nBlock); - } - total_judge = SDPA_SUCCESS; - for (int l=0; l= SDP_sp_block[l].NonZeroNumber){ - rError("SparseLinearSpace::setElement NonZeroCount >= NonZeroNumber"); - } - if ((i >= SDP_sp_block[l].nRow) || (j >= SDP_sp_block[l].nCol)){ - rError("out of range in input data"); - } - - // set element - int count = SDP_sp_block[l].NonZeroCount; - #if DATA_CAPSULE - SDP_sp_block[l].DataS[count].vRow = i; - SDP_sp_block[l].DataS[count].vCol = j; - SDP_sp_block[l].DataS[count].vEle = ele; - #else - SDP_sp_block[l].row_index[count] = i; - SDP_sp_block[l].column_index[count] = j; - SDP_sp_block[l].sp_ele[count] = ele; - #endif - SDP_sp_block[l].NonZeroCount++; - if (i==j){ - SDP_sp_block[l].NonZeroEffect++; - } else { - SDP_sp_block[l].NonZeroEffect += 2; - } - -} - -void SparseLinearSpace::setElement_SOCP(int block, int i, int j, - double ele) -{ - rError("DenseLinearSpace:: current version does not support SOCP"); -} - -void SparseLinearSpace::setElement_LP(int block, double ele) -{ - int l; - - for (l=0; l0 && SDP_sp_index && SDP_sp_block) { - for (int l=0; l0 && SOCP_sp_index && SOCP_sp_block) { - for (int l=0; l0 && LP_sp_index && LP_sp_block) { - for (int l=0; l0 && SDP_sp_index && SDP_sp_block) { - for (int l=0; l0 && SOCP_sp_index && SOCP_sp_block) { - for (int l=0; l0 && LP_sp_index && LP_sp_block) { - for (int l=0; l0 && SDP_sp_index && SDP_sp_block) { - for (int l_in=0; l_in0 && SOCP_sp_index && SOCP_sp_block) { - for (int l_in=0; l_inSDP_nBlock = bs.SDP_nBlock; - this->LP_nBlock = bs.LP_nBlock; - SDP_block = NULL; - LP_block = NULL; - // rMessage("DenseLinearSpace::initialize"); - if (SDP_nBlock + LP_nBlock <= 0) { - rError("DenseLinearSpace:: SDP + LP Block is nonpositive"); - } - - // for SDP - if (SDP_nBlock<0) { - rError("DenseLinearSpace:: SDP_nBlock is negative"); - } - if (SDP_nBlock > 0) { - NewArray(SDP_block,DenseMatrix,SDP_nBlock); - } - for (int l=0; l0) { - SDP_block[l].initialize(size,size); - } else { - rError("DenseLinearSpace:: SDP size is nonpositive"); - } - } - - // for LP - if (LP_nBlock<0) { - rError("DenseLinearSpace:: LP_nBlock is negative"); - } - if (LP_nBlock > 0) { - NewArray(LP_block,double,LP_nBlock); - } - for (int l=0; l0) { - for (int l=0; l0) { - for (int l=0; l0) { - DeleteArray(LP_block); - } -} - -void DenseLinearSpace::display(FILE* fpout, char* printFormat) -{ - if (fpout == NULL) { - return; - } - if (strcmp(printFormat,NO_P_FORMAT) == 0) { - fprintf(fpout,"%s\n",NO_P_FORMAT); - return; - } - if (SDP_nBlock>0 && SDP_block) { - fprintf(fpout,"SDP part{\n"); - for (int l=0; l0 && SOCP_block) { - fprintf(fpout,"SOCP part{\n"); - for (int l=0; l0 && LP_block) { - fprintf(fpout,"LP part{\n"); - for (int l=0; l 0) { - fprintf(fpout,printFormat,LP_block[start+size-1]); - fprintf(fpout,"}\n"); - } else { - fprintf(fpout," }\n"); - } - } else { - rError("io::displayDenseLinearSpaceLast not valid blockType"); - } - } - fprintf(fpout,"}\n"); -} - -bool DenseLinearSpace::copyFrom(DenseLinearSpace& other) -{ - if (this == &other) { - return SDPA_SUCCESS; - } - - if (other.SDP_nBlock+other.LP_nBlock<=0) { - rError("DenseLinearSpace:: SDP + LP Block is nonpositive"); - } - bool total_judge = SDPA_SUCCESS; - - // for SDP - if (other.SDP_nBlock<0) { - rError("DenseLinearSpace:: SDP_nBlock is negative"); - } - if (SDP_nBlock!=other.SDP_nBlock) { - DeleteArray(SDP_block); - } - SDP_nBlock = other.SDP_nBlock; - if (SDP_nBlock > 0 && SDP_block == NULL) { - NewArray(SDP_block,DenseMatrix,SDP_nBlock); - } - for (int l=0; l 0) && (LP_block == NULL)) { - LP_block = new double[LP_nBlock]; - if (LP_block==NULL) { - rError("DenseLinearSpace:: memory exhausted"); - } - } - for (int l=0; l= SDP_nBlock){ - rError("out of range in input data"); - } - if ((i >= SDP_block[block].nRow) || (j >= SDP_block[block].nCol)){ - rError("out of range in input data"); - } - - int nCol = SDP_block[block].nCol; - SDP_block[block].de_ele[i + j * nCol] = ele; - SDP_block[block].de_ele[j + i * nCol] = ele; -} - -void DenseLinearSpace::setElement_SOCP(int block, int i, int j, - double ele) -{ - rError("DenseLinearSpace:: current version does not support SOCP"); -} - -void DenseLinearSpace::setElement_LP(int block, double ele) -{ - // check range - if (block >= LP_nBlock){ - rError("out of range in input data"); - } - LP_block[block] = ele; -} - -void DenseLinearSpace::setZero() -{ - // for SDP - if (SDP_nBlock>0 && SDP_block) { - for (int l=0; l0 && LP_block) { - for (int l=0; l0 && SDP_block) { - for (int l=0; l0 && LP_block) { - for (int l=0; lsize(); - for (int index = 0; index < size; ++index) { - DeleteArray(inputVector->at(index)); - } - } - DeleteArray(inputVector); - nRow = 0; - nCol = 0; - nzColumn = 0; - NNZ = 0; - lowerNNZ = 0; - nzColumn_diag = 0; - nzColumn_nondiag = 0; -} - -CompMatrix::~CompMatrix() -{ - finalize(); -} - -void CompMatrix::initializeInputVector() -{ - NewArray(inputVector,vector,1); -} - -void CompMatrix::setElement(int i, int j, double v) -{ - CompMatrix::inputIJV* ele; - NewArray(ele, inputIJV, 1); - ele[0].i = i; - ele[0].j = j; - ele[0].v = v; - inputVector->push_back(ele); - - // both upper and lower triangular are assigned - if (i!=j) { - CompMatrix::inputIJV* ele2; - NewArray(ele2, inputIJV, 1); - ele2[0].i = j; - ele2[0].j = i; - ele2[0].v = v; - inputVector->push_back(ele2); - } -} - -void CompMatrix::sortInputVector() -{ - const int size = inputVector->size(); - - // to make sort easier, (i,j) information is wrapped into (i) - for (int index = 0; index < size; ++index) { - CompMatrix::inputIJV* ele = inputVector->at(index); - ele->i = ele->i + (ele->j)*nRow; - } - sort(inputVector->begin(), inputVector->end(), - CompMatrix::compareIJV); - for (int index = 0; index < size; ++index) { - CompMatrix::inputIJV* ele = inputVector->at(index); - ele->i = ele->i - (ele->j)*nRow; - } -} - -bool CompMatrix::compareIJV(CompMatrix::inputIJV* a, - CompMatrix::inputIJV* b) -{ - // sort by [i + j*nRow] (now this value is inserted in i) - // that is, sort by column-wise - if (a->i < b-> i) { - return true; - } - else if (a->i > b-> i){ - return false; - } - return false; // a==b -} - -void CompMatrix::checkInputDataStructure(int& i, int& j, double& v1, double& v2) -{ - // if correct, minus numbers are assigned to (i,j) - // otherwise, the index of duplicate values are assigned to (i,j) - i = -100; - j = -100; - v1 = 0.0; - v2 = 0.0; - - const int size = inputVector->size(); - if (size == 0) { - return; - } - CompMatrix::inputIJV* ele = inputVector->at(0); - for (int index = 1; index < size; ++index) { - CompMatrix::inputIJV* eleNext = inputVector->at(index); - #if 0 - printf("ele[%d] => i=%d, j=%d, v=%lf\n", - index-1, ele->i, ele->j, ele->v); - printf("eleNext[%d] => i=%d, j=%d, v=%lf\n", - index, eleNext->i, eleNext->j, eleNext->v); - #endif - if (ele->i == eleNext->i && ele->j == eleNext->j) { - i = ele->i; - j = ele->j; - v1 = ele->v; - v2 = eleNext->v; - return; - } - ele = eleNext; - } -} - -void CompMatrix::makeInternalStructure() -{ - // this routine should be called after checkInputVector - - NNZ = inputVector->size(); - // rMessage("NNZ = " << NNZ); - nzColumn = 0; - int oldColumn = -1; - for (int index = 0; index < NNZ; ++index) { - CompMatrix::inputIJV* ele1 = inputVector->at(index); - const int currentColumn = ele1->j; - if (currentColumn != oldColumn) { - nzColumn++; - oldColumn = currentColumn; - } - } - NewArray(column_index, int, nzColumn); - NewArray(column_start, int, nzColumn+1); - NewArray(diag_index, int, nzColumn); - NewArray(row_index, int, NNZ); - NewArray(agg_index, int, NNZ); - NewArray(blockNumber, int, NNZ); - NewArray(blockIndex, int, NNZ); - NewArray(ele, double, NNZ); - - for (int index1=0; index1 < nzColumn; ++index1) { - diag_index[index1] = -1; // -1 means "not assiged" - } - for (int index1=0; index1 < NNZ; ++index1) { - agg_index[index1] = -1; // -1 means "not assiged" - } - - column_start[nzColumn] = NNZ; - oldColumn = -1; - lowerNNZ = 0; - int columnIndex = -1; // this should be -1 precisely - for (int index1=0; index1 < NNZ; ++index1) { - CompMatrix::inputIJV* ele1 = inputVector->at(index1); - #if 0 - rMessage("i = " << ele1->i << ": j = " << ele1->j - << ": value = " << ele1->v); - #endif - const int currentColumn = ele1->j; - if (currentColumn != oldColumn) { - columnIndex++; - column_index[columnIndex] = currentColumn; - column_start[columnIndex] = index1; - oldColumn = currentColumn; - } - if (diag_index[columnIndex] == -1 && ele1->i >= ele1->j) { - diag_index[columnIndex] = index1; - } - if (diag_index[columnIndex] >= 0) { - lowerNNZ++; - } - row_index[index1] = ele1->i; - ele[index1] = ele1->v; - DeleteArray(ele1); - } - DeleteArray(inputVector); - effectiveNzColumn = nzColumn; - for (int ncol = 0; ncol < nzColumn; ++ncol) { - if (diag_index[ncol] == -1) { // only upper part - effectiveNzColumn--; - } - } - - nzColumn_diag = 0; - nzColumn_nondiag = 0; - for (int ncol = 0; ncol < nzColumn; ++ncol) { - if (diag_index[ncol] == -1) { - continue; - } - const int j = column_index[ncol]; - if (row_index[diag_index[ncol]] == j) { - nzColumn_diag++; - } - else { - nzColumn_nondiag++; - } - } - NewArray(column_diag_index, int, nzColumn_diag); - NewArray(column_nondiag_index, int, nzColumn_nondiag); - - nzColumn_diag = 0; - nzColumn_nondiag = 0; - for (int ncol = 0; ncol < nzColumn; ++ncol) { - if (diag_index[ncol] == -1) { - continue; - } - const int j = column_index[ncol]; - if (row_index[diag_index[ncol]] == j) { - column_diag_index[nzColumn_diag] = ncol; - nzColumn_diag++; - } - else { - column_nondiag_index[nzColumn_nondiag] = ncol; - nzColumn_nondiag++; - } - } -} - -void CompMatrix::assignAgg(CholmodMatrix& cholmodMatrix) -{ - cholmod_sparse* Z = cholmodMatrix.Z; - // agg_index in Aggregate-matrix is already computed in indexAgg - for (int ncol = 0; ncol < nzColumn; ++ncol) { - const int j = column_index[ncol]; - if (diag_index[ncol] < 0) { - continue; - } - // column_index of aggregate should contain all columns - const int agg_start = ((int*)Z->p)[j]; - const int agg_end = ((int*)Z->p)[j+1]; - int index2 = agg_start; - // only lower elements will have valid agg_index - for (int index1 = diag_index[ncol]; - index1 < column_start[ncol+1]; ++index1) { - const int i = row_index[index1]; - // Next 'while' must find target, - // because Aggregate must contain this information - while (i != ((int*)Z->i)[index2]) { - index2++; - } - agg_index[index1] = index2; - } - } -} - -void CompMatrix::assignBlockIndex(OrderingMatrix& order) -{ - for (int j_index = 0; j_index < nzColumn; ++j_index) { - int j = column_index[j_index]; - const int row_start = column_start[j_index]; - const int row_end = column_start[j_index+1]; - for (int i_index = row_start; i_index < row_end; ++i_index) { - const int i = row_index[i_index]; - order.getIndex(i,j,blockNumber[i_index],blockIndex[i_index]); - } - } -} - - -CompSpace::CompSpace() -{ - initialize(); -} - -CompSpace::~CompSpace() -{ - finalize(); -} - -void CompSpace::initialize() -{ - LP_sp_nBlock = 0; - SDP_sp_nBlock = 0; - LP_sp_index = NULL; - SDP_sp_index = NULL; - LP_sp_block = NULL; - SDP_sp_block = NULL; - NNZ = 0; - lowerNNZ = 0; -} - -void CompSpace::initialize(int LP_sp_nBlock, - int SDP_sp_nBlock) -{ - initialize(); - this->LP_sp_nBlock = LP_sp_nBlock; - this->SDP_sp_nBlock = SDP_sp_nBlock; - if (LP_sp_nBlock > 0) { - NewArray(this->LP_sp_index, int, LP_sp_nBlock); - NewArray(this->LP_sp_block, double, LP_sp_nBlock); - } - if (SDP_sp_nBlock > 0) { - NewArray(this->SDP_sp_index, int, SDP_sp_nBlock); - NewArray(this->SDP_sp_block, CompMatrix, SDP_sp_nBlock); - } -} - -void CompSpace::finalize() -{ - for (int index = 0; index < SDP_sp_nBlock; ++index) { - SDP_sp_block[index].finalize(); - } - DeleteArray(LP_sp_index); - DeleteArray(SDP_sp_index); - DeleteArray(LP_sp_block); - DeleteArray(SDP_sp_block); - - LP_sp_nBlock = 0; - SDP_sp_nBlock = 0; -} - -void CompSpace::display(FILE* fpout, char* printFormat) -{ - if (fpout == NULL) { - return; - } - - // fprintf(fpout, "Display start \n"); - fprintf(fpout, "== LP block== LP_sp_nBlock = %d\n", LP_sp_nBlock); - for (int index1=0; index1 < LP_sp_nBlock; ++index1) { - fprintf(fpout, "[%d,%d] = ", LP_sp_index[index1], LP_sp_index[index1]); - fprintf(fpout, printFormat, LP_sp_block[index1]); - fprintf(fpout, "\n"); - } - fprintf(fpout, "==SDP block== SDP_sp_nBlock = %d\n", SDP_sp_nBlock); - for (int index1=0; index1 < SDP_sp_nBlock; ++index1) { - fprintf(fpout, "-- %d-th(%d-th in full) block --\n", - index1, SDP_sp_index[index1]); - SDP_sp_block[index1].display(fpout, printFormat); - } - // fprintf(fpout, "Display end \n"); -} - -void CompSpace::initializeInputVector() -{ - for (int index=0; index < SDP_sp_nBlock; ++index) { - SDP_sp_block[index].initializeInputVector(); - } -} - -void CompSpace::setElement_LP(int i, double v) -{ - int index = 0; - for (index=0; index < LP_sp_nBlock; ++index) { - if (i == LP_sp_index[index]) { - break; - } - } - if (index == LP_sp_nBlock) { - rError("Out of LP_sp_nBlock :: code bug"); - } - LP_sp_block[index] = v; -} - -void CompSpace::setElement_SDP(int l, int i, int j, double v) -{ - int index1 = 0; - for (index1=0; index1 < SDP_sp_nBlock; ++index1) { - if (l == SDP_sp_index[index1]) { - break; - } - } - if (index1 == SDP_sp_nBlock) { - rError("Out of SDP_sp_nBlock :: code bug"); - } - SDP_sp_block[index1].setElement(i,j,v); -} - -void CompSpace::sortInputVector() -{ - for (int l=0; l < SDP_sp_nBlock; ++l) { - SDP_sp_block[l].sortInputVector(); - } -} - -void CompSpace::makeInternalStructure() -{ - NNZ = LP_sp_nBlock; - lowerNNZ = LP_sp_nBlock; - for (int l=0; l < SDP_sp_nBlock; ++l) { - SDP_sp_block[l].makeInternalStructure(); - NNZ += SDP_sp_block[l].NNZ; - lowerNNZ += SDP_sp_block[l].lowerNNZ; - } -} - - -void CompSpace::checkInputDataStructure(int& l, int& i, int& j, - double& v1, double& v2) -{ - for (l=0; l=0) { - // found error - l = SDP_sp_index[l]; - return; - } - } - l = -100; // to indicate correctness, l is set to minus -} - -void CompSpace::assignAgg(CholmodSpace& Aggregate) -{ - for (int l=0; lnBlock = nBlock; - NewArray(this->blockStruct, int, nBlock); - NewArray(ele, DenseMatrix, nBlock); - for (int index1=0; index1 < nBlock; ++index1) { - this->blockStruct[index1] = blockStruct[index1]; - ele[index1].initialize(blockStruct[index1], blockStruct[index1]); - } -} - -void CliqueMatrix::finalize() -{ - if (nBlock > 0) { - DeleteArray(blockStruct); - for (int index = 0; index < nBlock; ++index) { - ele[index].finalize(); - } - DeleteArray(ele); - } -} - -void CliqueMatrix::display(FILE* fpout, char* printFormat) -{ - if (fpout == NULL) { - return; - } - - fprintf(fpout, "CliqueMatrix::display nBlock = %d\n", nBlock); - for (int index = 0; index < nBlock; ++index) { - fprintf(fpout, "%d-th block\n", index); - ele[index].display(fpout, printFormat); - } - fprintf(fpout, "CliqueMatrix::display end \n", nBlock); -} - -void CliqueMatrix::setZero() -{ - for (int index = 0; index < nBlock; ++index) { - ele[index].setZero(); - } -} - -void CliqueMatrix::setIdentity(double scalar) -{ - for (int index1 = 0; index1 < nBlock; ++index1) { - ele[index1].setIdentity(scalar); - } -} - - -CliqueSpace::CliqueSpace() -{ - initialize(); -} - -CliqueSpace::~CliqueSpace() -{ - finalize(); -} - -void CliqueSpace::initialize() -{ - LP_nBlock = 0; - SDP_nBlock = 0; - LP_block = NULL; - SDP_block = NULL; -} - -void CliqueSpace::initialize(BlockStruct& bs, - OrderingSpace& order) -{ - int LP_nBlock = bs.LP_nBlock; - int SDP_nBlock = bs.SDP_nBlock; - this->LP_nBlock = LP_nBlock; - this->SDP_nBlock = SDP_nBlock; - NewArray(LP_block, double, LP_nBlock); - NewArray(SDP_block, CliqueMatrix, SDP_nBlock); - for (int l=0; lSDP_block[l].initialize(orderMatrix.nClique, - orderMatrix.cliqueSize); - } -} - -void CliqueSpace::finalize() -{ - if (LP_nBlock > 0) { - DeleteArray(LP_block); - LP_nBlock = 0; - } - if (SDP_nBlock > 0) { - for (int index = 0; index < SDP_nBlock; ++index) { - SDP_block[index].finalize(); - } - DeleteArray(SDP_block); - SDP_nBlock = 0; - } -} - -void CliqueSpace::display(FILE* fpout, char* printFormat) -{ - if (fpout == NULL) { - return; - } - fprintf(fpout, "== LP Part, LP_nBlock = %d ==\n", LP_nBlock); - for (int index=0; index < LP_nBlock; ++index) { - fprintf(fpout, printFormat, LP_block[index]); - } - fprintf(fpout, "== SDP Part, SDP_nBlock = %d ==\n", SDP_nBlock); - for (int index=0; index < SDP_nBlock; ++index) { - SDP_block[index].display(fpout, printFormat); - } -} - -void CliqueSpace::setZero() -{ - for (int l=0; lnDim = nDim; -} - -void OrderingMatrix::finalize() -{ - if (nClique > 0) { - DeleteArray(cliqueSize); - for (int index1 = 0; index1Perm, do not delete Perm here - DeleteArray(ReversePerm); - - if (dXtNonzeros != NULL) { - for (int index1 = 0; index1 < nDim; ++index1) { - DeleteArray(dXtIndex[index1]); - DeleteArray(dXtClique[index1]); - DeleteArray(dXtBlock[index1]); - } - DeleteArray(dXtIndex); - DeleteArray(dXtClique); - DeleteArray(dXtBlock); - DeleteArray(dXtNonzeros); - } -} - -void OrderingMatrix::getIndex(int i, int j, int& blockNumber, int& blockIndex) -{ - // A(i,j) = APerm(iPerm,jPerm) - int iPerm = ReversePerm[i]; - int jPerm = ReversePerm[j]; - - // Find the clique which has both iPerm & jPerm - // If this fails, it means a bug. - - // Find iPerm & jPerm from the last clique to the first clique - // The last clique has more elements, so it should be - // accessed as many time as possible. - - // Lower-triangular, that is, iPerm >= jPerm - if (iPerm < jPerm) { - int tmpPerm = iPerm; - iPerm = jPerm; - jPerm = tmpPerm; - } - - int iIndex = -1; // dummy initialize - int jIndex = -1; // dummy initialize - int cIndex = nClique-1; - for ( /* nothing */ ; cIndex >=0 ; cIndex--) { - const int length = cliqueSize[cIndex]; - int index1 = 0; - // find jPerm - for (/* nothing */; index1 < length; ++ index1) { - if (cliqueIndex[cIndex][index1] == jPerm) { - break; - } - } - jIndex = index1; - for (/* nothing */; index1 < length; ++ index1) { - if (cliqueIndex[cIndex][index1] == iPerm) { - break; - } - } - iIndex = index1; - - if (jIndex < length && iIndex < length) { - // found both iPerm & jPerm - break; - } - } - - if (cIndex < 0) { - rMessage("Ordering display"); display(); - rMessage("i = " << i << " : j = " << j); - rError("Code bug here."); - } - blockNumber = cIndex; - blockIndex = iIndex + jIndex*cliqueSize[cIndex]; -} - -void OrderingMatrix::extractCliques(CholmodMatrix& C) -{ - if (nDim == 0) { - rError("OrderingMatrix is not initialized"); - } - cholmod_factor* L = C.Lz; - // L is already set by analyze(); - // This function will initialize the structure of OrderingMatrix - nClique = L->nsuper; - // rMessage("nClique = " << nClique); - NewArray(cliqueSize, int, nClique); - NewArray(cliqueIndex, int*, nClique); - int* super = (int*) (L->super); - for (int s = 0; s < nClique; ++s) { - int start_column = super[s]; - int end_column = super[s+1]; - const int psi = ((int*)L->pi)[s]; - const int psiend = ((int*)L->pi)[s+1]; - const int nsrow = psiend-psi; - cliqueSize[s] = nsrow; - #if 0 - rMessage("clique["<s)[psi+index_i]; - cliqueIndex[s][index_i] = i; - } - } - - Perm = (int*) L->Perm; - NewArray(ReversePerm, int, L->n); - for (size_t index1 = 0; index1 < L->n; ++index1) { - ReversePerm[Perm[index1]] = index1; - } - - vector* tmpVector; - NewArray(tmpVector, vector, nDim); - for (int s = 0; s < nClique; ++s) { - const int length = cliqueSize[s]; - for (int j_index = 0; j_index < length; ++j_index) { - const int j = Perm[cliqueIndex[s][j_index]]; - // since dX~tilde is not symmetric, - // we have to add both lower and upper triangular information - for (int i_index = 0; i_index < length; ++i_index) { - OrderingMatrix::ISB* tmpISB; - NewArray(tmpISB, OrderingMatrix::ISB, 1); - const int i = Perm[cliqueIndex[s][i_index]]; - tmpISB[0].i = i; - tmpISB[0].s = s; - tmpISB[0].b = i_index + j_index*length; - tmpVector[j].push_back(tmpISB); - } - } - } - - NewArray(dXtNonzeros, int, nDim); - NewArray(dXtIndex, int*, nDim); - NewArray(dXtClique, int*, nDim); - NewArray(dXtBlock, int*, nDim); - for (int j=0; ji; - dXtClique[j][index] = tmpISB->s; - dXtBlock [j][index] = tmpISB->b; - DeleteArray(tmpISB); - } - } - DeleteArray(tmpVector); -} - -void OrderingMatrix::displayDxIndex(FILE* fpout, char* printFormat) -{ - if (dXtNonzeros == NULL) { - fprintf(fpout, "dXtNonzeros is not set yet\n"); - } - else { - for (int k=0; k ", dXtIndex[k][index1], k); - fprintf(fpout, "cl{%d}(%d)\n", dXtClique[k][index1], - dXtBlock[k][index1]); - } - } - } -} - -void OrderingMatrix::display(FILE* fpout, char* printFormat) -{ - if (fpout == NULL) { - return; - } - - if (nClique > 0) { - fprintf(fpout, "nClique = %d\n", nClique); - fprintf(fpout, "cliqueSize = "); - for (int s=0; s maxClique) { - maxClique = cliqueSize[s]; - } - } - fprintf(fpout, " sum = %d, ave = %.2f, max = %d\n", - sumClique, (double) sumClique / (double) nClique, maxClique); - -} - -bool OrderingMatrix::compareISB(OrderingMatrix::ISB* a, OrderingMatrix::ISB* b) -{ - if (a->i < b->i) { - return true; - } - if (a->i > b->i) { - return false; - } - if (a->s < b->s) { - return true; - } - if (a->s > b->s) { - return false; - } - if (a->b < b->b) { - return true; - } - if (a->b > b->b) { - return false; - } - return false; // a==b - -} - -OrderingSpace::OrderingSpace() -{ - initialize(); -} - -OrderingSpace::~OrderingSpace() -{ - finalize(); -} - -void OrderingSpace::initialize() -{ - SDP_nBlock = 0; - SDP_block = NULL; - // Memory assignment will be done by - // extractCliques() -} - -void OrderingSpace::initialize(int SDP_nBlock, int* SDP_blockStruct) -{ - this->SDP_nBlock = SDP_nBlock; - if (SDP_nBlock > 0 ) { - NewArray(SDP_block, OrderingMatrix, SDP_nBlock); - for (int l = 0; l < SDP_nBlock; ++l) { - SDP_block[l].initialize(SDP_blockStruct[l]); - } - } -} - -void OrderingSpace::finalize() -{ - if (SDP_nBlock > 0 ) { - for (int l = 0; l < SDP_nBlock; ++l) { - SDP_block[l].finalize(); - } - DeleteArray(SDP_block); - SDP_nBlock = 0; - } -} - -void OrderingSpace::display(FILE* fpout, char* printFormat) -{ - if (fpout == NULL) { - return; - } - if (SDP_nBlock > 0) { - for (int index1 = 0; index1 < SDP_nBlock; ++index1) { - fprintf(fpout, "Block = %d\n", index1); - SDP_block[index1].display(fpout, printFormat); - } - } -} - -void OrderingSpace::displayStatistics(FILE* fpout, CholmodSpace& cholmodSpace) -{ - if (fpout == NULL) { - return; - } - if (SDP_nBlock > 0) { - for (int index1 = 0; index1 < SDP_nBlock; ++index1) { - fprintf(fpout, "[SDP %d-th Block] : order = ", index1); - SDP_block[index1].displayStatistics(fpout, - cholmodSpace.SDP_block[index1]); - } - } -} - -void OrderingSpace::displayDxIndex(FILE* fpout, char* printFormat) -{ - if (fpout == NULL) { - return; - } - if (SDP_nBlock > 0) { - for (int index1 = 0; index1 < SDP_nBlock; ++index1) { - fprintf(fpout, "Block = %d\n", index1); - SDP_block[index1].displayDxIndex(fpout, printFormat); - } - } -} - -void OrderingSpace::extractCliques(CholmodSpace& C) -{ - for (int l=0; l < SDP_nBlock; ++l) { - SDP_block[l].extractCliques(C.SDP_block[l]); - } -} - - - -CholmodMatrix::CholmodMatrix() -{ - initialize(); -} - -CholmodMatrix::~CholmodMatrix() -{ - finalize(); -} - -void CholmodMatrix::initialize() -{ - nDim = 0; // nDim will be set by extractCliques - Z = NULL; - Lz = NULL; - Lx = NULL; - x_x = NULL; - x_z = NULL; - b_x = NULL; - b_z = NULL; - cholmod_start(&common); - common.supernodal = CHOLMOD_SUPERNODAL; - common.final_super = 1; - - common.nrelax[0] = 4; // default 4 - common.nrelax[1] = 16; // default 16 - common.nrelax[2] = 48; // default 48 - - NNZ_Z = 0; - NNZ_L = 0; - Z_blockNumber = NULL; - Z_blockIndex = NULL; -} - -void CholmodMatrix::finalize() -{ - nDim = 0; - if (Z != NULL) { - cholmod_free_sparse(&Z,&common); - Z = NULL; - } - if (Lz != NULL) { - cholmod_free_factor(&Lz,&common); - Lz = NULL; - } - if (Lx != NULL) { - cholmod_free_factor(&Lx,&common); - Lx = NULL; - } - if (x_x != NULL) { - cholmod_free_dense(&x_x,&common); - x_x = NULL; - } - if (x_z != NULL) { - cholmod_free_dense(&x_z,&common); - x_z = NULL; - } - if (b_x != NULL) { - cholmod_free_dense(&b_x,&common); - b_x = NULL; - } - if (b_z != NULL) { - cholmod_free_dense(&b_z,&common); - b_z = NULL; - } - if (dZ != NULL) { - cholmod_free_sparse(&dZ,&common); - dZ = NULL; - } - if (rD != NULL) { - cholmod_free_sparse(&rD,&common); - rD = NULL; - } - cholmod_finish(&common); - DeleteArray(Z_blockNumber); - DeleteArray(Z_blockIndex); -} - -void CholmodMatrix::display(FILE* fpout, char* printFormat) -{ - if (fpout == NULL) { - return; - } - if (Z == NULL) { - rMessage("Each matrix is not set yet."); - return; - } - fprintf(fpout, "CholmodMatrix::display =start=============\n"); - fprintf(fpout, "Z = \n"); - display_sparse(Z, fpout, printFormat); - fprintf(fpout, "dZ = \n"); - display_sparse(dZ, fpout, printFormat); - fprintf(fpout, "rD = \n"); - display_sparse(rD, fpout, printFormat); - fprintf(fpout, "Lz = \n"); - display_factor(Lz, fpout, printFormat); - fprintf(fpout, "Lx = \n"); - display_factor(Lx, fpout, printFormat); - fprintf(fpout, "clique_xMat = \n"); - clique_xMat.display(fpout, printFormat); - fprintf(fpout, "clique_choleskyX = \n"); - clique_choleskyX.display(fpout, printFormat); - fprintf(fpout, "clique_invCholeskyX = \n"); - clique_invCholeskyX.display(fpout, printFormat); - fprintf(fpout, "clique_dX = \n"); - clique_dX.display(fpout, printFormat); - - #if 0 - fprintf(fpout, "b_z = \n"); - display_dense(b_z, fpout, printFormat); - if (x_z == NULL) { - rMessage("x_z is not set yet."); - } - else { - fprintf(fpout, "x_z = \n"); - display_dense(x_z, fpout, printFormat); - } - fprintf(fpout, "b_x = \n"); - display_dense(b_x, fpout, printFormat); - if (x_x == NULL) { - rMessage("x_x is not set yet."); - } - else { - fprintf(fpout, "x_x = \n"); - display_dense(x_x, fpout, printFormat); - } - #endif - fprintf(fpout, "CholmodMatrix::display = end =============\n"); -} - -void CholmodMatrix::display_sparse(cholmod_sparse* A, - FILE* fpout, char* printFormat) -{ - fprintf(fpout, "NNZ = %d\n", A->nzmax); - const int ncol = (int) A->ncol; - for (int j=0; j < ncol; ++j) { - const int start_row = ((int*)A->p)[j]; - const int end_row = ((int*)A->p)[j+1]; - for (int i_index = start_row; i_index < end_row; ++i_index) { - const int i = (( int*)A->i)[i_index]; - const double value = ((double*)A->x)[i_index]; - fprintf(fpout, "%d,%d,",i,j); - fprintf(fpout, printFormat, value); - fprintf(fpout, "\n"); - } - } -} - -void CholmodMatrix::display_factor(cholmod_factor* L, - FILE* fpout, char* printFormat) -{ - const int nsuper = L->nsuper; - const int* super = (int*) L->super; - const int* Ls = (int*) L->s; - const int* Lpi = (int*) L->pi; - const int* Lpx = (int*) L->px; - const double* Lx = (double*) L->x; - const int xtype = L->xtype; - - fprintf(fpout, "noOfSupernode = %d\n", nsuper); - for (int s=0; snrow; - const int ncol = (int) X->ncol; - const double* x = (double*) X->x; - fprintf(fpout, "[\n"); - for (int i=0; ix))[start_row] = scalar; - } -} - -void CholmodMatrix::setXIdentity(double scalar) -{ - clique_xMat.setIdentity(scalar); -} - - -void CholmodMatrix::setB_Zzero() -{ - for (int index1=0;index1 < nDim; ++index1) { - ((double*)(b_z->x))[index1] = 0.0; - } -} - -void CholmodMatrix::setB_Xzero() -{ - for (int index1=0;index1 < nDim; ++index1) { - ((double*)(b_x->x))[index1] = 0.0; - } -} - -void CholmodMatrix::setDxZero() -{ - clique_dX.setZero(); -} - -void CholmodMatrix::initializeClique(OrderingMatrix& order) -{ - clique_dX.initialize(order.nClique, order.cliqueSize); - clique_xMat.initialize(order.nClique, order.cliqueSize); - clique_choleskyX.initialize(order.nClique, order.cliqueSize); - clique_invCholeskyX.initialize(order.nClique, order.cliqueSize); -} - -bool CholmodMatrix::getCholesky(OrderingMatrix& order) -{ - cholmod_factorize(Z, Lz, &common); - #if 0 - rMessage("Z before Cholesky = "); CholmodMatrix::display_sparse(Z); - rMessage("Lz after Cholesky = "); CholmodMatrix::display_factor(Lz); - #endif - bool total_judge = SDPA_SUCCESS; - for (int l = 0; ls; - int* Lpi = (int*) Lx->pi; - int* Lpx = (int*) Lx->px; - double* Lxx = (double*) Lx->x; - int* super = (int*) Lx->super; - int nsuper = (int) Lx->nsuper; - - for (int s=0; s target.nCol) { - rError("coding bug"); - } - const int start_row = Lpi[s]; - const int end_row = Lpi[s+1]; - const int nsrow = end_row - start_row; - int length = nsrow * nscol; - double* target_address = &Lxx[Lpx[s]]; - dcopy_fc(&length, target.de_ele, &IONE, target_address, &IONE); - } - #if 0 - rMessage("clique_xMat = "); clique_xMat.display(); - rMessage("clique_choleskyX = "); clique_choleskyX.display(); - rMessage("clique_invCholeskyX = "); clique_invCholeskyX.display(); - rMessage("Lx after Cholesky = "); CholmodMatrix::display_factor(Lx); - #endif - return SDPA_SUCCESS; -} - -CholmodSpace::CholmodSpace() -{ - initialize(); -} - -CholmodSpace::~CholmodSpace() -{ - finalize(); -} - -void CholmodSpace::initialize() -{ - LP_nBlock = 0; - LP_Z = NULL; - LP_invZ = NULL; - LP_dZ = NULL; - LP_X = NULL; - LP_invX = NULL; - LP_dX = NULL; - LP_rD = NULL; - SDP_nBlock = 0; -} - -void CholmodSpace::finalize() -{ - DeleteArray(LP_Z); - DeleteArray(LP_invZ); - DeleteArray(LP_dZ); - DeleteArray(LP_X); - DeleteArray(LP_invX); - DeleteArray(LP_dX); - DeleteArray(LP_rD); - if (SDP_nBlock > 0) { - for (int index = 0; indexLP_nBlock = LP_nBlock; - this->SDP_nBlock = SDP_nBlock; - NewArray(LP_Z, double, LP_nBlock); - NewArray(LP_invZ, double, LP_nBlock); - NewArray(LP_dZ, double, LP_nBlock); - NewArray(LP_X, double, LP_nBlock); - NewArray(LP_invX, double, LP_nBlock); - NewArray(LP_dX, double, LP_nBlock); - NewArray(LP_rD, double, LP_nBlock); - NewArray(SDP_block, CholmodMatrix, SDP_nBlock); - // nClique is NOT initialized now -} - -void CholmodSpace::makeAggregate(int m, int SDP_nBlock, int* SDP_blockStruct, - CompSpace& C, CompSpace* A) -{ - vector** tmpAggregate; - // tmpAggregate[l][j] contains row numbers (i) in vector - - NewArray(tmpAggregate, vector*, SDP_nBlock); - for (int l=0; l, SDP_blockStruct[l]); - // diagonal elements should be added anytime - for (int j=0; jSDP_sp_nBlock; ++l_index) { - const int l = targetSpace->SDP_sp_index[l_index]; - CompMatrix& target = targetSpace->SDP_sp_block[l_index]; - for (int j_index=0; j_index < target.nzColumn; ++j_index) { - const int j = target.column_index[j_index]; - // only lower triangular part - const int row_start = target.diag_index[j_index]; - const int row_end = target.column_start[j_index+1]; - if (row_start < 0) { - continue; - } - for (int i_index = row_start; i_index < row_end; ++i_index) { - tmpAggregate[l][j].push_back(target.row_index[i_index]); - } - } - } - } - - for (int l=0; l& vec = tmpAggregate[l][j]; - for (int i=0; i 0) { - for (int l = 0; l - -#define DATA_CAPSULE 1 - // DATA_CAPSULE 0 : Three Arrays (row,column,sp_ele) - // DATA_CAPSULE 1 : Capsuled data storage - -namespace sdpa { - -class CholmodMatrix; -class CholmodSpace; -class OrderingMatrix; -class OrderingSpace; - - -class Vector -{ -public: - int nDim; - double* ele; - - Vector(); - Vector(int nDim, double value = 0.0); - ~Vector(); - - void initialize(); - void initialize(int nDim, double value = 0.0); - void initialize(double value); - void finalize(); - - void setZero(); - void display(FILE* fpout = stdout, char* printFormat = P_FORMAT); - void display(FILE* fpout,double scalar, char* printFormat = P_FORMAT); - bool copyFrom(Vector& other); -}; - -class BlockVector -{ -public: - int nBlock; - int* blockStruct; - - Vector* ele; - - BlockVector(); - BlockVector(BlockStruct& bs, double value = 0.0); - BlockVector(int nBlock, int* blockStruct, double value = 0.0); - ~BlockVector(); - - void initialize(BlockStruct& bs, double value = 0.0); - void initialize(int nBlock, int* blockStruct, double value = 0.0); - void initialize(double value); - void finalize(); - - void setZero(); - void display(FILE* fpout = stdout, char* printFormat = P_FORMAT); - bool copyFrom(BlockVector& other); -}; - -class SparseMatrix -{ -public: - int nRow, nCol; - - enum Type { SPARSE, DENSE}; - Type type; - - int NonZeroNumber; - // for memory - int NonZeroCount; - // currentry stored - int NonZeroEffect; - // use for calculation of F1,F2,F3 - - // for Dense - double* de_ele; - - // for Sparse ; 0:sparse 1:dense - enum dsType {DSarrays, DScapsule}; - dsType DataStruct; - - // for Sparse Data1 // dsArrays - int* row_index; - int* column_index; - double* sp_ele; - - // for Sparse Data2 // dsCapsule - typedef struct{ - int vRow; - int vCol; - double vEle; - } SparseElement __attribute__( (aligned (16))); - - SparseElement* DataS; - - SparseMatrix(); - SparseMatrix(int nRow,int nCol, Type type, int NonZeroNumber); - ~SparseMatrix(); - - #if DATA_CAPSULE - void initialize(int nRow,int nCol, Type type, int NonZeroNumber, - dsType DataStruct = DScapsule); - #else - void initialize(int nRow,int nCol, Type type, int NonZeroNumber, - dsType DataStruct = DSarrays); - #endif - void finalize(); - - void display(FILE* fpout = stdout, char* printFormat = P_FORMAT); - bool copyFrom(SparseMatrix& other); - - void changeToDense(bool forceChange = false); - void setZero(); - void setIdentity(double scalar = 1.0); - - bool sortSparseIndex(int&i, int& j); -}; - -class DenseMatrix -{ -public: - int nRow, nCol; - - double* de_ele; - - DenseMatrix(); - ~DenseMatrix(); - - void initialize(); - void initialize(int nRow,int nCol); - void finalize(); - - void display(FILE* fpout = stdout, char* printFormat = P_FORMAT); - bool copyFrom(DenseMatrix& other); - bool copyFrom(SparseMatrix& other); - - void setZero(); - void setIdentity(double scalar = 1.0); -}; - -class SparseLinearSpace -{ -public: - int SDP_sp_nBlock; - int SOCP_sp_nBlock; - int LP_sp_nBlock; - - int* SDP_sp_index; - int* SOCP_sp_index; - int* LP_sp_index; - - SparseMatrix* SDP_sp_block; - SparseMatrix* SOCP_sp_block; - double* LP_sp_block; - - SparseLinearSpace(); - SparseLinearSpace(int SDP_nBlock, int* SDP_blockStruct, - int* SDP_NonZeroNumber, - int SOCP_nBlock, int* SOCP_blockStruct, - int* SOCP_NonZeroNumber, - int LP_nBlock, bool* LP_NonZeroNumber); - SparseLinearSpace(int SDP_sp_nBlock, - int* SDP_sp_index, - int* SDP_sp_blockStruct, - int* SDP_sp_NonZeroNumber, - int SOCP_sp_nBlock, - int* SOCP_sp_index, - int* SOCP_sp_blockStruct, - int* SOCP_sp_NonZeroNumber, - int LP_sp_nBlock, - int* LP_sp_index); - ~SparseLinearSpace(); - - // dense form of block index - void initialize(int SDP_nBlock, int* SDP_blockStruct, - int* SDP_NonZeroNumber, - int SOCP_nBlock, int* SOCP_blockStruct, - int* SOCP_NonZeroNumber, - int LP_nBlock, bool* LP_NonZeroNumber); - // sparse form of block index 2008/02/27 kazuhide nakata - void initialize(int SDP_sp_nBlock, - int* SDP_sp_index, - int* SDP_sp_blockStruct, - int* SDP_sp_NonZeroNumber, - int SOCP_sp_nBlock, - int* SOCP_sp_index, - int* SOCP_sp_blockStruct, - int* SOCP_sp_NonZeroNumber, - int LP_sp_nBlock, - int* LP_sp_index); - void finalize(); - - void changeToDense(bool forceChange=false); - void display(FILE* fpout = stdout, char* printFormat = P_FORMAT); - bool copyFrom(SparseLinearSpace& other); - - void setElement_SDP(int block, int nCol, int nRow, double ele); - void setElement_SOCP(int block, int nCol, int nRow, double ele); - void setElement_LP(int block, double ele); - - void setZero(); - void setIdentity(double scalar = 1.0); - // no check - bool sortSparseIndex(int&l , int& i, int& j); -}; - -class DenseLinearSpace -{ - public: - int SDP_nBlock; - int LP_nBlock; - - DenseMatrix* SDP_block; - double* LP_block; - - DenseLinearSpace(); - DenseLinearSpace(BlockStruct& bs); - ~DenseLinearSpace(); - void initialize(BlockStruct& bs); - void finalize(); - - void display(FILE* fpout = stdout, char* printFormat = P_FORMAT); - void displaySolution(BlockStruct& bs, FILE* fpout = stdout, - char* printFormat = P_FORMAT); - bool copyFrom(DenseLinearSpace& other); - void setElement_SDP(int block, int nCol, int nRow, double ele); - void setElement_SOCP(int block, int nCol, int nRow, double ele); - void setElement_LP(int block, double ele); - void setZero(); - void setIdentity(double scalar = 1.0); -}; - - // Input Matrix A_k for Compleition - // Column-Compressed structure -class CompMatrix -{ -public: - int nRow; - int nCol; - int nzColumn; // nunmber of non-zero columns - int effectiveNzColumn; // nunmber of non-zero LOWER columns - int* column_index; // index of non-zero columns [length:nzColumn] - int NNZ; // number of non-zero - int lowerNNZ; // number of non-zero in lower triangular matrix - int* column_start; // starting point of each non-zero columns - // [length:nzColumn+1] - // the last one should be NNZ - int* row_index; // row-index of each element [length:NNZ] - double* ele; // value of each element [length:NNZ] - int* diag_index; // diagonal point of each non-zero columns - // [length:nzColumn] - // if diagonal is empty, diag_index[j] = -1; - int* agg_index; // aggregate index [length: NNZ] - - // This element corresponds to X.ele[blockNumber].de_ele[blockIndex] - int* blockNumber; - int* blockIndex; - - int nzColumn_diag; // number of LOWER non-zero columns with diagonal elements - int* column_diag_index; - int nzColumn_nondiag; // number of LOWER non-zero columns WITHOUT diagonal elements - int* column_nondiag_index; - - - class inputIJV - { - public: - int i; - int j; - double v; - }; - vector* inputVector; - // inputVector is the vector - // After makeInternalStructure(), this vector will be released - - void display(FILE* fpout = stdout, char* printFormat = P_FORMAT); - void initialize(); - CompMatrix(); - void finalize(); - ~CompMatrix(); - - void initializeInputVector(); - void setElement(int i, int j, double v); - static bool compareIJV(inputIJV* a, inputIJV* b); - void sortInputVector(); - void makeInternalStructure(); - void checkInputDataStructure(int& i, int& j, double& v1, double& v2); - - void assignAgg(CholmodMatrix& cholmodMatrix); - // Aggregate contains only lower triangular - - void assignBlockIndex(OrderingMatrix& order); -}; - - // diagonal block structure of CompMatrix -class CompSpace -{ -public: - - int LP_sp_nBlock; - int SDP_sp_nBlock; - int* LP_sp_index; - int* SDP_sp_index; - - double* LP_sp_block; - CompMatrix* SDP_sp_block; - - int NNZ; - int lowerNNZ; - - // LP_agg_index is not neccesarry, because LP_sp_index does the same thing - - CompSpace(); - ~CompSpace(); - void initialize(); - void initialize(int LP_sp_nBlock, int SDP_sp_nBlock); - void finalize(); - - void display(FILE* fpout = stdout, char* printFormat = P_FORMAT); - - void initializeInputVector(); - void setElement_LP(int i, double v); - void setElement_SDP(int l, int i, int j, double v); - - void sortInputVector(); - void makeInternalStructure(); - void checkInputDataStructure(int& l, int& i, int& j, double& v1, double& v2); - void assignAgg(CholmodSpace& cholModSpace); - void assignBlockIndex(OrderingSpace& order); -}; - -// CliqueMatrix should be diagonal block of fully-dense matrix -// LP block is handled separately by CliqueSpace -class CliqueMatrix -{ -public: - int nBlock; - int* blockStruct; - DenseMatrix* ele; - - CliqueMatrix(); - ~CliqueMatrix(); - void initialize(); - void initialize(int nBlock, int* blockStruct); - void finalize(); - void display(FILE* fpout = stdout, char* printFormat = P_FORMAT); - void setZero(); - void setIdentity(double scalar = 1.0); -}; - // diagonal block structure of CliqueMatrix -class CliqueSpace -{ -public: - int LP_nBlock; - double* LP_block; - int SDP_nBlock; - CliqueMatrix* SDP_block; // each block is decomposed into multiple matrices - - CliqueSpace(); - ~CliqueSpace(); - void initialize(); - void initialize(BlockStruct& bs, OrderingSpace& order); - void finalize(); - void display(FILE* fpout = stdout, char* printFormat = P_FORMAT); - void setZero(); - void setIdentity(double scalar = 1.0); -}; - -class OrderingMatrix -{ -public: - int nClique; - int* cliqueSize; //length nCliques - // arrays of nCliques, i-th array has cliqueSize[i] length - int** cliqueIndex; - - int nDim; - int* Perm; - int* ReversePerm; - - // dXt means dX~tilde - // This matrix is nonsymemetric and [dX~]_{*k} - // is usually computed. - // By copying nonzero elements of [dX~]_{*k} to a clique structure, - // its efficiency will be enhanced. - // Details:: - // The dXtildeIndex-th element of [dX~]_{*k} will be mapped to - // cliqueMatrix{dXtilde[k][dXtClique]}(dXtBlock); - // dXtBlock is the index of the corresponding block inside. - int* dXtNonzeros; // size of nDim - int** dXtIndex; // size of nDim*dXtNonzeros - int** dXtClique; // size of nDim*dXtNonzeros - int** dXtBlock; // size of nDim*dXtNonzeros - - // tmporary class for making dXtNonzers, etc. - class ISB { - public: - int i; - int s; - int b; // blockIndex - }; - - static bool compareISB(ISB* a, ISB* b); - - OrderingMatrix(); - ~OrderingMatrix(); - void initialize(); - void initialize(int nDim); - void finalize(); - - // A[i,j] * X[i,j] means A[i,j] * X.ele[blockNumber].ele[blockIndex] - void getIndex(int i, int j, int& blockNumber, int& blockIndex); - void extractCliques(CholmodMatrix& C); - void displayDxIndex(FILE* fpout = stdout, char* printFormat = P_FORMAT); - void display(FILE* fpout = stdout, char* printFormat = P_FORMAT); - void displayStatistics(FILE* fpout, CholmodMatrix& cholmodMatrix); - -}; - -class OrderingSpace -{ -public: - int SDP_nBlock; - OrderingMatrix* SDP_block; - OrderingSpace(); - ~OrderingSpace(); - void initialize(); - void initialize(int SDP_nBlock, int* SDP_blockStruct); - void finalize(); - void displayDxIndex(FILE* fpout = stdout, char* printFormat = P_FORMAT); - void display(FILE* fpout = stdout, char* printFormat = P_FORMAT); - void displayStatistics(FILE* fpout, CholmodSpace& cholmodSpace); - void extractCliques(CholmodSpace& C); - -}; - -class CholmodMatrix -{ -public: - int nDim; - cholmod_sparse* Z; - cholmod_factor* Lz; - cholmod_factor* Lx; - cholmod_sparse* dZ; - cholmod_sparse* rD; - CliqueMatrix clique_xMat; - CliqueMatrix clique_dX; - CliqueMatrix clique_choleskyX; - CliqueMatrix clique_invCholeskyX; - - cholmod_dense* x_x; // solution of cholmod_solve - cholmod_dense* x_z; // solution of cholmod_solve - cholmod_dense* b_x; // right-hand-side of cholmod_solve - cholmod_dense* b_z; // right-hand-side of cholmod_solve - - cholmod_common common; - int NNZ_Z; - int NNZ_L; - int* Z_blockNumber; - int* Z_blockIndex; - - CholmodMatrix(); - ~CholmodMatrix(); - void initialize(); - void finalize(); - - void display(FILE* fpout = stdout, char* printFormat = P_FORMAT); - static void display_sparse(cholmod_sparse* A, FILE* fpout = stdout, - char* printFormat = P_FORMAT); - static void display_factor(cholmod_factor* L, FILE* fpout = stdout, - char* printFormat = P_FORMAT); - static void display_dense(cholmod_dense* X, FILE* fpout = stdout, - char* printFormat = P_FORMAT); - void analyze(); - void solveByZ(); // b should be set properly before solve. - void solveByX(); // b should be set properly before solve. - - void assignBlockIndex(OrderingMatrix& order); - - static void setZero_sparse(cholmod_sparse* A); - void setZzero(); - void setZIdentity(double scalar = 1.0); - void setXIdentity(double scalar = 1.0); - void setB_Zzero(); - void setB_Xzero(); - void setDxZero(); - void initializeClique(OrderingMatrix& order); - - bool getCholesky(OrderingMatrix& order); -}; - -class InputData; -// diagonal block structure of cholmod_sparse & cholmod_factor -// for Aggregate Matrix & Factorized Matrix -class CholmodSpace -{ -public: - - int LP_nBlock; - double* LP_Z; - double* LP_invZ; - double* LP_dZ; - double* LP_X; - double* LP_invX; - double* LP_dX; - int SDP_nBlock; - CholmodMatrix* SDP_block; - - Vector yVec; - Vector dyVec; - - Vector rp; // primal residual vector - double* LP_rD; // dual residual vector - - CholmodSpace(); - ~CholmodSpace(); - void initialize(); - void initialize(int LP_nBlock, int SDP_nBlock); - void finalize(); - - void makeAggregate(int m, int SDP_nBlock, int* SDP_blockStruct, - CompSpace& C, CompSpace* A); - void assignBlockIndex(OrderingSpace& order); - void setZzero(); - void setZIdentity(double scalar = 1.0); - void setXIdentity(double scalar = 1.0); - void display(FILE* fpout = stdout, char* printFormat = P_FORMAT); - void analyze(); - void initializeClique(int m, OrderingSpace& order); - - void getInnerProductAX(double& ret, - CompSpace& A, OrderingSpace& order); - void getInnerProductAdX(double& ret, - CompSpace& A, OrderingSpace& order); - void computeResiduals(InputData& inputData, OrderingSpace& order); - - bool getCholesky(OrderingSpace& order); - -}; - -} // end of namespace 'sdpa' - -#endif // __sdpa_struct_h__ diff --git a/external/sdpa/sdpa_tool.cpp b/external/sdpa/sdpa_tool.cpp deleted file mode 100644 index 2e5d7e2..0000000 --- a/external/sdpa/sdpa_tool.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ -/*----------------------------------------- - sdpa_tool.cpp ------------------------------------------*/ - -#include "sdpa_tool.h" -#include -#include - -#include -#ifndef CLK_TCK -#define CLK_TCK sysconf(_SC_CLK_TCK) -#endif - -namespace sdpa { - -// These are constant. -// Do Not Change . -int IZERO = 0; -int IONE = 1; -int IMONE = -1; -double DZERO = 0.0; -double DONE = 1.0; -double DMONE = -1.0; - -double Time::rGetUseTime() -{ - #if PROCESS_TIME - struct tms TIME; - times(&TIME); - return (double)TIME.tms_utime/(double)CLK_TCK; - #else - return 0.0; - #endif -} - -void Time::rSetTimeVal(struct timeval& targetVal) -{ - static struct timezone tz; - gettimeofday(&targetVal,&tz); -} - -double Time::rGetRealTime(const struct timeval& start, - const struct timeval& end) -{ - const long int second = end.tv_sec - start.tv_sec; - const long int usecond = end.tv_usec - start.tv_usec; - return ((double)second) + ((double)usecond)*(1.0e-6); -} - -} // end of namespace 'sdpa' - diff --git a/external/sdpa/sdpa_tool.h b/external/sdpa/sdpa_tool.h deleted file mode 100644 index ef24fb9..0000000 --- a/external/sdpa/sdpa_tool.h +++ /dev/null @@ -1,147 +0,0 @@ -/* ------------------------------------------------------------- - -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 - -------------------------------------------------------------- */ -/*-------------------------------------------------- - sdpa_tool.h ---------------------------------------------------*/ - -#ifndef __sdpa_tool_h__ -#define __sdpa_tool_h__ - -#include "sdpa_right.h" - -#include -#include -#include -#include -#include - - -namespace sdpa { - -// Note : only GNU has the macro __PRETTY_FUNCTION__ -#define USE_PRETTY_FUNCTION 0 -#if USE_PRETTY_FUNCTION -#define rMessage(message) \ -{ cout << message << " :: line " << __LINE__ \ - << " in " << __FILE__ \ - << " [ " << __PRETTY_FUNCTION__ << " ] " << endl; } -#elif 1 -#define rMessage(message) \ -{cout << message << " :: line " << __LINE__ \ - << " in " << __FILE__ << endl; } -#else -#define rMessage(message) ; -#endif - -#if USE_PRETTY_FUNCTION -#define rError(message) \ -{ cout << message << " :: line " << __LINE__ \ - << " in " << __FILE__ \ - << " [ " << __PRETTY_FUNCTION__ << " ] " << endl; \ -exit(false);} -#else -#define rError(message) \ -{cout << message << " :: line " << __LINE__ \ - << " in " << __FILE__ << endl; \ -exit(false);} -#endif - -#if 1 -#define NewArray(val,type,number) \ - {val = NULL; \ - try{ val = new type[number]; } \ - catch(bad_alloc){ \ - rMessage("Memory Exhausted (bad_alloc)"); abort(); } \ - catch(...){ \ - rMessage("Fatal Error (related memory allocation"); abort(); } \ - } -#else -#define NewArray(val,type,number) \ - {rMessage("New Invoked"); \ - val = NULL; val = new type[number]; \ - if (val==NULL) {rError("Over Memory");} \ - } -#endif - -#define DeleteArray(val) \ - { if (val!=NULL) { \ - delete[] val; \ - val = NULL; \ - } \ - } - -#define REVERSE_PRIMAL_DUAL 1 - - -// These are constant. Do NOT change -extern int IZERO ; // = 0; -extern int IONE ; // = 1; -extern int IMONE ; // = -1; -extern double DZERO; // = 0.0; -extern double DONE ; // = 1.0; -extern double DMONE; // = -1.0; - -class Time -{ -public: - static double rGetUseTime(); - static void rSetTimeVal(struct timeval & targetVal); - static double rGetRealTime(const struct timeval & start, - const struct timeval & end); -}; - -#define PROCESS_TIME 0 -#if PROCESS_TIME // count time with process time -#include -#define TimeStart(START__) \ - static double START__; START__ = Time::rGetUseTime() -#define TimeEnd(END__) \ - static double END__; END__ = Time::rGetUseTime() -#define TimeCal(START__,END__) (END__ - START__) -#else // count time with real time -#define TimeStart(START__) \ - static struct timeval START__; Time::rSetTimeVal(START__) -#define TimeEnd(END__) \ - static struct timeval END__; Time::rSetTimeVal(END__) -#define TimeCal(START__,END__) Time::rGetRealTime(START__,END__) -#endif - -#define sdpa_dset(dset_length,dset_value,dset_pointer,dset_step) \ -for (int dset_i=0,dset_index = 0; dset_i transformMatrix; [shader("vertex")] -VertexStageOutput vertexMain( +VertexShaderOutput vertexMain( VertexShaderInput input) { - VertexStageOutput output; - vec4 worldPos = 512 * vec4(input.position, 1.0f); - clip(dot(worldPos, clipPlane)); - output.clipPos = gViewParams.projectionMatrix * gViewParams.viewMatrix * worldPos; - output.texCoords = position; + VertexShaderOutput output; + float3x3 cameraRotation = float3x3(gViewParams.viewMatrix); + float4 worldPos = float4(mul(cameraRotation, input.position), 1.0f); + //clip(dot(worldPos, clipPlane)); + output.clipPos = mul(gViewParams.projectionMatrix, worldPos); + output.texCoords = normalize(input.position); return output; } [[vk::push_constant]] -ConstantBuffer fogColor; +ConstantBuffer fogBlend; -[[vk::push_constant]] -ConstantBuffer blendFactor; - -Texture3D cubeMap; -Texture3D cubeMap2; +layout(set = 0, binding = 1) +TextureCube cubeMap; +layout(set = 0, binding = 2) +TextureCube cubeMap2; +layout(set = 0, binding = 3) SamplerState sampler; -const float lowerLimit = 0.0; -const float upperLimit = 0.1; +static const float lowerLimit = 0.0; +static const float upperLimit = 0.1; -float4 fragMain( - VertexShaderOutput output) +[shader("fragment")] +float4 fragmentMain( + VertexShaderOutput output) : SV_Target { float4 texture1 = cubeMap.Sample(sampler, output.texCoords); float4 texture2 = cubeMap2.Sample(sampler, output.texCoords); - float4 finalColor = mix(texture1, texture2, blendFactor); + float4 finalColor = lerp(texture1, texture2, fogBlend.w); - float factor = (input.texCoords.y - lowerLimit) / (upperLimit - lowerLimit); + float factor = (output.texCoords.y - lowerLimit) / (upperLimit - lowerLimit); factor = clamp(factor, 0.0, 1.0); - return = mix(vec4(fogColor, 1), finalColor, factor); + return lerp(float4(fogBlend.xyz, 1), finalColor, factor); } \ No newline at end of file diff --git a/src/Editor/Platform/Windows/GameInterface.cpp b/src/Editor/Platform/Windows/GameInterface.cpp index 616b6dd..a7c0727 100644 --- a/src/Editor/Platform/Windows/GameInterface.cpp +++ b/src/Editor/Platform/Windows/GameInterface.cpp @@ -5,7 +5,6 @@ using namespace Seele; GameInterface::GameInterface(std::string dllPath) : dllPath(dllPath) { - reloadGame(); } GameInterface::~GameInterface() @@ -13,7 +12,12 @@ GameInterface::~GameInterface() } -Game* GameInterface::reloadGame() +Game* GameInterface::getGame() +{ + return game; +} + +void GameInterface::reload(AssetRegistry* registry) { if(lib != NULL) { @@ -23,6 +27,5 @@ Game* GameInterface::reloadGame() lib = LoadLibraryA(dllPath.c_str()); createInstance = (decltype(createInstance))GetProcAddress(lib, "createInstance"); destroyInstance = (decltype(destroyInstance))GetProcAddress(lib, "destroyInstance"); - game = createInstance(); - return game; + game = createInstance(registry); } \ No newline at end of file diff --git a/src/Editor/Platform/Windows/GameInterface.h b/src/Editor/Platform/Windows/GameInterface.h index f817d8b..e397ca2 100644 --- a/src/Editor/Platform/Windows/GameInterface.h +++ b/src/Editor/Platform/Windows/GameInterface.h @@ -9,12 +9,13 @@ class GameInterface public: GameInterface(std::string dllPath); ~GameInterface(); - Game* reloadGame(); + Game* getGame(); + void reload(AssetRegistry* registry); private: HMODULE lib = NULL; std::string dllPath; Game* game; - Game* (*createInstance)() = nullptr; + Game* (*createInstance)(AssetRegistry*) = nullptr; void (*destroyInstance)(Game*) = nullptr; }; } // namespace Seele \ No newline at end of file diff --git a/src/Editor/Window/GameView.cpp b/src/Editor/Window/GameView.cpp index 0ebbf84..f8c5dc9 100644 --- a/src/Editor/Window/GameView.cpp +++ b/src/Editor/Window/GameView.cpp @@ -3,9 +3,12 @@ #include "Window/Window.h" #include "Component/KeyboardInput.h" #include "Actor/CameraActor.h" +#include "Asset/AssetRegistry.h" using namespace Seele; +AssetRegistry* instance = new AssetRegistry(); + GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo) : View(graphics, window, createInfo, "Game") , gameInterface("C:\\Users\\Dynamitos\\TrackClear\\bin\\TrackCleard.dll") @@ -20,8 +23,10 @@ GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate )) { scene = new Scene(graphics); + gameInterface.reload(instance); + gameInterface.getGame()->importAssets(); systemGraph = new SystemGraph(); - gameInterface.reloadGame()->setupScene(scene, systemGraph); + gameInterface.getGame()->setupScene(scene, systemGraph); renderGraph.updateViewport(viewport); } @@ -52,6 +57,7 @@ void GameView::commitUpdate() lightCullingData.lightEnv = scene->getLightBuffer(); basePassData.staticDrawList = scene->getStaticMeshes(); basePassData.sceneDataBuffer = scene->getSceneDataBuffer(); + skyboxData.skybox = scene->getSkybox(); #ifdef EDITOR if(showDebug) { diff --git a/src/Editor/Window/GameView.h b/src/Editor/Window/GameView.h index 4ef6280..9056dc3 100644 --- a/src/Editor/Window/GameView.h +++ b/src/Editor/Window/GameView.h @@ -46,7 +46,7 @@ private: dp::thread_pool<> threadPool; float updateTime = 0; #ifdef EDITOR - bool showDebug = true; + bool showDebug = false; #endif virtual void keyCallback(Seele::KeyCode code, Seele::InputAction action, Seele::KeyModifier modifier) override; diff --git a/src/Editor/Window/InspectorView.cpp b/src/Editor/Window/InspectorView.cpp index be771e6..4a08a5e 100644 --- a/src/Editor/Window/InspectorView.cpp +++ b/src/Editor/Window/InspectorView.cpp @@ -3,6 +3,7 @@ #include "Actor/Actor.h" #include "Window/Window.h" #include "Asset/AssetRegistry.h" +#include "Asset/FontLoader.h" #include "UI/System.h" using namespace Seele; @@ -15,7 +16,9 @@ InspectorView::InspectorView(Gfx::PGraphics graphics, PWindow window, const View )) , uiSystem(new UI::System()) { - AssetRegistry::importFile("./fonts/Calibri.ttf"); + AssetRegistry::importFont(FontImportArgs{ + .filePath = "./fonts/Calibri.ttf", + }); renderGraph.updateViewport(viewport); uiSystem->updateViewport(viewport); } diff --git a/src/Editor/Window/SceneView.cpp b/src/Editor/Window/SceneView.cpp index ed7c86d..394eb23 100644 --- a/src/Editor/Window/SceneView.cpp +++ b/src/Editor/Window/SceneView.cpp @@ -25,7 +25,7 @@ SceneView::SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreat //AssetRegistry::importFile("D:\\Private\\Programming\\Unreal Engine\\Assets\\Ely\\Ely.fbx"); //AssetRegistry::importFile("D:\\Private\\Programming\\Unreal Engine\\Assets\\Cube\\cube.obj"); - AssetRegistry::importFile("D:\\Private\\Programming\\Unreal Engine\\Assets\\Plane\\plane.fbx"); + //AssetRegistry::importFile("D:\\Private\\Programming\\Unreal Engine\\Assets\\Plane\\plane.fbx"); cameraSystem.update(viewportCamera, static_cast(Gfx::currentFrameDelta)); diff --git a/src/Editor/main.cpp b/src/Editor/main.cpp index 7925848..b88267d 100644 --- a/src/Editor/main.cpp +++ b/src/Editor/main.cpp @@ -30,12 +30,12 @@ int main() sceneViewInfo.dimensions.offset.y = 0; PGameView sceneView = new GameView(graphics, window, sceneViewInfo); - ViewportCreateInfo inspectorViewInfo; - inspectorViewInfo.dimensions.size.x = 640; - inspectorViewInfo.dimensions.size.y = 720; - inspectorViewInfo.dimensions.offset.x = 640; - inspectorViewInfo.dimensions.offset.y = 0; - PInspectorView inspectorView = new InspectorView(graphics, window, inspectorViewInfo); + //ViewportCreateInfo inspectorViewInfo; + //inspectorViewInfo.dimensions.size.x = 640; + //inspectorViewInfo.dimensions.size.y = 720; + //inspectorViewInfo.dimensions.offset.x = 640; + //inspectorViewInfo.dimensions.offset.y = 0; + //PInspectorView inspectorView = new InspectorView(graphics, window, inspectorViewInfo); //window->addView(inspectorView); sceneView->setFocused(); diff --git a/src/Engine/Asset/Asset.cpp b/src/Engine/Asset/Asset.cpp index d6b7b9e..f40bfab 100644 --- a/src/Engine/Asset/Asset.cpp +++ b/src/Engine/Asset/Asset.cpp @@ -42,12 +42,12 @@ Asset::~Asset() std::ifstream Asset::getReadStream() const { - return std::ifstream(fullPath); + return std::ifstream(fullPath, std::ios::binary); } std::ofstream Asset::getWriteStream() const { - return std::ofstream(fullPath); + return std::ofstream(fullPath, std::ios::binary); } std::string Asset::getFileName() const diff --git a/src/Engine/Asset/AssetRegistry.cpp b/src/Engine/Asset/AssetRegistry.cpp index 969b48c..0f4c2e3 100644 --- a/src/Engine/Asset/AssetRegistry.cpp +++ b/src/Engine/Asset/AssetRegistry.cpp @@ -17,6 +17,8 @@ using namespace Seele; using json = nlohmann::json; +extern AssetRegistry* instance; + AssetRegistry::~AssetRegistry() { } @@ -26,36 +28,27 @@ void AssetRegistry::init(const std::string& rootFolder, Gfx::PGraphics graphics) get().initialize(rootFolder, graphics); } -void AssetRegistry::importFile(const std::string &filePath) +void AssetRegistry::importMesh(MeshImportArgs args) { - importFile(filePath, ""); + get().meshLoader->importAsset(args); } -void AssetRegistry::importFile(const std::string &filePath, const std::string& importPath) +void AssetRegistry::importTexture(TextureImportArgs args) { - std::filesystem::path fsPath = std::filesystem::path(filePath); - std::string extension = fsPath.extension().string(); - if (extension.compare(".fbx") == 0 - || extension.compare(".obj") == 0 - || extension.compare(".blend") == 0) - { - get().importMesh(fsPath, importPath); - } - if (extension.compare(".png") == 0 - || extension.compare(".jpg") == 0) - { - get().importTexture(fsPath, importPath); - } - if(extension.compare(".ttf") == 0) - { - get().importFont(fsPath, importPath); - } - if (extension.compare(".asset") == 0) - { - get().importMaterial(fsPath, importPath); - } + get().textureLoader->importAsset(args); } +void AssetRegistry::importFont(FontImportArgs args) +{ + get().fontLoader->importAsset(args); +} + +void AssetRegistry::importMaterial(MaterialImportArgs args) +{ + get().materialLoader->importAsset(args); +} + + PMeshAsset AssetRegistry::findMesh(const std::string &filePath) { AssetFolder& folder = get().assetRoot; @@ -125,8 +118,7 @@ std::ifstream AssetRegistry::createReadStream(const std::string& relativePath, s AssetRegistry &AssetRegistry::get() { - static AssetRegistry instance; - return instance; + return *instance; } AssetRegistry::AssetRegistry() @@ -148,26 +140,6 @@ std::string AssetRegistry::getRootFolder() return get().rootFolder.generic_string(); } -void AssetRegistry::importMesh(const std::filesystem::path &filePath, const std::string& importPath) -{ - meshLoader->importAsset(filePath, importPath); -} - -void AssetRegistry::importTexture(const std::filesystem::path &filePath, const std::string& importPath) -{ - textureLoader->importAsset(filePath, importPath); -} - -void AssetRegistry::importFont(const std::filesystem::path& filePath, const std::string& importPath) -{ - fontLoader->importAsset(filePath, importPath); -} - -void AssetRegistry::importMaterial(const std::filesystem::path &filePath, const std::string& importPath) -{ - materialLoader->importAsset(filePath, importPath); -} - void AssetRegistry::registerMesh(PMeshAsset mesh, const std::string& importPath) { AssetFolder& folder = getOrCreateFolder(importPath); diff --git a/src/Engine/Asset/AssetRegistry.h b/src/Engine/Asset/AssetRegistry.h index e52d756..9796490 100644 --- a/src/Engine/Asset/AssetRegistry.h +++ b/src/Engine/Asset/AssetRegistry.h @@ -15,6 +15,7 @@ DECLARE_REF(FontAsset) DECLARE_REF(MeshAsset) DECLARE_REF(MaterialAsset) DECLARE_NAME_REF(Gfx, Graphics) + class AssetRegistry { public: @@ -23,9 +24,6 @@ public: static std::string getRootFolder(); - static void importFile(const std::string& filePath); - static void importFile(const std::string& filePath, const std::string& importPath); - static PMeshAsset findMesh(const std::string& filePath); static PTextureAsset findTexture(const std::string& filePath); static PFontAsset findFont(const std::string& name); @@ -33,6 +31,13 @@ public: static std::ofstream createWriteStream(const std::string& relativePath, std::ios_base::openmode openmode = std::ios::out); static std::ifstream createReadStream(const std::string& relativePath, std::ios_base::openmode openmode = std::ios::in); + + static void importMesh(struct MeshImportArgs args); + static void importTexture(struct TextureImportArgs args); + static void importFont(struct FontImportArgs args); + static void importMaterial(struct MaterialImportArgs args); + static void set(AssetRegistry registry); + AssetRegistry(); private: struct AssetFolder { @@ -46,13 +51,8 @@ private: static AssetRegistry& get(); - AssetRegistry(); void initialize(const std::filesystem::path& rootFolder, Gfx::PGraphics graphics); - void importMesh(const std::filesystem::path& filePath, const std::string& importPath); - void importTexture(const std::filesystem::path& filePath, const std::string& importPath); - void importFont(const std::filesystem::path& filePath, const std::string& importPath); - void importMaterial(const std::filesystem::path& filePath, const std::string& importPath); void registerMesh(PMeshAsset mesh, const std::string& importPath); void registerTexture(PTextureAsset texture, const std::string& importPath); diff --git a/src/Engine/Asset/FontAsset.cpp b/src/Engine/Asset/FontAsset.cpp index b3fcde0..9355ba7 100644 --- a/src/Engine/Asset/FontAsset.cpp +++ b/src/Engine/Asset/FontAsset.cpp @@ -24,7 +24,6 @@ FontAsset::~FontAsset() void FontAsset::save(Gfx::PGraphics graphics) { - assert(false && "Cannot save font files"); } diff --git a/src/Engine/Asset/FontAsset.h b/src/Engine/Asset/FontAsset.h index 5fd351f..2d2bdf1 100644 --- a/src/Engine/Asset/FontAsset.h +++ b/src/Engine/Asset/FontAsset.h @@ -21,9 +21,9 @@ public: IVector2 bearing; uint32 advance; }; - const std::map getGlyphData() const { return glyphs; } + const Map getGlyphData() const { return glyphs; } private: - std::map glyphs; + Map glyphs; friend class FontLoader; }; DECLARE_REF(FontAsset) diff --git a/src/Engine/Asset/FontLoader.cpp b/src/Engine/Asset/FontLoader.cpp index 168e8f8..0547d8b 100644 --- a/src/Engine/Asset/FontLoader.cpp +++ b/src/Engine/Asset/FontLoader.cpp @@ -18,22 +18,22 @@ FontLoader::~FontLoader() { } -void FontLoader::importAsset(const std::filesystem::path& filePath, const std::string& importPath) +void FontLoader::importAsset(FontImportArgs args) { - std::filesystem::path assetPath = filePath.filename(); + std::filesystem::path assetPath = args.filePath.filename(); assetPath.replace_extension("asset"); PFontAsset asset = new FontAsset(assetPath.generic_string()); std::error_code code; - std::filesystem::copy_file(filePath, asset->getFullPath(), code); + std::filesystem::copy_file(args.filePath, asset->getFullPath(), code); asset->setStatus(Asset::Status::Loading); - AssetRegistry::get().registerFont(asset, importPath); - import(filePath, asset); + AssetRegistry::get().registerFont(asset, args.importPath); + import(args, asset); } // in case of the space character there is no bitmap // so we create a single pixel empty texture uint8 transparentPixel = 0; -void FontLoader::import(std::filesystem::path path, PFontAsset asset) +void FontLoader::import(FontImportArgs args, PFontAsset asset) { FT_Library ft; FT_Error error = FT_Init_FreeType(&ft); diff --git a/src/Engine/Asset/FontLoader.h b/src/Engine/Asset/FontLoader.h index 8c20c3f..9c8b289 100644 --- a/src/Engine/Asset/FontLoader.h +++ b/src/Engine/Asset/FontLoader.h @@ -7,14 +7,19 @@ namespace Seele { DECLARE_REF(FontAsset) DECLARE_NAME_REF(Gfx, Graphics) +struct FontImportArgs +{ + std::filesystem::path filePath; + std::string importPath; +}; class FontLoader { public: FontLoader(Gfx::PGraphics graphic); ~FontLoader(); - void importAsset(const std::filesystem::path& filePath, const std::string& importPath); + void importAsset(FontImportArgs args); private: - void import(std::filesystem::path path, PFontAsset asset); + void import(FontImportArgs args, PFontAsset asset); Gfx::PGraphics graphics; }; DEFINE_REF(FontLoader) diff --git a/src/Engine/Asset/MaterialLoader.cpp b/src/Engine/Asset/MaterialLoader.cpp index 057a5c3..88880b5 100644 --- a/src/Engine/Asset/MaterialLoader.cpp +++ b/src/Engine/Asset/MaterialLoader.cpp @@ -15,26 +15,29 @@ using json = nlohmann::json; MaterialLoader::MaterialLoader(Gfx::PGraphics graphics) : graphics(graphics) { - importAsset(std::filesystem::absolute("./shaders/Placeholder.asset"), ""); + importAsset(MaterialImportArgs{ + .filePath = std::filesystem::absolute("./shaders/Placeholder.asset"), + .importPath = "", + }); } MaterialLoader::~MaterialLoader() { } -void MaterialLoader::importAsset(const std::filesystem::path& name, const std::string& importPath) +void MaterialLoader::importAsset(MaterialImportArgs args) { - std::filesystem::path assetPath = name.filename(); + std::filesystem::path assetPath = args.filePath.filename(); assetPath.replace_extension("asset"); PMaterialAsset asset = new MaterialAsset(assetPath.generic_string()); asset->setStatus(Asset::Status::Loading); - AssetRegistry::get().registerMaterial(asset, importPath); - import(name, asset); + AssetRegistry::get().registerMaterial(asset, args.importPath); + import(args, asset); } -void MaterialLoader::import(std::filesystem::path name, PMaterialAsset asset) +void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset) { - auto stream = std::ifstream(name.c_str()); + auto stream = std::ifstream(args.filePath.c_str()); json j; stream >> j; std::string materialName = j["name"].get() + "Material"; diff --git a/src/Engine/Asset/MaterialLoader.h b/src/Engine/Asset/MaterialLoader.h index 1575535..577a424 100644 --- a/src/Engine/Asset/MaterialLoader.h +++ b/src/Engine/Asset/MaterialLoader.h @@ -7,15 +7,20 @@ namespace Seele { DECLARE_REF(MaterialAsset) DECLARE_NAME_REF(Gfx, Graphics) +struct MaterialImportArgs +{ + std::filesystem::path filePath; + std::string importPath; +}; class MaterialLoader { public: MaterialLoader(Gfx::PGraphics graphic); ~MaterialLoader(); - void importAsset(const std::filesystem::path& name, const std::string& importPath); + void importAsset(MaterialImportArgs args); PMaterialAsset getPlaceHolderMaterial(); private: - void import(std::filesystem::path filePath, PMaterialAsset asset); + void import(MaterialImportArgs args, PMaterialAsset asset); Gfx::PGraphics graphics; PMaterialAsset placeholderMaterial; }; diff --git a/src/Engine/Asset/MeshLoader.cpp b/src/Engine/Asset/MeshLoader.cpp index 0721657..539c4aa 100644 --- a/src/Engine/Asset/MeshLoader.cpp +++ b/src/Engine/Asset/MeshLoader.cpp @@ -15,6 +15,8 @@ #include #include #include +#include +#include using namespace Seele; @@ -27,14 +29,14 @@ MeshLoader::~MeshLoader() { } -void MeshLoader::importAsset(const std::filesystem::path &path, const std::string& importPath) +void MeshLoader::importAsset(MeshImportArgs args) { - std::filesystem::path assetPath = path.filename(); + std::filesystem::path assetPath = args.filePath.filename(); assetPath.replace_extension("asset"); PMeshAsset asset = new MeshAsset(assetPath.generic_string()); asset->setStatus(Asset::Status::Loading); - AssetRegistry::get().registerMesh(asset, importPath); - import(path, asset); + AssetRegistry::get().registerMesh(asset, args.importPath); + import(args, asset); } void MeshLoader::loadMaterials(const aiScene* scene, Array& globalMaterials) @@ -93,7 +95,10 @@ void MeshLoader::loadMaterials(const aiScene* scene, Array& globalMat outMatFile.close(); std::cout << "writing json to " << outMatFilename << std::endl; - AssetRegistry::importFile(AssetRegistry::getRootFolder() + "/" + outMatFilename); + AssetRegistry::importMaterial(MaterialImportArgs{ + .filePath = AssetRegistry::getRootFolder() + "/" + outMatFilename, + .importPath = "", + }); PMaterialAsset asset = AssetRegistry::findMaterial(matCode["name"].get()); globalMaterials[i] = asset->getMaterial(); } @@ -262,15 +267,18 @@ void MeshLoader::loadTextures(const aiScene* scene, const std::filesystem::path& delete[] texData; } std::cout << "Loading model texture " << texPngPath.string() << std::endl; - AssetRegistry::importFile(texPngPath.string()); + AssetRegistry::importTexture(TextureImportArgs { + .filePath = texPath, + .importPath = "" + }); } } -void MeshLoader::import(std::filesystem::path path, PMeshAsset meshAsset) +void MeshLoader::import(MeshImportArgs args, PMeshAsset meshAsset) { - std::cout << "Starting to import "<setStatus(Asset::Status::Loading); Assimp::Importer importer; - importer.ReadFile(path.string().c_str(), (uint32)( + importer.ReadFile(args.filePath.string().c_str(), (uint32)( aiProcess_FlipUVs | aiProcess_Triangulate | aiProcess_SortByPType | @@ -281,7 +289,7 @@ void MeshLoader::import(std::filesystem::path path, PMeshAsset meshAsset) const aiScene *scene = importer.ApplyPostProcessing(aiProcess_CalcTangentSpace); Array globalMaterials(scene->mNumMaterials); - loadTextures(scene, path.parent_path()); + loadTextures(scene, args.filePath.parent_path()); loadMaterials(scene, globalMaterials); Array globalMeshes(scene->mNumMeshes); @@ -300,5 +308,5 @@ void MeshLoader::import(std::filesystem::path path, PMeshAsset meshAsset) } meshAsset->physicsMesh = std::move(collider); meshAsset->setStatus(Asset::Status::Ready); - std::cout << "Finished loading " << path << std::endl; + std::cout << "Finished loading " << args.filePath<< std::endl; } diff --git a/src/Engine/Asset/MeshLoader.h b/src/Engine/Asset/MeshLoader.h index 726806f..f7d43e1 100644 --- a/src/Engine/Asset/MeshLoader.h +++ b/src/Engine/Asset/MeshLoader.h @@ -12,19 +12,24 @@ DECLARE_REF(Mesh) DECLARE_REF(MeshAsset) DECLARE_REF(Material) DECLARE_NAME_REF(Gfx, Graphics) +struct MeshImportArgs +{ + std::filesystem::path filePath; + std::string importPath; +}; class MeshLoader { public: MeshLoader(Gfx::PGraphics graphic); ~MeshLoader(); - void importAsset(const std::filesystem::path& filePath, const std::string& importPath); + void importAsset(MeshImportArgs args); private: void loadMaterials(const aiScene* scene, Array& globalMaterials); void loadTextures(const aiScene* scene, const std::filesystem::path& meshPath); void loadGlobalMeshes(const aiScene* scene, const Array& materials, Array& globalMeshes, Component::Collider& collider); void convertAssimpARGB(unsigned char* dst, aiTexel* src, uint32 numPixels); - void import(std::filesystem::path path, PMeshAsset meshAsset); + void import(MeshImportArgs args, PMeshAsset meshAsset); Gfx::PGraphics graphics; }; DEFINE_REF(MeshLoader) diff --git a/src/Engine/Asset/TextureLoader.cpp b/src/Engine/Asset/TextureLoader.cpp index a78d355..eea7473 100644 --- a/src/Engine/Asset/TextureLoader.cpp +++ b/src/Engine/Asset/TextureLoader.cpp @@ -23,15 +23,15 @@ TextureLoader::~TextureLoader() { } -void TextureLoader::importAsset(const std::filesystem::path& path, const std::string& importPath) +void TextureLoader::importAsset(TextureImportArgs args) { - std::filesystem::path assetPath = path.filename(); + std::filesystem::path assetPath = args.filePath.filename(); assetPath.replace_extension("asset"); PTextureAsset asset = new TextureAsset(assetPath.generic_string()); asset->setStatus(Asset::Status::Loading); asset->setTexture(placeholderAsset->getTexture()); - AssetRegistry::get().registerTexture(asset, importPath); - import(path, asset); + AssetRegistry::get().registerTexture(asset, args.importPath); + import(args, asset); } PTextureAsset TextureLoader::getPlaceholderTexture() @@ -39,14 +39,14 @@ PTextureAsset TextureLoader::getPlaceholderTexture() return placeholderAsset; } -void TextureLoader::import(std::filesystem::path path, PTextureAsset textureAsset) +void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset) { int totalWidth, totalHeight, n; - unsigned char* data = stbi_load(path.string().c_str(), &totalWidth, &totalHeight, &n, 4); + unsigned char* data = stbi_load(args.filePath.string().c_str(), &totalWidth, &totalHeight, &n, 4); ktxTexture2* kTexture; ktxTextureCreateInfo createInfo; - if (totalWidth / 4 == totalHeight / 3) + if (args.type == TextureImportType::TEXTURE_CUBEMAP) { uint32 faceWidth = totalWidth / 4; uint32 faceHeight = totalHeight / 3; @@ -56,7 +56,7 @@ void TextureLoader::import(std::filesystem::path path, PTextureAsset textureAsse createInfo.baseHeight = totalHeight / 3; createInfo.baseDepth = 1; createInfo.numFaces = 6; - createInfo.numDimensions = 3; + createInfo.numDimensions = 2; createInfo.numLevels = 1; createInfo.numLayers = 1; createInfo.isArray = false; @@ -66,7 +66,7 @@ void TextureLoader::import(std::filesystem::path path, PTextureAsset textureAsse KTX_TEXTURE_CREATE_ALLOC_STORAGE, &kTexture); - auto loadCubeFace = [kTexture, faceWidth, totalWidth, data](int xPos, int yPos, int faceName) + auto loadCubeFace = [&kTexture, &faceWidth, &totalWidth, &data](int xPos, int yPos, int faceName) { std::vector vec(faceWidth * faceWidth * 4); for (int y = 0; y < faceWidth; ++y) @@ -81,12 +81,12 @@ void TextureLoader::import(std::filesystem::path path, PTextureAsset textureAsse ktxTexture_SetImageFromMemory(ktxTexture(kTexture), 0, 0, faceName, vec.data(), vec.size()); }; - loadCubeFace(1, 0, 0); - loadCubeFace(0, 1, 1); - loadCubeFace(1, 1, 2); - loadCubeFace(2, 1, 3); - loadCubeFace(3, 1, 4); - loadCubeFace(1, 2, 5); + loadCubeFace(2, 1, 0); // +X + loadCubeFace(0, 1, 1); // -X + loadCubeFace(1, 0, 2); // +Y + loadCubeFace(1, 2, 3); // -Y + loadCubeFace(1, 1, 4); // -Z + loadCubeFace(3, 1, 5); // -Z } else { diff --git a/src/Engine/Asset/TextureLoader.h b/src/Engine/Asset/TextureLoader.h index a61f16e..1109312 100644 --- a/src/Engine/Asset/TextureLoader.h +++ b/src/Engine/Asset/TextureLoader.h @@ -8,15 +8,26 @@ namespace Seele DECLARE_REF(TextureAsset) DECLARE_NAME_REF(Gfx, Graphics) DECLARE_NAME_REF(Gfx, Texture2D) +enum class TextureImportType +{ + TEXTURE_2D, + TEXTURE_CUBEMAP, +}; +struct TextureImportArgs +{ + std::filesystem::path filePath; + std::string importPath; + TextureImportType type = TextureImportType::TEXTURE_2D; +}; class TextureLoader { public: TextureLoader(Gfx::PGraphics graphic); ~TextureLoader(); - void importAsset(const std::filesystem::path& filePath, const std::string& importPath); + void importAsset(TextureImportArgs args); PTextureAsset getPlaceholderTexture(); private: - void import(std::filesystem::path path, PTextureAsset asset); + void import(TextureImportArgs args, PTextureAsset asset); Gfx::PGraphics graphics; PTextureAsset placeholderAsset; }; diff --git a/src/Engine/Component/Skybox.h b/src/Engine/Component/Skybox.h index c3eae5d..e2e5f61 100644 --- a/src/Engine/Component/Skybox.h +++ b/src/Engine/Component/Skybox.h @@ -9,7 +9,6 @@ struct Skybox { Gfx::PTextureCube day; Gfx::PTextureCube night; - Gfx::PSamplerState sampler; Vector fogColor; float blendFactor; }; diff --git a/src/Engine/Containers/Map.h b/src/Engine/Containers/Map.h index fa4afe6..2b2c51a 100644 --- a/src/Engine/Containers/Map.h +++ b/src/Engine/Containers/Map.h @@ -364,7 +364,6 @@ public: { return _size; } - private: void verifyTree() { @@ -441,7 +440,7 @@ private: return Iterator(endIndex, &nodeContainer, std::move(endTraversal)); } - Array nodeContainer; + Array nodeContainer = Array(); size_t root; Iterator beginIt; Iterator endIt; diff --git a/src/Engine/Game.h b/src/Engine/Game.h index f7e567f..d4f51e5 100644 --- a/src/Engine/Game.h +++ b/src/Engine/Game.h @@ -1,14 +1,16 @@ #pragma once #include "Scene/Scene.h" #include "System/SystemGraph.h" +#include "Asset/AssetRegistry.h" namespace Seele { class Game { public: - Game() {} + Game(AssetRegistry* registry) {} virtual ~Game() {} + virtual void importAssets() = 0; virtual void setupScene(PScene scene, PSystemGraph graph) = 0; }; } // namespace Seele \ No newline at end of file diff --git a/src/Engine/Graphics/GraphicsResources.h b/src/Engine/Graphics/GraphicsResources.h index b99ed43..de62d50 100644 --- a/src/Engine/Graphics/GraphicsResources.h +++ b/src/Engine/Graphics/GraphicsResources.h @@ -547,6 +547,8 @@ public: virtual uint32 getMipLevels() const = 0; virtual void changeLayout(SeImageLayout newLayout) = 0; virtual class Texture2D* getTexture2D() { return nullptr; } + virtual class Texture3D* getTexture3D() { return nullptr; } + virtual class TextureCube* getTextureCube() { return nullptr; } virtual void* getNativeHandle() { return nullptr; } protected: // Inherited via QueueOwnedResource diff --git a/src/Engine/Graphics/RenderPass/SkyboxRenderPass.cpp b/src/Engine/Graphics/RenderPass/SkyboxRenderPass.cpp index 46dbe37..b32eb83 100644 --- a/src/Engine/Graphics/RenderPass/SkyboxRenderPass.cpp +++ b/src/Engine/Graphics/RenderPass/SkyboxRenderPass.cpp @@ -8,58 +8,58 @@ SkyboxRenderPass::SkyboxRenderPass(Gfx::PGraphics graphics) { Array vertices = { // Back - Vector(-1, -1, -1), - Vector(1, -1, -1), - Vector(-1, 1, -1), + Vector(-512, -512, 512), + Vector(-512, 512, 512), + Vector( 512, -512, 512), - Vector(1, -1, -1), - Vector(-1, 1, -1), - Vector(1, 1, -1), + Vector( 512, -512, 512), + Vector(-512, 512, 512), + Vector( 512, 512, 512), // Front - Vector(1, -1, 1), - Vector(-1, 1, 1), - Vector(-1, -1, 1), + Vector( 512, -512, -512), + Vector( 512, 512, -512), + Vector(-512, -512, -512), - Vector(-1, 1, 1), - Vector(1, 1, 1), - Vector(1, -1, 1), + Vector(-512, -512, -512), + Vector( 512, 512, -512), + Vector(-512, 512, -512), // Top - Vector(-1, -1, -1), - Vector(1, -1, -1), - Vector(1, -1, 1), + Vector(-512, -512, -512), + Vector(-512, -512, 512), + Vector( 512, -512, -512), - Vector(1, -1, -1), - Vector(1, -1, 1), - Vector(1, -1, 1), + Vector( 512, -512, -512), + Vector(-512, -512, 512), + Vector( 512, -512, 512), // Bottom - Vector(-1, 1, -1), - Vector(-1, 1, 1), - Vector(1, 1, -1), + Vector(-512, 512, 512), + Vector(-512, 512, -512), + Vector( 512, 512, 512), - Vector(1, 1, -1), - Vector(-1, 1, 1), - Vector(1, 1, 1), + Vector( 512, 512, 512), + Vector(-512, 512, -512), + Vector( 512, 512, -512), // Left - Vector(-1, -1, -1), - Vector(-1, -1, 1), - Vector(-1, 1, -1), + Vector(-512, -512, -512), + Vector(-512, 512, -512), + Vector(-512, -512, 512), - Vector(-1, 1, -1), - Vector(-1, -1, 1), - Vector(-1, 1, 1), + Vector(-512, -512, 512), + Vector(-512, 512, -512), + Vector(-512, 512, 512), // Right - Vector(1, -1, 1), - Vector(1, 1, -1), - Vector(1, -1, -1), + Vector( 512, -512, 512), + Vector( 512, 512, 512), + Vector( 512, -512, -512), - Vector(1, -1, 1), - Vector(1, 1, 1), - Vector(1, 1, -1), + Vector( 512, -512, -512), + Vector( 512, 512, 512), + Vector( 512, 512, -512), }; VertexBufferCreateInfo vertexBufferInfo = { @@ -93,7 +93,7 @@ void SkyboxRenderPass::beginFrame(const Component::Camera& cam) descriptorSet->updateBuffer(0, viewParamsBuffer); descriptorSet->updateTexture(1, passData.skybox.day); descriptorSet->updateTexture(2, passData.skybox.night); - descriptorSet->updateSampler(3, passData.skybox.sampler); + descriptorSet->updateSampler(3, skyboxSampler); descriptorSet->writeChanges(); } @@ -105,8 +105,8 @@ void SkyboxRenderPass::render() renderCommand->bindPipeline(pipeline); renderCommand->bindDescriptor(descriptorSet); renderCommand->bindVertexBuffer({ VertexInputStream(0, 0, cubeBuffer) }); - renderCommand->pushConstants(pipelineLayout, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, sizeof(Vector), &passData.skybox.fogColor); - renderCommand->pushConstants(pipelineLayout, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, sizeof(Vector), sizeof(float), &passData.skybox.blendFactor); + renderCommand->pushConstants(pipelineLayout, Gfx::SE_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(Vector), &passData.skybox.fogColor); + renderCommand->pushConstants(pipelineLayout, Gfx::SE_SHADER_STAGE_FRAGMENT_BIT, sizeof(Vector), sizeof(float), &passData.skybox.blendFactor); renderCommand->draw(36, 1, 0, 0); graphics->executeCommands(Array{ renderCommand }); graphics->endRenderPass(); @@ -138,17 +138,14 @@ void SkyboxRenderPass::publishOutputs() pipelineLayout = graphics->createPipelineLayout(); pipelineLayout->addDescriptorLayout(0, descriptorLayout); pipelineLayout->addPushConstants(Gfx::SePushConstantRange{ - .stageFlags = Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, + .stageFlags = Gfx::SE_SHADER_STAGE_FRAGMENT_BIT, .offset = 0, - .size = sizeof(Vector), - }); - pipelineLayout->addPushConstants(Gfx::SePushConstantRange{ - .stageFlags = Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, - .offset = sizeof(Vector), - .size = sizeof(float), + .size = sizeof(Vector4), }); pipelineLayout->create(); + + skyboxSampler = graphics->createSamplerState({}); } void SkyboxRenderPass::createRenderPass() diff --git a/src/Engine/Graphics/RenderPass/SkyboxRenderPass.h b/src/Engine/Graphics/RenderPass/SkyboxRenderPass.h index f88533d..3203b0f 100644 --- a/src/Engine/Graphics/RenderPass/SkyboxRenderPass.h +++ b/src/Engine/Graphics/RenderPass/SkyboxRenderPass.h @@ -29,6 +29,7 @@ private: Gfx::PDescriptorSet descriptorSet; Gfx::PPipelineLayout pipelineLayout; Gfx::PGraphicsPipeline pipeline; + Gfx::PSamplerState skyboxSampler; }; DEFINE_REF(SkyboxRenderPass) } // namespace Seele diff --git a/src/Engine/Graphics/Vulkan/VulkanGraphicsResources.h b/src/Engine/Graphics/Vulkan/VulkanGraphicsResources.h index 3fec584..335eaca 100644 --- a/src/Engine/Graphics/Vulkan/VulkanGraphicsResources.h +++ b/src/Engine/Graphics/Vulkan/VulkanGraphicsResources.h @@ -258,6 +258,7 @@ private: uint32 sizeY; uint32 sizeZ; uint32 arrayCount; + uint32 layerCount; uint32 mipLevels; uint32 samples; Gfx::SeFormat format; diff --git a/src/Engine/Graphics/Vulkan/VulkanTexture.cpp b/src/Engine/Graphics/Vulkan/VulkanTexture.cpp index a965b06..be616cb 100644 --- a/src/Engine/Graphics/Vulkan/VulkanTexture.cpp +++ b/src/Engine/Graphics/Vulkan/VulkanTexture.cpp @@ -37,6 +37,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, , sizeY(createInfo.height) , sizeZ(createInfo.depth) , arrayCount(createInfo.bArray ? createInfo.arrayLayers : 1) + , layerCount(1) , mipLevels(createInfo.mipLevels) , samples(createInfo.samples) , format(createInfo.format) @@ -53,10 +54,8 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, info.extent.width = sizeX; info.extent.height = sizeY; info.extent.depth = sizeZ; - info.arrayLayers = arrayCount; info.format = cast(format); - uint32 layerCount = 1; switch (viewType) { case VK_IMAGE_VIEW_TYPE_1D: @@ -72,6 +71,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, break; case VK_IMAGE_VIEW_TYPE_CUBE: case VK_IMAGE_VIEW_TYPE_CUBE_ARRAY: + info.flags = VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; info.imageType = VK_IMAGE_TYPE_2D; layerCount = 6 * arrayCount; break; @@ -127,7 +127,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; region.imageSubresource.mipLevel = 0; region.imageSubresource.baseArrayLayer = 0; - region.imageSubresource.layerCount = 1; + region.imageSubresource.layerCount = layerCount; region.imageOffset = {0, 0, 0}; region.imageExtent = {sizeX, sizeY, sizeZ}; @@ -153,7 +153,7 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, viewInfo.viewType = viewType; viewInfo.image = image; viewInfo.format = cast(format); - viewInfo.subresourceRange.layerCount = (viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY || viewType == VK_IMAGE_VIEW_TYPE_CUBE) ? 6 : 1; + viewInfo.subresourceRange.layerCount = layerCount; viewInfo.subresourceRange.levelCount = mipLevels; VK_CHECK(vkCreateImageView(graphics->getDevice(), &viewInfo, nullptr, &defaultView)); @@ -181,6 +181,16 @@ TextureHandle* TextureBase::cast(Gfx::PTexture texture) PTexture2D texture2D = texture.cast(); return texture2D->textureHandle; } + if(texture->getTexture3D() != nullptr) + { + PTexture3D texture3D = texture.cast(); + return texture3D->textureHandle; + } + if(texture->getTextureCube() != nullptr) + { + PTextureCube textureCube = texture.cast(); + return textureCube->textureHandle; + } return nullptr; } @@ -193,6 +203,7 @@ void TextureHandle::changeLayout(Gfx::SeImageLayout newLayout) cast(newLayout)); barrier.subresourceRange = init::ImageSubresourceRange(aspect); + barrier.subresourceRange.layerCount = layerCount; PCommandBufferManager cmdManager = graphics->getQueueCommands(currentOwner); vkCmdPipelineBarrier(cmdManager->getCommands()->getHandle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, diff --git a/src/Engine/Math/Vector.h b/src/Engine/Math/Vector.h index 6f0de18..af363b0 100644 --- a/src/Engine/Math/Vector.h +++ b/src/Engine/Math/Vector.h @@ -72,7 +72,7 @@ static inline Vector toRotator(const Quaternion &other) const float yawX = (1.f - 2.f * (square(other.y) + square(other.z))); const float SINGULARITY_THRESHOLD = 0.4999995f; - const float RAD_TO_DEG = (180.f) / glm::pi(); + constexpr const float RAD_TO_DEG = (180.f) / glm::pi(); Vector rotatorFromQuat; if (singularityTest < -SINGULARITY_THRESHOLD) diff --git a/src/Engine/Scene/Scene.cpp b/src/Engine/Scene/Scene.cpp index 5b28018..f61e9e6 100644 --- a/src/Engine/Scene/Scene.cpp +++ b/src/Engine/Scene/Scene.cpp @@ -3,6 +3,8 @@ #include "Graphics/Mesh.h" #include "Component/StaticMesh.h" #include "Component/Transform.h" +#include "Asset/AssetRegistry.h" +#include "Asset/TextureAsset.h" using namespace Seele; @@ -88,4 +90,14 @@ LightEnv Scene::getLightBuffer() const result.numDirectionalLights = 1; result.numPointLights = 0; return result; +} + +Component::Skybox Scene::getSkybox() +{ + return Seele::Component::Skybox { + .day = AssetRegistry::findTexture("FS000_Day_01")->getTexture().cast(), + .night = AssetRegistry::findTexture("FS000_Night_01")->getTexture().cast(), + .fogColor = Vector(0.2, 0.1, 0.6), + .blendFactor = 0, + }; } \ No newline at end of file diff --git a/src/Engine/Scene/Scene.h b/src/Engine/Scene/Scene.h index e472235..10f33bf 100644 --- a/src/Engine/Scene/Scene.h +++ b/src/Engine/Scene/Scene.h @@ -4,6 +4,7 @@ #include "Graphics/Graphics.h" #include "Graphics/MeshBatch.h" #include "Physics/PhysicsSystem.h" +#include "Component/Skybox.h" namespace Seele { @@ -70,6 +71,7 @@ public: } Array getStaticMeshes(); LightEnv getLightBuffer() const; + Component::Skybox getSkybox(); Gfx::PStructuredBuffer getSceneDataBuffer() const { return sceneDataBuffer; } Gfx::PGraphics getGraphics() const { return graphics; } entt::registry registry; diff --git a/src/Engine/Serialization/ArchiveBuffer.h b/src/Engine/Serialization/ArchiveBuffer.h new file mode 100644 index 0000000..4e07e71 --- /dev/null +++ b/src/Engine/Serialization/ArchiveBuffer.h @@ -0,0 +1,13 @@ +#pragma once +#include "Array.h" + +namespace Seele +{ +class ArchiveBuffer +{ +public: + +private: + Array memory; +}; +} // namespace Seele \ No newline at end of file diff --git a/src/Engine/Serialization/CMakeLists.txt b/src/Engine/Serialization/CMakeLists.txt new file mode 100644 index 0000000..1c12ffe --- /dev/null +++ b/src/Engine/Serialization/CMakeLists.txt @@ -0,0 +1,9 @@ +target_sources(Engine + PRIVATE + ArchiveBuffer.h) + + +target_sources(Engine + PUBLIC FILE_SET HEADERS + FILES + ArchiveBuffer.h) \ No newline at end of file