No limits
You will probably find a solution with fmincon or fminunc in MATLAB. For example, using fminunc because its syntax is a little cluttered, you can start by defining the cost function in a separate file called "NameOfFunction.m":
function cost = NameOfFunction(w, a, b, c, Structure1, Structure2, Structure3) % Your code goes here, just remember that you return a scalar-valued cost from % this function.
Note that fminunc and the like will try to minimize this cost function. If you need to maximize it, just multiply the final cost by -1 at the end. Then you create a handle to your function in your main file:
h = @(w)NameOfFunction(w, a, b, c, Structure1, Structure2, Structure3);
Where w is the vector of variables you want to optimize:
w = [w1, w2, w3];
This basically masks your function with all its inputs as the function you want to optimize, w as far as fminunc is concerned. This allows you to pass your parameters a , b , c , Structure , Structure2 and Structure3 into your NameOfFunction cost NameOfFunction without fminunc , touching them. Now you can call fminunc on your descriptor with the original assumption for your vector w :
w0 = [w1_init, w2_init, w3_init]; [w, fval] = fminunc(h, w0);
And fminunc should find the optimal values ββfor your vector w , which minimizes (note that it is looking for the minimum) your cost function.
With restrictions
In this case, you would most likely use fmincon . If your constraints are in the forms of the upper and lower bounds of each of your parameters that you optimize, then put them in vectors:
ub = [w1_upper, w2_upper, w3_upper]; lb = [w1_lower, w2_lower, w3_lower];
And call the same descriptor as before using fmincon :
[w, fval] = fmincon(h, w0, [], [], [], [], lb, ub);
Four [] in the example above are just placeholders for parameters that you are not using. fmincon can handle more complex constraints; check the documentation (linked at the beginning of this discussion) for more details.