Optimizing the location of fuel stations on a linear road

Hi there,

I have a simple problem to solve, but I’m not able to get there. It’s as follows:

Consider a linear road along which there are a number of nodes for potential location of fuel stations.
The distance between consecutive nodes is constant (e.g. 40 km).
Fuel stations should be placed at nodes such that the distance between consecutive fuel stations cannot be larger that a certain distance (e.g. 150 km).


I understand I need to use a binary variable to allocate stations to nodes. If I say the first node is occupied with a station, I can do a loop statement that gives me the location of the next station. I should use this station as the starting point for the next loop but I can’t find a way around it.

Could someone advise on how to proceed?

Here is where I went so far with my code:


Set i /1*10/;
alias (i,j);

Parameters
a /40/,
p(i) /1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7, 8 8, 9 9, 10 10/
dmax /150/
;

Binary Variable x(i);


loop(i,
if(a*(p(i)-p(‘1’))<=(dmax-a),
x.l(i)=0;
else
x.l(i)=1;
break;
);
);

display x.l;