Maximize D2D rate - FMINCON problem

Hello!
I would like to ask for your help if easy... I have to solve a maximization problem where there are some D2D users deployed in the network and I am trying to allocate resources in order to maximize the total throughput (all users' rates summed).
Below I write down my objective function form and the example to solve:
% Objective function for maximizing minimum D2D rates
function f = objfunc(z,x)
a = z.*x;
f = sum(sum(sum(a)));
f = -f;
and also I have another function with nonlinear constraints in it that receives two decision variables as an input (z,x), as already noted in objfunc.
  • z: matrix of z_{k,j} elements where k is the number of D2D users and j the Resource indicator. If z_{k,j} > 0, k user utilizes j resource, else it is zero
  • x: matrix of x_{k,j} -- value set to one if k user utilizes j resource, otherwise it is zero
I also have some linear constraints that for each user k, the sum(x_{k,j}) for all j resources equals to 1, this means that each user will use only one resource. I then try to call the Matlab solver of fmincon like this:
fun = @objfunc;
cfun = @confunc;
% Linear inequality constraints
A = [];
b = [];
% Linear equality constraints
Aeq = ones(d2d_pairs, Nband);
beq = ones(1,d2d_pairs)';
% Lower and upper bounds
lb = [];
ub = [];
opts = optimoptions(@fmincon,'Algorithm','interior-point');
x0 = zeros(d2d_pairs, Nband);
[x , fval] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,confunc,opts);
- where Aeq and beq are the matrices to satisfy the equality constraints mentioned above.
Then, after running the code, the result is:
Error using fmincon (line 284)
Aeq must have 150 column(s).
Error in multipoint_D2D_scenario_v20 (line 197)
[x , fval] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,confunc,opts);
- (if I also by hand change this to be 150 columns, the errors change:
Error using objfunc (line 5)
Not enough input arguments.
Error in fmincon (line 564)
initVals.f = feval(funfcn{3},X,varargin{:});
Error in multipoint_D2D_scenario_v20 (line 197)
[x , fval] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,confunc,opts);
Caused by:
Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.
)
Do you know what kind of problem is this? It is too complicated to refer to this in its whole extent.
Thank you in advance!

 Accepted Answer

Matt J
Matt J on 6 Jul 2014
Edited: Matt J on 6 Jul 2014
and also I have another function with nonlinear constraints in it that receives two decision variables as an input (z,x), as already noted in objfunc.
You are not allowed to write your functions in terms of multiple separate unknowns like z and x. You must express everything in terms of a single concatenated vector of unknown parameters, p=[x(:);z(:)]. If it helps to break p into separate parts inside your objective and nonlinear constraint functions, you can do so, but the input argument syntax of the functions must be in terms of p, like below. I assume throughout that the matrix dimensions of z and x are both MxN.
function f = objfunc(p)
xcol=p(1:M*N);
zcol=p(M*N+1:end);
f=-dot(zcol,xcol);
You must also shape your A,b,Aeq,beq linear constraint matrices with the assumption that they will be multiplied with p as in
A*p <= b,
Aeq*p = beq
You can use Kronecker products to express the row sum operator of a matrix x that has been converted to a vector x(:),
rowsums_for_x = kron(ones(1,N),speye(M));
zeros_for_z = sparse(M,M*N);
Aeq=[rowsums_for_x, zeros_for_z];
beq=ones(M,1);
Finally, the bound vectors ub,lb must be the same length as the total unknown vector p (or else left empty []) as must your initial guess p0=[x0(:);z0(:)].

10 Comments

Thank you very much for your kind information! It was really helpful to make me understand somehow how it works!
Just another question, if you don't mind...
my main function contains this code in the end:
fun = @objfunc;
cfun = @confunc;
% Linear inequality constraints
A = [];
b = [];
% Linear equality constraints
rowsums_for_x = kron(ones(1,N),speye(M));
zeros_for_z = sparse(M, M*N);
Aeq = [rowsums_for_x, zeros_for_z];
beq = ones(M, 1); % one cell, needs change
% Lower and upper bounds
lb = [];
ub = [];
% p-vector initialization
x0 = zeros(M, N);
z0 = zeros(M, N);
p0 = [x0(:) ; z0(:)];
opts = optimoptions(@fmincon,'Algorithm','interior-point');
[x , fval] = fmincon(fun,p0,A,b,Aeq,beq,lb,ub,confunc,opts);
My constraints function (just to make it run) has now become as follows:
function [c,ceq] = confunc(p)
c = []; % Init
vec_len = M*N;
xc = p(1 : vec_len);
zc = p(vec_len + 1 : end);
% Constraints for satisfying minimum rate according to Shannon capacity
% formula
for k = 1:vec_len,
c = [c ; 2^zc(k) - P_D2D*xc(k) - 1]; % rate to satisfy SCF
c = [c ; -zc(k)]; % rate to be greater than zero
end
% Non-linear equality constraints
ceq = []; % Init
Also, the objfunc remains as you wrote down in your last answer.
After executing this in MATLAB, I receive the following error message:
''Error using confunc (line 77) Not enough input arguments.
Error in multipoint_D2D_scenario_v21 (line 203) [x , fval] = fmincon(fun,p0,A,b,Aeq,beq,lb,ub,confunc,opts);'' It is just a simple example just to show you the problem... Is it sth again that I didn't do well?
Regards, Chris
You didn't pass cfun to fmincon,
[x , fval] = fmincon(fun,p0,A,b,Aeq,beq,lb,ub,cfun,opts);
Thank you!
Matt J
Matt J on 18 Jul 2014
Edited: Matt J on 18 Jul 2014
Are you ready to
?
Another question if easy for you... For example, if I want the sum of the first 20 out of N elements (according to your notation) to be equal to 1 and the others to be zero, how could this implemented?
s=zeros(1,N);
s(1:20)=1;
rowsums_for_x = kron(s,speye(M));
Christoforos Vlachos commented:
I did it in a different way, but this also works! Thanks!
Last question, I promise :)
I have already constructed the objective function as noted afore, as well as the summation constraints that we discussed.
Additionally, I want to add another matric c of non-linear inequality constraints. That is:
c = []; % Init
vec_len = d2d_pairs*Nband;
xc = p(1 : vec_len);
zc = p(vec_len + 1 : end);
% Constraints for satisfying minimum rate according to Shannon capacity formula
for k = 1 : vec_len,
c = [c ; 2^zc(k) - P_D2D*gain(k)/tot_interf(k)*xc(k) - 1];
c = [c ; -zc(k)]; % rate to be greater than zero
end
where k: user id, gain(k): gain estimation from the path loss between the D2D users that construct the D2D pair k, and tot_interf(k) is the estimated interference to user k from other users (that utilize the j-th RB).
My question is: if I include all this kind of restrictions and constraints, the optimization solver will assign several j RBs to each user (until the sum reaches 1), where as I needed only one to be assigned to each one of them. Therefore, a user will be assigned with lots of RBs and then, the interference factor for each k will be enhanced.
Am I right?
No idea. I don't even know what an RB is...
j element let's say... It's OK.. I will try to fix it! Thanks

Sign in to comment.

More Answers (0)

Asked:

on 6 Jul 2014

Commented:

on 21 Jul 2014

Community Treasure Hunt

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

Start Hunting!