wip: wdwr

This commit is contained in:
Krzysztof kuhy Rudnicki 2025-05-24 17:15:34 +02:00
parent b2e0efe2ee
commit 7839f5e555
35 changed files with 3976 additions and 788 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,18 @@
library(MASS) # mvrnorm()
mu <- c(9, 8, 7, 6); # expected values
sigma <- matrix(c(16,-2,-1,-3,-2,9,-4,-1,-1,-4,4,1,-3,-1,1,1), 4); # covariance matrix
nu <- 4; # degrees of freedom
n <- 10000; # number of scenarios
y <- t(t(mvrnorm(n, rep(0, length(mu)), sigma) * sqrt(nu / rchisq(n, nu))) + mu)
y <- y[y[,1]>=5,]
y <- y[y[,2]>=5,]
y <- y[y[,3]>=5,]
y <- y[y[,4]>=5,]
y <- y[y[,1]<=12,]
y <- y[y[,2]<=12,]
y <- y[y[,3]<=12,]
y <- y[y[,4]<=12,]
y <- y[1:1000,]
write.table(y, "scenarios.txt", sep=" ", eol="]\n[", row.names = FALSE, col.names=FALSE)

View File

@ -1,101 +0,0 @@
1 9.76311690917431 7.44135196072098 8.03080769529443 5.91262278007238
2 9.07190145652961 7.65985278468609 7.81364884192831 6.23563982924631
3 7.30586779807710 10.46831565453596 6.17860514098604 5.62316983488756
4 6.06518115356950 6.82247048657865 6.70439394704260 5.97874895226848
5 9.96818163646533 5.92140003729828 8.95647683901296 5.92957172143291
6 8.63538473131973 10.78452347210609 5.33874254384498 5.71561846706637
7 10.78779012148249 8.38993971621506 6.95119513298764 6.15728792196850
8 9.47255420321130 5.24835077098752 9.00959525502073 6.84285948274497
9 11.70926888809931 6.88871099028457 5.11505870322385 5.79141681866100
10 9.64287670970948 6.99374980548690 6.93364646280594 6.63473958816273
11 9.74417642254796 9.27515630991583 5.79381433859841 6.33880079977867
12 9.84932031583696 8.13369675991747 9.56326564416240 5.47164097940741
13 10.84180657665224 10.44173212698402 5.75796156005717 5.17082844375342
14 6.42546815399896 11.41163561400132 6.98718847694160 6.19182014565093
15 6.65343747480972 5.96491367509542 8.43404931472053 6.81514933519179
16 8.41058204665803 9.81581254769240 6.22528708513955 5.45922484668070
17 11.07466468261044 8.63685491994975 8.32064327582552 6.00532812753081
18 5.66007803163167 10.59708873150259 6.40117913595970 6.61684806440770
19 8.11097377453294 11.39989719535908 7.19879715792936 5.81867289870583
20 10.18544068664910 8.00246586468051 7.78414367307899 6.39143329793770
21 8.37417778106186 8.66901423662847 6.63403929668899 5.62622698569807
22 5.71457990443940 8.10569739243788 6.93419305872531 6.80590758355993
23 10.90693358349595 7.14177718551252 5.91236679453024 5.76232274027454
24 8.56484398609648 6.22762158139036 8.11135450623580 5.62211012798539
25 10.96985518991559 6.68271088560539 6.35539102212538 5.78652050813314
26 7.62410553749944 5.47750296350388 8.10356514381925 6.80674322754784
27 9.17309223739274 7.35075102155314 9.39642670821667 6.08239889804591
28 11.69619190069919 5.81353083316989 6.71866562538033 5.83460977495301
29 8.70647218713260 8.54952873879837 6.01177366865153 5.80247711748981
30 10.19801770668396 8.40706649849486 7.78289804784438 5.59571260544491
31 10.18823792131140 10.30622317535783 6.01007216642801 5.10730031536544
32 8.89257975110205 9.05255653431256 7.04806430135429 5.72317637496039
33 5.55169965201331 6.46995754365869 6.73752334538523 8.11225243525766
34 7.38041303280808 6.03431805441005 6.54177632374026 6.26813757511362
35 9.53600312164939 9.82870887668159 6.37298666598656 6.29512946813344
36 9.62084627760301 8.38877821804972 9.60663262550341 6.14199642708027
37 8.53371147142969 9.96028980160928 5.48461964749732 5.58700748945751
38 11.43883601853922 7.43794182684747 8.19299665196631 6.53522296979568
39 8.94531533108458 7.72770669562578 5.86612093622741 6.14249195015319
40 8.56163972282782 8.78267109358917 8.09620140224837 5.84072057986787
41 11.10581874422519 6.41650146716222 7.94880945361463 5.92181030289048
42 8.79709510873987 6.96326671422654 6.81226688976441 6.08034755239137
43 8.36353994459570 8.65114541354765 5.20396052285658 5.64107960525657
44 10.72631955621739 10.40656722635996 6.40361955726036 5.00588106915542
45 7.92377449146379 7.57337326655799 7.28981137176010 5.86937295871601
46 6.44898752031030 9.84455679079283 7.56743321024807 5.61123930238106
47 6.59142079861976 8.25490687097256 7.18086136653190 6.36808055523271
48 7.47434811723050 7.57534400043646 7.40042557613225 5.77766925416132
49 10.37922558429701 7.51649541751660 7.76007217627671 5.71165340725927
50 11.22955957441164 9.11763834237000 5.91162025004763 5.22909656515264
51 9.93626606347435 10.36742543458079 5.50414492338928 5.09387877291345
52 7.46956075160300 8.85209992891748 5.66758603774144 6.84847007082318
53 10.94818425908296 11.21395252595940 5.02869416739786 5.11896599852232
54 8.59930902434361 10.23728557433725 6.43052152866663 5.55350545843695
55 7.18223178367374 8.39628843993716 6.78631274384210 6.40826198282814
56 10.50650695671218 7.14292577351122 6.97271222602888 5.67492382261040
57 9.43266157452829 8.59707825452923 7.44232496740155 6.33561282221721
58 11.45217548324165 6.23806997675535 7.62498135882166 5.84032703043151
59 11.36423152742698 7.73909888403765 5.83487677225264 5.30267540082782
60 7.40126925234506 7.78983701703254 7.26783254076869 6.35068014074993
61 9.72974571794505 8.14279615037054 6.43258828020491 5.60905301174744
62 9.71958329969389 8.25791366588767 6.81451687462449 5.84590714949131
63 11.78371126050813 7.89117263445312 8.21483466145989 5.60333890798316
64 6.43302225580614 8.07865860135554 5.44469004007024 6.25543936966105
65 11.32524672426065 6.23439997420789 9.09984135190236 5.92522151214137
66 6.11523920037522 9.46855519033448 8.99139954457499 7.26985178631296
67 10.75986956011578 8.89269588219645 6.16473844457922 5.01830225504361
68 7.44261078629228 5.59781415962693 8.47555931122058 6.71081007297257
69 6.13170779809489 7.22655838486716 7.72995785629984 6.90573736168416
70 9.43027479825457 11.48319339258313 7.38708836041081 5.82689865183140
71 5.29171692626969 8.09437078836054 6.39563010794279 6.62912879511093
72 5.09893294234523 7.74584955672930 8.88018284918212 7.01212790493029
73 6.20578320069247 6.80617867447727 8.18103843191598 6.83958319443877
74 6.30258685494809 7.43138054831968 6.54063201012806 6.49666135387873
75 5.99078754250444 9.43740619647565 6.33367827869915 6.32580787466866
76 6.09773092392164 8.81422152842116 6.40425733606985 6.00528108344304
77 9.77514087744415 8.44932475630892 7.94420117667674 5.69585236521884
78 9.52359733569984 5.16479502907556 8.95174376770244 6.78672071859107
79 10.87512003895627 7.94035821507262 7.57773074672391 5.84630709056388
80 7.03228696898568 6.60340093608582 6.44468568443036 6.19149860676074
81 9.65992578732530 8.56527229906357 6.09872442954240 5.20440692261623
82 6.30983535489480 9.30561393417605 6.54859829930319 6.52106231396463
83 5.82137666724151 5.35827290855938 8.49191286969823 6.71371780289945
84 11.37494716877100 5.81213960381298 8.05853844161706 5.69806024484299
85 8.15267985634545 10.97224605386566 5.12446664947324 5.15795103491506
86 11.73086416587584 5.65124348656024 6.77078823854425 5.90352878508404
87 6.72960532844368 8.10521896869132 11.60799014602290 5.36046426627923
88 5.25102730028672 6.84949245261905 8.49279919952933 6.29483292662839
89 7.90449528978985 7.68346606583354 8.26036057308542 5.78474731288598
90 8.64103203208981 6.57844735571956 8.12280488732531 7.36240059132464
91 8.46655660484256 8.36699115351209 6.70419093097301 6.03113661709298
92 8.50248558815979 6.35585412244623 5.95963894605528 5.55306703237114
93 8.11096815930533 6.26958795090084 6.89847746026576 6.79423199764579
94 11.05399477820485 6.64260318869504 8.29929372751188 6.03566117360477
95 9.56800557695653 8.79263357467837 8.58788350167046 6.06774627920175
96 11.90421443450454 6.78214769706352 9.14111391052618 5.69759901474202
97 7.57911702883690 7.65716973584061 7.10622237301328 5.97627526735100
98 5.12673628692985 11.33334016193997 7.83474212553888 5.91330252723919
99 8.25983441252135 10.48661063799430 6.24054516528815 5.59523265380788
100 6.37952025900229 7.91998372816597 10.27190171308190 6.82383475873556

File diff suppressed because it is too large Load Diff

View File

@ -83,7 +83,7 @@ var storage {m in MONTHS, p in PRODUCTS} =
startingStorage[p] + sum {m2 in MONTHS: ord(m2) <= ord(m)} stored[m2, p]; startingStorage[p] + sum {m2 in MONTHS: ord(m2) <= ord(m)} stored[m2, p];
# Czas pracy narzedzi w danym miesi<EFBFBD>cu # Czas pracy narzedzi w danym miesi<EFBFBD>cu
var availableToolTime {t in TOOLS} = param availableToolTime {t in TOOLS} =
toolCount[t]*workHoursPerMonth; toolCount[t]*workHoursPerMonth;
var usedToolTime {m in MONTHS, t in TOOLS} = var usedToolTime {m in MONTHS, t in TOOLS} =
sum {p in PRODUCTS} produced[m,p]*toolTimePerUnit[t,p]; sum {p in PRODUCTS} produced[m,p]*toolTimePerUnit[t,p];

View File

@ -0,0 +1,101 @@
1 8.38640970547137 6.65206459832990 9.25340899939379 6.12210936270431
2 11.47174561833503 6.88159003640127 9.35722657222265 5.55953923603233
3 9.35744107333980 7.76050018607139 7.52248263888872 6.66070883253532
4 11.79462832089452 8.84904849612396 9.54663595886239 5.86135113067846
5 10.60333708223467 6.98611327352300 6.65687557067754 5.79843895114186
6 9.99227622682918 8.40138468818306 7.29067133904427 5.54635515729128
7 6.85386681919369 9.61502157413213 6.72665279049544 6.17021595187704
8 7.22585612837712 5.98643566600382 7.66228380776991 7.24401202983452
9 6.02120294740299 8.82748462758594 7.54667264901398 6.57719185154700
10 7.81781171233356 8.62835915477718 6.69726720537751 6.37457957246354
11 7.41500923685725 7.43485281864021 7.99043379062193 6.48482328886511
12 8.03069531050207 6.25690178404796 6.09093011988645 5.67595896061141
13 8.99392642494794 8.28778594511316 6.13973684710108 5.83600264194769
14 6.24245696460346 6.39232539486031 10.84375535721419 6.36547052046049
15 9.01023319607629 11.68740944894835 5.69616732483115 6.19037506643131
16 9.65669838710216 7.92589484304334 6.60602391314122 6.09008609139752
17 8.01383159007860 8.87589828833432 6.18744116565941 6.46341139819787
18 6.41168277703518 11.65174704526084 5.49260854548204 5.76322499127593
19 11.86071617832331 5.58525736824701 7.17211512854709 5.06082016193722
20 6.16988486968262 11.78961088001470 6.84648432837472 6.13006129755091
21 10.50307551032826 8.35431195348345 5.24642726566315 6.32424486960449
22 10.20706145000350 8.50839048007318 8.52712330116200 5.50646744442542
23 6.67901786642918 5.58637733835291 8.63780188181508 9.79688443744826
24 5.83844381890308 8.44063550564077 11.22412896684246 6.13391763721968
25 5.02725511916500 10.03499520640502 7.80231695276266 6.54152914586194
26 7.91401589299405 9.43722696656540 5.35523258143446 5.59975014714696
27 7.98004967073562 8.17745136624177 6.32951390326732 5.63731883625499
28 7.98467051395001 11.57545107974183 6.83123357010320 6.27858288227011
29 6.34805208941412 7.25317285835048 7.58786865181772 6.59504070525953
30 7.08336994763901 8.92594639512021 5.92035329828115 5.98401448315642
31 9.06644162062782 8.98837754871222 6.19341005514600 6.00305466546488
32 8.48729551927738 9.17269835317290 5.36419157013662 5.59485038217624
33 8.66648920402347 6.93300043060390 8.38462196805040 6.03127556347140
34 11.83627063752078 8.90221524236904 7.55194888744446 5.19695360377865
35 5.09649338467916 6.60060145222713 9.36785231110391 7.06996018633803
36 10.14756579853665 8.47018085753289 7.61659609253176 5.72166332448810
37 10.88873903559452 9.06214456213366 7.61335949698699 5.47398480579050
38 8.66435312312922 5.81229049155926 8.55479425754780 6.47574711245415
39 7.77804978645783 8.38793000591525 6.76635383352524 6.66232938066654
40 5.96600192497750 10.92926350511743 5.40151489712682 6.59120257044565
41 5.59690630619186 9.91317237753740 5.07563394246842 5.64387291599931
42 6.74012145870261 9.04595375599635 9.06481634407877 6.91232814922274
43 6.03915855388625 7.71614169885073 8.28544678648988 6.36744151062543
44 10.68083156161457 5.35912754560182 8.45534166067838 5.98217635572583
45 7.86523236391356 10.61707772747047 6.51071080752149 5.80556023866074
46 10.59881295279743 8.70314595132368 6.93415201276310 6.13852414071696
47 7.06365029787463 9.07856555481288 7.53503836286952 6.52970502515429
48 9.66573092179861 9.51712670813631 7.56413274760444 5.43826427090938
49 10.55908768529984 6.53006759211473 5.23363222181494 6.69026800097002
50 8.37783980089781 11.34206626209622 8.52375903867853 5.00311515741636
51 8.60678360655386 6.63301566152829 7.46356953969518 6.93623756199315
52 8.10058227419441 9.67607064120733 5.07417893078212 5.92823677000808
53 11.86328450036617 8.18571575346197 7.46703693228165 5.34308211339548
54 10.91964716957687 6.32937436794021 6.97739368373887 5.31821065018457
55 10.69583569884245 6.60565970760443 8.29033521579438 5.88004180161757
56 7.99079208388755 10.25400562851183 8.83683368944479 5.80492792288328
57 6.23273822505752 9.36429957708976 6.87922116365394 6.78874486297183
58 5.88386384170986 8.59117274674032 7.72631503884364 6.09387234225471
59 5.40661550602730 7.28181911598468 6.79417546649187 6.21515229248254
60 8.26547024374017 8.25847144246441 7.78496725231724 5.98659129929383
61 7.19259795212615 7.40286958820430 5.78243225576006 6.64588580256380
62 6.21344556592916 8.87805667457996 8.92385174527858 6.65881574936494
63 8.18272681675361 7.51144843783451 7.00028011235120 6.37742187397881
64 9.33166132930610 7.14827316983078 8.19261176835498 5.48345528030911
65 5.67795830603908 5.93268424509028 7.52055184914644 6.20004184094185
66 6.61224775512171 11.07008594498179 5.59809093557888 5.76022429445898
67 9.18526157242251 10.33093428932847 6.20248135198736 5.69069389194741
68 10.35460673197286 6.31819949708236 7.26007034644003 5.98527710153962
69 11.41775692269698 5.38885381828595 8.60474576946179 6.01560597252629
70 7.51574587595340 10.20758422859382 7.95010579784885 5.84405786774390
71 6.67147508169887 9.99676503954841 7.88196193877892 6.36471569850198
72 8.81493026032693 9.55217236694784 6.88640408825999 5.85335196560115
73 10.34100833805265 6.19309416422451 6.54276954947828 5.85229534744097
74 8.21225622897127 9.19420261352311 5.50976361832561 6.50474402181068
75 5.21712163609094 8.99345997972815 8.90935395647960 6.95465457249704
76 7.19263314339272 7.75122339336118 6.55400244396229 6.17420524444947
77 7.47042045387234 8.57992190152031 8.81054618695823 5.89474805758430
78 9.40144483135410 8.12162393352070 6.87945218422346 5.32293412183378
79 10.43568612418940 7.56903040482999 8.11467631685016 6.15185553754121
80 6.89788205797093 10.49090726456854 5.60573364312945 5.90016825245131
81 8.40187075462482 6.63200111204084 8.80002231974220 6.52807896556919
82 11.09530562833293 7.17846988472875 6.17825717640593 5.15314774961649
83 5.30169200307174 10.00677222950092 7.02250570949688 6.58898550622257
84 7.12941565748076 10.79383482977027 6.94724538603335 5.63368869104514
85 10.51315181327761 7.97803822244174 6.23221470948432 5.12188223474996
86 9.60719281025592 8.06562427926403 6.72890591184924 5.37227501894104
87 7.36932186905072 6.38892407121165 9.39023244605481 6.77826088317697
88 6.18127154860016 9.06836518560135 7.99958754457252 6.45060931728576
89 6.57666298108503 10.99205738028462 7.73908984591217 5.72724756133371
90 6.32937368664344 9.62668784336028 5.84276743584105 6.21380406480346
91 6.05330532218822 8.22361956350043 6.47166304886069 5.62673428466093
92 9.79501831949422 6.36857961118238 7.54098230329907 6.39432823108518
93 9.91808445954114 9.13469023862793 7.98132008822906 5.00940577737874
94 10.68937894068579 9.95804209382347 5.31316321040921 5.01886724569659
95 10.93776822739210 9.06480582511433 5.07546190641304 5.32852345019194
96 8.91747138855106 8.89253508752477 7.04055074088613 5.94737846911610
97 9.44216658550990 5.79280042118289 8.05260652410974 6.70053612755559
98 8.06891980451287 11.30085871569205 6.46414921073781 5.58982387487253
99 7.33190851491788 9.58145942349845 5.25495825638714 5.61862630847008
100 9.66308325670658 10.43672680962318 5.88883182273180 5.27629211394324

View File

@ -0,0 +1,53 @@
i;minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4
1;-600;-600;0;0;0;0;0;0;0;0;0;0;0;0;0;50;50;50;50;50;50;50;50;50;50;50;50
2;-67.59000000000003;-67.19889931518434;9.26551;1;0;0;0;0;1;0;0;10;8;6;34;40;50;44;16;40;42;44;16;50;50;50;50
3;464.82;465.107;19.0047;0;0;0;1;0;0;0;0;23;20;14;64;27;50;36;0;27;30;36;0;50;50;50;50
4;997.23;997.357;29.4848;0;0;0;43;0;0;0;0;36;30;23;57;15;50;27;0;14;20;27;0;50;50;50;50
5;1529.64;1530.25;39.9669;0;0;0;85;0;0;0;0;47;42;31;52;3;50;19;0;3;8;19;0;50;50;50;50
6;2062.05;2062.08;50.8849;3;0;0;120;7;2;0;0;50;51;42;51;0;50;8;0;0;0;8;0;50;50;50;50
7;2594.46;2594.52;62.1001;0;0;0;162;24;13;0;0;50;51;49;50;0;50;1;0;0;0;1;0;50;50;50;50
8;3126.87;3127.18;73.5215;36;0;2;246;2;24;0;0;50;51;50;73;0;50;0;0;0;0;0;0;50;50;50;50
9;3659.28;3659.63;85.1089;44;0;8;248;8;32;1;0;50;53;50;116;0;50;0;0;0;0;0;0;50;50;50;50
10;4191.69;4192.2;96.6978;15;0;17;244;51;0;0;0;50;97;50;160;0;50;0;0;0;0;0;0;50;50;50;50
11;4724.1;4724.19;108.275;79;0;0;77;0;57;24;0;50;52;52;374;0;50;0;0;0;0;0;0;50;50;50;50
12;5256.51;5256.76;119.859;0;0;0;188;93;71;34;0;50;50;50;239;0;50;0;0;0;0;0;0;50;50;50;50
13;5788.92;5789.33;131.455;64;0;42;109;43;81;0;0;50;52;50;436;0;50;0;0;0;0;0;0;50;50;50;50
14;6321.33;6321.9;143.053;2;0;49;192;119;95;1;0;50;50;50;365;0;50;0;0;0;0;0;0;50;50;50;50
15;6853.74;6853.79;154.626;3;0;57;187;132;101;1;0;50;55;50;442;0;50;0;0;0;0;0;0;50;50;50;50
16;7386.15;7386.47;166.79;3;0;114;250;147;120;0;0;50;56;51;450;0;50;0;0;0;0;0;0;50;50;50;50
17;7918.56;7918.79;180.122;165;0;109;190;0;145;2;0;50;53;51;370;0;50;0;0;0;0;0;0;50;50;50;50
18;8450.97;8450.98;194.31;95;0;117;250;85;172;50;0;50;50;56;450;0;50;0;0;0;0;0;0;50;50;50;50
19;8983.38;8983.46;209.32;201;0;146;190;1;191;51;0;50;52;54;450;0;50;0;0;0;0;0;0;50;50;50;50
20;9515.79;9515.8;225.023;288;0;148;250;1;212;81;0;50;50;50;450;0;50;0;0;0;0;0;0;50;50;50;50
21;10048.2;10048.3;241.223;1;0;150;190;236;302;0;0;50;51;160;370;0;50;0;0;0;0;0;0;50;50;50;50
22;10580.6;10580.7;257.65;257;0;109;250;1;0;0;0;50;304;184;450;0;50;0;0;0;0;0;0;50;50;50;50
23;11113;11113.1;274.336;1;0;149;250;274;349;162;0;50;56;50;450;0;50;0;0;0;0;0;0;50;50;50;50
24;11645.4;11645.6;291.421;272;0;150;190;85;1;188;0;50;346;50;450;0;50;0;0;0;0;0;0;50;50;50;50
25;12177.8;12177.9;308.783;270;0;111;190;36;270;0;0;50;99;301;450;0;50;0;0;0;0;0;0;50;50;50;50
26;12710.2;12710.4;326.256;0;0;0;250;324;271;409;0;50;183;80;450;0;50;0;0;0;0;0;0;50;50;50;50
27;13242.7;13242.9;343.752;270;0;148;190;135;0;275;0;50;411;52;450;0;50;0;0;0;0;0;0;50;50;50;50
28;13775.1;13775.2;361.295;0;0;3;250;362;350;0;0;50;160;560;370;0;50;0;0;0;0;0;0;50;50;50;50
29;14307.5;14307.7;378.849;271;0;146;190;176;11;327;0;50;439;52;450;0;50;0;0;0;0;0;0;50;50;50;50
30;14839.9;14840;396.41;347;0;110;190;131;270;482;0;50;266;51;370;0;50;0;0;0;0;0;0;50;50;50;50
31;15372.3;15372.7;414.073;0;0;5;190;417;349;5;0;50;225;530;450;0;50;0;0;0;0;0;0;50;50;50;50
32;15904.7;15904.9;431.837;270;0;110;190;162;270;400;0;50;246;60;370;0;50;0;0;0;0;0;0;50;50;50;50
33;16437.1;16437.2;449.621;270;0;0;190;239;350;72;0;50;269;649;450;0;50;0;0;0;0;0;0;50;50;50;50
34;16969.5;16969.6;467.424;350;0;5;250;190;1;399;0;50;560;227;370;0;50;0;0;0;0;0;0;50;50;50;50
35;17501.9;17502;485.233;349;0;1;250;204;23;129;0;50;691;530;370;0;50;0;0;0;0;0;0;50;50;50;50
36;18034.3;18034.4;503.08;0;0;148;250;610;0;51;0;50;748;530;450;0;50;0;0;0;0;0;0;50;50;50;50
37;18566.8;18566.9;520.949;1;0;150;190;502;0;401;0;50;776;288;450;0;50;0;0;0;0;0;0;50;50;50;50
38;19099.2;19099.2;538.82;1;0;1;250;520;1;499;0;50;803;344;450;0;50;0;0;0;0;0;0;50;50;50;50
39;19631.6;19631.6;556.705;1;0;150;190;672;349;500;0;50;406;261;370;0;50;0;0;0;0;0;0;50;50;50;50
40;20164;20164;574.59;1;0;36;250;693;9;497;0;50;690;363;370;0;50;0;0;0;0;0;0;50;50;50;50
41;20696.4;20696.4;592.504;347;0;2;190;305;34;290;0;50;850;648;450;0;50;0;0;0;0;0;0;50;50;50;50
42;21228.8;21228.8;610.459;271;0;1;190;383;59;499;0;50;850;444;370;0;50;0;0;0;0;0;0;50;50;50;50
43;21761.2;21761.3;628.438;350;0;150;190;338;349;500;0;50;500;362;450;0;50;0;0;0;0;0;0;50;50;50;50
44;22293.6;22293.7;646.432;348;0;148;190;358;296;401;0;50;690;471;450;0;50;0;0;0;0;0;0;50;50;50;50
45;22826;22826.1;664.435;350;0;0;250;374;347;400;0;50;543;527;450;0;50;0;0;0;0;0;0;50;50;50;50
46;23358.4;23358.5;682.428;270;0;149;190;570;145;313;0;50;848;530;450;0;50;0;0;0;0;0;0;50;50;50;50
47;23890.9;23891;700.439;271;0;150;250;591;270;339;0;50;719;650;450;0;50;0;0;0;0;0;0;50;50;50;50
48;24423.3;24423.3;718.467;323;0;150;250;561;258;366;0;50;761;650;370;0;50;0;0;0;0;0;0;50;50;50;50
49;24955.7;24955.8;736.497;350;0;150;250;446;272;498;0;50;850;524;450;0;50;0;0;0;0;0;0;50;50;50;50
50;25488.1;25488.3;755.133;185;0;110;190;700;307;400;0;50;848;530;450;0;50;0;0;0;0;0;0;50;50;50;50
51;26020.5;26020.6;774.872;221;0;150;250;696;263;400;0;50;690;530;450;0;50;0;0;0;0;0;0;50;50;50;50
52;26552.9;26553.9;796.113;270;0;110;190;700;270;500;0;50;690;650;450;0;50;0;0;0;0;0;0;50;50;50;50

View File

@ -0,0 +1,99 @@
minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4
10580.7;10580.8;257.666;336;0;149;190;0;1;134;0;50;301;51;370;0;50;0;0;0;0;0;0;50;50;50;50
avgProfit:
10431.3
10701.3
10289.3
10069.9
10850.6
10484.8
10350.1
10326.3
10453.9
10467.4
10049.4
10603.5
11024.6
11070.8
10234.5
10268
10798.3
9880.5
10836.7
11107.6
10320.1
11855.6
9764.31
11123.6
10475
11498.3
10815
10594.3
9900.24
10777.9
minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4
20164;20164;574.598;346;0;0;250;289;9;401;0;50;689;583;370;0;50;0;0;0;0;0;0;50;50;50;50
avgProfit:
20154.7
20455.9
20073
18945.5
20449.9
19784.6
19458
19834.6
20212.1
20071.6
18646.7
20721.6
20994.7
21696
19350
19462
20773.9
18405.2
20631.2
20984
18959.4
22145.5
18483.8
21647.1
20124.6
22142.5
20811.8
20397.9
18593.3
20510
minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4
26553.9;26553.9;796.113;270;0;150;190;700;270;400;0;50;850;530;370;0;50;0;0;0;0;0;0;50;50;50;50
avgProfit:
26799.8
27035.6
26275.1
24812.5
26806
25731.5
25709.3
26040
26796.5
26717.3
24063.1
27351.1
27509.7
28774
25328.3
25695.7
27530.2
24353
26997.2
27534.5
24894.9
28956
24512.9
28704.1
26404.1
29275.3
27718.4
27043.9
24179.5
27068.2

View File

@ -0,0 +1,99 @@
minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4
25488.3;25488.3;755.133;268;0;110;190;477;270;500;0;50;654;530;370;0;50;0;0;0;0;0;0;50;50;50;50
avgProfit:
25609.4
25873.7
25413.2
23878.9
25764.6
24872.7
24604.1
25059.6
25695.3
25506.2
23307.3
26302.3
26478.7
27585.3
24356.9
24579.8
26361.5
23240.8
26012.6
26449.8
23820.7
27877.6
23386.8
27485.6
25413.4
28068.6
26454.6
25893.9
23353.4
25942
minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4
26020.6;26020.8;774.88;218;0;110;190;700;266;400;0;50;846;530;450;0;50;0;0;0;0;0;0;50;50;50;50
avgProfit:
26186
26404.1
25894.4
24381.3
26283.5
25336.7
25180.9
25542.5
26294.8
26116.1
23699.7
26835.4
26989.9
28161.5
24813.8
25087.9
26951.7
23788.7
26512.6
26979.8
24345.2
28472.6
23907.3
28056.3
25890.8
28668.9
27075.7
26478.2
23787.7
26501.1
minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4
26553.9;26553.9;796.113;270;0;150;190;700;270;400;0;50;850;530;370;0;50;0;0;0;0;0;0;50;50;50;50
avgProfit:
26799.8
27035.6
26275.1
24812.5
26806
25731.5
25709.3
26040
26796.5
26717.3
24063.1
27351.1
27509.7
28774
25328.3
25695.7
27530.2
24353
26997.2
27534.5
24894.9
28956
24512.9
28704.1
26404.1
29275.3
27718.4
27043.9
24179.5
27068.2

View File

@ -0,0 +1,99 @@
minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4
10580.7;10580.8;257.666;336;0;149;190;0;1;134;0;50;301;51;370;0;50;0;0;0;0;0;0;50;50;50;50
Risk:
184.458
195.09
207.678
278.26
220.823
181.042
195.281
199.255
182.194
181.295
285.773
185.306
272.997
288.405
223.407
213.341
208.693
354.01
217.093
301.892
200.499
637.424
408.232
308.314
181.042
470.693
212.039
184.694
345.455
205.291
minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4
20164;20164;574.598;346;0;0;250;289;9;401;0;50;689;583;370;0;50;0;0;0;0;0;0;50;50;50;50
Risk:
403.784
414.043
408.225
664.379
413.447
448.303
513.763
439.966
403.784
408.366
773.926
459.531
537.056
795.835
542.569
512.817
471.741
879.425
441.46
533.521
659.742
990.73
842.758
776.278
404.787
989.35
481.833
409.978
795.275
421.261
minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4
26553.9;26553.9;796.113;270;0;150;190;700;270;400;0;50;850;530;370;0;50;0;0;0;0;0;0;50;50;50;50
Risk:
559.839
576.633
596.264
942.092
560.045
679.026
683.47
627.607
559.839
562.478
1245.41
638.37
675.366
1132.8
784.609
686.634
680.842
1115.92
572.793
682.114
914.647
1211.67
1051.95
1104.87
583.36
1360.71
743.425
577.734
1191.09
581.791

View File

@ -0,0 +1,99 @@
minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4
25488.3;25488.3;755.133;268;0;110;190;477;270;500;0;50;654;530;370;0;50;0;0;0;0;0;0;50;50;50;50
Risk:
530.713
540.297
540.363
880.892
533.022
618.647
672.371
587.509
530.713
534.152
1092.72
618.438
665.276
1074.34
737.478
678.05
632.259
1123.76
560.502
655.794
900.277
1201.02
1059.4
1034.46
540.34
1290.13
657.239
542.315
1072.76
548.737
minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4
26020.6;26020.8;774.88;218;0;110;190;700;266;400;0;50;846;530;450;0;50;0;0;0;0;0;0;50;50;50;50
Risk:
545.117
552.781
562.228
899.047
545.117
643.324
674.499
609.029
545.491
547.446
1160.56
629.71
667.372
1097.62
769.274
696.182
656.859
1119.07
565.151
664.345
911.073
1232.42
1071.62
1055.54
562.586
1324.02
695.983
560.188
1119.5
563.245
minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4
26553.9;26553.9;796.113;270;0;150;190;700;270;400;0;50;850;530;370;0;50;0;0;0;0;0;0;50;50;50;50
Risk:
559.839
576.633
596.264
942.092
560.045
679.026
683.47
627.607
559.839
562.478
1245.41
638.37
675.366
1132.8
784.609
686.634
680.842
1115.92
572.793
682.114
914.647
1211.67
1051.95
1104.87
583.36
1360.71
743.425
577.734
1191.09
581.791

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,117 @@
/*********************************************
* OPL 12.5.1.0 Model
* Author: Mateusz Percinski
* Creation Date: May 23, 2017 at 6:34:43 PM
*********************************************/
/***********PARAMETRY************************/
//Paramatry zostaladniej opisane w pliku .dat oraz raporcie
// Parametry liczbowe
int nMachType = ...;
int nMonth = ...;
int nProdType = ...;
int nHours = ...;
int nScenarios = ...;
// Utworzenie wektorow indeksujacych
{int} machines = asSet(1..nMachType);
{int} months = asSet(1..nMonth);
{int} products = asSet(1..nProdType);
{int} scenarios = asSet(1..nScenarios);
//Parametry produkcji i sprzedazy
int machineCount[machines] = ...;
float prodTime[machines][products] = ...;
int maxInMonth[months][products] = ...;
//Parametry magazynowania
int storageMax[products] = ...;
int storageCost = ...;
int storageStart[products] = ...;
//Parametry do generowania scenariusze (nieuzywane w modelu CPLEX)
int mu[products] = ...;
int sigma[products][products] = ...;
//Macierz scenariuszy dochodow ze sprzedazy: typ produkty (kolumna) - scenariusz (wiersz)
float sellProfit[scenarios][products] = ...;
/*********** ZMIENNE DECYZYJNE ********************************************/
dvar int produce[months][products]; // Liczba wyprodukowanych
dvar int sell[months][products]; // Liczba sprzedanych
dvar int stock[months][products]; // Liczba w magazynie
// Czas wykorzystany na danym typie maszyna na dany typ produktu
dvar float workTime[months][machines][products];
// Zmienna binarna - czy sprzedaz danego typu produktu przekaroczyla 80 procent pojemnosci rynku
dvar boolean if80prec[months][products];
// Zmienna - ile pieniedzy nalezy odjac od dochodow z poszczegolnych produkow
// w poszczegolnych miesiacach ze wzgledu na przekroczenie 80% pojmnosci rynku
dvar float lowerProfit[scenarios][months][products];
/************ KRYTERIA OCENY *********************************************/
// zysk policzony dla poszczegolnych scenariuszy
dexpr float profit[i in scenarios] = sum(m in months, p in products)
(sell[m][p]*sellProfit[i][p]-lowerProfit[i][m][p]- stock[m][p]*storageCost);
// wartosc oczekiwana zysku policzona jako srednia
dexpr float avgProfit = sum(i in scenarios)(profit[i])/nScenarios;
// funkcja celu
maximize avgProfit;
// ************** OGRANICZENIA ******************************************/
subject to {
// Zmienne decyzyjne nie mniejsze niz zero
forall(i in scenarios, m in months, mc in machines, p in products) {
workTime[m][mc][p] >= 0;
produce[m][p] >= 0;
sell[m][p] >= 0;
stock[m][p] >= 0;
lowerProfit[i][m][p] >= 0;
}
// Ogranicznie czasu produkcji maszyn w miesiacu
forall(m in months, mc in machines) {
sum(p in products) (workTime[m][mc][p]) <= (machineCount[mc]*nHours);
}
// Ograniczenie definiujace wykorzystany czas pracy maszyn
forall(m in months, p in products, mc in machines) {
workTime[m][mc][p] == produce[m][p]*prodTime[mc][p];
}
// Ogranicznie maksymalnej pojemnosci rynku
forall(m in months, p in products) {
sell[m][p] <= maxInMonth[m][p];
}
// Ogranicznie ustawiajace zmienna binarna po przekroczeniu 80 procent pojemnosci rynku
forall(m in months, p in products) {
sell[m][p] <= 0.8*maxInMonth[m][p] + 1000000 * if80prec[m][p];
sell[m][p] >= 0.8*maxInMonth[m][p] * if80prec[m][p];
}
// Ograniczenia linearyzujace wplyw zmiennej binarnej na funkcje celu
forall (i in scenarios,m in months, p in products) {
lowerProfit[i][m][p] <= 1000000 * if80prec[m][p];
lowerProfit[i][m][p] <= 0.2 * sell[m][p]*sellProfit[i][p];
0.2 * sell[m][p]*sellProfit[i][p] - lowerProfit[i][m][p] + 1000000 * if80prec[m][p] <= 1000000;
}
// Ograniczenie sprzedazy oraz definicja ilosci towaru pozostajacej w magazynie
forall(m in months, p in products) {
if(m == 1) { //pierwszy miesiac
sell[m][p] <= produce[m][p]+storageStart[p];
stock[m][p]==(produce[m][p] + storageStart[p])-sell[m][p];
}else { // kolejne miesiace
sell[m][p] <= produce[m][p] + stock[m-1][p];
stock[m][p]==(produce[m][p] + stock[m-1][p])-sell[m][p];
}
}
// Ogranicznie maksymalnej ilosci magazynowanych produktow oraz
// wymaganej ilosc pozostalej w magazynie na na koniec symulacji
forall(m in months, p in products) {
stock[m][p] <= storageMax[p];
if(m == 3) {
stock[m][p] >= 50;
}
}
}

View File

@ -0,0 +1,77 @@
/*********************************************
* OPL 12.5.1.0 Data
* Author: Mateusz Percinski
* Creation Date: May 24, 2017 at 10:09:32 PM
*********************************************/
/***************PARAMETRY********************/
nMachType = 5; //ilosc typow maszun
nMonth = 3; //ilosc symulowanych miesiecy
nProdType = 4; //ilosc typow produktow
nHours = 384; //liczba godzin roboczych w miesiacu 2*8*24=384
nScenarios = 30; //ilosc scenariuszy w symulacji
// Ilosc maszyn poszczegolnych typow
machineCount = [4 2 3 1 1];
// Koszty wykorzystania typow maszyn (wiersze)
//w wytwarzaniu poszczegolnych typow produktow (kolumny)
prodTime = [[ 0.4 0.6 0 0]
[ 0.2 0.1 0 0.6]
[ 0.1 0 0.7 0]
[ 0.06 0.04 0 0.05]
[ 0 0.05 0.02 0]];
// Pojemnosc rynku - typ produktu(kolumny) w miesiacu(wiersz)
maxInMonth = [[ 400 0 200 300]
[ 700 400 500 0]
[ 0 800 600 400]];
// Magazyn
storageMax = [200 200 200 200]; //maksymalna pojemnosc dla typow produktow
storageCost = 1; //koszt magazynowania zl/sztuka/miesiac
storageStart = [50 50 50 50]; //poczatkowa ilosc w magazynach
/************************* SCENARIOS *************************/
// expected values (used only in t-student.R script)
mu = [9 8 7 6];
// covariance (used only in t-student.R script)
sigma = [[ 16 -2 -1 -3]
[ -2 9 -4 -1]
[ -1 -4 4 1]
[ -3 -1 1 1]];
// scenarios (generated by t-student.R script)
sellProfit = [[10.7349277395552 7.72178696852481 6.91313555665251 5.3580692014906]
[11.4029325398093 5.35289018472828 8.44560627918346 5.94437008867837]
[5.9511305436333 9.89072813219028 8.15019579921374 5.92283032635847]
[6.98653442934503 9.43820696539249 6.08947859890014 6.28684001183198]
[8.97632928181137 7.73492022936159 7.69443003815675 6.65911599366542]
[6.3718935550723 8.80949463923562 7.79090422832384 6.81174804312265]
[8.78246371277526 9.96223625339419 5.07839427301482 6.04541265888823]
[8.61200211939238 6.9004774184148 8.38569802461679 6.01047636955988]
[8.04259291408092 11.6005401405856 5.51825529023523 5.52418355625024]
[10.2568641176451 9.42484863719592 5.61768337124079 5.44832826311492]
[6.06345343273768 6.67810135189213 8.25425855603235 7.11046580533962]
[8.74262951486885 8.49193741618487 8.26781448661321 5.63718569432722]
[8.96019482191789 7.48206038212727 8.64020735666332 6.61806454609454]
[10.7060656286305 7.74073441264031 8.70806653294011 5.56273592101066]
[9.14849596786536 5.38206186993592 8.48324089408178 6.31836607658665]
[10.9884988766065 5.05294389126629 7.81201862380442 5.89377116896792]
[9.85025400030063 9.20603928762331 6.76845266520436 5.77678827669309]
[9.76699335636152 7.83363407758539 5.01347383618885 5.84594312150737]
[8.22098260831502 7.93964476990494 8.36747212617667 6.58666346744554]
[9.64940023484707 7.34646951028725 8.15389801271092 6.71485257935324]
[9.56697193644308 7.24791547600423 5.82061898605385 6.6329880618574]
[7.64858383380397 11.8956850930214 6.57566578417732 7.52978318768004]
[10.8667504186116 5.6239431792075 6.49095275149094 5.44747350145729]
[11.5459204391574 6.5874000517338 8.91791399632966 5.70569902009294]
[9.00453124705504 6.25952067886102 8.93937357845343 6.11437998871486]
[10.4316051568988 8.89165309349428 8.00183466339121 6.22792967489147]
[11.1403947310683 8.80153331584519 6.36710780356291 5.52424084189948]
[9.5907049066395 9.30053224873728 6.5052199777433 5.64308372528693]
[6.47305423724122 7.66508680006143 7.42589600717661 6.52108273658984]
[9.76726531281191 8.22194904261638 7.1081746124431 6.13833241033153]
];

View File

@ -0,0 +1,128 @@
/*********************************************
* OPL 12.5.1.0 Model
* Author: mateu
* Creation Date: May 24, 2017 at 10:08:31 PM
*********************************************/
/***********PARAMETRY************************/
//Paramatry zostaladniej opisane w pliku .dat oraz raporcie
// Parametry liczbowe
int nMachType = ...;
int nMonth = ...;
int nProdType = ...;
int nHours = ...;
int nScenarios = ...;
// Utworzenie wektorow indeksujacych
{int} machines = asSet(1..nMachType);
{int} months = asSet(1..nMonth);
{int} products = asSet(1..nProdType);
{int} scenarios = asSet(1..nScenarios);
//Parametry produkcji i sprzedazy
int machineCount[machines] = ...;
float prodTime[machines][products] = ...;
int maxInMonth[months][products] = ...;
//Parametry magazynowania
int storageMax[products] = ...;
int storageCost = ...;
int storageStart[products] = ...;
//Parametry do generowania scenariusze (nieuzywane w modelu CPLEX)
int mu[products] = ...;
int sigma[products][products] = ...;
//Macierz scenariuszy dochodow ze sprzedazy: typ produkty (kolumna) - scenariusz (wiersz)
float sellProfit[scenarios][products] = ...;
/*********** ZMIENNE DECYZYJNE ********************************************/
dvar int produce[months][products]; // Liczba wyprodukowanych
dvar int sell[months][products]; // Liczba sprzedanych
dvar int stock[months][products]; // Liczba w magazynie
// Czas wykorzystany na danym typie maszyna na dany typ produktu
dvar float workTime[months][machines][products];
// Zmienna binarna - czy sprzedaz danego typu produktu przekaroczyla 80 procent pojemnosci rynku
dvar boolean if80prec[months][products];
// Zmienna - ile pieniedzy nalezy odjac od dochodow z poszczegolnych produkow
// w poszczegolnych miesiacach ze wzgledu na przekroczenie 80% pojmnosci rynku
dvar float lowerProfit[scenarios][months][products];
/************ KRYTERIA OCENY *********************************************/
// ZYSK policzony dla poszczegolnych scenariuszy
dexpr float profit[i in scenarios] = sum(m in months, p in products)
(sell[m][p]*sellProfit[i][p]-lowerProfit[i][m][p]- stock[m][p]*storageCost);
// wartosc oczekiwana zysku policzona jako srednia
dexpr float avgProfit = sum(i in scenarios)(profit[i])/nScenarios;
// RYZYKO zdefiniowane srednia roznica Giniego
dexpr float giniRisk = sum (t1 in scenarios, t2 in scenarios ) (
0.5 * abs(profit[t1] - profit[t2]) * 1/nScenarios * 1/nScenarios
);
// funkcja celu
//minimize giniRisk;
maximize avgProfit;
// ************** OGRANICZENIA ******************************************/
subject to {
// Zmienne decyzyjne nie mniejsze niz zero
forall(i in scenarios, m in months, mc in machines, p in products) {
workTime[m][mc][p] >= 0;
produce[m][p] >= 0;
sell[m][p] >= 0;
stock[m][p] >= 0;
lowerProfit[i][m][p] >= 0;
}
// Ogranicznie czasu produkcji maszyn w miesiacu
forall(m in months, mc in machines) {
sum(p in products) (workTime[m][mc][p]) <= (machineCount[mc]*nHours);
}
// Ograniczenie definiujace wykorzystany czas pracy maszyn
forall(m in months, p in products, mc in machines) {
workTime[m][mc][p] == produce[m][p]*prodTime[mc][p];
}
// Ogranicznie maksymalnej pojemnosci rynku
forall(m in months, p in products) {
sell[m][p] <= maxInMonth[m][p];
}
// Ogranicznie ustawiajace zmienna binarna po przekroczeniu 80 procent pojemnosci rynku
forall(m in months, p in products) {
sell[m][p] <= 0.8*maxInMonth[m][p] + 1000000 * if80prec[m][p];
sell[m][p] >= 0.8*maxInMonth[m][p] * if80prec[m][p];
}
// Ograniczenia linearyzujace wplyw zmiennej binarnej na funkcje celu
forall (i in scenarios,m in months, p in products) {
lowerProfit[i][m][p] <= 1000000 * if80prec[m][p];
lowerProfit[i][m][p] <= 0.2 * sell[m][p]*sellProfit[i][p];
0.2 * sell[m][p]*sellProfit[i][p] - lowerProfit[i][m][p] + 1000000 * if80prec[m][p] <= 1000000;
}
// Ograniczenie sprzedazy oraz definicja ilosci towaru pozostajacej w magazynie
forall(m in months, p in products) {
if(m == 1) { //pierwszy miesiac
sell[m][p] <= produce[m][p]+storageStart[p];
stock[m][p]==(produce[m][p] + storageStart[p])-sell[m][p];
}else { // kolejne miesiace
sell[m][p] <= produce[m][p] + stock[m-1][p];
stock[m][p]==(produce[m][p] + stock[m-1][p])-sell[m][p];
}
}
// Ogranicznie maksymalnej ilosci magazynowanych produktow oraz
// wymaganej ilosc pozostalej w magazynie na na koniec symulacji
forall(m in months, p in products) {
stock[m][p] <= storageMax[p];
if(m == 3) {
stock[m][p] >= 50;
}
}
}
execute {
cplex.tilim = 600;
writeln("avgProfit: ",avgProfit,", giniRisk: ",giniRisk);
}

View File

@ -0,0 +1,80 @@
/*********************************************
* OPL 12.5.1.0 Data
* Author: Mateusz Percinski
* Creation Date: May 24, 2017 at 10:09:32 PM
*********************************************/
/***************PARAMETRY********************/
nMachType = 5; //ilosc typow maszun
nMonth = 3; //ilosc symulowanych miesiecy
nProdType = 4; //ilosc typow produktow
nHours = 384; //liczba godzin roboczych w miesiacu 2*8*24=384
nScenarios = 30; //ilosc scenariuszy w symulacji
// Ilosc maszyn poszczegolnych typow
machineCount = [4 2 3 1 1];
// Koszty wykorzystania typow maszyn (wiersze)
//w wytwarzaniu poszczegolnych typow produktow (kolumny)
prodTime = [[ 0.4 0.6 0 0]
[ 0.2 0.1 0 0.6]
[ 0.1 0 0.7 0]
[ 0.06 0.04 0 0.05]
[ 0 0.05 0.02 0]];
// Pojemnosc rynku - typ produktu(kolumny) w miesiacu(wiersz)
maxInMonth = [[ 400 0 200 300]
[ 700 400 500 0]
[ 0 800 600 400]];
// Magazyn
storageMax = [200 200 200 200]; //maksymalna pojemnosc dla typow produktow
storageCost = 1; //koszt magazynowania zl/sztuka/miesiac
storageStart = [50 50 50 50]; //poczatkowa ilosc w magazynach
/******************* METODA: WYMAGANY POZIOM ZYSKU ***********/
minAvgProfit = 20000.0; //wymagany poziom zysku
/************************* SCENARIOS *************************/
// expected values (used only in t-student.R script)
mu = [9 8 7 6];
// covariance (used only in t-student.R script)
sigma = [[ 16 -2 -1 -3]
[ -2 9 -4 -1]
[ -1 -4 4 1]
[ -3 -1 1 1]];
// scenarios (generated by t-student.R script)
sellProfit = [[10.7349277395552 7.72178696852481 6.91313555665251 5.3580692014906]
[11.4029325398093 5.35289018472828 8.44560627918346 5.94437008867837]
[5.9511305436333 9.89072813219028 8.15019579921374 5.92283032635847]
[6.98653442934503 9.43820696539249 6.08947859890014 6.28684001183198]
[8.97632928181137 7.73492022936159 7.69443003815675 6.65911599366542]
[6.3718935550723 8.80949463923562 7.79090422832384 6.81174804312265]
[8.78246371277526 9.96223625339419 5.07839427301482 6.04541265888823]
[8.61200211939238 6.9004774184148 8.38569802461679 6.01047636955988]
[8.04259291408092 11.6005401405856 5.51825529023523 5.52418355625024]
[10.2568641176451 9.42484863719592 5.61768337124079 5.44832826311492]
[6.06345343273768 6.67810135189213 8.25425855603235 7.11046580533962]
[8.74262951486885 8.49193741618487 8.26781448661321 5.63718569432722]
[8.96019482191789 7.48206038212727 8.64020735666332 6.61806454609454]
[10.7060656286305 7.74073441264031 8.70806653294011 5.56273592101066]
[9.14849596786536 5.38206186993592 8.48324089408178 6.31836607658665]
[10.9884988766065 5.05294389126629 7.81201862380442 5.89377116896792]
[9.85025400030063 9.20603928762331 6.76845266520436 5.77678827669309]
[9.76699335636152 7.83363407758539 5.01347383618885 5.84594312150737]
[8.22098260831502 7.93964476990494 8.36747212617667 6.58666346744554]
[9.64940023484707 7.34646951028725 8.15389801271092 6.71485257935324]
[9.56697193644308 7.24791547600423 5.82061898605385 6.6329880618574]
[7.64858383380397 11.8956850930214 6.57566578417732 7.52978318768004]
[10.8667504186116 5.6239431792075 6.49095275149094 5.44747350145729]
[11.5459204391574 6.5874000517338 8.91791399632966 5.70569902009294]
[9.00453124705504 6.25952067886102 8.93937357845343 6.11437998871486]
[10.4316051568988 8.89165309349428 8.00183466339121 6.22792967489147]
[11.1403947310683 8.80153331584519 6.36710780356291 5.52424084189948]
[9.5907049066395 9.30053224873728 6.5052199777433 5.64308372528693]
[6.47305423724122 7.66508680006143 7.42589600717661 6.52108273658984]
[9.76726531281191 8.22194904261638 7.1081746124431 6.13833241033153]
];

View File

@ -0,0 +1,164 @@
/*********************************************
* OPL 12.5.1.0 Model
* Author: mateu
* Creation Date: May 24, 2017 at 10:08:31 PM
*********************************************/
/***********PARAMETRY************************/
//Paramatry zostaladniej opisane w pliku .dat oraz raporcie
// Parametry liczbowe
int nMachType = ...;
int nMonth = ...;
int nProdType = ...;
int nHours = ...;
int nScenarios = ...;
// Utworzenie wektorow indeksujacych
{int} machines = asSet(1..nMachType);
{int} months = asSet(1..nMonth);
{int} products = asSet(1..nProdType);
{int} scenarios = asSet(1..nScenarios);
//Parametry produkcji i sprzedazy
int machineCount[machines] = ...;
float prodTime[machines][products] = ...;
int maxInMonth[months][products] = ...;
//Parametry magazynowania
int storageMax[products] = ...;
int storageCost = ...;
int storageStart[products] = ...;
//Parametry do generowania scenariusze (nieuzywane w modelu CPLEX)
int mu[products] = ...;
int sigma[products][products] = ...;
//Macierz scenariuszy dochodow ze sprzedazy: typ produkty (kolumna) - scenariusz (wiersz)
float sellProfit[scenarios][products] = ...;
/******************* PARAMTERY METODY: WYMAGANY POZIOM ZYSKU ***********/
float minAvgProfit = ...; //wymagany poziom zysku
/*********** ZMIENNE DECYZYJNE ********************************************/
dvar int produce[months][products]; // Liczba wyprodukowanych
dvar int sell[months][products]; // Liczba sprzedanych
dvar int stock[months][products]; // Liczba w magazynie
// Czas wykorzystany na danym typie maszyna na dany typ produktu
dvar float workTime[months][machines][products];
// Zmienna binarna - czy sprzedaz danego typu produktu przekaroczyla 80 procent pojemnosci rynku
dvar boolean if80prec[months][products];
// Zmienna - ile pieniedzy nalezy odjac od dochodow z poszczegolnych produkow
// w poszczegolnych miesiacach ze wzgledu na przekroczenie 80% pojmnosci rynku
dvar float lowerProfit[scenarios][months][products];
/************ KRYTERIA OCENY *********************************************/
// ZYSK policzony dla poszczegolnych scenariuszy
dexpr float profit[i in scenarios] = sum(m in months, p in products)
(sell[m][p]*sellProfit[i][p]-lowerProfit[i][m][p]- stock[m][p]*storageCost);
// wartosc oczekiwana zysku policzona jako srednia
dexpr float avgProfit = sum(i in scenarios)(profit[i])/nScenarios;
// RYZYKO zdefiniowane srednia roznica Giniego
dexpr float giniRisk = sum (t1 in scenarios, t2 in scenarios ) (
0.5 * abs(profit[t1] - profit[t2]) * 1/nScenarios * 1/nScenarios
);
// funkcja celu
minimize giniRisk;
//maximize avgProfit;
// ************** OGRANICZENIA ******************************************/
subject to {
// Zmienne decyzyjne nie mniejsze niz zero
forall(i in scenarios, m in months, mc in machines, p in products) {
workTime[m][mc][p] >= 0;
produce[m][p] >= 0;
sell[m][p] >= 0;
stock[m][p] >= 0;
lowerProfit[i][m][p] >= 0;
}
// Ogranicznie czasu produkcji maszyn w miesiacu
forall(m in months, mc in machines) {
sum(p in products) (workTime[m][mc][p]) <= (machineCount[mc]*nHours);
}
// Ograniczenie definiujace wykorzystany czas pracy maszyn
forall(m in months, p in products, mc in machines) {
workTime[m][mc][p] == produce[m][p]*prodTime[mc][p];
}
// Ogranicznie maksymalnej pojemnosci rynku
forall(m in months, p in products) {
sell[m][p] <= maxInMonth[m][p];
}
// Ogranicznie ustawiajace zmienna binarna po przekroczeniu 80 procent pojemnosci rynku
forall(m in months, p in products) {
sell[m][p] <= 0.8*maxInMonth[m][p] + 1000000 * if80prec[m][p];
sell[m][p] >= 0.8*maxInMonth[m][p] * if80prec[m][p];
}
// Ograniczenia linearyzujace wplyw zmiennej binarnej na funkcje celu
forall (i in scenarios,m in months, p in products) {
lowerProfit[i][m][p] <= 1000000 * if80prec[m][p];
lowerProfit[i][m][p] <= 0.2 * sell[m][p]*sellProfit[i][p];
0.2 * sell[m][p]*sellProfit[i][p] - lowerProfit[i][m][p] + 1000000 * if80prec[m][p] <= 1000000;
}
// Ograniczenie sprzedazy oraz definicja ilosci towaru pozostajacej w magazynie
forall(m in months, p in products) {
if(m == 1) { //pierwszy miesiac
sell[m][p] <= produce[m][p]+storageStart[p];
stock[m][p]==(produce[m][p] + storageStart[p])-sell[m][p];
}else { // kolejne miesiace
sell[m][p] <= produce[m][p] + stock[m-1][p];
stock[m][p]==(produce[m][p] + stock[m-1][p])-sell[m][p];
}
}
// Ogranicznie maksymalnej ilosci magazynowanych produktow oraz
// wymaganej ilosc pozostalej w magazynie na na koniec symulacji
forall(m in months, p in products) {
stock[m][p] <= storageMax[p];
if(m == 3) {
stock[m][p] >= 50;
}
}
/******************OGRANICZENIE: WYMAGANY POZIOM ZYSKU ****************************/
avgProfit>=minAvgProfit;
}// Koniec ogranicznen
main {
var file = new IloOplOutputFile("result-minAvgProfit.txt");
//var fileAP = new IloOplOutputFile("avgProfitScenario.txt");
//var fileMR = new IloOplOutputFile("maxRiskScenario.txt");
var mod = thisOplModel;
var def = mod.modelDefinition;
var data = mod.dataElements;
var maxAvgProfit = 26553;
var i = 1;
file.writeln("i;minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4");
data.minAvgProfit = -600.0;
while (data.minAvgProfit <= maxAvgProfit) {
mod = new IloOplModel (def, cplex);
mod.addDataSource(data);
mod.generate();
cplex.tilim = 300;
cplex.solve();
file.writeln(i,";",data.minAvgProfit,";",mod.avgProfit,";",mod.giniRisk,";",mod.produce[1][1],";",mod.produce[1][2],";",mod.produce[1][3],";",mod.produce[1][4], ";",mod.produce[2][1],";",mod.produce[2][2],";",mod.produce[2][3],";",mod.produce[2][4],";",mod.produce[3][1],";",mod.produce[3][2], ";",mod.produce[3][3],";",mod.produce[3][4],";",mod.stock[1][1],";",mod.stock[1][2],";",mod.stock[1][3],";",mod.stock[1][4], ";",mod.stock[2][1],";",mod.stock[2][2],";",mod.stock[2][3],";",mod.stock[2][4],";",mod.stock[3][1],";",mod.stock[3][2], ";",mod.stock[3][3],";",mod.stock[3][4]);
writeln(i," minAvgProfit: ",data.minAvgProfit," avgProfit: ",mod.avgProfit,", giniRisk: ",mod.giniRisk);
mod.end();
data.minAvgProfit = data.minAvgProfit + 532.41;
i = i+1;
};
file.close();
//fileAP.close();
//fileMR.close();
}

View File

@ -0,0 +1,80 @@
/*********************************************
* OPL 12.5.1.0 Data
* Author: Mateusz Percinski
* Creation Date: May 24, 2017 at 10:09:32 PM
*********************************************/
/***************PARAMETRY********************/
nMachType = 5; //ilosc typow maszun
nMonth = 3; //ilosc symulowanych miesiecy
nProdType = 4; //ilosc typow produktow
nHours = 384; //liczba godzin roboczych w miesiacu 2*8*24=384
nScenarios = 30; //ilosc scenariuszy w symulacji
// Ilosc maszyn poszczegolnych typow
machineCount = [4 2 3 1 1];
// Koszty wykorzystania typow maszyn (wiersze)
//w wytwarzaniu poszczegolnych typow produktow (kolumny)
prodTime = [[ 0.4 0.6 0 0]
[ 0.2 0.1 0 0.6]
[ 0.1 0 0.7 0]
[ 0.06 0.04 0 0.05]
[ 0 0.05 0.02 0]];
// Pojemnosc rynku - typ produktu(kolumny) w miesiacu(wiersz)
maxInMonth = [[ 400 0 200 300]
[ 700 400 500 0]
[ 0 800 600 400]];
// Magazyn
storageMax = [200 200 200 200]; //maksymalna pojemnosc dla typow produktow
storageCost = 1; //koszt magazynowania zl/sztuka/miesiac
storageStart = [50 50 50 50]; //poczatkowa ilosc w magazynach
/******************* METODA: WYMAGANY POZIOM ZYSKU ***********/
minAvgProfit = 20000.0; //wymagany poziom zysku
/************************* SCENARIOS *************************/
// expected values (used only in t-student.R script)
mu = [9 8 7 6];
// covariance (used only in t-student.R script)
sigma = [[ 16 -2 -1 -3]
[ -2 9 -4 -1]
[ -1 -4 4 1]
[ -3 -1 1 1]];
// scenarios (generated by t-student.R script)
sellProfit = [[10.7349277395552 7.72178696852481 6.91313555665251 5.3580692014906]
[11.4029325398093 5.35289018472828 8.44560627918346 5.94437008867837]
[5.9511305436333 9.89072813219028 8.15019579921374 5.92283032635847]
[6.98653442934503 9.43820696539249 6.08947859890014 6.28684001183198]
[8.97632928181137 7.73492022936159 7.69443003815675 6.65911599366542]
[6.3718935550723 8.80949463923562 7.79090422832384 6.81174804312265]
[8.78246371277526 9.96223625339419 5.07839427301482 6.04541265888823]
[8.61200211939238 6.9004774184148 8.38569802461679 6.01047636955988]
[8.04259291408092 11.6005401405856 5.51825529023523 5.52418355625024]
[10.2568641176451 9.42484863719592 5.61768337124079 5.44832826311492]
[6.06345343273768 6.67810135189213 8.25425855603235 7.11046580533962]
[8.74262951486885 8.49193741618487 8.26781448661321 5.63718569432722]
[8.96019482191789 7.48206038212727 8.64020735666332 6.61806454609454]
[10.7060656286305 7.74073441264031 8.70806653294011 5.56273592101066]
[9.14849596786536 5.38206186993592 8.48324089408178 6.31836607658665]
[10.9884988766065 5.05294389126629 7.81201862380442 5.89377116896792]
[9.85025400030063 9.20603928762331 6.76845266520436 5.77678827669309]
[9.76699335636152 7.83363407758539 5.01347383618885 5.84594312150737]
[8.22098260831502 7.93964476990494 8.36747212617667 6.58666346744554]
[9.64940023484707 7.34646951028725 8.15389801271092 6.71485257935324]
[9.56697193644308 7.24791547600423 5.82061898605385 6.6329880618574]
[7.64858383380397 11.8956850930214 6.57566578417732 7.52978318768004]
[10.8667504186116 5.6239431792075 6.49095275149094 5.44747350145729]
[11.5459204391574 6.5874000517338 8.91791399632966 5.70569902009294]
[9.00453124705504 6.25952067886102 8.93937357845343 6.11437998871486]
[10.4316051568988 8.89165309349428 8.00183466339121 6.22792967489147]
[11.1403947310683 8.80153331584519 6.36710780356291 5.52424084189948]
[9.5907049066395 9.30053224873728 6.5052199777433 5.64308372528693]
[6.47305423724122 7.66508680006143 7.42589600717661 6.52108273658984]
[9.76726531281191 8.22194904261638 7.1081746124431 6.13833241033153]
];

View File

@ -0,0 +1,248 @@
/*********************************************
* OPL 12.5.1.0 Model
* Author: mateu
* Creation Date: May 24, 2017 at 10:08:31 PM
*********************************************/
/***********PARAMETRY************************/
//Paramatry zostaladniej opisane w pliku .dat oraz raporcie
// Parametry liczbowe
int nMachType = ...;
int nMonth = ...;
int nProdType = ...;
int nHours = ...;
int nScenarios = ...;
// Utworzenie wektorow indeksujacych
{int} machines = asSet(1..nMachType);
{int} months = asSet(1..nMonth);
{int} products = asSet(1..nProdType);
{int} scenarios = asSet(1..nScenarios);
//Parametry produkcji i sprzedazy
int machineCount[machines] = ...;
float prodTime[machines][products] = ...;
int maxInMonth[months][products] = ...;
//Parametry magazynowania
int storageMax[products] = ...;
int storageCost = ...;
int storageStart[products] = ...;
//Parametry do generowania scenariusze (nieuzywane w modelu CPLEX)
int mu[products] = ...;
int sigma[products][products] = ...;
//Macierz scenariuszy dochodow ze sprzedazy: typ produkty (kolumna) - scenariusz (wiersz)
float sellProfit[scenarios][products] = ...;
/******************* PARAMTERY METODY: WYMAGANY POZIOM ZYSKU ***********/
float minAvgProfit = ...; //wymagany poziom zysku
/*********** ZMIENNE DECYZYJNE ********************************************/
dvar int produce[months][products]; // Liczba wyprodukowanych
dvar int sell[months][products]; // Liczba sprzedanych
dvar int stock[months][products]; // Liczba w magazynie
// Czas wykorzystany na danym typie maszyna na dany typ produktu
dvar float workTime[months][machines][products];
// Zmienna binarna - czy sprzedaz danego typu produktu przekaroczyla 80 procent pojemnosci rynku
dvar boolean if80prec[months][products];
// Zmienna - ile pieniedzy nalezy odjac od dochodow z poszczegolnych produkow
// w poszczegolnych miesiacach ze wzgledu na przekroczenie 80% pojmnosci rynku
dvar float lowerProfit[scenarios][months][products];
/************ KRYTERIA OCENY *********************************************/
// ZYSK policzony dla poszczegolnych scenariuszy
dexpr float profit[i in scenarios] = sum(m in months, p in products)
(sell[m][p]*sellProfit[i][p]-lowerProfit[i][m][p]- stock[m][p]*storageCost);
// wartosc oczekiwana zysku policzona jako srednia
dexpr float avgProfit = sum(i in scenarios)(profit[i])/nScenarios;
// DODATKOWE OBLICZNIE RYZYKA DLA KAZDEGO SCENARIUSZA - POTRZEBNE DO ANALIZY FSD
dexpr float risk[i in scenarios] = sum (t in scenarios) (
0.5 * abs(profit[i] - profit[t]) * 1/nScenarios
);
// RYZYKO zdefiniowane srednia roznica Giniego
dexpr float giniRisk = sum (t1 in scenarios, t2 in scenarios ) (
0.5 * abs(profit[t1] - profit[t2]) * 1/nScenarios * 1/nScenarios
);
// funkcja celu
minimize giniRisk;
//maximize avgProfit;
// ************** OGRANICZENIA ******************************************/
subject to {
// Zmienne decyzyjne nie mniejsze niz zero
forall(i in scenarios, m in months, mc in machines, p in products) {
workTime[m][mc][p] >= 0;
produce[m][p] >= 0;
sell[m][p] >= 0;
stock[m][p] >= 0;
lowerProfit[i][m][p] >= 0;
}
// Ogranicznie czasu produkcji maszyn w miesiacu
forall(m in months, mc in machines) {
sum(p in products) (workTime[m][mc][p]) <= (machineCount[mc]*nHours);
}
// Ograniczenie definiujace wykorzystany czas pracy maszyn
forall(m in months, p in products, mc in machines) {
workTime[m][mc][p] == produce[m][p]*prodTime[mc][p];
}
// Ogranicznie maksymalnej pojemnosci rynku
forall(m in months, p in products) {
sell[m][p] <= maxInMonth[m][p];
}
// Ogranicznie ustawiajace zmienna binarna po przekroczeniu 80 procent pojemnosci rynku
forall(m in months, p in products) {
sell[m][p] <= 0.8*maxInMonth[m][p] + 1000000 * if80prec[m][p];
sell[m][p] >= 0.8*maxInMonth[m][p] * if80prec[m][p];
}
// Ograniczenia linearyzujace wplyw zmiennej binarnej na funkcje celu
forall (i in scenarios,m in months, p in products) {
lowerProfit[i][m][p] <= 1000000 * if80prec[m][p];
lowerProfit[i][m][p] <= 0.2 * sell[m][p]*sellProfit[i][p];
0.2 * sell[m][p]*sellProfit[i][p] - lowerProfit[i][m][p] + 1000000 * if80prec[m][p] <= 1000000;
}
// Ograniczenie sprzedazy oraz definicja ilosci towaru pozostajacej w magazynie
forall(m in months, p in products) {
if(m == 1) { //pierwszy miesiac
sell[m][p] <= produce[m][p]+storageStart[p];
stock[m][p]==(produce[m][p] + storageStart[p])-sell[m][p];
}else { // kolejne miesiace
sell[m][p] <= produce[m][p] + stock[m-1][p];
stock[m][p]==(produce[m][p] + stock[m-1][p])-sell[m][p];
}
}
// Ogranicznie maksymalnej ilosci magazynowanych produktow oraz
// wymaganej ilosc pozostalej w magazynie na na koniec symulacji
forall(m in months, p in products) {
stock[m][p] <= storageMax[p];
if(m == 3) {
stock[m][p] >= 50;
}
}
/******************OGRANICZENIE: WYMAGANY POZIOM ZYSKU ****************************/
avgProfit>=minAvgProfit;
}// Koniec ogranicznen
main {
//var fileProfit = new IloOplOutputFile("results-minAvgProfit-FSD-profit.txt");
//var fileRisk = new IloOplOutputFile("results-minAvgProfit-FSD-risk.txt");
var fileProfit = new IloOplOutputFile("results-minAvgProfit-FSD-profit(2).txt");
var fileRisk = new IloOplOutputFile("results-minAvgProfit-FSD-risk(2).txt");
var mod = thisOplModel;
var def = mod.modelDefinition;
var data = mod.dataElements;
var maxAvgProfit = 26553;
var i = 1;
/**************** Pierwsze wybrane rozwiazanie ************************************/
fileProfit.writeln("minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4");
fileRisk.writeln("minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4");
//data.minAvgProfit = 25488.3;
data.minAvgProfit = 10580.7;
mod = new IloOplModel (def, cplex);
mod.addDataSource(data);
mod.generate();
writeln("Pierwsze wybrane rozwiazanie: ");
cplex.solve();
writeln(i," minAvgProfit: ",data.minAvgProfit," avgProfit: ",mod.avgProfit,", giniRisk: ",mod.giniRisk);
fileProfit.writeln(data.minAvgProfit,";",mod.avgProfit,";",mod.giniRisk,";",mod.produce[1][1],";",mod.produce[1][2],";",mod.produce[1][3],";",mod.produce[1][4], ";",mod.produce[2][1],";",mod.produce[2][2],";",mod.produce[2][3],";",mod.produce[2][4],";",mod.produce[3][1],";",mod.produce[3][2], ";",mod.produce[3][3],";",mod.produce[3][4],";",mod.stock[1][1],";",mod.stock[1][2],";",mod.stock[1][3],";",mod.stock[1][4], ";",mod.stock[2][1],";",mod.stock[2][2],";",mod.stock[2][3],";",mod.stock[2][4],";",mod.stock[3][1],";",mod.stock[3][2], ";",mod.stock[3][3],";",mod.stock[3][4]);
fileRisk.writeln(data.minAvgProfit,";",mod.avgProfit,";",mod.giniRisk,";",mod.produce[1][1],";",mod.produce[1][2],";",mod.produce[1][3],";",mod.produce[1][4], ";",mod.produce[2][1],";",mod.produce[2][2],";",mod.produce[2][3],";",mod.produce[2][4],";",mod.produce[3][1],";",mod.produce[3][2], ";",mod.produce[3][3],";",mod.produce[3][4],";",mod.stock[1][1],";",mod.stock[1][2],";",mod.stock[1][3],";",mod.stock[1][4], ";",mod.stock[2][1],";",mod.stock[2][2],";",mod.stock[2][3],";",mod.stock[2][4],";",mod.stock[3][1],";",mod.stock[3][2], ";",mod.stock[3][3],";",mod.stock[3][4]);
i = 1;
fileProfit.writeln("avgProfit: ");
while (i<=data.nScenarios) {
fileProfit.writeln(mod.profit[i]);
i++;
};
i = 1;
fileRisk.writeln("Risk: ");
while (i<=data.nScenarios) {
fileRisk.writeln(mod.risk[i]);
i++;
};
/**************** Drugie wybrane rozwiazanie ************************************/
fileProfit.writeln("minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4");
fileRisk.writeln("minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4");
//data.minAvgProfit = 26020.6;
data.minAvgProfit = 20164;
mod = new IloOplModel (def, cplex);
mod.addDataSource(data);
mod.generate();
writeln("Drugie wybrane rozwiazanie: ");
cplex.solve();
writeln(i," minAvgProfit: ",data.minAvgProfit," avgProfit: ",mod.avgProfit,", giniRisk: ",mod.giniRisk);
fileProfit.writeln(data.minAvgProfit,";",mod.avgProfit,";",mod.giniRisk,";",mod.produce[1][1],";",mod.produce[1][2],";",mod.produce[1][3],";",mod.produce[1][4], ";",mod.produce[2][1],";",mod.produce[2][2],";",mod.produce[2][3],";",mod.produce[2][4],";",mod.produce[3][1],";",mod.produce[3][2], ";",mod.produce[3][3],";",mod.produce[3][4],";",mod.stock[1][1],";",mod.stock[1][2],";",mod.stock[1][3],";",mod.stock[1][4], ";",mod.stock[2][1],";",mod.stock[2][2],";",mod.stock[2][3],";",mod.stock[2][4],";",mod.stock[3][1],";",mod.stock[3][2], ";",mod.stock[3][3],";",mod.stock[3][4]);
fileRisk.writeln(data.minAvgProfit,";",mod.avgProfit,";",mod.giniRisk,";",mod.produce[1][1],";",mod.produce[1][2],";",mod.produce[1][3],";",mod.produce[1][4], ";",mod.produce[2][1],";",mod.produce[2][2],";",mod.produce[2][3],";",mod.produce[2][4],";",mod.produce[3][1],";",mod.produce[3][2], ";",mod.produce[3][3],";",mod.produce[3][4],";",mod.stock[1][1],";",mod.stock[1][2],";",mod.stock[1][3],";",mod.stock[1][4], ";",mod.stock[2][1],";",mod.stock[2][2],";",mod.stock[2][3],";",mod.stock[2][4],";",mod.stock[3][1],";",mod.stock[3][2], ";",mod.stock[3][3],";",mod.stock[3][4]);
i = 1;
fileProfit.writeln("avgProfit: ");
while (i<=data.nScenarios) {
fileProfit.writeln(mod.profit[i]);
i++;
};
i = 1;
fileRisk.writeln("Risk: ");
while (i<=data.nScenarios) {
fileRisk.writeln(mod.risk[i]);
i++;
};
/**************** Trzecie wybrane rozwiazanie ************************************/
fileProfit.writeln("minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4");
fileRisk.writeln("minAvgProfit;avgProfit;giniRisk;m1_prod_P1;m1_prod_P2;m1_prod_P3;m1_prod_P4;m2_prod_P1;m2_prod_P2;m2_prod_P3;m2_prod_P4;m3_prod_P1;m3_prod_P2;m3_prod_P3;m3_prod_P4;m1_stock_P1;m1_stock_P2;m1_stock_P3;m1_stock_P4;m2_stock_P1;m2_stock_P2;m2_stock_P3;m2_stock_P4;m3_stock_P1;m3_stock_P2;m3_stock_P3;m3_stock_P4");
//data.minAvgProfit = 26553.9;
data.minAvgProfit = 26553.9;
mod = new IloOplModel (def, cplex);
mod.addDataSource(data);
mod.generate();
writeln("Trzecie wybrane rozwiazanie: ");
cplex.solve();
writeln(i," minAvgProfit: ",data.minAvgProfit," avgProfit: ",mod.avgProfit,", giniRisk: ",mod.giniRisk);
fileProfit.writeln(data.minAvgProfit,";",mod.avgProfit,";",mod.giniRisk,";",mod.produce[1][1],";",mod.produce[1][2],";",mod.produce[1][3],";",mod.produce[1][4], ";",mod.produce[2][1],";",mod.produce[2][2],";",mod.produce[2][3],";",mod.produce[2][4],";",mod.produce[3][1],";",mod.produce[3][2], ";",mod.produce[3][3],";",mod.produce[3][4],";",mod.stock[1][1],";",mod.stock[1][2],";",mod.stock[1][3],";",mod.stock[1][4], ";",mod.stock[2][1],";",mod.stock[2][2],";",mod.stock[2][3],";",mod.stock[2][4],";",mod.stock[3][1],";",mod.stock[3][2], ";",mod.stock[3][3],";",mod.stock[3][4]);
fileRisk.writeln(data.minAvgProfit,";",mod.avgProfit,";",mod.giniRisk,";",mod.produce[1][1],";",mod.produce[1][2],";",mod.produce[1][3],";",mod.produce[1][4], ";",mod.produce[2][1],";",mod.produce[2][2],";",mod.produce[2][3],";",mod.produce[2][4],";",mod.produce[3][1],";",mod.produce[3][2], ";",mod.produce[3][3],";",mod.produce[3][4],";",mod.stock[1][1],";",mod.stock[1][2],";",mod.stock[1][3],";",mod.stock[1][4], ";",mod.stock[2][1],";",mod.stock[2][2],";",mod.stock[2][3],";",mod.stock[2][4],";",mod.stock[3][1],";",mod.stock[3][2], ";",mod.stock[3][3],";",mod.stock[3][4]);
i = 1;
fileProfit.writeln("avgProfit: ");
while (i<=data.nScenarios) {
fileProfit.writeln(mod.profit[i]);
i++;
};
i = 1;
fileRisk.writeln("Risk: ");
while (i<=data.nScenarios) {
fileRisk.writeln(mod.risk[i]);
i++;
};
fileProfit.close();
fileRisk.close();
}