【问题标题】:importing a .txt file into a .dat cplex opl将 .txt 文件导入 .dat cplex opl
【发布时间】:2017-06-30 13:30:25
【问题描述】:

在优化问题中,我需要在 .dat 文件中打开问题的数据。问题是数据在一个文本文件(笔记本)中,我不知道应该如何连接它并使用很多实例。有人可以帮助我吗?我正在寻找它,但我找不到解释清楚的东西。

【问题讨论】:

  • CPLEX 使用的 .dat 文件格式只是一种文本文件格式。如果您想使用 .dat 格式的文件,您可能需要手动编辑您的文本文件。查看 CPLEX 示例目录中的一些示例和/或阅读文档。您最好将文本文件中的数据读取到数据库(例如 SQL Server)或电子表格中,然后使用 CPLEX 直接从那里读取数据。

标签: text cplex instances opl


【解决方案1】:
  1. 在记事本中打开文件
  2. 转到另存为
  3. 键入 yourfilename.dat(不带空格)。您应该手动添加 .dat 扩展名
  4. 保存

【讨论】:

    【解决方案2】:

    您可以从 cplex 中的文本文件中读取,例如:

    execute //you should write this code in an execute block
    {
       var fileID= new IloOplInputFile("fileName.txt");
       var contenct = fileID.readline();
       var intContenct = Opl.intValue(contenct); //in case you want to convert what you read into an integer value
       fileID.clos();
    }
    

    【讨论】:

      猜你喜欢
      • 2015-11-27
      • 2012-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 2017-09-07
      相关资源
      最近更新 更多