How can I use gamma function in optimization problem
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Daud
el 25 de Sept. de 2018
Comentada: Michele Carone
el 22 de Nov. de 2022
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 comentarios
Matt J
el 22 de Nov. de 2022
Editada: Matt J
el 22 de Nov. de 2022
@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
Michele Carone
el 22 de Nov. de 2022
Respuesta aceptada
Matt J
el 25 de Sept. de 2018
Editada: Matt J
el 27 de Sept. de 2018
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 comentarios
Walter Roberson
el 26 de Sept. de 2018
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)
Matt J
el 27 de Sept. de 2018
Editada: Matt J
el 27 de Sept. de 2018
And the reason gamma() is not defined for datatype optim.problemdef.OptimizationVariable is because you are not supposed to be doing any nonlinear operations on it, since optimproblem is only intended for linear programming (prior to R2018b).
Más respuestas (0)
Ver también
Categorías
Más información sobre Surrogate Optimization en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!