def solve(self): # mpp fixed ts = [t for t in self.terms if t != 1] tcs = Miscs.keys_to_str(self.tcs) if self.subset_siz is None: subset_siz = len(ts) else: subset_siz = self.subset_siz blacklist = [] if self.xinfo['Input']: blacklist = self.xinfo['Input'] if (self.xinfo['Output'] and len(self.xinfo['Output']) > len(self.xinfo['Input'])): blacklist = self.xinfo['Output'] ts_common = gen_terms_fixed_coefs(ts, subset_siz=subset_siz, blacklist=blacklist, is_mpp=True) if self.mpp_opt == IeqMPP.opt_max_then_min: def wprocess(is_max_plus, Q): Q.put(IeqMPPFixed.build_poly(ts_common, tcs, is_max_plus)) Q = mp.Queue() workers = [ mp.Process(target=wprocess, args=(is_max_plus, Q)) for is_max_plus in [True, False] ] for w in workers: w.start() rs = [] for _ in workers: rs.extend(Q.get()) else: is_max_plus = self.mpp_opt == IeqMPP.opt_max_plus rs = IeqMPPFixed.build_poly(ts_common, tcs, is_max_plus) self.sols = map(InvMPP, rs)
def solve(self): ts = [t for t in self.terms if t != 1] if self.subset_siz is None: subset_siz = len(ts) else: subset_siz = self.subset_siz ts_ = gen_terms_fixed_coefs(ts,subset_siz=subset_siz, blacklist=None,is_mpp=False) logger.debug('Build (fixed CL) poly from {} tcs in {} dims ' '(~ {} facets)' .format(len(self.tcs),len(ts),len(ts_))) #can be done in parallel rs = [] for t in ts_: rs.append(t - min(t.subs(tc) for tc in self.tcs) >= 0) self.sols = map(InvIeq,rs)
def solve(self): #mpp fixed ts = [t for t in self.terms if t != 1] tcs = Miscs.keys_to_str(self.tcs) if self.subset_siz is None: subset_siz = len(ts) else: subset_siz = self.subset_siz blacklist = None if self.xinfo['Input']: blacklist = self.xinfo['Input'] if (self.xinfo['Output'] and len(self.xinfo['Output']) > len(self.xinfo['Input'])): blacklist = self.xinfo['Output'] ts_common = gen_terms_fixed_coefs(ts,subset_siz=subset_siz, blacklist=blacklist, is_mpp=True) if self.mpp_opt == IeqMPP.opt_max_then_min: def worker(Q,is_max_plus): Q.put(IeqMPPFixed.build_poly(ts_common,tcs,is_max_plus)) Q = mp.Queue() workers = [mp.Process(target=worker,args=(Q,is_max_plus)) for is_max_plus in [True,False]] for w in workers: w.start() rs = [] for _ in workers: rs.extend(Q.get()) else: is_max_plus = self.mpp_opt == IeqMPP.opt_max_plus rs = IeqMPPFixed.build_poly(ts_common, tcs, is_max_plus) self.sols = map(InvMPP, rs)
def solve(self): ts = [t for t in self.terms if t != 1] if self.subset_siz is None: subset_siz = len(ts) else: subset_siz = self.subset_siz ts_ = gen_terms_fixed_coefs(ts, subset_siz=subset_siz, blacklist=None, is_mpp=False) logger.debug('Build (fixed CL) poly from {} tcs in {} dims ' '(~ {} facets)'.format(len(self.tcs), len(ts), len(ts_))) #can be done in parallel rs = [] for t in ts_: rs.append(t - min(t.subs(tc) for tc in self.tcs) >= 0) self.sols = map(InvIeq, rs)