我有一个线性程序,我可以在其中输入 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;