A list comprehension creates a list by evaluating an expression for each item in an iterable. Its compact syntax is useful for turning feature records into optimization inputs while keeping the transformation visible. section 8.2.3
In linear-programming setup, comprehensions perform targeted collection transformations:
- Calculate one objective coefficient per feature, such as the negated value-to-effort ratio used to convert maximization into minimization. section 8.2.3
- Extract each feature's first-year and total costs into rows of a NumPy constraint matrix. section 8.2.4
- Create repeated binary bounds, assigning every feature a permitted decision-variable range of 0 to 1. section 8.2.5
Optimization inputs from feature records
Use `[-f.value_points / f.effort_points for f in features]` to produce objective coefficients. Use `[(0, 1) for _ in features]` to produce one binary bound tuple per feature. Attribute-based comprehensions similarly produce cost rows such as `[f.cost_1yr for f in features]`. section 8.2.3 section 8.2.4 section 8.2.5
>>> c = [-f.value_points / f.effort_points for f in features]
Inspect the complete objective-coefficient expression used to transform feature priority scores for a minimization solver. section 8.2.3





