def approximate(self, gap, nof_sol=3, rel_tol=1e-05, abs_tol=0.0001): sols = self.solve_grid(nof_sol=nof_sol) #filter non pareto points sols = ParetoFilter.filter(sorted(sols), rel_tol=rel_tol, abs_tol=abs_tol) if self.verbose: print "Filtered pareto points" for s in sols: print s print "\n", "Starting rectangle refinement\n" curr_gap = HyperVolume.calc_hypervol_gap(sols, [sols[0].objs, sols[-1].objs], []) if curr_gap < gap: return sols self.approximate_rectangle(gap, init_recs=sols, rel_tol=1e-05, abs_tol=0.0001) for _ in xrange(nof_sol): self.task_q.put(("DONE", None, None, None, None)) self._manager.shutdown() return self.solutions
def solve(self, nof_sol=3, rel_tol=1e-05, abs_tol=0.0001): sols = self.solve_grid(nof_sol=nof_sol) #filter non pareto points sols = sorted(ParetoFilter.filter(sols,rel_tol=rel_tol, abs_tol=abs_tol)) if self.verbose: print "Filtered pareto points" for s in sols: print s #pcl.dump(sols, open(".".join(args.output.split(".")[:-1])+"_temp.pcl", "w")) self.solve_rectangle(init_recs=sols,rel_tol=rel_tol, abs_tol=abs_tol) for _ in xrange(nof_sol): self.task_q.put(("DONE",None,None,None,None)) self._manager.shutdown() return self.solutions
def approximate(self, gap, nof_sol=3, rel_tol=1e-05, abs_tol=0.0001): sols = self.solve_grid(nof_sol=nof_sol) #filter non pareto points sols = ParetoFilter.filter(sorted(sols),rel_tol=rel_tol, abs_tol=abs_tol) if self.verbose: print "Filtered pareto points" for s in sols: print s print "\n","Starting rectangle refinement\n" curr_gap = HyperVolume.calc_hypervol_gap(sols, [sols[0].objs, sols[-1].objs], []) if curr_gap < gap: return sols self.approximate_rectangle(gap, init_recs=sols, rel_tol=1e-05, abs_tol=0.0001) for _ in xrange(nof_sol): self.task_q.put(("DONE",None,None,None,None)) self._manager.shutdown() return self.solutions
required=False, help="Reinitialize with partial solution") parser.add_argument('--verbose','-v', default=0, type=int, required=False, help="Verbosity (default 0)") args = parser.parse_args() manager = RectangleEpsilonGridManager(port=args.port, authkey=args.key, output=args.output, verbose=args.verbose) if args.resolve: f = open(args.resolve, "r") sol = sorted(pcl.load(f)) s = time.time() sols=manager.approximate_rectangle(args.approximate, init_recs=sol, nof_sol=args.worker, rel_tol=args.relTol, abs_tol=args.absTol) manager._manager.shutdown() e=time.time() else: s = time.time() sols = manager.solve(nof_sol=args.worker,rel_tol=args.relTol, abs_tol=args.absTol) #sols = manager.approximate(args.approximate, nof_sol=args.worker) #sols = manager.solve_rectangle(rel_tol=args.relTol, abs_tol=args.absTol) e= time.time() filtered_sols = ParetoFilter.filter(sols) print "Solution time ", e-s for s in sols: print s print "NOF: ",len(sols), len(filtered_sols) pcl.dump(sols, open(args.output, "w"))
parser.add_argument('--resolve','-r', required=False, help="Reinitialize with partial solution") parser.add_argument('--verbose','-v', default=0, type=int, required=False, help="Verbosity (default 0)") args = parser.parse_args() manager = RectangleEpsilonGridManager(port=args.port, authkey=args.key, output=args.output, verbose=args.verbose) if args.resolve: f = open(args.resolve, "r") sol = sorted(pcl.load(f)) s = time.time() sols=manager.approximate_rectangle(args.approximate, init_recs=sol, nof_sol=args.worker, rel_tol=args.relTol, abs_tol=args.absTol) manager._manager.shutdown() e=time.time() else: s = time.time() sols = manager.solve(nof_sol=args.worker,rel_tol=args.relTol, abs_tol=args.absTol) #sols = manager.approximate(args.approximate, nof_sol=args.worker) #sols = manager.solve_rectangle(rel_tol=args.relTol, abs_tol=args.absTol) e= time.time() filtered_sols = ParetoFilter.filter(sols) print "Solution time ", e-s for s in sols: print s print "NOF: ",len(sols), len(filtered_sols) #pcl.dump(sols, open(args.output, "w"))