Using fmincon for a black box optimization (through a simulation.exe file)

5 views (last 30 days)
Dear community,
I'm trying to run an optimization concerning a vertical geothermal heatpump. It focuses mainly on the borehole configuration. I'm using the function fmincon. I'm starting simple (1 optimization variable: depth of 1 borehole). My objective function is the total cost, which is:
total_cost = depth*22*M_drilling ... % M_drilling is the drilling cost per meter
+ 1444* peak_load^(0.665) ... % heat pump cost, peak load is given
+tot_energy_used*c_elec... %energy cost heat pump, tot_energy_used is in function of depth
+c_elec*732*s2*2*((delta_p*depth*aantal_boreholes/rho)+...
(s1*dist_between_boreholes*delta_p*rate_flow/(aantal_boreholes*rho))); % pumping cost, dependend on the depth and on the configuration (configuration is fixed at the moment)
To get the values that depend on the depth, I have to run a sim.exe file. This file is ran in the function objfun(depth). In this function we thus also find the total_cost function.
I got 4 boundary constraints. 2 boundaries on the depth (min and max) and 2 boundaries on the maximum and minimum fluidum temperature entering the configuration (which is important to get a stable system). These temperatures also depend on the depth, so in the constraint function the sim.exe file is also ran.
My problem is defined as the following:
var0 = depth_init;
options = optimset('fmincon');
options.MaxIter = 2000;
options.MaxFunEvals = 2000;
options.TolCon = 1e-6;
options.Display='off';
problem = createOptimProblem('fmincon', 'objective', @(var) objfun(var), ...
'nonlcon', @(var) constraint(var, depth_lb, depth_ub, ...
T_lb, T_ub), 'x0', var0, 'options', options);
with depth_init the initial value (taken random between the boundaries of the depth), depth lb and depth ub resp. the lower boundary and the upper boundary of the depth and T_lb and T_ub resp. the lower boundary and upper boundary of the fluidum temperature.
After this is defined, fmincon is used:
[depth_opt, z_opt, exitflag] =fmincon(problem);
And I also tried with globalsearch:
gs=GlobalSearch;
[depth_opt, z_opt, exitflag] = run(gs,problem);
display(exitflag)
The solution expected is as follows: The lower the depth (so the closer to the lower boundary), the smaller the total_cost will be. However, the lower temperature boundary will kick in. So for example, if I use reasonable values for the drilling cost, elecricity cost etc. and I take boundaries for my depth: [50;90] [m] and for my temperature: [-5;35] [°C] I should find something around depth_opt = 56.5meter. However, if I try, and I display the depths during the optimization, along with the constraints, there are some iterations around 56.5, with the lower bound temperature constraint not ok (so around the optimal solution, but not yet there). After a while the optimization fills in 2 ridiculous values for the depth, which are out of the boundaries, after which it stops at depth_opt = depth_lb and exitflag = -2 (no feasible point found).
I tried my best to explain it as clear as possible. The sim.exe file takes as input the depth, and returs the different parameters needed to calculate the total cost. Could it be that the coupling between this .exe file and fmincon algorithm is the problem? If you need any more information I can provide. Eventually I want to the optimization to include many other parameters, so It gets more complicated, but this has to work first :).
thank you in advance
Nick De Vocht
Master student engineering
Faculty Energy
KULeuven

Answers (2)

Alan Weiss
Alan Weiss on 9 Dec 2013
I don't understand exactly what your problem is, but perhaps you could see if there is a feasible point as suggested in the documentation.
You might also want to look at the documentation on optimizing simulations.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

Nick
Nick on 9 Dec 2013
Yeah it's really hard to explain, thanks for the fast response though. It might be a problem with the simulation file, but I just wanted to be sure that there wasn't like an option in the optimization tool that I overlooked, or something like that.
Thanks anyway, I'm going to keep on trying!
Nick De Vocht

Community Treasure Hunt

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

Start Hunting!