title: GLPK linear programming
body: <p>I am working on some very large scale linear programming problems.  (Matrices are currently roughly 1000x1000 and these are the 'mini' ones.)</p>
  
  <p>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&lt;10 and y+z &lt;5.  I run this and get an optimal solution.  Then, I run the same equation but with different constraints: x+y&lt;20 and y+z&lt;5.  Yet in the second iteration, my maximization decreases!</p>
  
  <p>I have painstakingly gone through and assured myself that the constraints are loading correctly.  </p>
  
  <p>Does anyone know what the problem might be?</p>
  
  <p>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. </p>
  
  <p>I made an attempt and got the error message lpx_check_kkt not defined. </p>
  
  <p>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.<br>
  I have confirmed that my bounds are going up and not down. </p>
  
  <pre><code>    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&lt;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 &lt;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&lt;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)
  </code></pre>