5

I am working on some very large scale linear programming problems. (Matrices are currently roughly 1000x1000 and these are the 'mini' ones.)

I thought that I had the program running successfully, only I have realized that I am getting some very unintuitive answers. For example, let's say I were to maximize x+y+z subject to a set of constraints x+y<10 and y+z <5. I run this and get an optimal solution. Then, I run the same equation but with different constraints: x+y<20 and y+z<5. Yet in the second iteration, my maximization decreases!

I have painstakingly gone through and assured myself that the constraints are loading correctly.

Does anyone know what the problem might be?

I found something in the documentation about lpx_check_kkt which seems to tell you when your solution is likely to be correct or high confidence (or low confidence for that matter), but I don't know how to use it.

I made an attempt and got the error message lpx_check_kkt not defined.

I am adding some code as an addendum in hopes that someone can find an error. The result of this is that it claims an optimal solution has been found. And yet every time I raise an upper bound, it gets less optimal.
I have confirmed that my bounds are going up and not down.

    size = 10000000+1
    ia = intArray(size)
    ja = intArray(size)
    ar = doubleArray(size)
    prob = glp_create_prob()

    glp_set_prob_name(prob, "sample")
    glp_set_obj_dir(prob, GLP_MAX)
    glp_add_rows(prob, Num_constraints)
    for x in range(Num_constraints):
            Variables.add_variables(Constraints_for_simplex)
            glp_set_row_name(prob, x+1, Variables.variers[x])
            glp_set_row_bnds(prob, x+1, GLP_UP, 0, Constraints_for_simplex[x][1])
            print 'we set the row_bnd for', x+1,' to ',Constraints_for_simplex[x][1]
    glp_add_cols(prob, len(All_Loops))
    for x in range(len(All_Loops)):
            glp_set_col_name(prob, x+1, "".join(["x",str(x)]))
            glp_set_col_bnds(prob,x+1,GLP_LO,0,0)
            glp_set_obj_coef(prob,x+1,1)
    for x in range(1,len(All_Loops)+1):
            z=Constraints_for_simplex[0][0][x-1]
            ia[x] = 1; ja[x] = x;  ar[x] = z
    x=len(All_Loops)+1
    while x<Num_constraints + len(All_Loops):
    for y in range(2, Num_constraints+1):
                    z=Constraints_for_simplex[y-1][0][0]
                    ia[x] = y; ja[x] =1 ; ar[x] = z
                    x+=1
    x=Num_constraints+len(All_Loops)
    while x <len(All_Loops)*(Num_constraints-1):
            for z in range(2,len(All_Loops)+1):
                    for y in range(2,Num_constraints+1):
                            if x<len(All_Loops)*Num_constraints+1:
                                    q = Constraints_for_simplex[y-1][0][z-1]
                                    ia[x] = y ; ja[x]=z; ar[x] = q
                                    x+=1


    glp_load_matrix(prob, len(All_Loops)*Num_constraints, ia, ja, ar)
    glp_exact(prob,None)
    Z = glp_get_obj_val(prob)
4

1 回答 1

4

首先使用不同的求解器解决有问题的实例并检查目标函数值。如果您可以将模型导出为 .mps 格式(我不知道如何使用 GLPK 执行此操作,抱歉),您可以将 mps 文件上传到http://www.neos-server.org/neos/solvers/index .html并用几个不同的 LP 求解器求解。

于 2013-02-20T18:52:11.163 回答