Hi there! I’m trying to write a flow conservation constrains. Yet it says key not found
# this is the constraint I'd like to write (and α(i,j) is a binary variable and A1 is a subset of nodes)
∑ᵢ α[i,j] = ∑ₖ α[j,k] ∀ j ∈ A1 # flow conservation on all nodes belong to A1
using JuMP, CPLEX
m = Model(CPLEX.Optimizer)
A1 = [1,2,5]
Arcs = ((3, 1), (1, 2), (2, 5), (7, 7), (4, 2))
@variable(m, α[i in Arcs]>= 0, Bin)
Do you know why the above is not working? any suggestion to write it the other way?
@Takashy! In order to make it easier to help you, please read the advice below. In particular, a reproducible chunk of code would help clarify your problem and look for solutions!
Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer.
Keywords are highlighted to make it easier to refer to specific points.
Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …
@gdalle Thanks for your advice. I’ve made some change. Basically, there are some arcs in a newtrok and I need to ensure that for a subset of nodes (A1); flow conservation constraints hold.
They require that, for each node in
A1, the sum of the flow into the node must be equal to the sum of the flow out of the node.
Something like this?
[jj in A1],
sum(α[(i, j)] for (i, j) in Arcs if j == jj) == sum(α[(j, k)] for (j, k) in Arcs if j == jj),