@@ -647,32 +647,35 @@ Integer Linear Programming is a universal modeling framework: virtually every NP
647647
648648 # figure (
649649 canvas (length : 0.8cm , {
650+ import draw : *
650651 // Lattice points: B*(x1,x2) = x1*(2,0) + x2*(1,2)
651652 for x1 in range (0 , 3 ) {
652653 for x2 in range (0 , 3 ) {
653654 let px = x1 * 2 + x2 * 1
654655 let py = x2 * 2
655656 let is-closest = (x1 == 1 and x2 == 1 )
656- draw . circle (
657+ let nm = " p" + str (x1 ) + str (x2 )
658+ circle (
657659 (px , py ),
658660 radius : if is-closest { 0.15 } else { 0.08 },
659661 fill : if is-closest { graph-colors . at (0 ) } else { luma (180 ) },
660662 stroke : if is-closest { 0.8pt + graph-colors . at (0 ) } else { 0.4pt + luma (120 ) },
663+ name : nm ,
661664 )
662665 }
663666 }
664667 // Target vector
665- draw . circle ((2.8 , 1.5 ), radius : 0.1 , fill : graph-colors . at (1 ), stroke : none )
666- draw . content ((2.8 , 1.05 ), text (7pt )[$ bold (t)$ ])
668+ circle ((2.8 , 1.5 ), radius : 0.1 , fill : graph-colors . at (1 ), stroke : none , name : " target " )
669+ content ((rel : ( 0 , - 0.45 ), to : " target " ), text (7pt )[$ bold (t)$ ])
667670 // Dashed line from target to closest point
668- draw . line (( 2.8 , 1.5 ), ( 3 , 2 ), stroke : stroke (paint : graph-colors . at (0 ), thickness : 0.8pt , dash : " dashed" ))
671+ line (" target " , " p11 " , stroke : (paint : graph-colors . at (0 ), thickness : 0.8pt , dash : " dashed" ))
669672 // Basis vectors as arrows from origin
670- draw . line (( 0 , 0 ), ( 2 , 0 ), mark : (end : " > " ), stroke : 0.8pt + luma (100 ))
671- draw . content ((1. 0 , - 0.35 ), text (7pt )[$ bold (b)_1$ ])
672- draw . line (( 0 , 0 ), ( 1 , 2 ), mark : (end : " > " ), stroke : 0.8pt + luma (100 ))
673- draw . content ((0.2 , 1.1 ), text (7pt )[$ bold (b)_2$ ])
673+ line (" p00 " , " p10 " , mark : (end : " straight " ), stroke : 0.8pt + luma (100 ), name : " b1 " )
674+ content ((rel : ( 0 , - 0.35 ), to : " b1.mid " ), text (7pt )[$ bold (b)_1$ ])
675+ line (" p00 " , " p01 " , mark : (end : " straight " ), stroke : 0.8pt + luma (100 ), name : " b2 " )
676+ content ((rel : ( - 0.3 , 0 ), to : " b2.mid " ), text (7pt )[$ bold (b)_2$ ])
674677 // Label closest point
675- draw . content ((3 .45 , 2.3 ), text (7pt )[$ bold (B)(1,1)^top $ ])
678+ content ((rel : ( 0 .45 , 0.3 ), to : " p11 " ), text (7pt )[$ bold (B)(1,1)^top $ ])
676679 }),
677680 caption : [2D lattice with basis $ bold (b)_1 = (2, 0)^top $ , $ bold (b)_2 = (1, 2)^top $ . Target $ bold (t) = (2.8, 1.5)^top $ (red) and closest lattice point $ bold (B)(1,1)^top = (3, 2)^top $ (blue). Distance $ norm (bold (B)(1,1)^top - bold (t))_2 approx 0.539$ .],
678681 ) <fig:cvp-example>
0 commit comments