diff options
Diffstat (limited to 'src/act4e_mcdp_solution')
-rw-r--r-- | src/act4e_mcdp_solution/solver_dp.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/act4e_mcdp_solution/solver_dp.py b/src/act4e_mcdp_solution/solver_dp.py index dfcfc90..b4b0461 100644 --- a/src/act4e_mcdp_solution/solver_dp.py +++ b/src/act4e_mcdp_solution/solver_dp.py @@ -694,28 +694,33 @@ class DPSolver(DPSolverInterface): # As in the book, the intermediate goal is to define a function f such that # the solution is the least fixed point of f. + + # Feedback, we let FT = (F1, M) and RT = (R1, M) + # __________________________ + # | ________ | + # F1 --|- F1 ---| DP |--- R1 -|-- R1 + # | | FT->RT | | + # | M .--|________|--. M | + # | | | | + # | '------O<------' | + # |__________________________| def uppersets_intersection(poset: Poset[RT], us: List[UpperSet[RT]]) -> UpperSet[RT]: if len(us) < 2: return us - # def poset_max(m1: RT, m2: RT) -> RT: - # return m1 if poset.geq(m1, m2) else m2 - def intersect_pair(u1: UpperSet[RT], u2: UpperSet[RT]) -> UpperSet[RT]: # always get the bigger of the two minimals - # minimals: List[RT] = list(starmap(poset_max, zip(u1.minimals, u2.minimals))) minimals: List[RT] = [m for m in u1.minimals if m in u2.minimals] return UpperSet.from_points(poset, minimals) - return reduce(intersect_pair, us[1:], us[0]) + return reduce(intersect_pair, us) - # Map antichain to antichain + # Map antichain to antichain in RT def phi(chain: List[RT]) -> List[RT]: uppersets: List[UpperSet[RT]] = [] for r in chain: # Query for internal system that is looped - # with FT = F1 \otimes M and RT = R1 \otimes M inner_f: FT = (query.functionality,) + r[1:] inner_query: FixFunMinResQuery[FT] = FixFunMinResQuery(functionality=inner_f) @@ -734,14 +739,15 @@ class DPSolver(DPSolverInterface): # Return antichain that is fixed point of phi def kleene_ascent(phi) -> List[R1]: - # initialize with bottoms, - chain: List[RT] = dp.dp.R.global_maxima().maximals + # initialize with bottoms + chain: List[RT] = dp.dp.R.global_minima().minimals prev_chain = None # Ascent procedure while chain != prev_chain: prev_chain = chain chain = phi(chain) + # assert chain, "No chain!" # Take R1 out of RT first = lambda r: r[0] @@ -769,7 +775,7 @@ class DPSolver(DPSolverInterface): maximals: List[FT] = [m for m in l1.maximals if m in l2.maximals] return LowerSet.from_points(poset, maximals) - return reduce(intersect_pair, ls[1:], ls[0]) + return reduce(intersect_pair, ls) def phi(chain: List[FT]) -> List[FT]: lowersets: List[LowerSet[FT]] = [] @@ -794,6 +800,7 @@ class DPSolver(DPSolverInterface): while chain != prev_chain: prev_chain = chain chain = phi(chain) + # assert chain, "No chain!" first = lambda f: f[0] chain: List[F1] = list(map(first, chain)) |