Nonlinear Programming/ Steiner Weber Modell with barriers

Problems with modeling
Post Reply
Student75
User
User
Posts: 2
Joined: 1 month ago

Nonlinear Programming/ Steiner Weber Modell with barriers

Post by Student75 »

Hello everyone,
I would like to solve a mathematical model with GAMS and unfortunately I can't find the solution. I would like to solve the following problem with the GAMS programme:

I would like to carry out location planning taking a barrier into account. I will take the federal state of Brandenburg as an example. My demand/requirement locations are all cities in Brandenburg. I get the coordinates of the cities from Excel using geocoordinates and can thus determine the respective distances between the cities. To do this, I form a distance matrix between the cities and insert the values in a table in GAMS. I have one demand point per 200 inhabitants. For example, if I have 1000 inhabitants in a small town, then I have 5 demand points for this town. My barrier should be Berlin. The barrier area is represented by a circle or, even more simply, by the corner points of the rectangle as an area. The corner points of the rectangle represent the area for the barrier zone. The new locations should be shown with X and Y coordinates. If a new location falls on the barrier area, the location is moved to the edge of the barrier. There should also be a capacity limit for the new location. For example, a location can only cover 20 demand points.

My objective function is to minimise the distance between demand points and new locations.There should also be the possibility to limit the number of new locations.

How can I create a formula, that moves locations out of the barrier zone to the edge of the barrier zones?

Many thanks in advance :)
User avatar
bussieck
Moderator
Moderator
Posts: 1045
Joined: 7 years ago

Re: Nonlinear Programming/ Steiner Weber Modell with barriers

Post by bussieck »

This is a straight forward text book optimization problem. Get the math straight and GAMS will follow. If you have detailed questions on how to to particular formulations or tasks in GAMS you will find answers here. Getting the math right is the whole fun and you should not shortcut this experience. Good luck and have fun.

-Michael
Student75
User
User
Posts: 2
Joined: 1 month ago

Re: Nonlinear Programming/ Steiner Weber Modell with barriers

Post by Student75 »

Hi Michael,

I know try to program the capacitive multi weber problem with a Cirucums barriers.
The function doesn't work. I want a forbidden barrier where travelling through it is also forbidden.
Can you please help ?

this is the program:
Sets

j Nachfragestandort /1*30/
i Neue Standorte /1*15/
;

Parameter

a(j) X-Koordinate Nachfrage Ort also die Breitengrade in Radian /
1 0.914799298
2 0.90339648
3 0.913541692
4 0.914552528
5 0.922110773
6 0.912661755
7 0.901082827
8 0.918043187
9 0.917708665
10 0.920738751
11 0.899135453
12 0.913970752
13 0.923667025
14 0.914169525
15 0.925119257
16 0.900095384
17 0.913679863
18 0.926125031
19 0.916297857
20 0.916297857
21 0.916879634
22 0.916879634
23 0.916588746
24 0.915973032
25 0.917461416
26 0.917461992
27 0.917170522
28 0.915134304
29 0.915716081
30 0.915425193

/

b(j) Y-Koordinate Nachfrage Ort also Längengrade als radiant /
1 0.914799298
2 0.90339648
3 0.913541692
4 0.914552528
5 0.922110773
6 0.912661755
7 0.901082827
8 0.918043187
9 0.917708665
10 0.920738751
11 0.899135453
12 0.913970752
13 0.923667025
14 0.914169525
15 0.925119257
16 0.900095384
17 0.913679863
18 0.926125031
19 0.916297857
20 0.916297857
21 0.916879634
22 0.916879634
23 0.916588746
24 0.915973032
25 0.917461416
26 0.917461992
27 0.917170522
28 0.915134304
29 0.915716081
30 0.915425193


/



d(j) Nachfragewerte pro 100 Einwohner /
1 736.09
2 995.15
3 582.3
4 1857.5
5 1827.6
6 1603.14
7 1026.38
8 1552.26
9 1907.14
10 2112.49
11 1152.12
12 1786.58
13 991.25
14 2043.88
15 775.73
16 1144.29
17 1604.48
18 1208.78
19 3435.92
20 2903.86
21 2942.01
22 2699.67
23 3857.48
24 1672.48
25 571.13
26 806.87
27 2451.97
28 3100.71
29 3509.84
30 2736.89
/

s(i) Kapastandort /1*15 5000/


;


Scalar
sx X-Koordinate vom Kreis Mittelpunkt /52.52/
sy X-Koordinaten vom Kreis Mittelpunkt /13.40495/
R Radius von der Barriere /15/
;


free Variable f;

Positive Variable w(i,j);

Variable
*c(i,j)
x(i) X-Koordinate der Standorte
y(i) Y-Koordinate der Standorte
;



equations
Gesamtdistanz Die Gesamtdistanz zwischen Nachfrager und neuem Standort
Kapa(i) Die maximale Kapazität der neuen Standorte muss kleiner gleich der Nachgefragtenmengen sein
Nachfragebed(j) Die Nachfrage menge entspricht der Transpoortierten Menge
Barriere(i) Die Restriktion für die Bairre
haversine_formula
;

Function haversine_distance /lat1, lon1, lat2, lon2/;
haversine_distance(lat1, lon1, lat2, lon2) =
2 * 6371 * asin(sqrt(sqr(sin((lat2-lat1)/2)) + cos(lat1) * cos(lat2) * sqr(sin((lon2-lon1)/2))));




Gesamtdistanz..
f =e= sum((i,j), haversine_distance(x(i), y(i), a(j), b(j)) * w(i,j));

Nachfragebed(j)..
sum(i,w(i,j))=E=d(j);

Kapa(i)..
sum(j,w(i,j))=L=s(i);

Barriere(i)..
haversine_distance(x(i), y(i), sx, sy) =g= R
;


Model MultiWeber /all/;

Solve MultiWeber using NLP minimizing f;
User avatar
bussieck
Moderator
Moderator
Posts: 1045
Joined: 7 years ago

Re: Nonlinear Programming/ Steiner Weber Modell with barriers

Post by bussieck »

GAMS has no simple user defined functions (only extrinsic function implemented in a shared library where you need to provide derivatives etc). Anyhow, you can define your function as a macro. Moreover, arcus sinus is called arcsin in GAMS not asin. I have made the changes for you in the attached model. Conopt is the only solver that works okay. The numerics of the model are not very good and hence Conopt terminates with a feasible but not (locally) optimal solution.

-Michael
Attachments
new8.gms
(2.82 KiB) Downloaded 1 time
Post Reply