我试图通过使用apache-commons的Simplex解算器解决以下线性问题:org.apache.commons.math3.optim.linear.SimplexSolver
.
n
行
m
数是列数
L
是每行总和的全局限制
这是我到目前为止:
List<LinearConstraint> constraints = new ArrayList<>();
double[][] A = calculateAValues();
// m = count of columns
// constraint 1: the sum of values in all column must be <= 1
for(int i = 0; i < m; i++) {
double[] v = new double[n];
for(int j=0; j < n; j++) {
v[j] = 1;
}
constraints.add(new LinearConstraint(v, Relationship.LEQ, 1));
}
// n = count of rows
// constraint 2: sum of …
Run Code Online (Sandbox Code Playgroud)