The following is the code:
cvx_begin
variable bor_brwr_lndr(no_cells,no_cells) nonnegative
expression supply(no_cells,1);
supply = supply+capacity;
for brwr=1:no_cells
for lndr =1:no_cells
supply(brwr) = supply(brwr) + neighs_mapping(brwr,lndr) * bor_brwr_lndr(brwr,lndr); % borrowed, supply increases
supply(lndr) = supply(lndr) - neighs_mapping(brwr,lndr) * bor_brwr_lndr(brwr,lndr); % lent, supply decreases
end
end
minimize sum(demand - supply)
for iter_ci=1:no_cells
sum(bor_brwr_lndr(:,iter_ci)) <= capacity- demand(iter_ci); % Lend only the surplus
supply(iter_ci)<=demand(iter_ci); % Don't borrow after meeting the demand
end
cvx_end
The initial values are the follows:
demand=
1080
1510
710
1700
970
420
750
990
970
920
neighs_mapping=
0 0 0 0 0 1 1 0 0 0
0 0 0 0 0 0 1 0 0 1
0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
capacity = 1000
no_cells = 10
It is a load distribution problem. There are 10 cells and the initial supply is 1000 in each cell. If the demand is more than the supply in a given cell, such a deficit cell can borrow from its neighbouring surplus cells. The neighbours mapping is given by the matrix neighs_mapping (rows indicate borrower and columns indicate lender). The task is to determine who should borrow how much from whom: in bor_brwr_lndr matrix, with the objective that the deficit is minimized.
It can be seen that some borrowing is possible. However, the CVX says that the problem is infeasible. Kindly help me