Skip to content

Scatter search crashes with "'tuple' object has no attribute 'score'" when a fit evaluation fails #388

@wshlavacek

Description

@wshlavacek

Summary

When a single fit evaluation fails (the model's execute() raises an
exception), the scatter-search run aborts entirely with

AttributeError: 'tuple' object has no attribute 'score'

instead of recording that parameter set as a failed simulation and
continuing. PyBNF's generic handler reports it as "an unknown error
occurred ... Please report this bug", so the crash is also user-facing.

Traceback

Sorry, an unknown error occurred: AttributeError: 'tuple' object has no attribute 'score'
Traceback (most recent call last):
  File "pybnf/pybnf.py", line 249, in main
  File "pybnf/algorithms.py", line 1385, in run
  File "pybnf/algorithms.py", line 1063, in add_to_trajectory
    if res.score is None:  # Check if the objective wasn't evaluated on the workers
AttributeError: 'tuple' object has no attribute 'score'

Where

In the scatter-search run() loop (algorithms.py:1385), each completed
job res is passed to add_to_trajectory(res) and then read as
res.score. Both assume res is a Result. When the evaluation failed,
res arrives as a tuple, so add_to_trajectory (algorithms.py:1063,
res.score) raises.

PyBNF already has FailedSimulation(Result) for exactly this case — a
failed evaluation should yield a FailedSimulation with a penalizing
objective. The failing path here does not produce one; a bare tuple
reaches the trajectory code instead.

Reproduction context

Hit with bngl_backend=bngsim on a network-free fitting job: a model
action produced simulation output missing an expected .exp column, so
Model.execute() raised PybnfError. The underlying column issue was a
separate bug; the point here is the failure mode — any exception from a
fit evaluation crashes the whole run rather than penalizing that one
parameter set.

Expected behavior

A failed fit evaluation should:

  • be turned into a FailedSimulation (penalizing objective),
  • be logged to FailedSimLogs/,
  • and let the scatter-search run continue.

A single bad parameter set should not abort an entire multi-hour fit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions