如何从C ++中的.lp格式中提取A,b,f的系数

时间:2017-06-10 05:03:56

标签: c++ linear-programming

我正在尝试lp问题的基准问题。我找到了几个关于这个基准的网站。在一个站点中,我发现了lp问题的格式如下:

min c'x经受Ax = b,l <= x <= u

文件格式:

nrow  (number of rows in A)
ncol  (number of cols in A)
Anz   (number of nonzeros in A)
dcost (add to cost to get original cost)

Ap    (column pointers, ncol+1 integer)
Ai    (row indices of nonzeros in A, Anz integer)
Ax    (numerical values of nonzeros in A ,Anz real)
b     (nrow real)
c     (ncol real)
l     (ncol real)
u     (ncol real)

Ap (j) = location of start of column j
Ai (Ap (j)) through Ai (Ap (j+1)-1) are the row indices in column j
Ax (Ap (j)) through Ax (Ap (j+1)-1) are the numerical values in column j

我无法理解如何从Ap,Ai和Ax形成2D数组A[][]。例如,假设根据上述格式,这个问题的格式是什么:

Minimize w = 2x1 + 10x2 + 8x3
subject to   2x1 + 2x2 + 2x3 >= 6
             2x2 + 2x3 >= 8
             -2x1 + 2x2 + 2x3 >= 4
bound to x1>=0,x2>=0,x3>=0 

针对上述问题的[] []如下:

2 2 2 
0 2 2 
-2 2 2

我必须在C ++中提取A和b的系数。 Plz帮助我。

0 个答案:

没有答案