# [AMPL 24606] Index problem

I have this code in .mod:

``````# Sets
set paths;
set intersections;
set fixed;
set prohibited;
set path_intersections dimen 2;

# Params
param path_flow {paths} >= 0;

# Variables de decision
var x{intersections} binary;
var y{paths} binary;

# Objective function
maximize total:
sum {p in paths} (path_flow[p]*y[p]);

# Constraints
subject to at_least_two_intersections {p in paths}:
sum {i in path_intersections} x[i] >= 2*y[p];

subject to prohibited_intersections{i in prohibited}:
x[i] = 0;

subject to fixed_intersections{i in fixed}:
x[i] = 1;

subject to max_intersections:
sum {i in intersections} x[i] <= 15;
``````

The path_intersections consists of rows of two numbers, the first one is the number of the path, and the second one the number of the intersection.

And now the problem is with the first constraint, I want to say that the road is sensorized if at least two of its intersections are, " ∑(i ∈ path_intersections[p]) x_i ≥ 2y_p, ∀p ∈ paths".

And I get this error:

``````ampl: model practica.mod;

practica.mod, line 21 (offset 383):
1 index for set of dimen 2
context: sum {i in >>> path_intersections} <<< x[i] >= 2*y[p];
``````

How can I solve it without changing it a lot?

This has been answered in our new user forum, at
https://discuss.ampl.com/t/ampl-duplicate-member-x-for-set-y-how-to-fix-it/474/