nonlinear constraint game theory
Show older comments

Plzz solve this problem in matlab.
5 Comments
Torsten
on 3 Nov 2023
Why do you write "this problem" ? Aren't these two (separate) problems ?
Akshay Tanaji Bhosale
on 6 Nov 2023
Dyuman Joshi
on 6 Nov 2023
Show what you have tried yet.
Walter Roberson
on 6 Nov 2023
Problem Based Optimization
Akshay Tanaji Bhosale
on 6 Nov 2023
Edited: Walter Roberson
on 6 Nov 2023
Answers (1)
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);
% 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)]);
% 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);
% 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)]);
3 Comments
Akshay Tanaji Bhosale
on 7 Nov 2023
Akshay Tanaji Bhosale
on 7 Nov 2023
Torsten
on 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.
Categories
Find more on Number games in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!