I'm having some problem using fmincon. I have three variables:
var(1) = sym('pilotPower');
var(2) = sym('dataPower');
gamma = sym('gamma');
With the vpasolve I solve the equation in function of gamma so fun has two variable var(1) and var(2). Then I take one of the solution and I put it in fmincon after the conversion in a Matlab function (if I don't do that I receive a different error).
These are the constraints:
% Starting evaluation point for fmin con
x0 = [1,249];
% pilotPower + dataPower <= powerBudgetLin
A = [1,1];
b = powerBudgetLin;
And this is the remaining part of the code
eqn = usersNum*alpha^2*var(2)*q+dataSigma2 ==...
receiversNum*alpha^2*var(2)*d/gamma-(usersNum 1)*alpha^2*var(2)*d/(1+gamma);
fun = -vpasolve(eqn,gamma);
myMatlabFunction = matlabFunction(fun(1));
[pilotPowerOpt,fval] = fmincon(myMatlabFunction,x0,A,b);
If I inspect myMatlabFunction I see that it has two variable "pilotPower" and "dataPower"
At the moment I have as a error "Not enough input arguments. Error in optimizationtest (line 106) [pilotPowerOpt,fval] = fmincon(myMatlabFunction,x0,A,b); Caused by: Failure in initial objective function evaluation. FMINCON cannot continue. "
My aim is to maximize the positive result of "fun".

 Respuesta aceptada

Torsten
Torsten el 17 de Oct. de 2018
Editada: Torsten el 17 de Oct. de 2018

1 voto

fun = -solve(eqn,gamma);
[pilotPowerOpt,fval] = fmincon(@(x)myMatlabFunction(x(1),x(2)),x0,A,b);

5 comentarios

Daniele Davoli
Daniele Davoli el 17 de Oct. de 2018
Hi, thank you very much, so, now it works but the results do not respect my constraints -1.77634611474494e+20 6.55702664354688e+19 these are my two results, but their sum should be 250
Walter Roberson
Walter Roberson el 17 de Oct. de 2018
Their sum is 250 to within the accuracy of floating point numbers.
>> eps(-1.77634611474494e+20)
ans =
32768
We will need your full code (all variables initialized) to test further.
Daniele Davoli
Daniele Davoli el 18 de Oct. de 2018
This is my code, and my request for the fmincon is that pilot power + data power <= 250 with pilot power >= 0 and data power >=0.
%%Parameter
% Power Budget (pilot + data) for each users [mW]
powerBudgetLin = 250;
% Number of Users
usersNum = 3;
% Number of receivers
receiversNum = 10;
% Number of TX pilot symbols
pilotSymbolsNum = usersNum;
% Number of Subcarriers
subcarriersNum = 24;
% Channel distribution power
rho = 1;
% Channel Covariance Matrix
C = rho*eye(receiversNum);
% Channel distrubution mean
muC = 0;
% Noise Variance [mW] value found on Ming thesis
sigma2 = 1.99e-10;
% Noise Variance (pilot)
pilotSigma2 = sigma2;
% Noise Variance (data)
dataSigma2 = sigma2;
%%Simulation variables
x(1) = sym('pilotPower');
x(2) = sym('dataPower');
gamma = sym('gamma');
% Starting evaluation point for fmin con
x0 = [1,249];
% pilotPower + dataPower <= powerBudgetLin
A = [1,1];
b = powerBudgetLin;
%%Tx Power
% Pilot TX Power
pilotPowerSym = x(1)/pilotSymbolsNum;
% Data TX Power
dataPowerSym = x(2)/(subcarriersNum-pilotSymbolsNum);
alpha = sqrt(db2pow(-100));
R = C + pilotSigma2./(alpha^2*x(1))*eye(receiversNum);
r = norm(R);
D = C/R;
d = norm(D);
Q = C-C/R*C;
q = norm(Q);
eqn = usersNum*alpha^2*x(2)*q+dataSigma2 ==...
receiversNum*alpha^2*x(2)*d/gamma-(usersNum-1)*alpha^2*x(2)*d/(1+gamma);
fun = - solve(eqn,gamma);
myMatlabFunction = matlabFunction(fun(1));
[pilotPowerOpt,fval] = fmincon(@(x)myMatlabFunction(x(1),x(2)),x0,A,b);
I think that I made a mistake because I haven't defined the second and the third inequality. So I tried to put
lb = [0,0]
ub = [powerBudgetLin, powerBudgetLin]
[pilotPowerOpt,fval] = fmincon(@(x)myMatlabFunction(x(1),x(2)),x0,A,b,[],[],lb,ub);
And now seems to work. Thank you!
Walter Roberson
Walter Roberson el 18 de Oct. de 2018
So problem solved?
Daniele Davoli
Daniele Davoli el 18 de Oct. de 2018
I think so, thank you again.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2018b

Etiquetas

Preguntada:

el 17 de Oct. de 2018

Comentada:

el 18 de Oct. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by