nonlinear constraint game theory
이전 댓글 표시

Plzz solve this problem in matlab.
댓글 수: 5
Torsten
2023년 11월 3일
Why do you write "this problem" ? Aren't these two (separate) problems ?
Akshay Tanaji Bhosale
2023년 11월 6일
Dyuman Joshi
2023년 11월 6일
Show what you have tried yet.
Walter Roberson
2023년 11월 6일
Problem Based Optimization
Akshay Tanaji Bhosale
2023년 11월 6일
편집: Walter Roberson
2023년 11월 6일
답변 (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
Akshay Tanaji Bhosale
2023년 11월 7일
Akshay Tanaji Bhosale
2023년 11월 7일
Torsten
2023년 11월 7일
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.
카테고리
도움말 센터 및 File Exchange에서 Number games에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!