Beispiel #1
0
    def run(self):
        # Wait 5 seconds ...
        time.sleep(5)

        # ... and abort the CPLEX optimization.
        print("Aborting CPLEX via a cplex.terminate() call.")
        cplex.terminate()
Beispiel #2
0
    def run(self):
        # Wait 5 seconds ...
        time.sleep(5)

        # ... and abort the CPLEX optimization.
        print "Aborting CPLEX via a cplex.terminate() call."
        cplex.terminate()
Beispiel #3
0
    dense.parameters.lpmethod.set(alg.barrier)
    dense.parameters.barrier.crossover.set(-1)
    start_time = dense.get_time()
    dense.solve()
    end_time = dense.get_time()

    iter_time = end_time - start_time
    times.append(iter_time)

    #TODO: check if feasible, if not divide the scalar by 2.

    if(dense.solution.get_status() == dense.solution.status.infeasible_or_unbounded):
      print "infeasible solution."
      scalar = scalar * 0.5
      lamda = oldlamda[:]
    else:
      j += 1
      if scalar < 0.01:
          break
      prev_t    = dense.solution.get_values(0)
      prev_xijm = dense.solution.get_values(range(1,len(xijm)))
      prev_val  = dense.solution.get_objective_value()
    
      print "Iteration "+str(j)+" ("+str(iter_time)+" sec.): "+str(prev_val)

total_time = sum(times)
print "Total time: " + str(total_time) + " sec."
printResults.save(dense)
cplex.terminate()
os.remove("dense.lp")