
% startup
if (exist('initDone')==0),
	% startup TOMLAB
	addpath c:\tomlab;
	startup;

	% add bin folder to Matlab path and initialize RTC Tools
	addpath('../../x86-windows-vc-9.0/bin');
	
	initDone = 1;
end

% initial parameter definition
id = {
'B01.01'
'B01.02'
'B01.03'
'B02.01'
'B02.02'
'B03.01'
'B03.02'
'B04.01'
'B04.02'
'B05.01'
'B05.02'
'B10.01'
'B10.02'
'B10.03'
'B10.04'
'B11.01'
'B11.02'
'B13.01'
'B13.02'
'B13.03'
}; 
input = [
49.000000
53.000000
56.000000
44.000000
48.000000
40.000000
45.000000
38.000000
58.000000
38.000000
58.000000
42.000000
46.000000
50.000000
55.000000
30.000000
34.000000
30.000000
50.000000
60.000000
];
saveParameters(id, input);

% initialize RTC Tools
RTCToolsMatlab('initialize');
RTCToolsMatlab('DA mode');

% problem definition
Prob = conAssign('jResCalibration', [], [], [], 30*ones(20,1), 80*ones(20,1), 'Name', input, [], [], [], [], []);
Prob.SOL.optPar(10) = 0.001;

% optimization
tic
Result = tomRun('snopt', Prob, 2);
time=toc

% save optimized parameters
saveParameters(id, Result.x_k);

% close RTC Tools
RTCToolsMatlab('close');