【问题标题】:Getting a profiler error i CPLEX OPL -Overflow occured获取探查器错误 i CPLEX OPL - 发生溢出
【发布时间】:2023-03-29 05:14:01
【问题描述】:

我在 CPLEX 中收到关于探查器错误的错误。这显示在底部窗口的探查器选项卡中。

发生溢出,请使用 oplrun -profile

我使用 sheetwrite 命令将我的输出写回 excel(例如 solXbimt 到 SheetWrite(sheet,"Result!B3:E1000000"); )。引擎日志显示已经生成了几个解决方案,但它们没有被写回 excel。我怀疑溢出是造成这种情况的原因。

请您帮忙解决这个问题。

【问题讨论】:

    标签: cplex opl


    【解决方案1】:

    您可以尝试使用 oplrun 运行您的模型吗?

    如果您不需要分析,您也可以删除它。

    您也可以在 .dat 文件中编写解决方案

    要节省内存而不是在 OPL IDE 中运行模型,您可以使用命令行 oplrun。

    在后处理块中,您可以通过 IloOplOutputFile 将解决方案保存到文件中。

    来自https://github.com/AlexFleischerParis/oplscripting/blob/main/zooandsaveresultindatfile.mod的示例

    int nbKids=300;
    float costBus40=500;
    float costBus30=400;
     
    dvar int+ nbBus40;
    dvar int+ nbBus30;
     
    minimize
     costBus40*nbBus40  +nbBus30*costBus30;
     
    subject to
    {
     40*nbBus40+nbBus30*30>=nbKids;
    } 
    
    execute
    {
      var o=new IloOplOutputFile("zooresult.dat");
      o.writeln("nbBus40=",nbBus40,";");
      o.writeln("nbBus30=",nbBus30,";");
      o.close();
    }
    
    /*
    generates zooresult.dat
    nbBus40=6;
    nbBus30=2;
    */
    

    【讨论】:

    • 嗨,Alex 非常感谢您的回复,并对我的延迟回复感到非常抱歉。我花了一些时间来尝试它。我将要作为元组写入 .dat 文件的行,它也适用于元组。
    【解决方案2】:

    再次感谢 Alex 使用您的回复我尝试了以下方法:对我来说,下面的每个 Sol 变量都是元组。另一件值得注意的事情是,现在它的运行速度比我写回 excel 时要快得多。当您的输出大小很大时,这是将结果写入 .dat 文件的一个很好的解决方法。

    execute
    {
      var o=new IloOplOutputFile("optscheduleXbmt.dat");
      o.writeln(solXbmt);
      o.close();
      
      var o=new IloOplOutputFile("optscheduleXbdt.dat");
      o.writeln(solXbdt);
      o.close();
      
      var o=new IloOplOutputFile("optscheduleXbst.dat");
      o.writeln(solXbst);
      o.close();
      
      
      var o=new IloOplOutputFile("optscheduleXsmt.dat");
      o.writeln(solXsmt);
      o.close();  
      
       
      var o=new IloOplOutputFile("optschedulePath.dat");
      o.writeln(solPath);
      o.close(); 
    }
    

    【讨论】:

      猜你喜欢
      • 2020-04-13
      • 2022-09-24
      • 1970-01-01
      • 2018-10-23
      • 2016-07-30
      • 1970-01-01
      • 2019-07-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多