forked from aeroimperial-optimization/mpYALMIP
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall_sdpa_gmp_neos.m
109 lines (94 loc) · 4.36 KB
/
install_sdpa_gmp_neos.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
function install_sdpa_gmp_neos(varargin)
% INSTALL_SDPA_GMP_NEOS
%
% INSTALL_SDPA_GMP_NEOS adds support for the multiple-precision SDPA-GMP solver
% using NEOS solver to YALMIP.
%
% ----------------------------------------------------------------------- %
%
% Copyright (C) 2017 Hugo Tadashi
%
% 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 3 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, see <http://www.gnu.org/licenses/>.
% ----------------------------------------------------------------------- %
% ----------------------------------------------------------------------- %
% CHECK IF YALMIP IS INSTALLED
% ----------------------------------------------------------------------- %
% Copied and edited from yalmiptest.m, YALMIP
detected = which('yalmip.m','-all');
if isa(detected,'cell') && ~isempty(detected)
if length(detected)>1
disp('You seem to have multiple installations of YALMIP in your path:');
disp(detected)
disp('Please correct this, then run the installation again.');
return
end
else
error(['A working version of YALMIP is required.\n '...
'Please correct this, then run the installation again.']);
end
% ----------------------------------------------------------------------- %
% ADD SDPA-GMP-NEOS TO LIST OF SUPPORTED SOLVERS
% ----------------------------------------------------------------------- %
fname = which('definesolvers');
% make a backup copy of the original YALMIP file
fpath = fileparts(fname);
success = copyfile(fname,[fpath,filesep,'definesolvers_original.m']);
if ~success
error('Could not back up the file definesolvers.m')
end
% Add solver definition to definesolvers.m
fid = fopen(fname,'a+'); fprintf(fid,'\n\n');
fprintf(fid,'%% %% ********************************************\n');
fprintf(fid,'%% %% DEFINE SDPA-GMP-NEOS AS A SOLVER - ADDED BY \n');
fprintf(fid,'%% %% install_sdpa_gmp_neos \n');
fprintf(fid,'%% %% ********************************************\n');
fprintf(fid,'solver(i) = sdpsolver; \n');
fprintf(fid,'solver(i).tag = ''SDPA-GMP-NEOS''; \n');
fprintf(fid,'solver(i).version = ''''; \n');
fprintf(fid,'solver(i).checkfor= {''callsdpagmp_neos.m''}; \n');
fprintf(fid,'solver(i).call = ''callsdpagmp_neos''; \n');
fprintf(fid,'solver(i).constraint.equalities.linear = 0; \n');
fprintf(fid,'i = i+1; \n');
fclose(fid);
% ----------------------------------------------------------------------- %
% ADD SDPA-GMP CALLER FUNCTION TO YALMIP/solvers/
% ----------------------------------------------------------------------- %
fpath = fileparts(which('callsdpa'));
success = movefile('callsdpagmp_neos.m',[fpath,filesep,'callsdpagmp_neos.m']);
if ~success
error('Could not copy callsdpagmp_neos.m to the correct location.')
end
% ----------------------------------------------------------------------- %
% CREATE EMAIL FILE IN UTILS PATH
% ----------------------------------------------------------------------- %
fid = fopen([pwd,filesep,'utils',filesep,'neos_email.dat'],'w');
email = input('Insert email for NEOS results: ','s');
fprintf(fid,'%s',email);
fclose(fid);
% ----------------------------------------------------------------------- %
% ADD UTILS TO MATLAB PATH
% ----------------------------------------------------------------------- %
addpath([pwd,filesep,'utils',filesep]);
savepath;
% ----------------------------------------------------------------------- %
% CLEAR YALMIP CACHED SOLVERS
% ----------------------------------------------------------------------- %
clear('compileinterfacedata.m')
% ----------------------------------------------------------------------- %
% RUN MEX
% ----------------------------------------------------------------------- %
cd utils;
mex -silent sdpagmp_read_output.cpp
cd ..;
end