Iteration method of optimization
I am trying to solve the problem using stackelberg sequential equilibrium method –
Understanding the Approach:
In a Stackelberg game, we have two players: the leader and the follower. The leader chooses its strategy first, knowing that the follower will then optimize their strategy in response to the leader’s choice. This sequential decision-making process requires us to iteratively solve for the best responses of each player until we converge to a Nash equilibrium.
-Follower’s Best Response (t given k):
The follower’s strategy t is a function of the leader’s strategy k. We need to find the value of t that maximizes the follower’s utility given the leader’s choice of k. We start by initial guess of k and compute corresponding optimal t.
Leader’s Best Response (k inputing response of t):
Once we have the optimal t, the leader then chooses its strategy k to maximize its utility, knowing the follower will choose t optimally in response.
We will do this iteration till initial guess converge to optimal k. Following code encapsulate my idea –
% Parameters
m_values = linspace(0, 1, 100); % Range of m values
tolerance = 1e-6; % Convergence tolerance
max_iter = 1000; % Maximum number of iterations
% Initialize arrays to store results
k_solutions = zeros(size(m_values));
t_solutions = zeros(size(m_values));
% Function to compute follower’s best response t given k and m
compute_t = @(k, m) fminbnd(@(t) abs(sqrt(k) * ((m./t + 2) / 3) – sqrt(1 – k) * (1 / 3) * (2 + m./t + (2 * m + t) ./ ((m – t).^2 – 2 * t))), 0, 1);
% Function to compute leader’s objective function given k, t, and m
compute_obj = @(k, t, m) -(sqrt(1 – k) * (t^6 * (2 * m * (3 * m + 2) + 4) – t^5 * (m * (m * (5 * m + 6) + 11) + 12) + m^6 + 2 * t^7 – t^8 – t^4 * (m * (3 * m * (m * (3 * m + 2) – 3) – 16) – 9) – 2 * m^3 * t^2 * (3 * m^3 + 2 * m + 3) + m^2 * t^3 * (m * (3 * m * (5 * m + 4) + 1) – 4)) + sqrt(k) * (t^4 * (m * (9 * m * (m * (m + 4) + 5) + 28) + 9) – m^4 * (3 * m – 2) – t^6 * (6 * m * (m + 2) + 10) + t^5 * (4 * m^3 + 12 * m + 8) + t^8 + m * t^2 * (m * (m * (4 * m^3 + 3 * m + 9) + 6) – 8) + 2 * m^2 * t * (3 * m – 2) – 2 * m * t^3 * (m * (m * (6 * m * (m + 2) + 7) + 6) – 2))) / (18 * t^3 * (2 * t – (m – t)^2));
% Main loop to solve for each m
for i = 1:length(m_values)
m = m_values(i);
k_guess = 0.75; % Initial guess for k
k_opt = k_guess;
t_opt = compute_t(k_opt, m);
% Iterative optimization
for iter = 1:max_iter
% Compute optimal t given k
t_opt = compute_t(k_opt, m);
% Optimize k given t
k_opt_new = fminbnd(@(k) compute_obj(k, t_opt, m), 0.5, 1); % Use fminbnd for bounded optimization
% Check for convergence
if abs(k_opt_new – k_opt) < tolerance
k_opt = k_opt_new;
break;
end
k_opt = k_opt_new;
end
% Store solutions
k_solutions(i) = k_opt;
t_solutions(i) = t_opt;
end
% Plot results
figure;
plot(m_values, k_solutions, ‘b-‘, ‘LineWidth’, 1.5);
hold on;
plot(m_values, t_solutions, ‘r–‘, ‘LineWidth’, 1.5);
xlabel(‘m’);
ylabel(‘Value’);
legend(‘Optimal k’, ‘Optimal t’);
title(‘Stackelberg Equilibrium Solutions’);
% Display final values
fprintf(‘Final solutions:n’);
fprintf(‘m t k t tn’);
for i = 1:length(m_values)
fprintf(‘%.4f t %.4f t %.4fn’, m_values(i), k_solutions(i), t_solutions(i));
end
I could have used calculus… But since expression of t cannot be explicitly expressed as a function of k, substituting t into k and then differentiating wrt k (where, t is also function k) would give an untractably long expression.
Is the Approach I used correct? Can someone please suggest a better approach? Anyone please helpI am trying to solve the problem using stackelberg sequential equilibrium method –
Understanding the Approach:
In a Stackelberg game, we have two players: the leader and the follower. The leader chooses its strategy first, knowing that the follower will then optimize their strategy in response to the leader’s choice. This sequential decision-making process requires us to iteratively solve for the best responses of each player until we converge to a Nash equilibrium.
-Follower’s Best Response (t given k):
The follower’s strategy t is a function of the leader’s strategy k. We need to find the value of t that maximizes the follower’s utility given the leader’s choice of k. We start by initial guess of k and compute corresponding optimal t.
Leader’s Best Response (k inputing response of t):
Once we have the optimal t, the leader then chooses its strategy k to maximize its utility, knowing the follower will choose t optimally in response.
We will do this iteration till initial guess converge to optimal k. Following code encapsulate my idea –
% Parameters
m_values = linspace(0, 1, 100); % Range of m values
tolerance = 1e-6; % Convergence tolerance
max_iter = 1000; % Maximum number of iterations
% Initialize arrays to store results
k_solutions = zeros(size(m_values));
t_solutions = zeros(size(m_values));
% Function to compute follower’s best response t given k and m
compute_t = @(k, m) fminbnd(@(t) abs(sqrt(k) * ((m./t + 2) / 3) – sqrt(1 – k) * (1 / 3) * (2 + m./t + (2 * m + t) ./ ((m – t).^2 – 2 * t))), 0, 1);
% Function to compute leader’s objective function given k, t, and m
compute_obj = @(k, t, m) -(sqrt(1 – k) * (t^6 * (2 * m * (3 * m + 2) + 4) – t^5 * (m * (m * (5 * m + 6) + 11) + 12) + m^6 + 2 * t^7 – t^8 – t^4 * (m * (3 * m * (m * (3 * m + 2) – 3) – 16) – 9) – 2 * m^3 * t^2 * (3 * m^3 + 2 * m + 3) + m^2 * t^3 * (m * (3 * m * (5 * m + 4) + 1) – 4)) + sqrt(k) * (t^4 * (m * (9 * m * (m * (m + 4) + 5) + 28) + 9) – m^4 * (3 * m – 2) – t^6 * (6 * m * (m + 2) + 10) + t^5 * (4 * m^3 + 12 * m + 8) + t^8 + m * t^2 * (m * (m * (4 * m^3 + 3 * m + 9) + 6) – 8) + 2 * m^2 * t * (3 * m – 2) – 2 * m * t^3 * (m * (m * (6 * m * (m + 2) + 7) + 6) – 2))) / (18 * t^3 * (2 * t – (m – t)^2));
% Main loop to solve for each m
for i = 1:length(m_values)
m = m_values(i);
k_guess = 0.75; % Initial guess for k
k_opt = k_guess;
t_opt = compute_t(k_opt, m);
% Iterative optimization
for iter = 1:max_iter
% Compute optimal t given k
t_opt = compute_t(k_opt, m);
% Optimize k given t
k_opt_new = fminbnd(@(k) compute_obj(k, t_opt, m), 0.5, 1); % Use fminbnd for bounded optimization
% Check for convergence
if abs(k_opt_new – k_opt) < tolerance
k_opt = k_opt_new;
break;
end
k_opt = k_opt_new;
end
% Store solutions
k_solutions(i) = k_opt;
t_solutions(i) = t_opt;
end
% Plot results
figure;
plot(m_values, k_solutions, ‘b-‘, ‘LineWidth’, 1.5);
hold on;
plot(m_values, t_solutions, ‘r–‘, ‘LineWidth’, 1.5);
xlabel(‘m’);
ylabel(‘Value’);
legend(‘Optimal k’, ‘Optimal t’);
title(‘Stackelberg Equilibrium Solutions’);
% Display final values
fprintf(‘Final solutions:n’);
fprintf(‘m t k t tn’);
for i = 1:length(m_values)
fprintf(‘%.4f t %.4f t %.4fn’, m_values(i), k_solutions(i), t_solutions(i));
end
I could have used calculus… But since expression of t cannot be explicitly expressed as a function of k, substituting t into k and then differentiating wrt k (where, t is also function k) would give an untractably long expression.
Is the Approach I used correct? Can someone please suggest a better approach? Anyone please help I am trying to solve the problem using stackelberg sequential equilibrium method –
Understanding the Approach:
In a Stackelberg game, we have two players: the leader and the follower. The leader chooses its strategy first, knowing that the follower will then optimize their strategy in response to the leader’s choice. This sequential decision-making process requires us to iteratively solve for the best responses of each player until we converge to a Nash equilibrium.
-Follower’s Best Response (t given k):
The follower’s strategy t is a function of the leader’s strategy k. We need to find the value of t that maximizes the follower’s utility given the leader’s choice of k. We start by initial guess of k and compute corresponding optimal t.
Leader’s Best Response (k inputing response of t):
Once we have the optimal t, the leader then chooses its strategy k to maximize its utility, knowing the follower will choose t optimally in response.
We will do this iteration till initial guess converge to optimal k. Following code encapsulate my idea –
% Parameters
m_values = linspace(0, 1, 100); % Range of m values
tolerance = 1e-6; % Convergence tolerance
max_iter = 1000; % Maximum number of iterations
% Initialize arrays to store results
k_solutions = zeros(size(m_values));
t_solutions = zeros(size(m_values));
% Function to compute follower’s best response t given k and m
compute_t = @(k, m) fminbnd(@(t) abs(sqrt(k) * ((m./t + 2) / 3) – sqrt(1 – k) * (1 / 3) * (2 + m./t + (2 * m + t) ./ ((m – t).^2 – 2 * t))), 0, 1);
% Function to compute leader’s objective function given k, t, and m
compute_obj = @(k, t, m) -(sqrt(1 – k) * (t^6 * (2 * m * (3 * m + 2) + 4) – t^5 * (m * (m * (5 * m + 6) + 11) + 12) + m^6 + 2 * t^7 – t^8 – t^4 * (m * (3 * m * (m * (3 * m + 2) – 3) – 16) – 9) – 2 * m^3 * t^2 * (3 * m^3 + 2 * m + 3) + m^2 * t^3 * (m * (3 * m * (5 * m + 4) + 1) – 4)) + sqrt(k) * (t^4 * (m * (9 * m * (m * (m + 4) + 5) + 28) + 9) – m^4 * (3 * m – 2) – t^6 * (6 * m * (m + 2) + 10) + t^5 * (4 * m^3 + 12 * m + 8) + t^8 + m * t^2 * (m * (m * (4 * m^3 + 3 * m + 9) + 6) – 8) + 2 * m^2 * t * (3 * m – 2) – 2 * m * t^3 * (m * (m * (6 * m * (m + 2) + 7) + 6) – 2))) / (18 * t^3 * (2 * t – (m – t)^2));
% Main loop to solve for each m
for i = 1:length(m_values)
m = m_values(i);
k_guess = 0.75; % Initial guess for k
k_opt = k_guess;
t_opt = compute_t(k_opt, m);
% Iterative optimization
for iter = 1:max_iter
% Compute optimal t given k
t_opt = compute_t(k_opt, m);
% Optimize k given t
k_opt_new = fminbnd(@(k) compute_obj(k, t_opt, m), 0.5, 1); % Use fminbnd for bounded optimization
% Check for convergence
if abs(k_opt_new – k_opt) < tolerance
k_opt = k_opt_new;
break;
end
k_opt = k_opt_new;
end
% Store solutions
k_solutions(i) = k_opt;
t_solutions(i) = t_opt;
end
% Plot results
figure;
plot(m_values, k_solutions, ‘b-‘, ‘LineWidth’, 1.5);
hold on;
plot(m_values, t_solutions, ‘r–‘, ‘LineWidth’, 1.5);
xlabel(‘m’);
ylabel(‘Value’);
legend(‘Optimal k’, ‘Optimal t’);
title(‘Stackelberg Equilibrium Solutions’);
% Display final values
fprintf(‘Final solutions:n’);
fprintf(‘m t k t tn’);
for i = 1:length(m_values)
fprintf(‘%.4f t %.4f t %.4fn’, m_values(i), k_solutions(i), t_solutions(i));
end
I could have used calculus… But since expression of t cannot be explicitly expressed as a function of k, substituting t into k and then differentiating wrt k (where, t is also function k) would give an untractably long expression.
Is the Approach I used correct? Can someone please suggest a better approach? Anyone please help iteration, optimization, fmincon MATLAB Answers — New Questions