How can I use gamma function in optimization problem
3 次查看(过去 30 天)
显示 更早的评论
epsilon_c = 10e-9; % unitless
lambda = 1e-3; % seconds
P_t = -30; % dB
d = 10; % m
L_H = 40; % bits
L_U = 16; %bits
M_1 = 10; %dB
N_o = -204; %dB
A_o = 30; %dB
m = 1;
alpha = 3;
%%%Variables for Solution
K = optimvar('K', 1, 1, 'Type', 'integer', 'LowerBound', 0, 'UpperBound', 10);
z = optimvar('z', 1, 1, 'Type', 'integer', 'LowerBound', 0, 'UpperBound',10);
%%%Linear Constraints
L = L_H+(K*L_U); % Packet length
R_b = L/lambda; % minimum bit rate
decisioncons = (K/2) - z <= 0;
beta = ((epsilon_c*gamma(m*z+1))^(1/(m*z))*P_t)\(m*N_o*M_1*A_o*d^alpha);
bandwidthcons = B(2^(R_b/B)-1) <= beta;
%%%Solve the Problem
commm = optimproblem('ObjectiveSense','minimize');
commm.Objective = B;
commm.Constraints.decisioncons = decisioncons;
commm.Constraints.bandwidthcons = bandwidthcons;
options = optimoptions('intlinprog','Display','final');
[commmsol,fval,exitflag,output] = solve(commm,'options',options);
sol = commmsol.B
Error:
Undefined function
'gamma' for input
arguments of type
'optim.problemdef.OptimizationExpression'.
3 个评论
Matt J
2022-11-22
编辑:Matt J
2022-11-22
@Michele Carone No, you can use the gamma function in the solver-based framework, e.g.,
xoptimal=fmincon(@(x) gamma(x).^2, 1,[],[],[],[],0,5)
Also, in reecent matlab, you can make it work with the problem-based framework using fcn2optimexpr,
x=optimvar('x','Lower',0,'Upper',5);
GamSquare=fcn2optimexpr(@(z) gamma(z).^2, x);
sol0.x=1;
xoptimal = solve(optimproblem('Objective',GamSquare),sol0).x
采纳的回答
Matt J
2018-9-25
编辑:Matt J
2018-9-27
Your bandwidthcons are not linear, so optimproblem is not applicable here. Since there are only 100 combinations of K and z that satisfy the bounds, you should probably just use exhaustive search.
3 个评论
Walter Roberson
2018-9-26
gamma() is not defined for datatype optim.problemdef.OptimizationVariable
The defined arithmetic operations for the datatype are:
.\ (ldivide) -- only when the variable is on the right side, nonscalar constant left permitted
- (minus)
\ (mldivide) -- only when the variable is on the right side and left side is scalar
^ (mpower) -- only variable^2
/ (mrdivide) -- only when variable is on left side and right side is scalar
* (mtimes) -- nonscalar left and right permitted and variable^2 terms permitted as long as total degree of any term does not exceed 2
+ (plus)
.^ (power) -- only variable.^2
./ (rdivide) -- only when variable is on left side; right side can be non-scalar
.* (times) -- nonscalar left and right permitted and variable^2 terms permitted as long as total degree of any term does not exceed 2
- (uminus, unary minus)
+ (uplus, unary plus)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Gamma Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!