On 08/06/2017 01:51 PM, Andrew Makhorin wrote:
> Hi Heinrich,
> 
>> the appended file test.mod is examples/threads/clustering.mod with
>> appended line
>>
>> printf {t in T} "%d -> %d\n", t,  pt[t];
>>
>> Essentially the line prints out part of the generated problem.
>>
>> The output on x86-64 ends with:
>>
>> 49 -> 608
>> 50 -> 334
>> Model has been successfully processed
>>
>> The output on ARMv7 ends with:
>>
>> 49 -> 852
>> 50 -> 472
>> Model has been successfully processed
>>
>> How can it be that the generated model differs depending on the CPU
>> architecture?
> 
> I think this is due to round-off errors, because you are using
> floating-point computations in your model.

The important thing is that I observed a difference for model parameters.

./glpsol --wlp test.lp -m test.mod --check

yields totally different files test.lp and different objective values.
So this is a problem in model generation.

If I take one of the lp files as input I get the same objective value on
both platforms. There is no problem in the solver.

Replacing Uniform01() by round(Uniform01(), 5) does not change the
output for parameter pt[50] on both platforms.

By rounding you cannot explain the difference between 334 and 472 of
model parameter pt[50]. This could only be explained by the sequence of
generation steps and hence Uniform01() values assigned to different
parameters on the different platforms.

This should be fixed.

With the appended rnd.mod no difference occurs between x86-64 and armv7.

> Please conduct the following experiment: move the statement
>
> printf {t in T} "%d -> %d\n", t,  pt[t];

In this case I get the same results on both platforms but different to
the original values. This is expected because we changed the sequence in
which Uniform01() is called for the different parameters.

So the error must be in the code generating the constraints and the
objective.

Best regards

Heinrich Schuchardt
i,r
1,0.1283118040300906
2,0.0095966751687229
3,0.0296868691220880
4,0.5537919262424111
5,0.8182639055885375
6,0.2555594472214580
7,0.4122264189645648
8,0.4117954890243709
9,0.9262405140325427
10,0.9006356885656714
11,0.2921296940185130
12,0.5396903096698225
13,0.0966075621545315
14,0.2887144996784627
15,0.2510403958149254
16,0.9628592282533646
17,0.4821618809364736
18,0.0251924195326865
19,0.7129793898202479
20,0.6491678943857551
21,0.3921313951723278
22,0.5375207834877074
23,0.3429719866253436
24,0.7938511283136904
25,0.2059222082607448
26,0.1402976275421679
27,0.8419359494000673
28,0.1841345182619989
29,0.2093450678512454
30,0.3467838228680193
31,0.8280209200456738
32,0.0841145943850279
33,0.5216898573562503
34,0.4337504184804857
35,0.3556738244369626
36,0.5405400423333049
37,0.6723811845295131
38,0.9386785053648055
39,0.4563398407772183
40,0.8116365587338805
41,0.9145371220074594
42,0.4956066468730569
43,0.1909179259091616
44,0.0471117007546127
45,0.3927211072295904
46,0.9989088969305158
47,0.2465867609716952
48,0.4570853183977306
49,0.8424617522396147
50,0.5246065454557538
51,0.9202133091166615
52,0.2170099485665560
53,0.5642138123512268
54,0.9994520368054509
55,0.7895979653112590
56,0.7396589284762740
57,0.6809262032620609
58,0.4587963344529271
59,0.1945359613746405
60,0.6356118666008115
61,0.5652556745335460
62,0.1927311550825834
63,0.4559926986694336
64,0.4141473318450153
65,0.4965721392072737
66,0.4902477958239615
67,0.8174141729250550
68,0.6797858248464763
69,0.7622624132782221
70,0.2064960440620780
71,0.0774631835520267
72,0.4682604474946856
73,0.8217154666781425
74,0.0617517735809088
75,0.6986637557856739
76,0.2881247876212001
77,0.7896522823721170
78,0.0592444539070129
79,0.8189276908524334
80,0.3886528755538166
81,0.3286704719066620
82,0.5708905346691608
83,0.3592559648677707
84,0.1826520389877260
85,0.6903037726879120
86,0.2194952638819814
87,0.9558027903549373
88,0.5120931821875274
89,0.4040635493583977
90,0.8018818981945515
91,0.7222761367447674
92,0.4168217373080552
93,0.5264520864002407
94,0.0445443517528474
95,0.8853960447013378
96,0.0139014334417880
97,0.2034769528545439
98,0.6512276162393391
99,0.9505041386000812
100,0.1040066075511277
101,0.7478685011155903
102,0.2837275327183306
103,0.9749234374612570
104,0.8172693327069283
105,0.8116271556355059
106,0.2710454147309065
107,0.8248785533942282
108,0.0266930288635194
109,0.6564800501801074
110,0.4773332644253969
111,0.3465599189512432
112,0.1021311134099960
113,0.4602874587289989
114,0.3720337622798979
115,0.6900005741044879
116,0.4721874981187284
117,0.7628338565118611
118,0.2398488367907703
119,0.5829803529195487
120,0.5513049243018031
121,0.8829018590040505
122,0.7307499027810991
123,0.8282197620719671
124,0.4285414819605649
125,0.6179443909786642
126,0.6062144706957042
127,0.9509311532601714
128,0.1084863096475601
129,0.2279383302666247
130,0.4279454420320690
131,0.9463805933482945
132,0.2482798253186047
133,0.8529801047407091
134,0.3122647008858621
135,0.3930990095250309
136,0.5787950898520648
137,0.9985088757239282
138,0.8225021990947425
139,0.9456112924963236
140,0.0930681764148176
141,0.4298972985707223
142,0.2161438618786633
143,0.8311669789254665
144,0.9452672149054706
145,0.6073459368199110
146,0.0866642701439559
147,0.8515660627745092
148,0.3337209313176572
149,0.5885516530834138
150,0.4712487128563225
151,0.5173292942345142
152,0.7132291570305824
153,0.8338134433142841
154,0.2707183137536049
155,0.3417441942729056
156,0.5413724570535123
157,0.2062643491663039
158,0.5066629899665713
159,0.9955538660287857
160,0.7498753820545971
161,0.5723816589452326
162,0.5367537657730281
163,0.2370407464914024
164,0.5972355962730944
165,0.7208004002459347
166,0.8405284658074379
167,0.0452730753459036
168,0.6062147999182343
169,0.1399047356098890
170,0.7331502027809620
171,0.1233748132362962
172,0.8102698223665357
173,0.3702648938633502
174,0.8539444874040782
175,0.0663251681253314
176,0.6475896844640374
177,0.3340862067416310
178,0.4488411974161863
179,0.8576544071547687
180,0.2692415746860206
181,0.7179461107589304
182,0.9849067833274603
183,0.2781590116210282
184,0.1248747897334397
185,0.9854468903504312
186,0.0331778810359538
187,0.3248517592437565
188,0.2529302262701094
189,0.7565328641794622
190,0.5060314531438053
191,0.0568580380640924
192,0.8540726588107646
193,0.2321290266700089
194,0.9568503713235259
195,0.3488126848824322
196,0.9525640341453254
197,0.8695839429274201
198,0.7290358655154705
199,0.4849797561764717
200,0.2353121745400131
201,0.3966636960394681
202,0.3793785646557808
203,0.5708870748057961
204,0.3487028162926435
205,0.8882683599367738
206,0.9660243699327111
207,0.8303272980265319
208,0.1030635405331850
209,0.4424985516816378
210,0.9132027123123407
211,0.9234280660748482
212,0.6000498784705997
213,0.5557318367063999
214,0.8870675563812256
215,0.5219370517879725
216,0.1444362169131637
217,0.5903731724247336
218,0.9887609211727977
219,0.7442554915323853
220,0.5350925894454122
221,0.9434055574238300
222,0.3854772993363440
223,0.9111314676702023
224,0.4649710003286600
225,0.4402089933864772
226,0.2658873936161399
227,0.5785061884671450
228,0.3412094167433679
229,0.1701816972345114
230,0.1875602118670940
231,0.5521822455339134
232,0.6705727134831250
233,0.1928374459967017
234,0.0970371547155082
235,0.2908036522567272
236,0.6836222382262349
237,0.0852075815200806
238,0.0954213980585337
239,0.3558974559418857
240,0.9917895360849798
241,0.9776295758783817
242,0.6706652678549290
243,0.3708264585584402
244,0.1857078108005226
245,0.8971229083836079
246,0.6597957760095596
247,0.6950833322480321
248,0.6749337352812290
249,0.2929412093944848
250,0.8574874196201563
251,0.2317636338993907
252,0.0290554771199822
253,0.6837627901695669
254,0.8787649562582374
255,0.0954074389301240
256,0.6635134932585061
257,0.2560037514194846
258,0.7606172524392605
259,0.9784379224292934
260,0.0343238725326955
261,0.8996992018073797
262,0.1827376135624945
263,0.7689773337915540
264,0.9936573542654514
265,0.0555483051575720
266,0.6541864913888276
267,0.8821037677116692
268,0.5708250533789396
269,0.6089085447601974
270,0.3970622620545328
271,0.1589893265627325
272,0.5571952913887799
273,0.6639091619290411
274,0.4913252652622759
275,0.8350022505037487
276,0.5597697957418859
277,0.7668463294394314
278,0.3832479258999228
279,0.3696029805578291
280,0.1405116780661047
281,0.5288987806998193
282,0.8818351440131664
283,0.2555594970472157
284,0.8718962064012885
285,0.2199267232790589
286,0.9217458069324493
287,0.4472682136110961
288,0.2027210881933570
289,0.9149260907433927
290,0.6535751465708017
291,0.8194800629280508
292,0.3730685915797949
293,0.4648660300299525
294,0.2574928356334567
295,0.1909696278162301
296,0.0191184254363179
297,0.3072824287228286
298,0.1723449290730059
299,0.7000903389416635
300,0.3836357616819441
301,0.6186309698969126
302,0.5278835417702794
303,0.0953680197708309
304,0.2996973153203726
305,0.7369886129163206
306,0.6966710444539785
307,0.0856499196961522
308,0.2982854908332229
309,0.9676334885880351
310,0.6304364386014640
311,0.2233044998720288
312,0.9901163578033447
313,0.1821110639721155
314,0.6372285056859255
315,0.8641421752981842
316,0.7121389899402857
317,0.6305553680285811
318,0.0984046203084290
319,0.8008199082687497
320,0.9585111504420638
321,0.3633828391321003
322,0.1984815294854343
323,0.4856174718588591
324,0.5134871467016637
325,0.0411648061126471
326,0.1671997904777527
327,0.5795657155103981
328,0.9932438940741122
329,0.1204988067038357
330,0.2474607918411493
331,0.2247551507316530
332,0.9318873300217092
333,0.8315945467911661
334,0.8346822508610785
335,0.5267758280970156
336,0.7400640454143286
337,0.0201663500629365
338,0.7296793730929494
339,0.3404570450074971
340,0.6355411605909467
341,0.6609123488888144
342,0.3644753918051720
343,0.7415035110898316
344,0.6146501707844436
345,0.2719061379320920
346,0.8272340940311551
347,0.8808563249185681
348,0.7560564689338207
349,0.6063564289361238
350,0.5928708077408373
351,0.9755333657376468
352,0.5974747361615300
353,0.7933434625156224
354,0.5875414586625993
355,0.3350146450102329
356,0.8349589994177222
357,0.5516533791087568
358,0.5349207296967506
359,0.6137358499690890
360,0.7888347352854908
361,0.8616687939502299
362,0.5258801239542663
363,0.5314391613937914
364,0.5843855626881123
365,0.2608334580436349
366,0.0827928218059242
367,0.4612175771035254
368,0.3002759199589491
369,0.3816690086387098
370,0.9922459688968956
371,0.4922122666612267
372,0.7088095610961318
373,0.6511364066973329
374,0.5980988200753927
375,0.0435850596986711
376,0.7098076925612986
377,0.3790014665573835
378,0.1125488802790642
379,0.0486211166717112
380,0.7836719704791903
381,0.9762301626615226
382,0.5604472900740802
383,0.6859614653512836
384,0.9481538776308298
385,0.8916118885390460
386,0.1823051534593105
387,0.2742438721470535
388,0.6633005226030946
389,0.8846754455007613
390,0.0015267073176801
391,0.1060397252440453
392,0.4059583479538560
393,0.4285543998703361
394,0.7409052136354148
395,0.8827501446940005
396,0.2347611417062581
397,0.8084583980962634
398,0.0203499794006348
399,0.3345406008884311
400,0.6199165023863316
401,0.1754451701417565
402,0.0241852188482881
403,0.7081592567265034
404,0.3196954140439630
405,0.7362754987552762
406,0.5465984768234193
407,0.1595731815323234
408,0.2415760899893939
409,0.3558489033021033
410,0.0424499972723424
411,0.6576434578746557
412,0.1682940241880715
413,0.9500068053603172
414,0.5252491207793355
415,0.6340243201702833
416,0.6142080021090806
417,0.3011249732226133
418,0.5995518313720822
419,0.7527910158969462
420,0.4261512071825564
421,0.5560169937089086
422,0.7211535316891968
423,0.2801095698960125
424,0.6519896355457604
425,0.6517889238893986
426,0.8566711060702801
427,0.0478972122073174
428,0.2866610148921609
429,0.8565953089855611
430,0.4289348889142275
431,0.4379015546292067
432,0.5517673725262284
433,0.2316925553604960
434,0.2925646477378905
435,0.1773155415430665
436,0.3833593549206853
437,0.5849139243364334
438,0.0884867291897535
439,0.1548104151152074
440,0.7432703217491508
441,0.7242605471983552
442,0.4742205417715013
443,0.1420903545804322
444,0.9729840876534581
445,0.4051911341957748
446,0.3852497301995754
447,0.6833622343838215
448,0.3097345801070333
449,0.4155972544103861
450,0.7932596514001489
451,0.6932853800244629
452,0.2539681117050350
453,0.4052361729554832
454,0.4603893789462745
455,0.3964812667109072
456,0.2645614598877728
457,0.0502642574720085
458,0.8950231862254441
459,0.8414927972480655
460,0.9000301691703498
461,0.4522041887976229
462,0.3415881292894483
463,0.8652538876049221
464,0.1483415667898953
465,0.4580446062609553
466,0.8000233303755522
467,0.5212101680226624
468,0.9116913578473032
469,0.5963355731219053
470,0.7207899950444698
471,0.7225961135700345
472,0.1188198197633028
473,0.3253079592250288
474,0.0894904932938516
475,0.5414757616817951
476,0.5544902863912284
477,0.6151138064451516
478,0.8741512219421566
479,0.2234352356754243
480,0.9108837102539837
481,0.9739209613762796
482,0.8131360705010593
483,0.4782026167958975
484,0.8362453295849264
485,0.0943942880257964
486,0.8179850522428751
487,0.3763222023844719
488,0.2075073365122080
489,0.5844053910113871
490,0.8576201274991035
491,0.6470838561654091
492,0.0383154475130141
493,0.9289135476574302
494,0.9132343251258135
495,0.7521718339994550
496,0.9555981457233429
497,0.6903245416469872
498,0.3679338735528290
499,0.6474039885215461
500,0.3961809794418514
501,0.7124401726759970
502,0.7040364425629377
503,0.9151753075420856
504,0.5645098369568586
505,0.8458595126867294
506,0.1247937059961259
507,0.1046689595095813
508,0.1753720967099071
509,0.2696003913879395
510,0.4827806111425161
511,0.7692750040441751
512,0.8696029474958777
513,0.7751724957488477
514,0.6172582921572030
515,0.4690210125409067
516,0.8181992797181010
517,0.9200843437574804
518,0.7534931451082230
519,0.9910984877496958
520,0.7686624014750123
521,0.7838960001245141
522,0.7741564810276031
523,0.3255800991319120
524,0.0090101547539234
525,0.6728095575235784
526,0.9793257918208838
527,0.3945592725649476
528,0.8510874174535275
529,0.9474001387134194
530,0.5684916740283370
531,0.1492991521954536
532,0.2298640762455761
533,0.1907889875583351
534,0.9137006555683911
535,0.4952864558435977
536,0.1806613099761307
537,0.1198506904765964
538,0.2242345050908625
539,0.4310091566294432
540,0.6340049090795219
541,0.4215037855319679
542,0.1117607424966991
543,0.1572430790401995
544,0.6893822047859430
545,0.0161273302510381
546,0.7470536869950593
547,0.5861112587153912
548,0.5873254183679819
549,0.0479804375208914
550,0.0487134777940810
551,0.1011454532854259
552,0.3052975796163082
553,0.8718100669793785
554,0.0897358683869243
555,0.0544118992984295
556,0.3341179075650871
557,0.4768824847415090
558,0.4762141807004809
559,0.4037469611503184
560,0.2663932475261390
561,0.2037060204893351
562,0.3515507867559791
563,0.6579481931403279
564,0.7828478463925421
565,0.4842552631162107
566,0.8384983851574361
567,0.5348011502064764
568,0.7801155112683773
569,0.4976927465759218
570,0.2133839526213706
571,0.4537947620265186
572,0.9813611693680286
573,0.4110074066556990
574,0.7034583562053740
575,0.8544526924379170
576,0.3850269620306790
577,0.4961238065734506
578,0.5576681201346219
579,0.3417690801434219
580,0.3783222651109099
581,0.2271539578214288
582,0.4389611268416047
583,0.1607628758065403
584,0.5794662651605904
585,0.9210876855067909
586,0.7531181727536023
587,0.5174239035695791
588,0.4867525449953973
589,0.9985253480263054
590,0.9307766188867390
591,0.3348017972894013
592,0.9950569844804704
593,0.1195655455812812
594,0.2556370599195361
595,0.3644045176915824
596,0.9387231743894517
597,0.3424857384525239
598,0.2876401315443218
599,0.9142097090370953
600,0.3988690380938351
601,0.2780326744541526
602,0.7679119789972901
603,0.6672410746105015
604,0.2944872924126685
605,0.0980941029265523
606,0.3807869586162269
607,0.8214469091035426
608,0.4403349822387099
609,0.8461849652230740
610,0.3985227243974805
611,0.8392755282111466
612,0.2984420047141612
613,0.1383985071443021
614,0.5482816649600863
615,0.5587370493449271
616,0.3723542033694685
617,0.6528445133008063
618,0.4746421971358359
619,0.7729777861386538
620,0.9619440957903862
621,0.3114687274210155
622,0.4663926004432142
623,0.9887645472772419
624,0.7296779877506196
625,0.6156950858421624
626,0.8722380907274783
627,0.5268932580947876
628,0.9070200533606112
629,0.9506193748675287
630,0.7203584946691990
631,0.4838506705127656
632,0.4314750847406685
633,0.2435509031638503
634,0.6558891749009490
635,0.4948423793539405
636,0.1784404800273478
637,0.3378156735561788
638,0.8554652961902320
639,0.7076561981812119
640,0.8313518171198666
641,0.6987062734551728
642,0.1833059960044920
643,0.0098700602538884
644,0.5223111673258245
645,0.5270296577364206
646,0.0684085497632623
647,0.7913509639911354
648,0.7680147588253021
649,0.5976888667792082
650,0.5815566712990403
651,0.4544679112732410
652,0.5039873532950878
653,0.7528389813378453
654,0.1340941977687180
655,0.9011762915179133
656,0.0646487218327820
657,0.3141172169707716
658,0.6858799052424729
659,0.8834798857569695
660,0.4339211089536548
661,0.8057581144385040
662,0.5090945423580706
663,0.4578135334886611
664,0.0445131883025169
665,0.9016201966442168
666,0.3208929812535644
667,0.2180956276133657
668,0.1813697922043502
669,0.5142632778733969
670,0.2914158334024251
671,0.3871873514726758
672,0.3526609642431140
673,0.1306117293424904
674,0.0615497305989265
675,0.5780314356088638
676,0.3327207346446812
677,0.9567211000248790
678,0.5697677866555750
679,0.6145077422261238
680,0.4926484161987901
681,0.0636592055670917
682,0.0343694426119328
683,0.7145014274865389
684,0.6641729939728975
685,0.5750288441777229
686,0.3123523667454720
687,0.9825214487500489
688,0.8016717769205570
689,0.4969025277532637
690,0.5183825469575822
691,0.0803463771007955
692,0.9570287149399519
693,0.0340183870866895
694,0.2673212159425020
695,0.9851668518967927
696,0.3001835490576923
697,0.3440304677933455
698,0.7114280555397272
699,0.3839126601815224
700,0.9787479927763343
701,0.5096715004183352
702,0.4189967606216669
703,0.1151702455244958
704,0.1230466696433723
705,0.8085788851603866
706,0.4925238154828548
707,0.1925186258740723
708,0.2864463808946311
709,0.1453296504914761
710,0.1714983037672937
711,0.4489536359906197
712,0.4418791262432933
713,0.1589866471476853
714,0.9764598323963583
715,0.0994733958505094
716,0.8062911340966821
717,0.7537327371537685
718,0.4315973045304418
719,0.6210613320581615
720,0.5293348734267056
721,0.0644688392058015
722,0.5716703594662249
723,0.0300991917029023
724,0.9893394331447780
725,0.4819081509485841
726,0.4465336878784001
727,0.9540976118296385
728,0.1074742428027093
729,0.5682173026725650
730,0.3754885676316917
731,0.8682360197417438
732,0.7384654330089688
733,0.5379583775065839
734,0.8519984609447420
735,0.5002134758979082
736,0.3166300510056317
737,0.1198770627379417
738,0.8547035362571478
739,0.3344477131031454
740,0.9994669803418219
741,0.7553618052043021
742,0.0262162289582193
743,0.4234518562443554
744,0.3722853232175112
745,0.2564241420477629
746,0.6464252681471407
747,0.1512706005014479
748,0.5249238447286189
749,0.8095076824538410
750,0.9406536635942757
751,0.3985633524134755
752,0.0231374865397811
753,0.4933324279263616
754,0.2025428679771721
755,0.4644847149029374
756,0.2182556670159101
757,0.0318094091489911
758,0.7625092812813818
759,0.9924349403008819
760,0.7470291545614600
761,0.9144923798739910
762,0.8597978912293911
763,0.3297252808697522
764,0.5755618638359010
765,0.5569905615411699
766,0.9563052197918296
767,0.3782199206762016
768,0.1246172045357525
769,0.2619584049098194
770,0.3562855306081474
771,0.8444276400841773
772,0.7033630325458944
773,0.8614728194661438
774,0.2591993454843760
775,0.1617896920070052
776,0.2152995658107102
777,0.0247184871695936
778,0.6851197252981365
779,0.2181483255699277
780,0.1039977730251849
781,0.1269413563422859
782,0.0848691328428686
783,0.1488055954687297
784,0.6465552342124283
785,0.2030448913574219
786,0.3930907379835844
787,0.0021179169416428
788,0.9526826562359929
789,0.0435867914929986
790,0.6152527783997357
791,0.1378181991167367
792,0.5808732504956424
793,0.8631416647695005
794,0.7431878652423620
795,0.9618634940125048
796,0.0503697046078742
797,0.5701244850642979
798,0.3618619865737855
799,0.3675451814197004
800,0.8491692733950913
801,0.5469518722966313
802,0.3449794664047658
803,0.7711911075748503
804,0.3779103779233992
805,0.3195923315361142
806,0.8692284789867699
807,0.9586686473339796
808,0.9216620684601367
809,0.1724436762742698
810,0.4751452817581594
811,0.7363475160673261
812,0.5852757212705910
813,0.8084116694517434
814,0.8849606974981725
815,0.1788118518888950
816,0.5390038122422993
817,0.9915618714876473
818,0.5912598478607833
819,0.0376034863293171
820,0.7049921005964279
821,0.4560917438939214
822,0.0615898696705699
823,0.0047401417978108
824,0.4072548686526716
825,0.2022395962849259
826,0.9674849761649966
827,0.3143986370414495
828,0.1321872998960316
829,0.8211090294644237
830,0.2181114018894732
831,0.9102434962987900
832,0.8340521454811096
833,0.1845678989775479
834,0.1503202505409718
835,0.5875602145679295
836,0.0665483702905476
837,0.3774303458631039
838,0.4054365139454603
839,0.7496116529218853
840,0.7157209403812885
841,0.1360937817953527
842,0.3697681738995016
843,0.4943482913076878
844,0.3200442548841238
845,0.8790976763702929
846,0.6055615814402699
847,0.2449143296107650
848,0.2646705312654376
849,0.1540459343232214
850,0.8769426639191806
851,0.3889643955044448
852,0.7292855195701122
853,0.4380903160199523
854,0.9436782901175320
855,0.3050560695119202
856,0.1906663416884840
857,0.5005518263205886
858,0.0678280750289559
859,0.5164375584572554
860,0.0603929860517383
861,0.7074387869797647
862,0.7433690815232694
863,0.8969435812905431
864,0.4873239509761333
865,0.2569969561882317
866,0.6323497430421412
867,0.4583343649283051
868,0.7235425366088748
869,0.7361551020294428
870,0.5322566176764667
871,0.3359589208848774
872,0.5984711335040629
873,0.5891419309191406
874,0.0849208300933242
875,0.6614053091034293
876,0.8408389654941857
877,0.9237716705538332
878,0.4238668913021684
879,0.5441132038831711
880,0.2675674189813435
881,0.6811148510314524
882,0.2667952957563102
883,0.3646430694498122
884,0.7012288025580347
885,0.4533856734633446
886,0.8846300994046032
887,0.8456254000775516
888,0.6515010488219559
889,0.3968908125534654
890,0.2033099560067058
891,0.8272644137032330
892,0.8881029607728124
893,0.5723109287209809
894,0.6867202171124518
895,0.4129648883827031
896,0.0294170761480927
897,0.3249786454252899
898,0.1025622966699302
899,0.9739320641383529
900,0.5483790882863104
901,0.8229166166856885
902,0.6246763491071761
903,0.8022931795567274
904,0.9346721773035824
905,0.2863701251335442
906,0.0476033412851393
907,0.7675442304462194
908,0.1198802269063890
909,0.7647257284261286
910,0.0256133968941867
911,0.9884267454035580
912,0.5330668501555920
913,0.7534294379875064
914,0.3842502585612237
915,0.2392839565873146
916,0.4893273850902915
917,0.8331255852244794
918,0.0628914358094335
919,0.3027560519985855
920,0.1066767056472600
921,0.0447895284742117
922,0.3917859946377575
923,0.3461121907457709
924,0.3307185880839825
925,0.7826449647545815
926,0.6202379805035889
927,0.4623773517087102
928,0.2193737570196390
929,0.5905725387856364
930,0.3413610542193055
931,0.9617412891238928
932,0.3182100891135633
933,0.1789525616914034
934,0.2794426726177335
935,0.2272903532721102
936,0.8827549680136144
937,0.5866209445521235
938,0.0104610398411751
939,0.0766420480795205
940,0.2429361576214433
941,0.3361661955714226
942,0.1247660736553371
943,0.7995490496978164
944,0.9102566703222692
945,0.1837027668952942
946,0.2892092596739531
947,0.8521612491458654
948,0.6238154429011047
949,0.4694541813805699
950,0.7617098852060735
951,0.3196311830542982
952,0.4834990729577839
953,0.5380407157354057
954,0.5159228341653943
955,0.7899714289233088
956,0.7269918690435588
957,0.4174032569862902
958,0.3693329039961100
959,0.0402770657092333
960,0.7983598830178380
961,0.6801743512041867
962,0.3541820296086371
963,0.6245867544785142
964,0.2104495158419013
965,0.5484639038331807
966,0.7208593264222145
967,0.8519519991241395
968,0.4866341422311962
969,0.0196071891114116
970,0.5380551540292799
971,0.0359417116269469
972,0.9484954858198762
973,0.2172660357318819
974,0.6512550031766295
975,0.7097858930937946
976,0.8414795724675059
977,0.5645215809345245
978,0.4580092299729586
979,0.7584076593630016
980,0.0959247476421297
981,0.2072730921208858
982,0.4329602755606174
983,0.8943951115943491
984,0.4880102421157062
985,0.3674289900809526
986,0.4133622008375823
987,0.4952934724278748
988,0.5542762125842273
989,0.4771494930610061
990,0.5979093261994421
991,0.0343646113760769
992,0.7579527492634952
993,0.2796697821468115
994,0.2203568969853222
995,0.1693595973774791
996,0.8955188808031380
997,0.6311971005052328
998,0.8303520185872912
999,0.0102434726431966
1000,0.1745566176250577
/*
 * Author: Heinrich Schuchardt <xypron.g...@gmx.de>
 *
 * This model solves a clustering problem:
 *
 * Out of 50 towns select 3 to be cluster centers and assign the other
 * towns to the clusters such that the sum of the population weighted
 * euclidian distances between towns and centers is minimized.
 *
 * The solution is saved as a scalable vector graphic file with a
 * pseudo-random file name.
 */

# Read random numbers
set I;
param r{I};
table ti IN "CSV" "rnd.csv":
  I <- [i], r;

# Output file
param fn, symbolic := "00000" & 100000 * r[1];
param f, symbolic := "ct" & substr(fn, length(fn) - 4) & ".svg";

# Centers
param nc := 3;
set C := {1 .. nc};

# Towns
param nt := 50;
set T := {1 .. nt};
param xt{t in T} := r[1 + t];
param yt{t in T} := r[1 + nt + t];
param pt{t in T} := ceil(1000 * r[1 + 2 * nt + t]);

# Image size
param scale := 1000;

# Colors
# saturation [0, 255]
param sat := 192;
param hue{c in C} := 6 * (c - 1) / nc;
param red{c in C} :=
  if hue[c] <= 1 or hue[c] >= 5 then 255
  else (if hue[c] >=2 and hue[c] <= 4 then 255 - sat
  else (if hue[c] <=2 then 255 - sat + sat * (2-hue[c])
  else 255 - sat + sat * (hue[c]-4) ));
param green{c in C} :=
  if hue[c] >= 1 and hue[c] <= 3 then 255
  else (if hue[c] >= 4 then 255 - sat
  else (if hue[c] <=1 then 255 - sat + sat * hue[c]
  else 255 - sat + sat * (4-hue[c]) ));
param blue{c in C} :=
  if hue[c] >= 3 and hue[c] <= 5 then 255
  else (if hue[c] <=2 then 255 - sat
  else (if hue[c] <=3 then 255 - sat + sat * (hue[c]-2)
  else 255 - sat + sat * (6-hue[c]) ));

var x{T};
var y{T,T}, binary;

minimize obj : sum{c in T, t in T} y[c,t] * pt[t]
               * sqrt((xt[c] - xt[t])^2 + (yt[c] - yt[t])^2);

s.t. sumx : sum{c in T} x[c] = nc;
s.t. cxy{c in T, t in T} : y[c,t] <= x[c];
s.t. sumy{t in T} : sum{c in T} y[c,t] = 1;

solve;

for {c in T : x[c] > .5} {
  printf "Center %5.4f %5.4f\n", xt[c], yt[c];
  for {t in T : y[c,t] > .5} {
    printf "  Town %5.4f %5.4f (%5.0f)\n", xt[t], yt[t], pt[t];
  }
}

# Output the solution as scalable vector graphic

# header
printf "<?xml version=""1.0"" standalone=""no""?>\n" > f;
printf "<!DOCTYPE svg PUBLIC ""-//W3C//DTD SVG 1.1//EN"" \n" >> f;
printf """http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"";>\n" >> f;
printf "<svg width=""%d"" height=""%d"" version=""1.0"" \n",
  1.2 * scale, 1.2 * scale >> f;
printf "xmlns=""http://www.w3.org/2000/svg"";>\n" >> f;

# background
printf "<rect x=""0"" y=""0"" width=""%d"" height=""%d""" &
       " stroke=""none"" fill=""white""/>\n",
       1.2 * scale, 1.2 * scale>> f;

# border
printf "<rect x=""%d"" y=""%d"" width=""%d"" height=""%d""" &
       " stroke=""black"" stroke-width="".5"" fill=""white""/>\n",
       .1 * scale, .1 * scale, scale, scale >> f;

# circles for towns
for {t in T}
  printf {s in T, c in C : y[s,t] > .5
         && c = floor( .5 + sum{u in T : u <= s} x[u])}
         "<circle cx=""%f"" cy=""%f"" r=""%f"" stroke=""black"" " &
         "stroke-width=""1"" fill=""rgb(%d,%d,%d)""/>\n",
         (.1 + xt[t]) * scale, (.1 + yt[t]) * scale, .001 * sqrt(pt[t]) * scale,
         red[c], green[c] , blue[c] >> f;

# lines from towns to assigned centers
for {t in T, c in T : y[c,t] > .5}
  printf "<line x1=""%f"" y1=""%f"" x2=""%f"" y2=""%f""" &
         " style=""stroke:black;stroke-width:.5""/>\n",
         (.1 + xt[c]) * scale, (.1 + yt[c]) * scale,
         (.1 + xt[t]) * scale, (.1 + yt[t]) * scale >> f;

printf "</svg>\n" >> f;

printf {t in T} "%d -> %d\n", t,  pt[t];

end;
_______________________________________________
Bug-glpk mailing list
Bug-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-glpk

Reply via email to