Files
imdd_silas/projects/run_loop.m
2025-04-16 09:18:18 +02:00

118 lines
3.8 KiB
Matlab

% loop_records.m
% === Prepare base configuration ===
% databasePath = 'C:\Users\sioe\Documents\MATLAB\imdd_simulation\projects\ECOC_2025\';
local = 1;
if local
databasePath = 'C:\Users\sioe\Documents\MATLAB\imdd_simulation\projects\ECOC_2025\';
savePath = 'Z:\2025\ECOC Silas\ecoc_2025\';
else
databasePath = 'C:\Users\sioe\Documents\MATLAB\imdd_simulation\projects\ECOC_2025\';
savePath = 'Z:\2025\ECOC Silas\ecoc_2025\';
end
database_name = 'ecoc2025_loops.db';
db = DBHandler("pathToDB", [databasePath, database_name],"type",'mysql');
conf = db.tables.Configurations;
if ~exist('confPrev','var')
confPrev = db.tables.Configurations;
end
awg_upload_required = 1; %still uploads every first round
subimt_DSP = 1;
recordlen = 5000000;
sequence_order = 17;
n_recording = 1; % Or any number you want
% Define vector parameters directly in conf:
conf.unique_elab_id = "20250408-842b0a3078172b48dd032795226fbe683190afc4";
conf.db_mode = db_mode.no_db;
conf.pulsef_alpha = 0.2;
conf.v_bias = 2.65;
conf.v_awg = 0.9;
conf.precomp_amp = -64; %-64
conf.wavelength = 1310;
conf.laser_power = 11;
conf.fiber_length = 0;
conf.pd_in_desired = 9;
conf.is_mpi = 1;
conf.signal_attenuation = 0;
conf.interference_path_length = 0; %m
conf.interference_attenuation = 40;%[0:2:30,40];
conf.pam_level = 4;%[4,6,8];
conf.symbolrate = 56e9;%[56,72,96,112].*1e9;
conf.bitrate = conf.symbolrate .* floor(log2(6)*10)/10;
conf.pam_source = [];
if conf.is_mpi
current_folder = ['mpi_',num2str(conf.interference_path_length),'m_pam',num2str(conf.pam_level)];
else
current_folder = 'testing';
end
% Init empty loop id
loop_id = [];
% === Detect vector fields automatically ===
paramNames = fieldnames(conf);
vectorParams = struct();
scalarConf = conf;
parallel_dsp = false;
max_occurences = 1;
for i = 1:numel(paramNames)
thisName = paramNames{i};
thisValue = conf.(thisName);
if isnumeric(thisValue) && numel(thisValue) > 1
vectorParams.(thisName) = thisValue;
parallel_dsp = true;
max_occurences = 10;
else
scalarConf.(thisName) = thisValue;
end
end
vectorFieldNames = fieldnames(vectorParams);
if isempty(vectorFieldNames)
% No vector parameters, single run
fprintf('Running single measurement (no parameter sweep)\n');
confRequest = scalarConf;
confRequest.bitrate = confRequest.symbolrate * floor(log2(confRequest.pam_level) * 10) / 10;
measure_run_script
else
% Vector parameters found, run parameter sweep
vectorValues = struct2cell(vectorParams);
nParams = numel(vectorValues);
grid = cell(1, nParams);
[grid{:}] = ndgrid(vectorValues{:});
totalRuns = numel(grid{1});
fprintf('Total runs: %d\n', totalRuns);
for runIdx = 1:totalRuns
confRequest = scalarConf;
paramDisplayCell = cell(1, nParams);
for vIdx = 1:nParams
fieldName = vectorFieldNames{vIdx};
paramValue = grid{vIdx}(runIdx);
confRequest.(fieldName) = paramValue;
if isnumeric(paramValue)
paramDisplayCell{vIdx} = sprintf('%s = %.4g', fieldName, paramValue);
else
paramDisplayCell{vIdx} = sprintf('%s = %s', fieldName, char(paramValue));
end
end
fprintf('Running measurement: %s\n', strjoin(paramDisplayCell, ', '));
confRequest.bitrate = confRequest.symbolrate * floor(log2(confRequest.pam_level) * 10) / 10;
% measure_run("config",confRun,"parallel",parallel_dsp,"max_occurences",max_occurences);
measure_run_script;
end
end
disp('- LOOP FINISHED - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ')
fprintf('\n')