nonlinear constraint game theory

Plzz solve this problem in matlab.

5 commentaires

Torsten
Torsten le 3 Nov 2023
Why do you write "this problem" ? Aren't these two (separate) problems ?
Akshay Tanaji Bhosale
Akshay Tanaji Bhosale le 6 Nov 2023
Actually both are separate problems but in a game this two problems represents two players. You can solve separately.
Dyuman Joshi
Dyuman Joshi le 6 Nov 2023
Show what you have tried yet.
Walter Roberson
Walter Roberson le 6 Nov 2023
Problem Based Optimization
Akshay Tanaji Bhosale
Akshay Tanaji Bhosale le 6 Nov 2023
Modifié(e) : Walter Roberson le 6 Nov 2023
This one is for maximization:
% Define the objective function
n = 5; % Set your desired value for n
k = 0.2; % Set your desired value for k
C = 100; % Set your desired value for C
V_i = [10; 10; 10; 10; 10];
% Generate random initial values for a_i
initial_a = zeros(n, 1);
% Generate random data for d_i and V_i
d_i = [2.5; 2.5; 2.5; 2.5; 2.5]; % Replace with your actual data
% Define the anonymous objective function
objective = @(a) -sum(V_i .* exp(-k * (d_i ./ a)) - a);
% Define the nonlinear inequality constraint
nonlcon = @(a) deal(C - sum(a), []); % Return an empty array for equality constraints
% Set up optimization options
options = optimoptions('fmincon', 'Display', 'iter');
% Solve the optimization problem
result = fmincon(objective, initial_a, [], [], [], [], zeros(n, 1), [], nonlcon, options);
% Extract the optimized values of a_i
optimal_a = result;
% Evaluate the objective function with the optimal values of a_i
optimal_objective_value = objective(optimal_a);
% Display the optimal solution and objective function value
disp('Optimal values of a_i:')
disp(optimal_a);
disp(['Optimal Objective Function Value: ', num2str(optimal_objective_value)]);
This one is for minimization:
% Define the objective function
n = 5; % Set your desired value for n
k = 0.2; % Set your desired value for k
B = 60; % Set your desired value for C
V_i = [10; 10; 10; 10; 10];
% Generate random initial values for a_i
initial_d = zeros(n, 1);
% Generate random data for d_i and V_i
a = [2.5; 2.5; 2.5; 2.5; 2.5]; % Replace with your actual data
% Define the anonymous objective function
objective = @(d) sum(V_i .* exp(-k * (d ./ a)) + d);
% Define the nonlinear inequality constraint
nonlcon = @(d) deal(B - sum(d), []); % Return an empty array for equality constraints
% Set up optimization options
options = optimoptions('fmincon', 'Display', 'iter');
% Solve the optimization problem
result = fmincon(objective, initial_d, [], [], [], [], zeros(n, 1), [], nonlcon, options);
% Extract the optimized values of a_i
optimal_d = result;
% Evaluate the objective function with the optimal values of a_i
optimal_objective_value = objective(optimal_d);
% Display the optimal solution and objective function value
disp('Optimal values of d_i:')
disp(optimal_d);
disp(['Optimal Objective Function Value: ', num2str(optimal_objective_value)]);
But I am not getting output as expected.

Connectez-vous pour commenter.

Réponses (1)

Torsten
Torsten le 6 Nov 2023
Modifié(e) : Torsten le 7 Nov 2023
By the way: What do you mean by "nonlinear constraint game theory" ? Your constraints are all linear.
% Define the objective function
n = 5; % Set your desired value for n
k = 0.2; % Set your desired value for k
C = 100; % Set your desired value for C
V_i = [10; 10; 10; 10; 10];
% Generate random initial values for a_i
initial_a = ones(n, 1);
% Generate random data for d_i and V_i
d_i = [2.5; 2.5; 2.5; 2.5; 2.5]; % Replace with your actual data
% Define the anonymous objective function
objective = @(a) -sum(V_i .* exp(-k * (d_i ./ a)) - a);
% Define the nonlinear inequality constraint
%nonlcon = @(a) deal(C - sum(a), []); % Return an empty array for equality constraints
A = ones(1,n);
b = C;
% Set up optimization options
options = optimoptions('fmincon', 'Display', 'iter');
% Solve the optimization problem
%result = fmincon(objective, initial_a, A, b, [], [], zeros(n, 1), [], nonlcon, options);
result = fmincon(objective, initial_a, A, b, [], [], zeros(n, 1), inf(n,1), [], options);
First-order Norm of Iter F-count f(x) Feasibility optimality step 0 6 -2.532653e+01 0.000e+00 2.032e+00 1 12 -2.750948e+01 0.000e+00 5.091e-01 4.312e+00 2 18 -2.831279e+01 0.000e+00 3.424e-01 8.050e-01 3 24 -2.872906e+01 0.000e+00 3.494e-01 1.987e+00 4 30 -2.888048e+01 0.000e+00 9.298e-02 1.034e+00 5 36 -2.893772e+01 0.000e+00 2.667e-02 2.867e-01 6 42 -2.894194e+01 0.000e+00 1.015e-02 8.285e-02 7 48 -2.894207e+01 0.000e+00 1.971e-04 1.731e-02 8 54 -2.894207e+01 0.000e+00 1.011e-06 1.502e-04 9 60 -2.894207e+01 0.000e+00 2.322e-07 3.512e-06 Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
% Extract the optimized values of a_i
optimal_a = result;
% Evaluate the objective function with the optimal values of a_i
optimal_objective_value = objective(optimal_a);
% Display the optimal solution and objective function value
disp('Optimal values of a_i:')
Optimal values of a_i:
disp(optimal_a);
1.9695 1.9695 1.9695 1.9695 1.9695
disp(['Optimal Objective Function Value: ', num2str(-optimal_objective_value)]);
Optimal Objective Function Value: 28.9421
% Define the objective function
n = 5; % Set your desired value for n
k = 0.2; % Set your desired value for k
B = 60; % Set your desired value for C
V_i = [10; 10; 10; 10; 10];
% Generate random initial values for a_i
initial_d = ones(n, 1);
% Generate random data for d_i and V_i
a = [2.5; 2.5; 2.5; 2.5; 2.5]; % Replace with your actual data
% Define the anonymous objective function
objective = @(d) sum(V_i .* exp(-k * (d ./ a)) + d);
% Define the nonlinear inequality constraint
%nonlcon = @(d) deal(B - sum(d), []); % Return an empty array for equality constraints
A = ones(1,n);
b = B;
% Set up optimization options
options = optimoptions('fmincon', 'Display', 'iter');
% Solve the optimization problem
result = fmincon(objective, initial_d, A, b, [], [], zeros(n, 1), inf(n,1), [], options);
First-order Norm of Iter F-count f(x) Feasibility optimality step 0 6 5.115582e+01 0.000e+00 1.309e-01 1 12 5.087684e+01 0.000e+00 1.178e-01 4.893e-01 2 18 5.000391e+01 0.000e+00 6.960e-02 1.738e+00 3 25 5.000588e+01 0.000e+00 6.973e-02 4.394e-03 4 31 5.000450e+01 0.000e+00 9.002e-04 3.082e-03 5 37 5.000100e+01 0.000e+00 2.008e-04 7.803e-03 6 43 5.000001e+01 0.000e+00 2.070e-06 2.221e-03 7 49 5.000000e+01 0.000e+00 1.937e-07 2.288e-05 Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
% Extract the optimized values of a_i
optimal_d = result;
% Evaluate the objective function with the optimal values of a_i
optimal_objective_value = objective(optimal_d);
% Display the optimal solution and objective function value
disp('Optimal values of d_i:')
Optimal values of d_i:
disp(optimal_d);
1.0e-06 * 0.1001 0.1001 0.1001 0.1001 0.1000
disp(['Optimal Objective Function Value: ', num2str(optimal_objective_value)]);
Optimal Objective Function Value: 50

3 commentaires

Akshay Tanaji Bhosale
Akshay Tanaji Bhosale le 7 Nov 2023
the objective function is nonlinear and about game theory so this problem is between two players each one of them try to satisfy their objective. So is there any matlab toolbox which solve adversial game between two players.
Akshay Tanaji Bhosale
Akshay Tanaji Bhosale le 7 Nov 2023
Also the output I want is with increase in the value of C the optimal objective value for maximization case will increase. And with increase in the value of B optimal objective value for minimization case will decrease.
Torsten
Torsten le 7 Nov 2023
Also the output I want is with increase in the value of C the optimal objective value for maximization case will increase. And with increase in the value of B optimal objective value for minimization case will decrease.
Your model is now correctly implemented. If you expect a different behaviour of the solution, then either your model is wrong or it has multiple local maxima and/or minima. In the last case, you could try with different initial values for a and d.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Strategy & Logic dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by