Skip to content

sum(by=) and at each send a diagonal read to the other, and both refuse it #772

Description

@FBumann

Prompt: "Let’s add one parent issue for caliope and file focused issues for individual topics or link existing ones."

Note

The following content was generated by AI.

What happened?

A read at the label a relation maps a carried key to is refused by sum(by=), and the error tells you to write at. at then refuses the same read, and its error tells you to move the factor or read onto another dimension. An error must name a rewrite that loads.

Reproduction
import mathspec as ms

base = {'dimensions': {'techs': {}, 'nodes': {}},
        'relations': {'link_from': {'key': 'techs', 'values': 'nodes'}},
        'variables': {'flow_cap': {'dims': ['techs', 'nodes'], 'bounds': {'lower': 0}}},
        'objective': {'expression': 'sum(sum(flow_cap, over=techs), over=nodes)'}}

for e in ['sum(flow_cap, by=link_from, over=nodes, into=techs) >= 1',
          'at(flow_cap, by=link_from, over=nodes, into=techs) >= 1']:
    ms.to_spec({**base, 'constraints': {'c': {'dims': ['techs'], 'expression': e}}})

The whole ask is in #771. That issue proposes to let at read this. If #771 is declined, the fix here is to change both messages so that they name what loads (a relation over the pair, and a mask). If #771 lands, the sum(by=) message becomes true.

Which operating systems have you used?

  • Linux

Version

main at 5fce82b.

Relevant log output

Constraint 'c': sum(by=link_from): this sum lands on the key ['techs'], so each coordinate has one term and nothing is added up — that is a read, which is at()'s. Write at(..., by=link_from, over=['nodes'], into=['techs']), or sum toward a value column.

Constraint 'c': at(by=link_from) lands on ['techs'], which the expression already carries.
A call brings the dims it lands on, so that reading it tells you what it adds. Move the factor carrying ['techs'] outside the operator, or read to a column over another dimension.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: operatorsWhat an operator may reduce, walk, read or refusebugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions