Commit a44e7c23 authored by ofgeorg's avatar ofgeorg

this script is for use with ETH brutus cluster to ease the process of...

this script is for use with ETH brutus cluster to ease the process of submitting and processing of simulations
parent 7d975304
%function to make putting together the string less of a pain
function [content] = AddLine(local_s,s)
local_s = [local_s sprintf('%s \n',s)];
content = local_s;
end
\ No newline at end of file
%collects multiple Runs together and submits them once they fill a certain
%time window
function [nr_o] = AddtoSub(pathtoCMA,queuetime,expt,out,mpi)
persistent timesize;
persistent l_count;
persistent batch;
persistent nr;
%initialize
if ((strcmpi(pathtoCMA,'')))
timesize = 0;
nr = 0;
l_count = 0;
batch = '#!/bin/sh';
batch = sprintf('%s\n',batch);
%batch = [batch 'bsub -W 08:00 -o report' num2str(nr) ' << EOF'];
%batch = sprintf('%s\n',batch);
else
s = '';
s = sprintf('%s;\n',s);
if ( (timesize + expt > queuetime || l_count > 600 || expt == 0) && l_count > 0) %we have a full batch
%submit it
fid = fopen(strcat(num2str(nr),'batch.txt'),'wt');
fprintf(fid,'%s',batch);
fclose(fid);
nr = nr + 1;
timesize = 0;
l_count = 0;
batch = '#!/bin/sh';
batch = sprintf('%s\n',batch);
%batch = [batch 'bsub -W 08:00 -o report' num2str(nr) ' << EOF'];
%batch = sprintf('%s\n',batch);
end
timesize = timesize + expt;
l_count = l_count + 6;
%extract input
%disp(input_file);
batch = [batch 'mkdir ' out s];
batch = [batch 'tar -x ' out '.txt -f inputs.tar.gz -O > ' out '/input.txt' s];
batch = [batch pathtoCMA ' ' out '/input.txt > ' out '/stdout.txt' s];
batch = [batch 'tar czvf ' out '.tar.gz ' out s];
batch = [batch 'rm -r ' out s];
end
nr_o = nr;
end
\ No newline at end of file
This diff is collapsed.
%this gives back rough runtimes on brutus cluster
function [time] = CEC2005runtime(dimi,fcnr)
dim10 = [1.86, 1.68, 2.33, 2.2, 2.66, ...
3.09, 4.25, 18.13, 9.75, 10.60, ...
91.65, 11.50, 9.76, 10.48, 217.39 ...
318.66, 235.64, 195.07, 195.97, 218.31 ...
255.86, 204.72, 195.94, 160.99, 120.84];
dim30 = [8.97, 10.34, 36.25, 34.36, 174.32, ...
40.30, 7.43, 102.25, 103.54, 91.60, ...
772.89, 266.95, 92.43, 207.96, 2212.97, ...
2316.02, 3253.15, 2184.87, 2138.16, 2137.54, ...
2217.40, 2316.71, 2239.95, 1440.75, 1389.31];
dim50 = [25.18, 70.76, 294.80, 315.31, 994.61, ...
398.49, 44.71, 617.08, 342.89, 268.45, ...
2573.59, 1221.93, 474.02, 1243.52, 6535.84, ...
6572.98, 7346.98, 7404.71, 7309.90, 7302.11, ...
7663.59, 7940.85, 7665.83, 5428.19, 5359.31];
if (dimi == 1)
time = dim10(fcnr);
elseif (dimi == 2)
time = dim30(fcnr);
else
time = dim50(fcnr);
end
time = time/25; %times given above are for 25 runs
end
\ No newline at end of file
function [vars,outputs,out_size] = CreateInputFiles(opts,defopts)
%% check which parameters are getting varied
namec = fieldnames(opts);
pers = ones(size(namec,1),1);
for i = 1:size(namec,1)
name = namec{i};
if (~(strcmp(name,'CECFolders') || strcmp(name,'seed_folder') || strcmp(name,'output_folder') || strcmp(name,'funcName')))
if (size(myeval(getfield(opts,name)),2) > 1)
pers(i) = size(myeval(getfield(opts,name)),2);
end
end
end
out_size = prod(pers);
outputs = cell(size(namec,1),out_size);
sw = zeros(out_size,1);
vars = cell(size(namec,1),1);
for i = 1:size(namec,1)
per_c = 1;
c_string = 0;
boolean = 0;
name = namec{i};
vars{i} = upper(name);
if (~(strcmp(name,'CECFolders') || strcmp(name,'seed_folder') || strcmp(name,'output_folder') || strcmp(name,'funcName')))
value = myeval(getfield(opts,name));
defvalue = getfield(defopts,name);
if ( ~(isempty(findstr('true',defvalue)) && isempty (findstr('false',defvalue))))
boolean = 1;
end
else
value = getfield(opts,name);
pos = strfind(value, '%');
if (~isempty(pos))
value = value(1:pos(1)-1);
end
c_string = 1;
end
if (pers(i) > 1)
last_div = find(sw,1);
if (isempty(last_div))
last_div = out_size;
end
x = last_div/pers(i);
sw(x) = 1;
end
count = 1;
for (j = 1:out_size)
if (c_string)
outputs{i,j} = value;
else
%we have to replace 0/1 with true false for booleans
if (boolean)
outputs{i,j} = value(per_c);
if (outputs{i,j})
outputs{i,j} = 'TRUE';
else
outputs{i,j} = 'FALSE';
end
else
outputs{i,j} = num2str(value(per_c));
end
end
count = count + 1;
if (count > find(sw,1))
per_c = per_c + 1;
if (per_c > pers(i))
per_c = 1;
end
count = 1;
end
end
end
end
\ No newline at end of file
function [dbConn] = DB_connect(open)
if (open)
% Database Server
host = 'localhost';
% Database Username/Password
user = 'root';
password = '';
% Database Name
dbName = 'CEC2005';
% JDBC Parameters
jdbcString = sprintf('jdbc:mysql://%s/%s', host, dbName);
jdbcDriver = 'com.mysql.jdbc.Driver';
% Set this to the path to your MySQL Connector/J JAR
javaaddpath('C:\Users\Georg\Downloads\mysql-connector-java-5.1.10\mysql-connector-java-5.1.10\mysql-connector-java-5.1.10-bin.jar')
% Create the database connection object
dbConn = database(dbName, user , password, jdbcDriver, jdbcString);
% Check to make sure that we successfully connected
if isconnection(dbConn)
% If the connection failed, print the error message
else
disp(sprintf('Connection failed: %s', dbConn.Message));
end
% Close the connection so we don't run out of MySQL threads
close(dbConn);
else
end
This diff is collapsed.
%returns all the Minimas of LJ Clusters up to size 150
%from http://physchem.ox.ac.uk/~doye/jon/structures/LJ/tables.150.html
function [min] = LJ_mins(nr)
g_min = [0 -1.000000 ...
-3.000000 ...
-6.000000 ...
-9.103852 ...
-12.712062 ...
-16.505384 ...
-19.821489 ...
-24.113360 ...
-28.422532 ...
-32.765970 ...
-37.967600 ...
-44.326801 ...
-47.845157 ...
-52.322627 ...
-56.815742 ...
-61.317995 ...
-66.530949 ...
-72.659782 ...
-77.177043 ...
-81.684571 ...
-86.809782 ...
-92.844472 ...
-97.348815 ...
-102.372663 ...
-108.315616 ...
-112.873584 ...
-117.822402 ...
-123.587371 ...
-128.286571 ...
-133.586422 ...
-139.635524 ...
-144.842719 ...
-150.044528 ...
-155.756643 ...
-161.825363 ...
-167.033672 ...
-173.928427 ...
-180.033185 ...
-185.249839 ...
-190.536277 ...
-196.277534 ...
-202.364664 ...
-207.688728 ...
-213.784862 ...
-220.680330 ...
-226.012256 ...
-232.199529 ...
-239.091864 ...
-244.549926 ...
-251.253964 ...
-258.229991 ...
-265.203016 ...
-272.208631 ...
-279.248470 ...
-283.643105 ...
-288.342625 ...
-294.378148 ...
-299.738070 ...
-305.875476 ...
-312.008896 ...
-317.353901 ...
-323.489734 ...
-329.620147 ...
-334.971532 ...
-341.110599 ...
-347.252007 ...
-353.394542 ...
-359.882566 ...
-366.892251 ...
-373.349661 ...
-378.637253 ...
-384.789377 ...
-390.908500 ...
-397.492331 ...
-402.894866 ...
-409.083517 ...
-414.794401 ...
-421.810897 ...
-428.083564 ...
-434.343643 ...
-440.550425 ...
-446.924094 ...
-452.657214 ...
-459.055799 ...
-465.384493 ...
-472.098165 ...
-479.032630 ...
-486.053911 ...
-492.433908 ...
-498.811060 ...
-505.185309 ...
-510.877688 ...
-517.264131 ...
-523.640211 ...
-529.879146 ...
-536.681383 ...
-543.665361 ...
-550.666526 ...
-557.039820 ...
-563.411308 ...
-569.363652 ...
-575.766131 ...
-582.086642 ...
-588.266501 ...
-595.061072 ...
-602.007110 ...
-609.033011 ...
-615.411166 ...
-621.788224 ...
-628.068416 ...
-634.874626 ...
-641.794704 ...
-648.833100 ...
-655.756307 ...
-662.809353 ...
-668.282701 ...
-674.769635 ...
-681.419158 ...
-687.021982 ...
-693.819577 ...
-700.939379 ...
-707.802109 ...
-714.920896 ...
-721.303235 ...
-727.349853 ...
-734.479629 ...
-741.332100 ...
-748.460647 ...
-755.271073 ...
-762.441558 ...
-768.042203 ...
-775.023203 ...
-782.206157 ...
-790.278120 ...
-797.453259 ...
-804.631473 ...
-811.812780 ...
-818.993848 ...
-826.174676 ...
-833.358586 ...
-840.538610 ...
-847.721698 ...
-854.904499 ...
-862.087012 ...
-869.272573 ...
-876.461207 ...
-881.072971 ...
-886.693405 ...
-893.310258 ];
min = g_min(nr);
end
\ No newline at end of file
%returns the max size (euclidian distance) within clusters
function [size] = LJ_size(nr)
max_size =[ 0 ...
0 ...
1.1225 ...
1.1225 ...
1.8259 ...
1.5803 ...
1.8188 ...
2.2121 ...
2.2017 ...
2.1871 ...
2.2019 ...
2.1723 ...
2.1637 ...
2.6916 ...
2.6911 ...
2.6966 ...
2.7493 ...
2.7095 ...
3.1742 ...
3.1696 ...
3.1640 ...
3.1849 ...
3.1685 ...
3.2020 ...
3.1865 ...
3.1677 ...
3.5781 ...
3.5568 ...
3.5265 ...
3.5972 ...
3.8206 ...
3.8231 ...
3.8223 ...
3.8212 ...
3.8409 ...
3.8322 ...
3.8455 ...
3.4991 ...
3.8185 ...
3.8451 ...
3.8506 ...
4.3033 ...
4.3057 ...
4.3059 ...
4.2983 ...
4.2968 ...
4.2965 ...
4.2894 ...
4.2879 ...
4.2884 ...
4.2828 ...
4.2817 ...
4.2810 ...
4.2798 ...
4.2788 ...
4.4804 ...
4.7145 ...
4.7161 ...
4.7172 ...
4.7163 ...
4.7148 ...
4.7253 ...
4.7266 ...
4.7215 ...
4.7280 ...
4.7298 ...
4.7247 ...
5.2628 ...
4.7030 ...
4.7235 ...
5.2596 ...
5.2584 ...
5.2567 ...
5.2560 ...
4.8636 ...
5.2715 ...
5.2939 ...
5.1381 ...
5.1375 ...
5.2567 ...
5.2577 ...
5.3557 ...
5.3559 ...
5.3538 ...
5.1409 ...
5.3560 ...
5.3525 ...
5.3549 ...
5.3528 ...
5.3541 ...
5.3542 ...
5.3543 ...
5.4729 ...
5.4700 ...
5.4759 ...
5.5587 ...
5.5584 ...
5.1745 ...
5.5557 ...
5.9013 ...
5.9021 ...
5.5807 ...
5.6035 ...
5.6219 ...
5.9096 ...
5.9068 ...
5.9085 ...
5.9070 ...
5.9075 ...
5.9059 ...
5.9020 ...
5.9033 ...
5.9045 ...
5.9032 ...
5.8987 ...
5.8975 ...
5.9244 ...
5.9159 ...
5.9117 ...
5.9245 ...
5.9318 ...
6.4052 ...
5.9318 ...
6.4045 ...
6.4053 ...
6.4007 ...
6.4003 ...
6.4000 ...
6.3996 ...
6.3993 ...
6.3990 ...
6.3986 ...
5.9063 ...
5.9061 ...
5.5883 ...
5.8973 ...
5.8973 ...
5.8973 ...
5.8973 ...
5.8973 ...
5.8972 ...
6.3888 ...
6.3886 ...
6.3884 ...
6.3882 ...
6.3880 ...
6.3878 ...
6.5158 ...
6.5093 ...
6.5109];
size = max_size(nr);
end
\ No newline at end of file
function [varnames2,varvalue2,vartypes,count] = Readsettings(name)
%mkdir(['dir_' name]);
%cd (['dir_' name]);
%cmd = ['"C:\Program Files\7-Zip\7z.exe" e ../' name '.tar.gz'];
%[status,result1] = system(cmd );
%cmd = ['"C:\Program Files\7-Zip\7z.exe" e ' name '.tar'];
cmd = ['tar -xf ' name '.tar.gz'];
[status,result2] = system(cmd );
cd (name);
fid = fopen('out_settings.txt','r');
varstat = 1;
count = 0;
varnames = {};
vartypes = {};
varvalues = {};
tline = fgetl(fid);
while ischar(tline)
t_line = strtrim(tline);
if (varstat == 1)
if (~isempty(t_line))
count = count + 1;
varnames{count} = strtrim(tline);
varstat = 0;
end
else
value = t_line;
x = str2num(value);
if (isempty(x))
if (strcmpi(value,'F') || strcmpi(value,'T'))
vartypes{count} = 'int(1)';
if (strcmpi(value,'F'))
varvalue{count} = '0';
else
varvalue{count} = '1';
end
else
vartypes{count} = 'varchar(300)';
varvalue{count} = value;
end
else
vartypes{count} = 'double';
varvalue{count} = num2str(str2num(value));
if ( strcmpi( varvalue{count},'-Inf') )
varvalue{count} = '0';
end
if ( strcmpi( varvalue{count}, 'Inf') )
varvalue{count} = '0';
end
end
varstat = 1;
end
tline = fgetl(fid);
end
fclose(fid);
varnames2 = strtrim(varnames);
varvalue2 = strtrim(varvalue);
end
\ No newline at end of file
% ---------------------------------------------------------------
function opts=getoptions(inopts, defopts)
% OPTS = GETOPTIONS(INOPTS, DEFOPTS) handles an arbitrary number of
% optional arguments to a function. The given arguments are collected
% in the struct INOPTS. GETOPTIONS matches INOPTS with a default
% options struct DEFOPTS and returns the merge OPTS. Empty or missing
% fields in INOPTS invoke the default value. Fieldnames in INOPTS can
% be abbreviated.
%
% The returned struct OPTS is first assigned to DEFOPTS. Then any
% field value in OPTS is replaced by the respective field value of
% INOPTS if (1) the field unambiguously (case-insensitive) matches
% with the fieldname in INOPTS (cut down to the length of the INOPTS
% fieldname) and (2) the field is not empty.
%
% Example:
% In the source-code of the function that needs optional
% arguments, the last argument is the struct of optional
% arguments:
%
% function results = myfunction(mandatory_arg, inopts)
% % Define four default options
% defopts.PopulationSize = 200;
% defopts.ParentNumber = 50;
% defopts.MaxIterations = 1e6;
% defopts.MaxSigma = 1;
%
% % merge default options with input options
% opts = getoptions(inopts, defopts);
%
% % Thats it! From now on the values in opts can be used
% for i = 1:opts.PopulationSize
% % do whatever
% if sigma > opts.MaxSigma
% % do whatever
% end
% end
%
% For calling the function myfunction with default options:
% myfunction(argument1, []);
% For calling the function myfunction with modified options:
% opt.pop = 100; % redefine PopulationSize option
% opt.PAR = 10; % redefine ParentNumber option
% opt.maxiter = 2; % opt.max=2 is ambiguous and would result in an error
% myfunction(argument1, opt);
%
% 04/07/19: Entries can be structs itself leading to a recursive
% call to getoptions.
%
if nargin < 2 || isempty(defopts) % no default options available
opts=inopts;
return;
elseif isempty(inopts) % empty inopts invoke default options
opts = defopts;
return;
elseif ~isstruct(defopts) % handle a single option value
if isempty(inopts)
opts = defopts;
elseif ~isstruct(inopts)
opts = inopts;
else
error('Input options are a struct, while default options are not');
end
return;