Help setting up an optimization problem

5 views (last 30 days)
falbinali
falbinali on 23 Jun 2015
Answered: anubhav goel on 29 Sep 2018
I am trying to setup an optimization problem where I have 2 very large time series generated from raw sensory data.
The first time series is generated using an algorithm that essentially integrates the full signals from the raw sensory data at fixed time steps t (e.g. 1 second). The second time series generates its values using an algorithm that adaptively samples the raw data (essentially it is a state machine that sometimes samples and sometimes generates 0 depending on the values of the differentials of the raw data, the machine has three states with cost per state that depends on the duration spent in each state). The adaptive methods has a number of variables that I would like to optimize for example, thresholds for differentials to trigger sampling the raw signal, duration of sampling of the raw signal etc.
The objective is to minimize the difference between the first and second time series while the total cost (sum of cost in each state of the state machine) is constrained to a maximum fixed value (i.e. total cost cannot exceed a certain maximum).
I have access to a large representative data set that can be used to optimize the values but I would appreciate any guidance and help on the best way to handle and set up this problem with Global Optimization Toolbox. Thanks.

Answers (2)

Mukul Rao
Mukul Rao on 24 Jun 2015
Assuming I have understood your questions, here is the framework I would suggest for the optimization process. I am assuming that the raw data is not stochastic in which case, the functions in the global optimization toolbox will not provide meaningful results. Therefore, the code described below assumes that you have a single large vector of raw sensory data at hand. I recommend reading the code snippet after copying it into the editor to avail the color coded content.
Note that the variable "opt_params" is an array that contains the values for the parameters required by the adaptive algorithm, these parameters are the ones being optimized while satisfying the cost constraint described in nonlinearconstraints function.
Finally, to pass the states and raw data across functions, I have made use of nested functions. The whole code can be restructured to pass parameters instead. You can refer this link if you would like to take this route:
function mainfunc
%INITIALIZE, replace '[]' with desired values
raw_data = []; %Initialize to whatever
%Consider a 3 by 1 vector that keeps count of the total number of states
%associated with the adaptive algorithm
states = [];%Initialize to whatever, doesn't matter in my opinion
number_of_opt_params = [];%Number of paramteres you'd like to optimize
lb = []; %Lowerbound array for these parameters
ub = []; %Upperbound array for these parameters
%Set settings for the genetic algorithm and call ga
options = gaoptimset('Display','iter')
% GENETIC ALGORITHM
optimumvalues = ga(@objectivefunc,number_of_opt_params,...
[],[],[],[],lb,ub,@nonlinearconstraints,options);
%%Define nested objective function
function delta = objectivefunc(opt_params)
%Process raw_data to yield time series - 1
tseries1 = algorithm1(raw_data);
%Process raw_data to yield time series - 2
%Keep track of the number of adaptive states
[tseries2,states] = adaptive_algorithm(raw_data,opt_params);
%
%Now return the objective, some metric calculated using the two series
delta = some_metric(tseries1,tseries2);
end
%%Define nested nonlinear constraint function
function output = nonlinearconstraints(opt_params)
%If cost(states) <= limit
output = cost(states) + limit;
end
end

anubhav goel
anubhav goel on 29 Sep 2018
this problem can also be solved by defining your raw data matrix. proceed by creating a buffer for final values and use for loop.

Categories

Find more on Problem-Based Optimization Setup in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!