Iteration method of optimization
12 views (last 30 days)
Show older comments
Sabrina Garland
on 17 Jun 2024
Commented: Sabrina Garland
on 18 Jun 2024
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 t\n');
for i = 1:length(m_values)
fprintf('%.4f \t %.4f \t %.4f\n', 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
3 Comments
Accepted Answer
Torsten
on 18 Jun 2024
That's what I get from your description. But I might have misunderstood something.
% Parameters
m_values = linspace(0, 1, 100); % Range of m values
% Function to compute leader's objective function given k, t, and m
compute_k_from_t = @(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));
% Function to compute follower's best response t given k and m
compute_t_from_k = @(k, t, m) abs(sqrt(k) * ((m./t + 2) / 3) - sqrt(1 - k) * (1 / 3) * (2 + m./t + (2 * m + t) ./ ((m - t).^2 - 2 * t)));
% Main loop to solve for each m
k_values = linspace(0.5,1,1000);
for i = 1:numel(m_values)
m = m_values(i);
for j = 1:numel(k_values)
k = k_values(j);
t(j) = fminbnd(@(t)compute_t_from_k(k,t,m),0,1);
leaders_gain(j) = compute_k_from_t(k,t(j),m);
end
[~,idx] = min(leaders_gain);
k_opt(i) = k_values(idx);
t_opt(i) = t(idx);
end
plot(m_values,[k_opt;t_opt])
6 Comments
More Answers (1)
Umar
on 18 Jun 2024
Hi Sabrina, Based on the detailed explanation and code snippet provided, it seems that you are on the right track with your Stackelberg sequential equilibrium method approach. The approach you outlined involves iteratively solving for the best responses of the leader and follower until convergence to a Nash equilibrium is achieved. Your code snippet effectively captures the essence of the Stackelberg game setup, including the computation of the follower's best response given the leader's strategy and the leader's best response taking into account the follower's optimal strategy. The iterative optimization process you have implemented appears to be correctly structured to converge to optimal values of k and t for different values of m. While your current approach is valid, there are alternative methods that could potentially enhance efficiency or accuracy in solving for the Stackelberg equilibrium solutions. One suggestion could be to explore numerical optimization techniques beyond fminbnd, such as gradient-based methods like gradient descent or quasi-Newton methods like BFGS, which may offer faster convergence rates in some cases. Additionally, considering the complexity of the objective functions involved, you may also want to investigate symbolic computation libraries that could help in handling derivatives and optimizations more effectively. Libraries like SymPy in Python or symbolic math toolboxes in MATLAB can assist in dealing with complex mathematical expressions and enable more sophisticated analyses. In summary, while your current approach is sound, exploring alternative numerical optimization methods and symbolic computation tools could potentially provide insights into improving the efficiency and robustness of your solution method for solving Stackelberg games. Feel free to experiment with different techniques and tools to refine your approach further.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!