forked from slaierno/OpResearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapitolo3.tex
1690 lines (1624 loc) · 69.9 KB
/
capitolo3.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\chapter{15/04/2014}
In questo capitolo, riguardante la terza esercitazione, verranno svolti alcuni dei punti mancanti dell'esercitazione precedente. Per essere precisi, tutti quelli riguardanti il \textbf{vincolo di interezza} sulle variabili, cioè i problemi ILP. Non saranno riportati, ovviamente, gli interi esercizi ma solo i tableau finali con i quali partire per eseguire il simplesso duale. Verranno comunque creati dei riferimenti ipertestuali negli esercizi precedenti che rimanderanno alle soluzioni che di seguito apporrò.
\section{Esercizio 4}
In questa sezione riprenderemo da dove eravamo rimasti in \vref{sec:es4ILP}, risolvendo il problema ILP prima con il metodo dei \textbf{tagli di Gomory} e poi con il metodo \textbf{branch and bound} (il primo in realtà non è richiesto dalla traccia, ma lo proveremo ugualmente come utile esercitazione).
Prima di ciò, è bene ricordare alcuni concetti teorici.
\subsection{Richiami (blandi, sempre blandi) di teoria}
\subsubsection{Tagli di Gomory}
Ricordiamo dato un problema ILP con \textbf{soluzione del rilassamento continuo $x^*$}, \textbf{eseguire un taglio} significa applicare un \textbf{vincolo} tale che:
\begin{enumerate}
\item \textbf{elimini} una parte della regione ammissibile \textbf{contente $x^*$};
\item \textbf{non elimini} nessuna soluzione intera ammissibile.
\end{enumerate}
Definendo:
\begin{align*}
\mathcal{B} & \qquad\textbf{base ottima} \\
f_{ij}=y_{ij}-\left\lfloor y_{ij} \right\rfloor & \qquad\textbf{parte frazionaria di $y_{ij}$}
\end{align*}
Un \textbf{taglio di Gomory} è tale che:
$$
\sum_{A_j \notin \mathcal{B}} f_{ij}x_j \geq f_{i0}
$$
Ove la riga $i$ è scelta arbitrariamente tra quelle per cui $y_{i0}\notin\mathbb{N}$.
Può essere dimostrato (ma non lo faremo qui) che questo tipo di taglio rispetta i due punti citati in precedenza.
\subsubsection{Branch and bound (da rivedere)}
Come dal nome del metodo, questo metodo si compone di due parti: \textbf{branching} e \textbf{bounding}.
\paragraph{Branching}
L'operazione di \textbf{branching} consiste nell'imporre due \textbf{vincoli mutualmente esclusivi ed esaustivi} su una variabile $x_j$, data $x_j^*$ la componente $j$-esima della soluzione del rilassamento continuo:
$$
x_j \leq \left\lfloor x_j^* \right\rfloor \qquad\veebar\qquad x_j \geq \left\lceil x_j^* \right\rceil
$$
Unendo al problema originario alternativamente questi due vincoli, si ottengono due nuovi sottoproblemi. La soluzione migliore tra i due sarà anche la migliore in assoluto. Per risolvere i due nuovi sottoproblemi si può applicare ricorsivamente un nuovo branching.
\paragraph{Bounding}
Ogni volta che si ottiene un nuovo sottoproblema da quello originario, si risolve nuovamente il rilassamento continuo.
Il rilassamento continuo di un problema costituisce un \textbf{lower bound}, poiché nessuna soluzione può essere migliore di quella offerta dal rilassamento continuo. In particolare, si può considerare come lower bound anche la sua \textbf{parte intera}.
Nel momento in cui uno dei sottoproblemi offre una soluzione intera uguale a quella del rilassamento continuo, si può evitare di risolvere \textbf{tutti i sottoproblemi non ancora risolti il cui lower bound è maggiore o uguale alla soluzione appena ottenuto} in quanto nella migliore delle ipotesi potremmo trovare solo una soluzione uguale a quella appena trovata, ma non una migliore.
\paragraph{Rappresentazione}
Il metodo migliore per rappresentare la soluzione tramite branch and bound è un albero binario.
\begin{figure}[ht!]
\centering
\begin{tikzpicture}[edge from parent/.style={draw=black,-latex},
level/.style={sibling distance=50mm, level distance=20mm},
cross/.style={path picture={
\draw[black]
(path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}}
]
\node [circle, draw, label=east:{$L_B=-9$}] (z) {$P_0$}
child {node [circle, draw, label=east:{$L_B=-8$}] (a) {$P_1$}
child {node [circle, draw, label=east:{$L_B=-8$}, label=south:{$-z=-8$}] (b) {$P_2$}
edge from parent node[above left] {$x_2\leq 3$}
}
edge from parent node[left] {$x_1\leq 1$}
}
child {node [circle, draw, cross] (b) {$P_3$}
edge from parent node[above right, label=east:{$L_B=-8$}] {$x_1\geq 2$}
}
;
\end{tikzpicture}
\end{figure}
Nell'esempio, il problema $P_2$ ha la soluzione del rilassamento continua uguale al lower bound del problema padre. Questo rende inutile esplorare l'altro figlio del problema $P_1$, in quanto non potremmo avere alcuna soluzione più bassa di $-8$, come indicato dal suo lower bound.
Poiché il lower bound del problema $P_0$ è migliore della soluzione attualmente disponibile, ha senso esplorare il suo altro figlio. Nel nostro esempio, però, il figlio $P_3$ ha un lower bound uguale a $-8$ e non c'è più possibilità di trovare una soluzione migliore di quella trovata in precedenza. Si dice, in questo caso, che il nodo $P_2$ \textbf{uccide} il nodo $P_3$ (sul quale abbiamo all'uopo apposto una croce).
\textit{Noto che è difficile spiegare in maniera generale il funzionamento del metodo branch and bound. Si spera perciò che risulti più chiaro applicandolo praticamente negli esercizi.}
\subsection{ILP - Tagli di Gomory}
Riportiamo in tabella \vref{tab:tab411} il tableau finale della soluzione del problema LP.
\begin{table}[htbp]
\centering
{
\newcommand{\sm}{$\frac{7}{2}$}
\newcommand{\nm}{$\frac{9}{2}$}
\newcommand{\um}{$\frac{1}{2}$}
\newcommand{\tm}{$\frac{3}{2}$}
\begin{tabular}{rrccccccc}
& &$-\varphi$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $x^a$\\
$R_0$ & $\OL{c_j}$ & \Sc{8} & 0 & 0 & 1 & 0 & \Sc{0}& 0\\
\cline{3-9}
$R_1$ & $x_2$ & \Sc{\sm} & 0 & 1 & \um & \um & \Sc{0}& -\um \\
$R_2$ & $x_1$ & \Sc{\nm} & 1 & 0 & \um & -\um & \Sc{0}& \um \\
$R_3$ & $x_5$ & \Sc{\tm} & 0 & 0 & -\um & \um & \Sc{1}& -\um \\
\end{tabular}
}
\caption{Tableau finale del problema LP. Rappresenta il rilassamento continuo del problema ILP.}
\label{tab:tab411}
\end{table}
Le righe $R_1$,$R_2$ ed $R_3$ sono valide candidate per applicare il taglio di Gomory. Scegliamo la riga $R_1$:
$$
\frac{1}{2}x_3+\frac{1}{2}x_4\geq\frac{1}{2}
$$
Portiamo in forma standard il vincolo moltiplicando per $-1$ e aggiungendo una variabile slack $s$:
$$
-\frac{1}{2}x_3-\frac{1}{2}x_4+s=\frac{1}{2}
$$
Il vincolo è abbastanza agevole da inserire nel tableau come in tabella \vref{tab:tab412} (è stata eliminata la variabile artificiale, ormai inutile).
\begin{table}[htbp]
\centering
{
\newcommand{\sm}{$\frac{7}{2}$}
\newcommand{\nm}{$\frac{9}{2}$}
\newcommand{\um}{$\frac{1}{2}$}
\newcommand{\mum}{$-\frac{1}{2}$}
\newcommand{\tm}{$\frac{3}{2}$}
\begin{tabular}{rrccccccc}
& &$-\varphi$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $s$\\
$R_0$ & $\OL{c_j}$ & \Sc{8} & 0 & 0 & 1 & 0 & \Sc{0}& 0\\
\cline{3-9}
$R_1$ & $x_2$ & \Sc{\sm} & 0 & 1 & \um & \um & \Sc{0}& 0 \\
$R_2$ & $x_1$ & \Sc{\nm} & 1 & 0 & \um & \mum & \Sc{0}& 0 \\
$R_3$ & $x_5$ & \Sc{\tm} & 0 & 0 & \mum & \um & \Sc{1}& 0 \\
\cline{3-8}
$R_4$ & $s$ & \Sc{\mum} & 0 & 0 & \mum &\C{\mum}& 0 & 1
\end{tabular}
}
\caption{Applicazione del primo taglio di Gomory.}
\label{tab:tab412}
\end{table}
È evidente che nel tableau è ancora presente la sottomatrice identità e che la soluzione rispetta il \textit{criterio di ottimalità} essendo tutti i $\OL{c_j}$ non negativi. L'unico intoppo è rappresentato dal valore della variabile $s$, che è negativo.
In altri termini, siamo in una soluzione ottima ma non ammissibile. Lo strumento che fa al caso nostro ora è il \textbf{simplesso duale}, che ci porterà da una base ottima ad una nuova base sempre ottima ma più vicina all'ammissibilità.
Il simplesso duale opera come il simplesso primale ma invertendo righe e colonne. Perciò, dovremo scegliere tra tutti gli elementi della \textit{riga} $i$-esima con $y_{i0}<0$ quello su cui fare pivot. A tal scopo, ridefiniamo la grandezza $\vartheta$ in tal modo:
$$
\vartheta=\max_{j>0:y_{ij}<0}\left(\frac{y_{0j}}{y_{ij}}\right)=\frac{y_{0s}}{y_{is}}
$$
L'elemento $y_{is}$ sarà quello di pivoting.
Nel nostro caso:
$$
\vartheta=\max\left(\frac{1}{-\frac{1}{2}},\frac{0}{-\frac{1}{2}}\right)=\frac{0}{-\frac{1}{2}}=\frac{y_{04}}{\pmb{y_{44}}}
$$
Faremo pivoting sull'elemento $y_{44}$, cerchiato in tabella \vref{tab:tab412}. Le operazioni da attuare sono le consuete operazioni elementari di riga:
\begin{align*}
R_1&\leftarrow R_1+R_4 \\
R_2&\leftarrow R_1-R_4 \\
R_3&\leftarrow R_3+R_4 \\
R_4&\leftarrow -2R_4
\end{align*}
Ciò che ne risulta è il tableau in tabella \vref{tab:tab413}.
\begin{table}
\centering
{
\newcommand{\sm}{$\frac{7}{2}$}
\newcommand{\nm}{$\frac{9}{2}$}
\newcommand{\um}{$\frac{1}{2}$}
\newcommand{\mum}{$-\frac{1}{2}$}
\newcommand{\tm}{$\frac{3}{2}$}
\begin{tabular}{rrccccccc}
& &$-\varphi$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $s$\\
$R_0$ & $\OL{c_j}$ & \Sc{8} & 0 & 0 & 1 & 0 & \Sc{0}& 0\\
\cline{3-9}
$R_1$ & $x_2$ & \Sc{3} & 0 & 1 & 0 & 0 & \Sc{0}& 1 \\
$R_2$ & $x_1$ & \Sc{5} & 1 & 0 & 1 & 0 & \Sc{0}& -1 \\
$R_3$ & $x_5$ & \Sc{1} & 0 & 0 & -1 & 0 & \Sc{1}& 1 \\
\cline{3-8}
$R_4$ & $x_4$ & \Sc{1} & 0 & 0 & 1 & 1 & 0 & -2
\end{tabular}
}
\caption{Dopo il taglio di Gomory siamo in una soluzione intera nel vertice $\varepsilon(5,3)$.}
\label{tab:tab413}
\end{table}
La nuova base e la nuova soluzione sono:
\begin{align*}
\mathcal{B}&=\{A_2,A_1,A_5,A_4\} \\
x&=(5,3,0,1,1)
\end{align*}
La soluzione è intera ed il nostro problema di ILP è risolto nel nuovo vertice $\varepsilon(5,3)$. Il valore della soluzione è:
$$
z(\varepsilon)=-\varphi=8
$$
\subsubsection{Rappresentazione grafica}
Per quanto riguarda i tagli di Gomory, la rappresentazione grafica non è agevole e immediata e se ne darà una rappresentazione solo alla fine.
Il taglio, in forma di disequazione, è il seguente:
$$
\frac{1}{2}x_3+\frac{1}{2}x_4\geq\frac{1}{2}
$$
Ovviamente non è rappresentabile, in questa forma algebrica, sul piano cartesiano. Le variabili $x_3$ e $x_4$ sono rispettivamente una variabile slack e una variabile surplus, perciò possiamo fare in modo di sostituirle con le variabili reali $x_1$ e $x_2$ operando algebricamente sui vincoli in forma standard che le introducono:
$$
\begin{cases}
x_1 + x_2 + x_3 = 8 \\
x_1 - x_2 - x_4 = 1
\end{cases}
\Rightarrow
\begin{cases}
x_3 = 8 - x_1 - x_2 \\
x_4 = -1 + x_1 - x_2
\end{cases}
$$
Sostituiamo le due variabili nella disequazione:
$$
\frac{1}{2}(8-x_1-x_2)+\frac{1}{2}(-1+x_1-x_2)\geq\frac{1}{2} \Rightarrow x_2 \leq 3
$$
Così espresso il vincolo è ora facilmente rappresentabile graficamente come in figura \vref{fig:graph42}.
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\begin{axis}
[axis lines=middle, axis equal, enlargelimits, xlabel=$x_1$, ylabel=$x_2$,
every axis x label/.style={
at={(ticklabel* cs:1.01)},
anchor=west,
},
every axis y label/.style={
at={(ticklabel* cs:1.01)},
anchor=south,
},]
\path[name path=AX]
(axis cs:\pgfkeysvalueof{/pgfplots/xmin},0)--
(axis cs:\pgfkeysvalueof{/pgfplots/xmax},0);
\path[name path=AY]
(axis cs:0,\pgfkeysvalueof{/pgfplots/ymin})--
(axis cs:0,\pgfkeysvalueof{/pgfplots/ymax});
\path[name path=UP]
(axis cs:\pgfkeysvalueof{/pgfplots/xmin},\pgfkeysvalueof{/pgfplots/ymax})--
(axis cs:\pgfkeysvalueof{/pgfplots/xmax},\pgfkeysvalueof{/pgfplots/ymax});
\dotgrid{0}{8}{0}{4}{black!50}
\addplot
[domain=0:8, samples=10, thick, blue, name path=xy8] {-x+8};
\addplot
[domain=0:8, samples=10, thick, red, name path=xy1] {x-1};
\addplot
[domain=0:8, samples = 10, thick, purple, name path=x6] (6,x);
\addplot
[domain=0:8, samples=10, very thick, green, name path=gomory]
{3} node [pos=0.8, anchor=south, pin={75:{\color{green}$x_2\leq 3$}}, inner sep= 0pt] {};
\addplot[thick, fill=yellow, fill opacity=0.5] fill between [of=xy1 and AX, soft clip={domain=1:6}];
\addplot[white] fill between [of=xy8 and UP];
\addplot[white] fill between [of=x6 and AX];
\addplot[white] fill between [of=gomory and UP];
%\addplot[pattern=north east lines, pattern color=blue!10] fill between [of=xy8 and AX];
\ints{AX}{xy1}{$\alpha$}{alp};
\ints{xy1}{xy8}{$\beta$}{bet};
\intw{xy8}{x6}{$\gamma$}{gam};
\intnw{x6}{AX}{$\delta$}{del};
\intne{gomory}{xy8}{$\varepsilon$}{eps};
\node at (axis cs:4.5,1.5) {$P'$};
\path[name path=GOM]
(axis cs:\pgfkeysvalueof{/pgfplots/xmin}, 2.5)--
(axis cs:\pgfkeysvalueof{/pgfplots/xmax}, 2.5);
\addplot[pattern=north east lines, pattern color=green!30] fill between [of=gomory and GOM, soft clip={domain=0:8}];
\addplot[-latex, thick] coordinates
{(0,0) (1/1.414,1/1.414)} node [pos=.3, anchor=south, label={45:{\small $\nabla z$}}] {};
\end{axis}
\end{tikzpicture}
\caption{Rappresentazione cartesiana del problema di programmazione lineare}
\label{fig:graph42}
\end{figure}
In giallo è rappresentato il nuovo politopo $P'$ risultato del vecchio politopo $P$ e del taglio di Gomory applicato.
\subsection{ILP - Branch and bound}
Il problema di LP iniziale verrà denominato $P_0$. La soluzione del rilassamento continuo $x^*=\left(\frac{9}{2},\frac{7}{2}\right)$ è $-z^*=-8$, il che imposterà il nostro lower bound a $L_B=\left\lceil -8 \right\rceil = -8$.
\begin{figure}[ht!]
\centering
\begin{tikzpicture}[edge from parent/.style={draw=black,-latex},
level/.style={sibling distance=50mm, level distance=20mm},
cross/.style={path picture={
\draw[black]
(path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}}
]
\node [circle, draw, label=east:{$L_B=-8$}] (z) {$P_0$}
;
\end{tikzpicture}
\end{figure}
Iniziando dalla variabile $x_1$ possiamo prendere in considerazione due diversi sottoproblemi derivati dall'aggiunta di uno dei due seguenti vincoli:
\begin{align*}
x_1&\geq\left\lceil x^*_1 \right\rceil &\Rightarrow x_1&\geq 5\\
x_1&\leq\left\lfloor x^*_1 \right\rfloor &\Rightarrow x_1&\leq 4
\end{align*}
Per convincerci che considerando questi due vincoli non si esclude nessuna soluzione e che sono mutuamente esclusivi, si faccia riferimento al grafico \vref{fig:graph43} e osservando che le due aree colorate in ciano e in verde non escludono nessuno dei punti interi.
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\begin{axis}
[axis lines=middle, axis equal, enlargelimits, xlabel=$x_1$, ylabel=$x_2$,
every axis x label/.style={
at={(ticklabel* cs:1.01)},
anchor=west,
},
every axis y label/.style={
at={(ticklabel* cs:1.01)},
anchor=south,
},]
\path[name path=AX]
(axis cs:\pgfkeysvalueof{/pgfplots/xmin},0)--
(axis cs:\pgfkeysvalueof{/pgfplots/xmax},0);
\path[name path=AY]
(axis cs:0,\pgfkeysvalueof{/pgfplots/ymin})--
(axis cs:0,\pgfkeysvalueof{/pgfplots/ymax});
\path[name path=UP]
(axis cs:\pgfkeysvalueof{/pgfplots/xmin},\pgfkeysvalueof{/pgfplots/ymax})--
(axis cs:\pgfkeysvalueof{/pgfplots/xmax},\pgfkeysvalueof{/pgfplots/ymax});
\dotgrid{0}{8}{0}{4}{black!50}
\addplot
[domain=4:8, samples=10, thick, blue, name path=xy8] {-x+8};
\addplot
[domain=1:5, samples=10, thick, red, name path=xy1] {x-1};
\addplot
[domain=0:3, samples = 10, thick, purple, name path=x6] (6,x);
\addplot
[domain=0:4, samples=10, thick, cyan, name path=bb1]
(4,x) node [pos=0, anchor=south, pin={-135:{\color{cyan}$x_1\leq 4$}}, inner sep= 0pt] {};
\path[name path=bb1i] (axis cs:3.75, 0)--(axis cs:3.75, 4);
\addplot
[domain=0:4, samples=10, thick, green, name path=bb2]
(5,x) node [pos=0, anchor=south, pin={-75:{\color{green}$x_2\geq 5$}}, inner sep= 0pt] {};
\path[name path=bb2i] (axis cs:5.25, 0)--(axis cs:5.25, 4);
\addplot[thick, fill=cyan, fill opacity=0.2] fill between [of=bb1 and xy1];
\addplot[white] fill between [of=xy1 and UP];
\addplot[thick, fill=green, fill opacity=0.2] fill between [of=bb2 and x6];
\addplot[white] fill between [of=xy8 and UP];
%\addplot[pattern=north east lines, pattern color=blue!10] fill between [of=xy8 and AX];
\ints{AX}{xy1}{$\alpha$}{alp};
\inte{xy1}{xy8}{$\beta\equiv x^*$}{bet};
\intw{xy8}{x6}{$\gamma$}{gam};
\intnw{x6}{AX}{$\delta$}{del};
\inte{gomory}{xy8}{$\varepsilon$}{eps};
\node at (axis cs:3.5,1.5) {$P_2$};
\node at (axis cs:5.5,1.5) {$P_1$};
\addplot[pattern=north east lines, pattern color=cyan] fill between [of=bb1 and bb1i];
\addplot[pattern=north east lines, pattern color=green] fill between [of=bb2 and bb2i];
\addplot[-latex, thick] coordinates
{(0,0) (1/1.414,1/1.414)} node [pos=.3, anchor=south, label={45:{\small $\nabla z$}}] {};
\end{axis}
\end{tikzpicture}
\caption{Rappresentazione cartesiana dei due sottoproblemi di $P_0$.}
\label{fig:graph43}
\end{figure}
Esploriamo ora il figlio $P_1$ del problema $P_0$, corrispondente al vincolo $x_1\geq\left\lceil x^*_1 \right\rceil = 5$.
\begin{figure}[ht!]
\centering
\begin{tikzpicture}[edge from parent/.style={draw=black,-latex},
level/.style={sibling distance=50mm, level distance=20mm},
cross/.style={path picture={
\draw[black]
(path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}}
]
\node [circle, draw, label=east:{$L_B=-8$}] (z) {$P_0$}
child {node [circle, draw] (a) {$P_1$}
edge from parent node[left] {$x_1\geq 5$}
}
;
\end{tikzpicture}
\end{figure}
In \textit{forma standard} il vincolo può essere così espresso:
$$
-x_1 + s = -5
$$
In questa formula risulta molto agevole l'introduzione nel tableau iniziale di $P_0$ (tabella \vref{tab:tab411}) come in tabella \vref{tab:tab414}.
\begin{table}[htbp]
\centering
{
\newcommand{\sm}{$\frac{7}{2}$}
\newcommand{\nm}{$\frac{9}{2}$}
\newcommand{\um}{$\frac{1}{2}$}
\newcommand{\mum}{$-\frac{1}{2}$}
\newcommand{\tm}{$\frac{3}{2}$}
\begin{tabular}{rrccccccc}
& &$-\varphi$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $s$\\
$R_0$ & $\OL{c_j}$ & \Sc{8} & 0 & 0 & 1 & 0 & \Sc{0}& 0\\
\cline{3-9}
$R_1$ & $x_2$ & \Sc{\sm} & 0 & 1 & \um & \um & \Sc{0}& 0 \\
$R_2$ & $x_1$ & \Sc{\nm} & 1 & 0 & \um & \mum & \Sc{0}& 0 \\
$R_3$ & $x_5$ & \Sc{\tm} & 0 & 0 & \mum & \um & \Sc{1}& 0 \\
\cline{3-8}
$R_4$ & $s$ & \Sc{-5} & -1 & 0 & 0 & 0 & 0 & 1
\end{tabular}
}
\caption{Sottoproblema $P_1$.}
\label{tab:tab414}
\end{table}
Poiché $y_{41}=-5$ rovina la nostra matrice identità in base, operiamo la seguente operazione elementare di riga:
$$
R_4\leftarrow R_4 + R_2
$$
Si giunge quindi al tableau in tabella \vref{tab:tab415}.
\begin{table}[htbp]
\centering
{
\newcommand{\sm}{$\frac{7}{2}$}
\newcommand{\nm}{$\frac{9}{2}$}
\newcommand{\um}{$\frac{1}{2}$}
\newcommand{\mum}{$-\frac{1}{2}$}
\newcommand{\tm}{$\frac{3}{2}$}
\begin{tabular}{rrccccccc}
& &$-\varphi$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $s$\\
$R_0$ & $\OL{c_j}$ & \Sc{8} & 0 & 0 & 1 & 0 & \Sc{0}& 0\\
\cline{3-9}
$R_1$ & $x_2$ & \Sc{\sm} & 0 & 1 & \um & \um & \Sc{0}& 0 \\
$R_2$ & $x_1$ & \Sc{\nm} & 1 & 0 & \um & \mum & \Sc{0}& 0 \\
$R_3$ & $x_5$ & \Sc{\tm} & 0 & 0 & \mum & \um & \Sc{1}& 0 \\
\cline{3-8}
$R_4$ & $s$ & \Sc{\mum} & 0 & 0 & \um &\C{\mum}& 0 & 1
\end{tabular}
}
\caption{Sottoproblema $P_1$, secondo tableau.}
\label{tab:tab415}
\end{table}
Si può ora procedere con il simplesso duale. L'unico elemento di $R_4$ negativo sul quale è possibile fare pivoting è $y_{44}$. Le operazioni elementari di riga sono, nell'ordine:
\begin{align*}
R_1&\leftarrow R_1 + R_4 \\
R_2&\leftarrow R_2 - R_4 \\
R_3&\leftarrow R_3 + R_4 \\
R_4&\leftarrow -2R_4
\end{align*}
Ne risulta il tableau in tabella \vref{tab:tab416}.
\begin{table}
\centering
{
\newcommand{\sm}{$\frac{7}{2}$}
\newcommand{\nm}{$\frac{9}{2}$}
\newcommand{\um}{$\frac{1}{2}$}
\newcommand{\mum}{$-\frac{1}{2}$}
\newcommand{\tm}{$\frac{3}{2}$}
\begin{tabular}{rrccccccc}
& &$-\varphi$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $s$\\
$R_0$ & $\OL{c_j}$ & \Sc{8} & 0 & 0 & 1 & 0 & \Sc{0}& 0\\
\cline{3-9}
$R_1$ & $x_2$ & \Sc{3} & 0 & 1 & 0 & 0 & \Sc{0}& 1 \\
$R_2$ & $x_1$ & \Sc{5} & 1 & 0 & 0 & 0 & \Sc{0}& -1 \\
$R_3$ & $x_5$ & \Sc{1} & 0 & 0 & 0 & 0 & \Sc{1}& 1 \\
\cline{3-8}
$R_4$ & $x_4$ & \Sc{1} & 0 & 0 & -1 & 1 & 0 & -2
\end{tabular}
}
\caption{Siamo in una soluzione intera nel vertice $\varepsilon(5,3)$.}
\label{tab:tab416}
\end{table}
La nuova base e la nuova soluzione sono:
\begin{align*}
\mathcal{B}&={A_2,A_1,A_5,A_4} \\
x&=(5,3,0,1,1)
\end{align*}
La soluzione è intera ed il ramo attuale dell'albero è giunto ad una foglia.
\begin{figure}[ht!]
\centering
\begin{tikzpicture}[edge from parent/.style={draw=black,-latex},
level/.style={sibling distance=50mm, level distance=20mm},
cross/.style={path picture={
\draw[black]
(path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}}
]
\node [circle, draw, label=east:{$L_B=-8$}] (z) {$P_0$}
child {node [circle, draw, label=east:{$L_B=-8$}, label=south:{$-z=-8$}] (a) {$P_1$}
edge from parent node[left] {$x_1\geq 5$}
}
;
\end{tikzpicture}
\end{figure}
Siamo fortunati perché l'attuale soluzione è uguale al lower bound del nodo \textit{root}, il che significa che non serve cercare altre soluzioni che potrebbero essere al più uguali a quella trovata. Ne conviene infine che il vertice $\varepsilon(5,3)$ è una soluzione ottima del problema ILP. Il valore della soluzione è:
$$
z(\varepsilon)=-\varphi=8
$$
\section{Esercizio 7}
In questa sezione riprenderemo da dove eravamo rimasti in \vref{sec:es7ILP}, risolvendo il problema ILP prima con il metodo dei \textbf{tagli di Gomory} e poi con il metodo \textbf{branch and bound} (il secondo in realtà non è richiesto dalla traccia, ma lo proveremo ugualmente come utile esercitazione).
\subsection{ILP - Tagli di Gomory}
Riportiamo in tabella \vref{tab:tab711} il tableau finale del problema LP.
\begin{table}[htbp]
\centering
{
\newcommand{\uq}{$\frac{1}{4}$}
\newcommand{\tq}{$\frac{3}{4}$}
\newcommand{\qq}{$\frac{15}{4}$}
\newcommand{\nq}{$\frac{9}{4}$}
\newcommand{\muq}{$-\frac{1}{4}$}
\newcommand{\mtq}{$-\frac{2}{4}$}
\newcommand{\mqq}{$-\frac{15}{4}$}
\newcommand{\ttq}{$\frac{33}{4}$}
\begin{tabular}{rrcccccc}
& &$-\varphi$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ \\
$R_0$ & $\OL{c_j}$ & \Sc{\ttq} & 0 & 0 & 0 & \qq & \Sc{\uq} \\
\cline{3-8}
$R_1$ & $x_3$ & \Sc{\nq} & 0 & 0 & 1 & \tq & \Sc{\uq} \\
$R_2$ & $x_2$ & \Sc{3} & 0 & 1 & 0 & 1 & \Sc{0} \\
$R_3$ & $x_1$ & \Sc{\tq} & 1 & 0 & 0 & \mtq & \Sc{\muq} \\
\end{tabular}
}
\caption{Tableau finale del problema LP. Rappresenta il rilassamento continuo del problema ILP.}
\label{tab:tab711}
\end{table}
Le righe $R_0$, $R_1$ ed $R_3$ sono valide candidate per un taglio di Gomory, scegliamo quindi la prima disponibile, cioè $R_0$. Il taglio sarà:
$$
\sum_{j\in\{4,5\}} f_{0j}x_j \geq f_{00} \Rightarrow \frac{3}{4}x_4+\frac{1}{4}x_5\geq\frac{1}{4}
$$
Trasformiamolo ora in una forma algebricamente adatta al nostro tableau:
$$
-\frac{3}{4}x_4-\frac{1}{4}x_5+s=-\frac{1}{4}
$$
Aggiungendo questo vincolo si ottiene il tableau in tabella \vref{tab:tab712}.
\begin{table}[htbp]
\centering
{
\newcommand{\uq}{$\frac{1}{4}$}
\newcommand{\tq}{$\frac{3}{4}$}
\newcommand{\qq}{$\frac{15}{4}$}
\newcommand{\nq}{$\frac{9}{4}$}
\newcommand{\muq}{$-\frac{1}{4}$}
\newcommand{\mtq}{$-\frac{2}{4}$}
\newcommand{\mqq}{$-\frac{15}{4}$}
\newcommand{\ttq}{$\frac{33}{4}$}
\begin{tabular}{rrccccccc}
& &$-\varphi$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $s$\\
$R_0$ & $\OL{c_j}$ & \Sc{\ttq} & 0 & 0 & 0 & \qq & \Sc{\uq} & 0 \\
\cline{3-9}
$R_1$ & $x_3$ & \Sc{\nq} & 0 & 0 & 1 & \tq & \Sc{\uq} & 0 \\
$R_2$ & $x_2$ & \Sc{3} & 0 & 1 & 0 & 1 & \Sc{0} & 0 \\
$R_3$ & $x_1$ & \Sc{\tq} & 1 & 0 & 0 & \mtq & \Sc{\muq} & 0 \\
\cline{3-8}
$R_4$ & $s$ & \Sc{\muq} & 0 & 0 & 0 & \mtq & \C{\muq} & 1 \\
\end{tabular}
}
\caption{Applicazione del primo taglio di Gomory.}
\label{tab:tab712}
\end{table}
La soluzione attuale rispetto il criterio di ottimalità ma non è ammissibile poiché $s<0$. Il simplesso duale ci porterà in una nuova base ottima e infine anche ammissibile.
Sceglieremo l'elemento di pivoting $y_{is}$ tale che:
$$
\vartheta=\max_{j>0:y_{ij}<0}\left(\frac{y_{0j}}{y_{ij}}\right)=\frac{y_{0s}}{y_{is}}
$$
Nel nostro caso:
$$
\vartheta=\max\left(\frac{\frac{15}{4}}{-\frac{3}{4}},\frac{\frac{1}{4}}{-\frac{1}{5}}\right)=\max(-5,-1)=-1=\frac{y_{05}}{\pmb{y_{45}}}
$$
Faremo pivoting sull'elemento $y_{45}$, cerchiato in tabella \vref{tab:tab712}. Attuiamo le operazioni elementari di riga:
\begin{align*}
R_0&\leftarrow R_0 + R_4 \\
R_1&\leftarrow R_1 + R_4 \\
R_3&\leftarrow R_3 - R_4 \\
R_4&\leftarrow -4R_4
\end{align*}
Il tableau che segue è quello in tabella \vref{tab:tab713}.
\begin{table}[htbp]
\centering
\begin{tabular}{rrccccccc}
& &$-\varphi$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $s$\\
$R_0$ & $\OL{c_j}$ & \Sc{8} & 0 & 0 & 0 & 3 & \Sc{0} & 1 \\
\cline{3-9}
$R_1$ & $x_3$ & \Sc{2} & 0 & 0 & 1 & 0 & \Sc{0} & 1 \\
$R_2$ & $x_2$ & \Sc{3} & 0 & 1 & 0 & 1 & \Sc{0} & 0 \\
$R_3$ & $x_1$ & \Sc{1} & 1 & 0 & 0 & 0 & \Sc{0} & -1 \\
\cline{3-8}
$R_4$ & $x_5$ & \Sc{1} & 0 & 0 & 0 & 3 & 1 & -4 \\
\end{tabular}
\caption{Secondo tableau. Soluzione ottima e intera al vertice $\delta(1,3)$.}
\label{tab:tab713}
\end{table}
La soluzione del nuovo problema LP è ottima e intera, quindi è anche la soluzione del problema ILP. La nuova base, la nuova soluzione e il suo valore sono:
\begin{align*}
\mathcal{B}&=\{A_3,A_2,A_1,A_5\} \\
x&=(1,3,2,0,1) \\
z(\delta)&=-\varphi=8
\end{align*}
\subsubsection{Rappresentazione grafica}
Rappresentiamo il taglio di Gomory in funzione delle variabili $x_1$ e $x_2$ ricavandole dai vincoli espressi all'inizio:
$$
\begin{cases}
x_2+x_4=3 \\
4x_1+3x_2-x_5=12
\end{cases}
\Rightarrow
\begin{cases}
x_4=3-x_2 \\
x_5=-12+4x_1+3x_2
\end{cases}
$$
Sostituiamo queste espressioni nel taglio di Gomory espresso sotto forma di disequazione:
$$
\frac{3}{4}x_4+\frac{1}{4}x_5\geq\frac{1}{4}\Rightarrow 3(3-x_2)+(-12+4x_1+3x_2)\geq 1 \Rightarrow x_1\geq 1
$$
In figura \vref{fig:graph71} è rappresentato il problema dopo il taglio.
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\begin{axis}
[axis lines=middle, axis equal, enlargelimits, xlabel=$x_1$, ylabel=$x_2$,
every axis x label/.style={
at={(ticklabel* cs:1.01)},
anchor=west,
},
every axis y label/.style={
at={(ticklabel* cs:1.01)},
anchor=south,
},%xtick={1,2,3}
]
\path[name path=AX]
(axis cs:\pgfkeysvalueof{/pgfplots/xmin},0)--
(axis cs:\pgfkeysvalueof{/pgfplots/xmax},0);
\path[name path=AY]
(axis cs:0,\pgfkeysvalueof{/pgfplots/ymin})--
(axis cs:0,\pgfkeysvalueof{/pgfplots/ymax});
\path[name path=UP]
(axis cs:\pgfkeysvalueof{/pgfplots/xmin},\pgfkeysvalueof{/pgfplots/ymax})--
(axis cs:\pgfkeysvalueof{/pgfplots/xmax},\pgfkeysvalueof{/pgfplots/ymax});
\dotgrid{0}{4}{0}{4}{black!50}
\addplot
[domain=0:4, samples=10, thick, blue, name path=x3] (3,x);
\addplot
[domain=0:4, samples=10, thick, red, name path=y3] {3};
\addplot
[domain=0:3, samples=10, thick, green, name path=4x3y12] {-(4/3)*x + 4};
\addplot
[domain=0:4, samples=10, thick, purple, name path=gomory]
(1,x) node [pos=0.8, anchor=west, pin={75:{\color{purple}$x_1\geq 1$}}, inner sep= 0pt] {};
\path[name path=GOM]
(axis cs:1.25,0)--(axis cs:1.25,4);
\addplot[thick, fill=yellow, fill opacity=0.5] fill between [of=4x3y12 and UP, soft clip={domain=0:3}];
\addplot[white] fill between [of=y3 and UP];
\addplot[white] fill between [of=gomory and AY];
\addplot[pattern=north east lines, pattern color=purple] fill between [of=gomory and GOM];
\intne{x3}{AX}{$\alpha$}{alp};
\intsw{y3}{4x3y12}{$\beta$}{bet};
\intne{y3}{x3}{$\gamma$}{gam};
\intsw{gomory}{y3}{$\delta$}{del};
\node at (axis cs:2.5,2) {$P_1$};
\addplot[-latex, thick] coordinates
{(0,0) (-1/3.16,3/3.16)} node [pos=.3, anchor=north, label={135:{\small $\nabla z$}}] {};
\end{axis}
\end{tikzpicture}
\caption{Rappresentazione cartesiana del problema di programmazione lineare dopo il taglio di Gomory}
\label{fig:graph71}
\end{figure}
In giallo è rappresentato il nuovo politopo $P'$ risultato del vecchio politopo $P$ e del taglio di Gomory applicato.
\subsection{ILP - Branch and bound}
Il problema di LP iniziale verrà denominato $P_0$. La soluzione del rilassamento continuo $x^*=\left(\frac{3}{4},3\right)$ è $-z^*=-\frac{33}{4}$, il che imposterà il nostro lower bound a $L_B=\left\lceil -\frac{33}{4} \right\rceil = -8$.
\begin{figure}[ht!]
\centering
\begin{tikzpicture}[edge from parent/.style={draw=black,-latex},
level/.style={sibling distance=50mm, level distance=20mm},
cross/.style={path picture={
\draw[black]
(path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}}
]
\node [circle, draw, label=east:{$L_B=-8$}] (z) {$P_0$}
;
\end{tikzpicture}
\end{figure}
Iniziando dalla variabile $x_1$ possiamo prendere in considerazione due diversi sottoproblemi derivati dall'aggiunta di uno dei due seguenti vincoli (si noti che non avrebbe senso iniziare dalla variabile $x_2$, che è già intera):
\begin{align*}
x_1&\geq\left\lceil x^*_1 \right\rceil &\Rightarrow x_1&\geq 1\\
x_1&\leq\left\lfloor x^*_1 \right\rfloor &\Rightarrow x_1&\leq 0
\end{align*}
Per convincerci che considerando questi due vincoli non si esclude nessuna soluzione e che sono mutuamente esclusivi, si faccia riferimento al grafico \vref{fig:graph43} e osservando che le due aree colorate in ciano e in verde non escludono nessuno dei punti interi.
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\begin{axis}
[axis lines=middle, axis equal, enlargelimits, xlabel=$x_1$, ylabel=$x_2$,
every axis x label/.style={
at={(ticklabel* cs:1.01)},
anchor=west,
},
every axis y label/.style={
at={(ticklabel* cs:1.01)},
anchor=south,
},%xtick={-2,-1,0,1,2,3}
]
\path[name path=AX]
(axis cs:\pgfkeysvalueof{/pgfplots/xmin},0)--
(axis cs:\pgfkeysvalueof{/pgfplots/xmax},0);
\path[name path=AY]
(axis cs:0,\pgfkeysvalueof{/pgfplots/ymin})--
(axis cs:0,\pgfkeysvalueof{/pgfplots/ymax});
\path[name path=UP]
(axis cs:\pgfkeysvalueof{/pgfplots/xmin},\pgfkeysvalueof{/pgfplots/ymax})--
(axis cs:\pgfkeysvalueof{/pgfplots/xmax},\pgfkeysvalueof{/pgfplots/ymax});
\dotgrid{0}{4}{0}{4}{black!50}
\addplot
[domain=-2:-1, samples=2, white, name path=enlarge] {2};
\addplot
[domain=0:4, samples=10, thick, blue, name path=x3] (3,x);
\addplot
[domain=0:4, samples=10, thick, red, name path=y3] {3};
\addplot
[domain=0:3, samples=10, thick, green, name path=4x3y12] {-(4/3)*x + 4};
\addplot
[domain=0:4, samples=10, thick, cyan, name path=gomory]
(1,x) node [pos=0.8, anchor=west, pin={75:{\color{cyan}$x_1\geq 1$}}, inner sep= 0pt] {};
\path[name path=GOM]
(axis cs:1.25,0)--(axis cs:1.25,4);
\addplot
[domain=0:4, samples=10, thick, purple, name path=bb]
(0,x) node [pos=0.8, anchor=east, pin={135:{\color{purple}$x_1\leq 0$}}, inner sep= 0pt] {}
;
\path [name path=BBi]
(axis cs:-0.25,0)--(axis cs:-0.25,4);
\addplot[thick, fill=cyan, fill opacity=0.5] fill between [of=4x3y12 and UP, soft clip={domain=0:3}];
\addplot[white] fill between [of=y3 and UP];
\addplot[white] fill between [of=gomory and AY];
\addplot[pattern=north east lines, pattern color=cyan] fill between [of=gomory and GOM];
\addplot[pattern=north east lines, pattern color=purple] fill between [of=bb and BBi];
\intne{x3}{AX}{$\alpha$}{alp};
\intsw{y3}{4x3y12}{$\beta$}{bet};
\intne{y3}{x3}{$\gamma$}{gam};
\intsw{gomory}{y3}{$\delta$}{del};
\node at (axis cs:2.5,2) {$P'$};
\node at (axis cs:-2,2) {};
\addplot[-latex, thick] coordinates
{(0,0) (-1/3.16,3/3.16)} node [pos=.3, anchor=north, label={135:{\small $\nabla z$}}] {};
\end{axis}
\end{tikzpicture}
\caption{Rappresentazione cartesiana dei sottoproblemi di $P_0$.}
\label{fig:graph72}
\end{figure}
Inizieremo, come di consueto, ad esplorare il ramo con la disequazione di maggioranza ma si noti dal grafico come l'altro ramo porterebbe evidentemente ad un nulla di fatto in quanto l'area di regione ammissibile sarebbe vuota.
\begin{figure}[ht!]
\centering
\begin{tikzpicture}[edge from parent/.style={draw=black,-latex},
level/.style={sibling distance=50mm, level distance=20mm},
cross/.style={path picture={
\draw[black]
(path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}}
]
\node [circle, draw, label=east:{$L_B=-8$}] (z) {$P_0$}
child {node [circle, draw] (a) {$P_1$}
edge from parent node[left] {$x_1\geq 1$}
}
;
\end{tikzpicture}
\end{figure}
\textbf{N.B.}: il taglio che applicheremo sarà lo stesso che abbiamo applicato in precedenza con i tagli di Gomory.
Il taglio applicato nel problema $P_1$ può essere così espresso in forma standard:
$$
-x_1+s=-1
$$
Lo introduciamo nel tableau in tabella \vref{tab:tab711} ottenendo quello in tabella \vref{tab:tab714}.
\begin{table}[htbp]
\centering
{
\newcommand{\uq}{$\frac{1}{4}$}
\newcommand{\tq}{$\frac{3}{4}$}
\newcommand{\qq}{$\frac{15}{4}$}
\newcommand{\nq}{$\frac{9}{4}$}
\newcommand{\muq}{$-\frac{1}{4}$}
\newcommand{\mtq}{$-\frac{2}{4}$}
\newcommand{\mqq}{$-\frac{15}{4}$}
\newcommand{\ttq}{$\frac{33}{4}$}
\begin{tabular}{rrccccccc}
& &$-\varphi$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $s$\\
$R_0$ & $\OL{c_j}$ & \Sc{\ttq} & 0 & 0 & 0 & \qq & \Sc{\uq} & 0 \\
\cline{3-9}
$R_1$ & $x_3$ & \Sc{\nq} & 0 & 0 & 1 & \tq & \Sc{\uq} & 0 \\
$R_2$ & $x_2$ & \Sc{3} & 0 & 1 & 0 & 1 & \Sc{0} & 0 \\
$R_3$ & $x_1$ & \Sc{\tq} & 1 & 0 & 0 & \mtq & \Sc{\muq} & 0 \\
\cline{3-8}
$R_4$ & $s$ & \Sc{-1} & -1 & 0 & 0 & 0 & 0 & 1 \\
\end{tabular}
}
\caption{Sottoproblema $P_1$.}
\label{tab:tab714}
\end{table}
Per riottenere la sottomatrice identità dobbiamo rendere $y_{41}=0$, a tal fine operiamo:
$$
R_4\leftarrow R_4+R_3
$$
Otterremo così il tableau in tabella \vref{tab:tab715}.
\begin{table}[htbp]
\centering
{
\newcommand{\uq}{$\frac{1}{4}$}
\newcommand{\tq}{$\frac{3}{4}$}
\newcommand{\qq}{$\frac{15}{4}$}
\newcommand{\nq}{$\frac{9}{4}$}
\newcommand{\muq}{$-\frac{1}{4}$}
\newcommand{\mtq}{$-\frac{2}{4}$}
\newcommand{\mqq}{$-\frac{15}{4}$}
\newcommand{\ttq}{$\frac{33}{4}$}
\begin{tabular}{rrccccccc}
& &$-\varphi$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $s$\\
$R_0$ & $\OL{c_j}$ & \Sc{\ttq} & 0 & 0 & 0 & \qq & \Sc{\uq} & 0 \\
\cline{3-9}
$R_1$ & $x_3$ & \Sc{\nq} & 0 & 0 & 1 & \tq & \Sc{\uq} & 0 \\
$R_2$ & $x_2$ & \Sc{3} & 0 & 1 & 0 & 1 & \Sc{0} & 0 \\
$R_3$ & $x_1$ & \Sc{\tq} & 1 & 0 & 0 & \mtq & \Sc{\muq} & 0 \\
\cline{3-8}
$R_4$ & $s$ & \Sc{\muq} & 0 & 0 & 0 & \mtq & \C{\muq} & 1 \\
\end{tabular}
}
\caption{Sottoproblema $P_1$, secondo tableau.}
\label{tab:tab715}
\end{table}
Non è sorprendente che questo tableau è \textbf{identico a quello in tabella \vref{tab:tab712}}. Non ripeteremo i calcoli sul tableau che sarebbero identici a quelli del caso del taglio di Gomory. Riportiamo soltanto il risultato finale:
\begin{align*}
\mathcal{B}&=\{A_3,A_2,A_1,A_5\} \\
x&=(1,3,2,0,1) \\
z(\delta)&=-\varphi=8
\end{align*}
Il nostro ramo dell'albero è giunto a una foglia.
\begin{figure}[ht!]
\centering
\begin{tikzpicture}[edge from parent/.style={draw=black,-latex},
level/.style={sibling distance=50mm, level distance=20mm},
cross/.style={path picture={
\draw[black]
(path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);}}
]
\node [circle, draw, label=east:{$L_B=-8$}] (z) {$P_0$}
child {node [circle, draw, label=east:{$L_B=-8$}, label=south:{$-z=-8$}] (a) {$P_1$}
edge from parent node[left] {$x_1\geq 1$}
}
;
\end{tikzpicture}
\end{figure}
Siamo fortunati perché l'attuale soluzione è uguale al lower bound del nodo \textit{root}, il che significa che non serve cercare altre soluzioni che potrebbero essere al più uguali a quella trovata. Ne conviene infine che il vertice $\delta(1,3)$ è una soluzione ottima del problema ILP. Il valore della soluzione è:
$$
z(\delta)=-\varphi=8
$$
\section{Esercizio 1}
Riprenderemo l'esercizio in \vref{sec:es1ILP}. Segue la parte di traccia che richiede come affrontare il problema ILP:
\begin{enumerate}
\item Risolvere con l'algoritmo branch-and-bound, scegliendo per il branching la variabile frazionaria di indice massimo ed esplorando per primo il nodo corrispondente alla condizione $x_j\leq\alpha$.
\end{enumerate}
Durante l'esercitazione in classe il tutor ha esplorato invece per prima la \textit{variabile di indice minimo}, concludendo l'esercizio in tempo record. Noi esploreremo come da traccia: l'esercizio sarà più lungo ma forse didatticamente più utile.
In ogni caso, come sempre, proveremo anche a utilizzare i tagli di Gomory.
\subsection{ILP - Tagli di Gomory}
Riportiamo in tabella \vref{tab:tab11} il tableau finale del problema LP.
\begin{table}[htbp]
\centering
{
\newcommand{\tm}{$\frac{13}{2}$}
\newcommand{\cm}{$\frac{5}{2}$}
\newcommand{\um}{$\frac{1}{2}$}
\newcommand{\mum}{$-\frac{1}{2}$}
\begin{tabular}{rrcccccc}
& & $-\varphi$ & $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ \\
$R_0$ & $\OL{c_j}$ & \Sc{\tm} & 0 & 0 & \um & 1 & 0 \\
\cline{3-8}
%\hline
$R_1$ & $x_1$ & \Sc{\cm} & 1 & 0 & \um & -1 & 0 \\
$R_2$ & $x_2$ & \Sc{2} & 0 & 1 & 0 & 1 & 0 \\
$R_3$ & $x_5$ & \Sc{\um} & 0 & 0 & \mum & 2 & 1 \\
\end{tabular}
}
\caption{Tableau finale del problema di LP.}
\label{tab:tab11}
\end{table}
Applichiamo quindi il taglio di Gomory sulla riga $R_0$, cioè la prima disponibile:
$$
\sum_{j\in\{3,4\}} f_{0j}x_j\geq f_{00} \Rightarrow \frac{1}{2}x_3+0x_4\geq\frac{1}{2}
$$
Trasformiamolo in una forma algebricamente più consona:
$$
-\frac{1}{2}x_3+s=-\frac{1}{2}
$$
Aggiungendo questo vincolo si ottiene il tableau in tabella \vref{tab:tab12}.
\begin{table}[htbp]
\centering
{
\newcommand{\tm}{$\frac{13}{2}$}
\newcommand{\cm}{$\frac{5}{2}$}
\newcommand{\um}{$\frac{1}{2}$}
\newcommand{\mum}{$-\frac{1}{2}$}
\begin{tabular}{rrccccccc}
& & $-\varphi$& $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $s$ \\
$R_0$ & $\OL{c_j}$ & \Sc{\tm} & 0 & 0 & \um & 1 & \Sc{0}& 0 \\
\cline{3-9}
$R_1$ & $x_1$ & \Sc{\cm} & 1 & 0 & \um & -1 & \Sc{0}& 0 \\
$R_2$ & $x_2$ & \Sc{2} & 0 & 1 & 0 & 1 & \Sc{0}& 0 \\
$R_3$ & $x_5$ & \Sc{\um} & 0 & 0 & \mum & 2 & \Sc{1}& 0 \\
\cline{3-8}
$R_4$ & $s$ & \Sc{\mum} & 0 & 0 &\C{\mum}& 0 & 0 & 1
\end{tabular}
}
\caption{Applicazione del primo taglio di Gomory.}
\label{tab:tab12}
\end{table}
L'unico elemento su cui è possibile fare pivoting è $y_{43}$ (cerchiato in tabella \vref{tab:tab12}). Procediamo con le operazioni elementari di riga (in ordine):
\begin{align*}
R_0&\leftarrow R_0 + R_4 \\
R_1&\leftarrow R_1 + R_4 \\
R_3&\leftarrow R_3 - R_4 \\
R_4&\leftarrow -2R_4
\end{align*}
Il tableau che otteniamo è quello in tabella \vref{tab:tab13}.
\begin{table}[htbp]
\centering
\begin{tabular}{rrccccccc}
& & $-\varphi$& $x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $s$ \\
$R_0$ & $\OL{c_j}$ & \Sc{6} & 0 & 0 & 0 & 1 & \Sc{0}& 1 \\
\cline{3-9}
$R_1$ & $x_1$ & \Sc{2} & 1 & 0 & 0 & -1 & \Sc{0}& 1 \\
$R_2$ & $x_2$ & \Sc{2} & 0 & 1 & 0 & 1 & \Sc{0}& 0 \\
$R_3$ & $x_5$ & \Sc{1} & 0 & 0 & 0 & 2 & \Sc{1}& -1 \\
\cline{3-8}
$R_4$ & $x_3$ & \Sc{1} & 0 & 0 & 1 & 0 & 0 & -2
\end{tabular}
\caption{Simplesso duale dopo il taglio di Gomory. Soluzione ottima e intera al vertice $\zeta(2,2)$.}
\label{tab:tab13}
\end{table}
La soluzione del nuovo problema LP è ottima e intera e quindi anche la soluzione ottima del problema ILP. I nuovi valori di base, soluzione e suo valore sono:
\begin{align*}
\mathcal{B}&=\{A_1,A_2,A_5,A_4\} \\
x&=(2,2,1,0,1) \\
z(\zeta)&=-\varphi=6
\end{align*}
\subsubsection{Rappresentazione grafica}
Rappresentiamo il taglio di Gomory in funzione delle variabili $x_1$ e $x_2$, ricavandole dal vincolo del problema iniziale:
$$
2x_1+2x_2+x_3=9\Rightarrow x_3=9-2x_1-2x_2
$$
Sostituiamo nel taglio di Gomory in forma di disequazione:
$$
\frac{1}{2}x_3\geq\frac{1}{2}\Rightarrow 9-2x_1-2x_2 \geq 1 \Rightarrow x_1+x_2 \leq 4
$$
In figura \vref{fig:graph11} è rappresentato il problema dopo il taglio. In giallo è rappresentato il politopo $P'$ risultato del vecchio politopo $P$ e del taglio di Gomory applicato.
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
\begin{axis}
[axis lines=middle, axis equal, enlargelimits, xlabel=$x_1$, ylabel=$x_2$,
every axis x label/.style={
at={(ticklabel* cs:1.01)},
anchor=west,
},
every axis y label/.style={
at={(ticklabel* cs:1.01)},
anchor=south,
},]
\path[name path=AX]
(axis cs:\pgfkeysvalueof{/pgfplots/xmin},0)--
(axis cs:\pgfkeysvalueof{/pgfplots/xmax},0);
\path[name path=AY]
(axis cs:0,\pgfkeysvalueof{/pgfplots/ymin})--
(axis cs:0,\pgfkeysvalueof{/pgfplots/ymax});
\path[name path=UP]
(axis cs:\pgfkeysvalueof{/pgfplots/xmin},\pgfkeysvalueof{/pgfplots/ymax})--
(axis cs:\pgfkeysvalueof{/pgfplots/xmax},\pgfkeysvalueof{/pgfplots/ymax});
\dotgrid{0}{5}{0}{4}{black!50}
\addplot [domain=0:4.5, samples=10, thick, blue, name path=2x2y9] {-x+(9/2)};
\addplot [domain=1:5, samples=10, thick, red, name path=yx-1] {x-1};
\addplot [domain=0:5, samples = 10, thick, purple, name path=y2] {2};
\addplot [domain=0:4, samples = 10, thick, green, name path=gomory] {-x+4}
node [pos=0.2, anchor=west, pin={75:{\color{green}$x_1+x_2\leq 4$}}, inner sep= 0pt] {};
\path[name path=GOM]
(axis cs:0,3.75)--(axis cs:3.75,0);
\addplot[thick, fill=yellow, fill opacity=0.5] fill between [of=2x2y9 and AX, soft clip={domain=0:11/4},];
\addplot[white] fill between [of=2x2y9 and y2];
\addplot[white] fill between [of=gomory and UP];
\addplot[white] fill between [of=yx-1 and AX];
\addplot[pattern=horizontal lines, pattern color=green] fill between [of=gomory and GOM];
\intse{AX}{AY}{$\alpha$}{alp};
\intse{AY}{y2}{$\beta$}{bet};
\intne{y2}{2x2y9}{$\gamma$}{gam};
\inte{2x2y9}{yx-1}{$\delta$}{del};
\intn{yx-1}{AX}{$\varepsilon$}{eps};
\intnw{gomory}{y2}{$\zeta$}{zet};
\node at (axis cs:1,1) {$P'$};
\addplot[-latex, thick] coordinates
{(0,0) (1/2.24,2/2.24)} node [pos=1, anchor=north, label={90:{\small $\nabla z$}}] {};
\end{axis}
\end{tikzpicture}
\caption{Rappresentazione cartesiana del problema di programmazione lineare intera.}
\label{fig:graph11}
\end{figure}
\subsection{ILP - Branch and bound}
\textbf{Premessa:} i calcoli li ho fatti io autonomamente, sono molto macchinosi ma \textit{credo} di averli fatti bene. In ogni caso, data la laboriosità di questa parte di esercizio, fate attenzione e se trovate errori, non esitate a inviarmi correzioni (o a fare una \textit{push request} su \textit{GitHub} al repository: \href{https://github.com/slaierno/OpResearch}{https://github.com/slaierno/OpResearch}).
La sezione sarà suddivisa in sottosezioni per comodità, ognuna riguardante un sottoproblema diverso.
\subsubsection{$\pmb{P_0}$}
Il problema $P_0$ sarà quello con cui indicheremo il problema LP iniziale. La sua soluzione è anche la soluzione del rilassamento continuo del problema ILP:
\begin{align*}
x^*=\left(\frac{5}{2},2\right) \\
-z^*=\frac{13}{2}
\end{align*}
Il rilassamento continuo imposterà il nostro \textit{lower bound} di partenza:
$$
L_B = \left\lceil -z^* \right\rceil = \left\lceil \frac{13}{2} \right\rceil = -6
$$
\begin{figure}[ht!]
\centering
\begin{tikzpicture}[edge from parent/.style={draw=black,-latex},
level/.style={sibling distance=50mm, level distance=20mm},
cross/.style={path picture={