可以通过 org.apache.commons.math3.optim 获得影子价格吗?
Possible to get shadow prices with org.apache.commons.math3.optim?
我有一个大型 LP 问题,如下所示:
max z = c^T * x
s.t. A*x <= b
and Aeq * x = beq
编写约束后代码如下所示:
import org.apache.commons.math3.optim.linear.LinearConstraint;
import org.apache.commons.math3.optim.linear.Relationship;
import org.apache.commons.math3.exception.TooManyIterationsException;
import org.apache.commons.math3.optim.OptimizationData;
import org.apache.commons.math3.optim.PointValuePair;
import org.apache.commons.math3.optim.linear.LinearConstraintSet;
import org.apache.commons.math3.optim.linear.LinearObjectiveFunction;
import org.apache.commons.math3.optim.linear.NoFeasibleSolutionException;
import org.apache.commons.math3.optim.linear.NonNegativeConstraint;
import org.apache.commons.math3.optim.linear.SimplexSolver;
import org.apache.commons.math3.optim.linear.UnboundedSolutionException;
import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
LinearObjectiveFunction objective = new LinearObjectiveFunction(objectiveCoefficients, 0);
SimplexSolver solver = new SimplexSolver(epsilon, maxUlps, cutOff);
LinearConstraintSet constraintSet = new LinearConstraintSet(constraints);
NonNegativeConstraint nonnegative = new NonNegativeConstraint(true);
GoalType maximization = GoalType.MAXIMIZE;
OptimizationData[] optData = new OptimizationData[]{maximization, objective, constraintSet, nonnegative};
try{
PointValuePair solution = solver.optimize(optData);
}catch ...
工作得很好。但是,如果不单独解决对偶问题,我无法获得对偶问题的值,即我的约束的影子价格。
是否有可能同时获得我的原始问题的 x 值和 org.apache.commons.math3.optim
约束的影子价格?
提前致谢
它不会 return 双重。您或许可以从最终画面中检索它们,但这可能需要一些管道。
请注意,除了最小的 LP 问题外,这不是一个很好的求解器。它不是一个严肃的算法,而是教科书第 1 章中完整单纯形法的实现。不建议用于大问题。
我有一个大型 LP 问题,如下所示:
max z = c^T * x
s.t. A*x <= b
and Aeq * x = beq
编写约束后代码如下所示:
import org.apache.commons.math3.optim.linear.LinearConstraint;
import org.apache.commons.math3.optim.linear.Relationship;
import org.apache.commons.math3.exception.TooManyIterationsException;
import org.apache.commons.math3.optim.OptimizationData;
import org.apache.commons.math3.optim.PointValuePair;
import org.apache.commons.math3.optim.linear.LinearConstraintSet;
import org.apache.commons.math3.optim.linear.LinearObjectiveFunction;
import org.apache.commons.math3.optim.linear.NoFeasibleSolutionException;
import org.apache.commons.math3.optim.linear.NonNegativeConstraint;
import org.apache.commons.math3.optim.linear.SimplexSolver;
import org.apache.commons.math3.optim.linear.UnboundedSolutionException;
import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
LinearObjectiveFunction objective = new LinearObjectiveFunction(objectiveCoefficients, 0);
SimplexSolver solver = new SimplexSolver(epsilon, maxUlps, cutOff);
LinearConstraintSet constraintSet = new LinearConstraintSet(constraints);
NonNegativeConstraint nonnegative = new NonNegativeConstraint(true);
GoalType maximization = GoalType.MAXIMIZE;
OptimizationData[] optData = new OptimizationData[]{maximization, objective, constraintSet, nonnegative};
try{
PointValuePair solution = solver.optimize(optData);
}catch ...
工作得很好。但是,如果不单独解决对偶问题,我无法获得对偶问题的值,即我的约束的影子价格。
是否有可能同时获得我的原始问题的 x 值和 org.apache.commons.math3.optim
约束的影子价格?
提前致谢
它不会 return 双重。您或许可以从最终画面中检索它们,但这可能需要一些管道。
请注意,除了最小的 LP 问题外,这不是一个很好的求解器。它不是一个严肃的算法,而是教科书第 1 章中完整单纯形法的实现。不建议用于大问题。