Skip to content

Improve documentation on overriding coordinates feature #256

@apfelix

Description

@apfelix

Hi,

I'm currently stuck trying to archive the following rather specific problem in linopy:

import linopy
m = linopy.Model()

# 2 days, hourly (48 hours)
t = list(range(1,49))
n = ["a", "b", "c", "d"]

level = m.add_variables(coords=[t, n], name="level", dims=["time", "node"])

change = m.add_variables(coords=[t, n], name="change", dims=["time", "node"])

# previous_level should by cyclic per day, so have time indices
#  24, 1, 2, ..., 23, 48, 25, 26, ..., 47
# |---- 1st day ----|----  2nd day   ----|
# constraint should be valid for each node
level == previous_level + change

So problem is in the creation of previous_level: I don't know have to do that. I know there is Variable.roll() for creating a shift in specific dimensions, but I basically want this operation but restricted to a subset of the time index. My plan was to use the result of roll() and assign the correct variable value to the positions 0 and 24 myself, but assignment does not seem to work. Is there any way to create a self-defined variable vector that has the form of the result of roll() (single variables per coordinate tuple), but using an arbitrary assignment?

PS: My fallback solution would be to create single constraints per point in time, but I would like to avoid that if possible ^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions