Spaces:
Runtime error

File size: 843 Bytes
c0e3412
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""Phase I: Entropic Segregation."""

from __future__ import annotations

import time

from ..core import EntropicSegregator
from ..types import PhaseOutput, RunConfig, SolutionState


def run(state: SolutionState, config: RunConfig) -> tuple[SolutionState, PhaseOutput]:
    t0 = time.perf_counter()
    segregator = EntropicSegregator()
    blocks = segregator.segregate(state.problem)
    block_solutions = [segregator.solve_linear_cot(b) for b in blocks]
    state.blocks = blocks
    state.block_solutions = block_solutions
    dt = time.perf_counter() - t0
    return (
        state,
        PhaseOutput(
            name="phase1_entropic_segregation",
            input={"problem": state.problem},
            output={"blocks": [b.id for b in blocks], "block_solutions": block_solutions},
            duration_sec=dt,
        ),
    )