SoPlex:精确理性计算

时间:2016-09-15 14:44:55

标签: c++ mathematical-optimization

我正在使用SoPlex解决一些LP。

解决方案非常重要。 尽管(默认)精度为1e-06,但由于数值精度,我面临着问题。

幸运的是,您可以通过更改feastolopttol参数来改变精度。将它们设置为0会导致它在以前没有数字问题的LP上抛出断言错误。

(例如) WSOLVE01 failed assertion on line 3711 in file src/clufactor.cpp: spxAbs( x ) < 1e40

我目前正在使用函数的Real版本(addColRealaddRowReal,...)来构建LP。

开发人员给出的例子是:

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*                                                                           */
/*                  This file is part of the class library                   */
/*       SoPlex --- the Sequential object-oriented simPlex.                  */
/*                                                                           */
/*    Copyright (C) 1996-2016 Konrad-Zuse-Zentrum                            */
/*                            fuer Informationstechnik Berlin                */
/*                                                                           */
/*  SoPlex is distributed under the terms of the ZIB Academic Licence.       */
/*                                                                           */
/*  You should have received a copy of the ZIB Academic License              */
/*  along with SoPlex; see the file COPYING. If not email to soplex@zib.de.  */
/*                                                                           */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/**@file   example.cpp
 * @brief  simple example of how to build up and solve an lp using the SoPlex callable library
 *
 * @author Ambros Gleixner
 */

#include <iostream>
#include "soplex.h"

using namespace soplex;


int main()
{
   SoPlex mysoplex;

   /* set the objective sense */
   mysoplex.setIntParam(SoPlex::OBJSENSE, SoPlex::OBJSENSE_MINIMIZE);

   /* we first add variables */
   DSVector dummycol(0);
   mysoplex.addColReal(LPCol(2.0, dummycol, infinity, 15.0));
   mysoplex.addColReal(LPCol(3.0, dummycol, infinity, 20.0));

   /* then constraints one by one */
   DSVector row1(2);
   row1.add(0, 1.0);
   row1.add(1, 5.0);
   mysoplex.addRowReal(LPRow(100.0, row1, infinity));

   /* NOTE: alternatively, we could have added the matrix nonzeros in dummycol already; nonexisting rows are then
    * automatically created. */

   /* write LP in .lp format */
   mysoplex.writeFileReal("dump.lp", NULL, NULL, NULL);

   /* solve LP */
   SPxSolver::Status stat;
   DVector prim(2);
   DVector dual(1);
   stat = mysoplex.solve();

   /* get solution */
   if( stat == SPxSolver::OPTIMAL )
   {
      mysoplex.getPrimalReal(prim);
      mysoplex.getDualReal(dual);
      std::cout << "LP solved to optimality.\n";
      std::cout << "Objective value is " << mysoplex.objValueReal() << ".\n";
      std::cout << "Primal solution is [" << prim[0] << ", " << prim[1] << "].\n";
      std::cout << "Dual solution is [" << dual[0] << "].\n";
   }

   return 0;
}

我理解我应该使用函数的Rational等价物(addRowRationaladdColRational,...)并强制程序将所有数字作为Rational处理,以便输出也是Rational,精确。为了做到这一点,求解器将所有变量输出为零,而这肯定不是一个可行的解决方案。

我使用类似的方法来构建LP,就像上面的代码示例一样。所以如果我知道它的Rational等价物,我会再次前进。

因此,上述代码示例的Rational等价物是什么?

0 个答案:

没有答案