I'm attempting to use NLOPT with Matlab on Windows 7, 32-bit.  I've been able 
to replicate the results from the tutorial example and understand how that 
problem is formulated.  However I'm having difficulty properly inputting in my 
own minimization problem.

Without getting to deep into the nitty gritty, I'm doing some data analysis and 
attempting to optimize a set of inputs within the analysis code to minimize 
some of the output values.  Specifically, there are 10 input values and 4 
output values that I've been summing into a single output.  So while not a 
normal mathematical function, I feel it should be possible to treat it as such, 
since output = function(input).

The constraints are pretty straightforward:
0 < inputs < 5
while  the output starts in the 14,000 range (for inputs(1:10) = 1) and would 
hopefully be lower than a few thousand when optimized.

Does my setup, shown below, look like a decent way to setup the problem, as it 
doesn't seem to be working as well as I'd like?  

What I've got looks something like the following (vars(1:10) would be the 
input, vars(11) is the output):
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

opt.algorithm = NLOPT_GN_ISRES
opt.lower_bounds = [0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 
0.001, 0.001, 100]
opt.upper_bounds = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 100000]
opt.min_objective = @myfunc
opt.h = { @(vars) myconstraint(vars) }
opt.h_tol = [1e-8]
opt.xtol_rel = 1e-4
opt.verbose = 1
opt.maxeval = 100
 
xinit = [1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 14370];
[xopt, fmin, retcode] = nlopt_optimize(opt, xinit)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [val] = myfunc(vars)
    val = vars(11);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [val] = myconstraint(vars)
    val = my_analysis_code(vars(1:10))-vars(11);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

With the following example output:

opt = 

        algorithm: 35
     lower_bounds: [1x11 double]
     upper_bounds: [5 5 5 5 5 5 5 5 5 5 100000]
    min_objective: @myfunc
                h: {[@(vars)myconstraint(vars)]}
         xtol_rel: 1.0000e-004
          verbose: 1
          maxeval: 100
            h_tol: 1.0000e-008

nlopt_optimize eval #1: 14370
nlopt_optimize eval #2: 12953.5
nlopt_optimize eval #3: 82528.7
nlopt_optimize eval #4: 66663.4
nlopt_optimize eval #5: 77607.3
nlopt_optimize eval #6: 30835.3
nlopt_optimize eval #7: 21649.4
nlopt_optimize eval #8: 41587.2
nlopt_optimize eval #9: 12097.4
nlopt_optimize eval #10: 28028.5
.
nlopt_optimize eval #20: 9475.86
.
nlopt_optimize eval #34: 3093.1
nlopt_optimize eval #35: 83702
.
nlopt_optimize eval #98: 80718.5
nlopt_optimize eval #99: 35348.6
nlopt_optimize eval #100: 11224.6

xopt =
           1           1           1           1           1           1        
   1           1           1           1       14370


fmin =
       14370


retcode =
     5

Cheers,
Jesse

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss

Reply via email to