【问题标题】:Running SCIMP for various n为各种 n 运行 SCIMP
【发布时间】:2015-09-05 13:52:38
【问题描述】:

我有一个线性程序,我可以在其中输入 n 的数字,它为我提供了这个特定 n 的 LP 输出。我现在想为各种 n=10...1000 执行此操作。有没有一种技术我不必手动执行每个 n 而是自动执行此操作并为文件中的每个 n 输出 LP 的解决方案?我喜欢稍后再绘制图表。

这是我的线性程序:

#Specify the number of n for the linear program.
param n := 5000;

#This is the set of probabilities of 
set N := {1 .. n};
#We specify the variables for the probabilities p_1,...p_n.
var p[<i> in N] real >= 0; 

#These are the values of the vector c. It specifies a constant for each p_i.
param c[<i> in N] := i/n ;

#We define the entries a_{ij} of the Matrix A.
defnumb a(i,j) := 
            if i < j then 0 
            else if i == j then i 
            else 1 end end;

#The objective function.
maximize prob: sum <i> in N : c[i] * p[i];

#The condition which needs to be fulfilled.
 subto condition:
    forall <i> in N:
      sum <j> in N: a(i,j) * p[j] <= 1;

【问题讨论】:

    标签: plot linear-programming scip


    【解决方案1】:

    您可以通过控制台提供参数:

    -D n=[number you want] -o [output file]
    

    然后你可以只使用一个 shell 脚本来迭代几个 n,例如,

    for i in {1..100}
    do
     zimpl -D n=$i -o 'output_'$i yourfile.zpl
    done
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-06
      相关资源
      最近更新 更多