Have you tried something like this?
sum {j in Nodes} a[i,j] * demand[j]
Of course this sum will need to be included in some constraint definition that is indexed over Subsets.
Bob Fourer
am...@googlegroups.com
=======
From:
am...@googlegroups.com [mailto:
am...@googlegroups.com] On Behalf Of Heidi
Sent: Thursday, April 21, 2016 11:14 AM
To: AMPL Modeling Language
Subject: [AMPL 11859] Multiplying and summing a column from a matrix with another column
Am trying to implement the VRP using set covering method.
Now I am trying to make sure the demand of each node on the route does not exceed the vehicle capacity
set Nodes := 0 1 2 3 4;
set Subsets := S1 S2 S3 S4 S5;
param demand:=
0 0
1 10
2 11
3 13
4 0;
param a (tr): =1 if subset covers node
S1 S2 S3 S4 S5:=
0 1 1 1 1 1
1 1 1 0 1 1
2 0 1 1 0 1
3 0 0 1 1 1
4 1 1 1 1 1
What I want to do is to multiply each column in a with the demand and sum it together to see if a route exceeds the vehicle capacity
e.g. for subset 1:
[ 0 ] [1]
[10] [1]
[11] * [0] and sum this to get 10
[13] [0]
[0 ] [1]