Hi Nice members,

Hope you are doing good. I have a question. I have many points and I am constructing a network in AIMMS such that all points are connected to one main source point but not only in direct manner. These points can be directly connected or connected to each other as well to be connect to source point (Such that end point is connected to the points lying in middle of source and end points). My decision variable is binary which tells either any two points are connected or not. Objective is to minimize the cost which actually depends on creating the total shortest connected path which obeys the constraints. I want to know the “xyz” property of any point which actually depends on its connection to the previous node(distance from previous node it is connected to) plus the “xyz” property of previous node. How can I write it in an equation in AIMMS. I do not know the order in which the connections of nodes are going to be happen because it is the optimization problem.

It was a long essay, sorry for that, and if you find my explanation not understandable, please tell me how can I add any variable or parameter value using its index value as a variable and not numerical. For example, to achieve above task, I am trying something like: variableXYZ(i,j) with definition as abxyz(i) + xyz(i,j) (where abxyz is another variable just to store the xyz values to be used) but then I want to store every xyz(i,j) into abxyz(i) for next addition of i,j value, that is, the present value of xyz(i,j) becomes previous value of abxyz(i) in next addition. I am trying to do it by: abxyz(ord(i) = ord(j)) = xyz(i,j). That is, I want to store the xyz(i,j) value in abxyz such that it is stored at jth position in abxyz. But it says I cant index using nor numerical expression and using ord.

Any help?

Many Thanks in Advance!

**Best answer by mohansx**

@zeb

You cannot refer to variables in index domains because the variables don’t have any values/data until the math program is solved. The index domain must be known so that the math program can be generated, and then passed to the solver to solve it. It is a cyclic issue.

You can track this xyz property at teach node in multiple ways. Think of this property as another flow in the network.

`var_connected(i, j) - is a binary variable which indicates node i is connected to node j. `

Typically, you would have a flow balance constraint like below indicating that all flows entering a node must also leave (expect at source and destination nodes). Notice the positiong of index j is opposite on LHS and RHS.

`forall i `

`sum[j, var_connected(j, i)] = sum[j, var_connected(i, j)]`

You can think of xyz(i,j) as a variable tracking how much of property xyz did node i contribute to node j. (How many goods are transported from node i to node j).

`forall (i, j) `

`sum[j, XYZ(j, i)] = sum[j, XYZ(i, j)]`

`! incoming + production at current node = outgoing + demand at current node`

Add the appropriate terms for production and demand as needed.

XYZ(i, j) can be non-zero only when the two nodes i and j are connected.

`forall (i, j)`

`XYZ(i, j) <= var_connected(i, j) * Big_M`

`! Big_M here usually represents the capacity of the arc between i and j, so Big_M(i, j) or just a sufficiently large value. `

As with flow balance constraints, you need to take care of the boundary conditions at the source and destination nodes.