I am currently using matlab to solve an optimization problem. I am generating the objective function using the symbolic toolbox. I planned use the symbolic toolbox to calculate the gradient and hessian and so speed up the optimization. The problem I have however is that when N is large (in my case over 8000) generating the function handles takes hours.
So my questions are these:
- is there a way to speed up function handle generation?
- is there an alternate way of generating an objective function when the length of N varies and be able to find the gradient and hessian?
- if not perhaps I should be using another package recommended for such a task? if so any recommendations?
here is a code snippet to show what I mean
X1 = sym('x1',[N,1]);
X2 = sym('intx',[2*N,1]);
P = sym('P',[N,1]);
FC = sym('FC',[N,1]);
CC = sym('CC',[N,1]);
SC = sym('SC',[N,1]);
AC = sym('AC',[N,1]);
efficiency6 = 0.1199 * (X1(1:N)/max_el_capacity_6).^3 - 0.3568 * (X1(1:N)/max_el_capacity_6).^2 + 0.4031* (X1(1:N)/max_el_capacity_6) + 0.2286;
income6 = X1(1:N).*(P(1:N)-CC(1:N)-AC(1:N)-FC(1:N)./efficiency6(1:N));
revenue6 = X2(1:N).*(income6) - SC(1:N).*X2(N+1:2*N);
totrevenue6 = -sum(revenue6);
totRevenue6 = subs(totrevenue6,[P;CC;FC;AC;SC],[ep';cc';fc';ac6';sc6']);
matlabFunction(totIncome6,'vars',{X1},'file','objectiveFcn2014_1');
many thanks, Jesse