微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

大型线性编程的Mosek内存问题

如何解决大型线性编程的Mosek内存问题

我使用MOSEK在Matlab中运行一个非常大的线性编程问题(32768未知数和691621约束)。 该代码在基于Linux的群集中提交。 在bash文件中,我要求以下内存量:

#$ -l h_vmem=20G
#$ -l tmem=20G

但是得到Mosek error: MSK_RES_ERR_SPACE (Out of space.)

我可以请求更多的内存(但是,尚不清楚还有多少?),但这意味着要在集群中排队很长一段时间。

因此,我想知道我是否可以尝试以其他方式改善这一问题。

1)引用一些MOSEK常见问题解答:

Java,.NET,amd Python applications runs under a virtual machine. MOSEK shares memeory
with the virtual machine. This implies it might be necessary to force the virtual machine to
free unused memory by explicitly calling the garbage collector (for example before optimization
is performed) in order to make sufficient memory available to MOSEK.

此建议有用吗?调用垃圾收集器是什么意思(即,我应该在Matlab代码添加哪一行?)。

2)https://docs.mosek.com/9.2/pythonapi/guidelines-optimizer.html(即使是针对Python),它建议设置

Task.putmaxnumvar. Estimate for the number of variables.
Task.putmaxnumcon. Estimate for the number of constraints.
Task.putmaxnumcone. Estimate for the number of cones.
Task.putmaxnumbarvar. Estimate for the number of semidefinite matrix variables.
Task.putmaxnumanz. Estimate for the number of non-zeros in A.
Task.putmaxnumqnz. Estimate for the number of non-zeros in the quadratic terms.

我可以在Matlab中做到吗?怎么样?

3)来自http://ask.cvxr.com/t/how-to-deal-with-out-of-space-error-when-using-mosek-to-solve-a-conic-optimization-problem/7510:“如果在1个线程上运行(在cvx求解器选项中将MSK_IPAR_NUM_THREADS设置为1或将MSK_IPAR_INTPNT_MULTI_THREAD设置为0),它将在一定程度上减少内存消耗”

这也可以在Matlab中完成吗?我尝试过

param_MOSEK.MSK_IPAR_NUM_THREADS = 1;
param_MOSEK.MSK_IPAR_INTPNT_MULTI_THREAD = 'MSK_OFF';

但是它似乎不起作用,因为输出文件仍然显示

Optimizer  - threads                : 16              
Optimizer  - solved problem         : the dual        
...

与以下问题相关的评论

  • 代码在180秒内使用16个线程在我的MacOS 64位中运行。的 计算机的内存是32 GB 2667 MHz DDR4。它使用的内存少于20G(大约9G)。

  • 在请求20G vmem和tmem后在我的univ(基于Linux)的集群上运行时,代码失败。在群集中,MOSEK执行预解决,基于GP的矩阵重新排序,然后失败。这是一个典型的日志文件

2020年9月9日星期三08:10:47 任务ID为6

                            < M A T L A B (R) >
                  copyright 1984-2019 The MathWorks,Inc.
              R2019b Update 3 (9.7.0.1261785) 64-bit (glnxa64)
                             November 27,2019
 
For online documentation,see https://www.mathworks.com/support
For product information,visit www.mathworks.com.
 

MOSEK Version 9.2.5 (Build date: 2020-4-22 22:56:56)
copyright (c) MOSEK ApS,Denmark. WWW: mosek.com
Platform: Linux/64-X86

Problem
  Name                   :                 
  Objective sense        : min             
  Type                   : LO (linear optimization problem)
  Constraints            : 691597          
  Cones                  : 0               
  Scalar variables       : 32768           
  Matrix variables       : 0               
  Integer variables      : 0               

Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator - tries                  : 1                 time                   : 0.00            
Lin. dep.  - tries                  : 1                 time                   : 0.33            
Lin. dep.  - number                 : 0               
Presolve terminated. Time: 2.99    
GP based matrix reordering started.
GP based matrix reordering terminated.
Optimizer terminated. Time: 20.15   


Interior-point solution summary
  Problem status  : UNKNowN
  Solution status : UNKNowN
  Primal.  obj: 0.0000000000e+00    nrm: 1e+00    Viol.  con: 1e+00    var: 0e+00  
  Dual.    obj: 0.0000000000e+00    nrm: 0e+00    Viol.  con: 0e+00    var: 0e+00  
Optimizer summary
  Optimizer                 -                        time: 20.15   
    Interior-point          - iterations : 0         time: 19.95   
      Basis identification  -                        time: 0.00    
        Primal              - iterations : 0         time: 0.00    
        Dual                - iterations : 0         time: 0.00    
        Clean primal        - iterations : 0         time: 0.00    
        Clean dual          - iterations : 0         time: 0.00    
    Simplex                 -                        time: 0.00    
      Primal simplex        - iterations : 0         time: 0.00    
      Dual simplex          - iterations : 0         time: 0.00    
    Mixed integer           - relaxations: 0         time: 0.00    

Mosek error: MSK_RES_ERR_SPACE (Out of space.)

解决方法

  1. Matlab中的抗氧化剂

  2. 在Matlab中不能使用,并且不能使用。 MEX界面将问题一口气送入Mosek,并自行处理所有分配。

  3. 要尊重MSK_IPAR_NUM_THREADS,您必须重新启动整个过程,即Matlab。参见https://docs.mosek.com/9.2/faq/faq.html#mosek-is-ignoring-the-limit-on-the-number-of-threads。但是,当您设置MSK_IPAR_INTPNT_MULTI_THREAD ='MSK_OFF'时,Mosek将使用1个线程,而不管所有可用线程的数量如何,即,打印到日志中的数量只是一个上限。您应该能够在任务管理器/顶部/其他任何CPU负载跟踪器中看到仅使用1个CPU。

基本问题是:您是否尝试过在没有任何内存限制的情况下运行该问题,以查看它是否可以工作并估算内存消耗?它可以在其他计算机上运行吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?