aosabook/500lines · error · Exception

Your contraints are too harsh. Please relax.

Error message

Your contraints are too harsh. Please relax.

What it means

Error "Your contraints are too harsh. Please relax." thrown in aosabook/500lines.

Source

Thrown at incomplete/typesetting-engine/breakpoints.py:138

                    self.add_block(character='-', block_type=Type.penalty,
                                   width=0,
                                   penalty=50, flag=True)
            last_seen_character = character
        self.add_forced_break_blocks()

    def compute_breakpoints(self):
        """Compute the best possible breakpoints.

        Basically, it determines the shortest path in a directed
        acyclic graph while constructing it."""
        for block in self.blocks:
            if block.type is Type.box:
                self.current_width += block.width
            if self.is_legal_breakpoint(block):
                # self.verbose(block.position)
                self.find_best_previous_breakpoints(block)
                if not self.first_candidate:
                    raise Exception(
                        'Your contraints are too harsh. Please relax.')
            if block.type is Type.glue:
                self.current_width += block.width
                self.current_stretch += block.stretch
                self.current_shrink += block.shrink
        best_candidate = self.choose_best_candidate()
        if ADJUSTMENT != 0:
            best_candidate = self.choose_adjusted_candidate(best_candidate)
        self.breakpoints = (
            [-1] + self.determine_breakpoint_sequence(best_candidate))

    def find_best_previous_breakpoints(self, block):
        """For a certain block that is a legal breakpoint, compute the
        best previous breakpoint possible among the linked list of
        candidates."""
        current_last_breakpoint = self.first_candidate
        self.previous_candidate = None
        while current_last_breakpoint:

View on GitHub (pinned to fba689d101)

Solutions

  1. Relax the badness/tolerance constraints so at least one legal breakpoint sequence exists.
  2. Add more legal breakpoints (glue/penalty blocks) between boxes so lines can be broken.
  3. Check that line widths are not smaller than the widest unbreakable box.

Example fix

breakpoints = Breakpoints(blocks, line_width, tolerance=2)  # raise tolerance from 1 to 2 to allow looser fits

When it happens

Trigger: Thrown at incomplete/typesetting-engine/breakpoints.py:138 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of aosabook/500lines@fba689d101 (2026-08-13). Data as JSON: /api/errors/4e29dfafe3731b8a. Report an issue: GitHub.