本文介绍了Julia-并行数学优化器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过Julia使用GLPK,我需要反复优化相同的GLPK.Prob.每次优化之间的变化是,变量的某些组合固定为0

Im using GLPK with through Julia, and I need to optimize the same GLPK.Prob repeatedly.What changes between each optimization is that some combination of variables gets fixed to 0

只需输入伪代码

lp = GLPK.Prob()
variables_to_block = [[1,2,3], [2,3], [6,7], [19,100,111]...]
for i in variables_to_block
    block_vars(lp, i)
    simplex(lp)
    restore_vars(lp, i)
end

当我随后运行此命令时,它看起来像CPU1充当调度程序,保持在9-11%的范围内,并且CPU3和CPU4的负载在0和100%之间交替变化,尽管从来没有同时出现过…… CPU2上的负载保持在0%

when I then run this, it looks like CPU1 acts as a scheduler, staying in the 9-11% range, and the load on CPU3 and CPU4 alternates between 0 and 100%, though never at the same time...the load on CPU2 stays at 0%

这可能需要一些时间,我想使用所有内核

This can take a bit of time and I'd like to use all cores

但是,使用Julia的并行功能有些麻烦,特别是对于lp模型,因为它们涉及指针,所以(据我所知)它们无法在内核之间轻松复制

There is however, a bit of a hassle to use the parallel features of Julia, particularly for lp-models because they involve pointers so (as far as I know) they cannot be copied easily between cores

是否有办法设置GLPK求解器二进制文件(或其他内容)以自动尝试充分利用所有内核?通过以这种方式或任何其他方式编译GLPK

Is there a way to either set the GLPK solver binary (or something) to automatically try to fully utilize all cores? either by compiling GLPK in such a way, or any other way

推荐答案

据我所知,GLPK是不是多线程的.如果必须使用多线程求解器,请考虑使用更新的求解器,例如 Gurobi MOSEK .他们有免费的学术许可证.

As far as I know, GLPK is not multithreaded. If you must have a multithreaded solver, then consider using a newer one such as Gurobi or MOSEK. They have free academic licenses.

如果商业求解器对您的目标有害,则可以尝试分离圆锥求解器.它根据MIT许可证免费发布.

If commercial solvers are anathema to your purposes, then perhaps try the Splitting Cone Solver. It is released for free under the MIT License.

否则,评论中的建议(例如批处理)可能是您唯一的求助方式.

Otherwise, the suggestions in the comments (e.g. batch proessing) may be your only recourse.

这篇关于Julia-并行数学优化器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-01 18:01