Optimal weights using outer optimization loop
How to optimize weights in the following problem:
a[100],b[100],c[100],w1,w2,w3;
f = w1*a+w2*b+w3*c;
for 1:100
{
fmincon (minimize(f) w.r.t a[i],b[i],c[i]) with one weight[w1,w2,w3](user defined)
}
after 100 values calculation is done:
X = [avg_a,avg_b,avg_c]
the sample code is as follows:
% Loop through each theta value
for i = 1:length(range)
% Solve for the current theta
[solution, objectiveValue] = fmincon(@(x) objectiveFcn(x, range(i),weights), initial_guess, [], [], [], [], lb, ub, @(x) constraintFcn(x, range(i)), options2);
% Display the value of the objective function in each iteration
disp([‘Iteration ‘, num2str(i), ‘: Objective Value = ‘, num2str(objectiveValue)]);
% Store solution and objective value
solutions(i, 🙂 = solution;
objective_values(i) = objectiveValue;
end
after this we have the average.
All this code mentioned works good….
objective for weight: change weights to minimize the max of X[avg_a,avg_b,avg_c]
The problem or issue I have right now is if i try to use outer fmincon or fminsearch for weights as X is just a scaler number so i dont understand how to create a second loop for weights(outer loop).
Am i thinking of the problem correctly? or any other methods that i can look into would also help like hill climb etc.How to optimize weights in the following problem:
a[100],b[100],c[100],w1,w2,w3;
f = w1*a+w2*b+w3*c;
for 1:100
{
fmincon (minimize(f) w.r.t a[i],b[i],c[i]) with one weight[w1,w2,w3](user defined)
}
after 100 values calculation is done:
X = [avg_a,avg_b,avg_c]
the sample code is as follows:
% Loop through each theta value
for i = 1:length(range)
% Solve for the current theta
[solution, objectiveValue] = fmincon(@(x) objectiveFcn(x, range(i),weights), initial_guess, [], [], [], [], lb, ub, @(x) constraintFcn(x, range(i)), options2);
% Display the value of the objective function in each iteration
disp([‘Iteration ‘, num2str(i), ‘: Objective Value = ‘, num2str(objectiveValue)]);
% Store solution and objective value
solutions(i, 🙂 = solution;
objective_values(i) = objectiveValue;
end
after this we have the average.
All this code mentioned works good….
objective for weight: change weights to minimize the max of X[avg_a,avg_b,avg_c]
The problem or issue I have right now is if i try to use outer fmincon or fminsearch for weights as X is just a scaler number so i dont understand how to create a second loop for weights(outer loop).
Am i thinking of the problem correctly? or any other methods that i can look into would also help like hill climb etc. How to optimize weights in the following problem:
a[100],b[100],c[100],w1,w2,w3;
f = w1*a+w2*b+w3*c;
for 1:100
{
fmincon (minimize(f) w.r.t a[i],b[i],c[i]) with one weight[w1,w2,w3](user defined)
}
after 100 values calculation is done:
X = [avg_a,avg_b,avg_c]
the sample code is as follows:
% Loop through each theta value
for i = 1:length(range)
% Solve for the current theta
[solution, objectiveValue] = fmincon(@(x) objectiveFcn(x, range(i),weights), initial_guess, [], [], [], [], lb, ub, @(x) constraintFcn(x, range(i)), options2);
% Display the value of the objective function in each iteration
disp([‘Iteration ‘, num2str(i), ‘: Objective Value = ‘, num2str(objectiveValue)]);
% Store solution and objective value
solutions(i, 🙂 = solution;
objective_values(i) = objectiveValue;
end
after this we have the average.
All this code mentioned works good….
objective for weight: change weights to minimize the max of X[avg_a,avg_b,avg_c]
The problem or issue I have right now is if i try to use outer fmincon or fminsearch for weights as X is just a scaler number so i dont understand how to create a second loop for weights(outer loop).
Am i thinking of the problem correctly? or any other methods that i can look into would also help like hill climb etc. optimization, fmincon, search MATLAB Answers — New Questions