[{"data":1,"prerenderedAt":7694},["ShallowReactive",2],{"dev-uc-gate-assignment":3},{"id":4,"title":5,"body":6,"description":7685,"extension":7686,"faq":7687,"meta":7688,"navigation":134,"noindex":7689,"path":7690,"seo":7691,"stem":7692,"__hash__":7693},"content\u002Fuse-cases\u002Fgate-assignment.md","Gate assignment for a connection bank",{"type":7,"value":8,"toc":7675},"minimark",[9,18,25,28,31,34,39,42,101,105,108,111,751,756,759,763,782,789,1256,1259,1262,1266,1280,1283,1571,1574,1577,1581,1602,1618,1621,1631,1929,1932,1947,1954,2146,2149,2152,2156,2159,3030,3033,3038,3041,3178,3181,3184,3188,3424,3799,4094,4489,4659,5243,6145,6148,6465,6468,6580,6587,6590,7357,7360,7363,7370,7374,7377,7654,7657,7660,7671],[10,11,12,13,17],"p",{},"At a hub airport, flights arrive and leave in waves, so that passengers can change from one flight to another. One such wave is called a ",[14,15,16],"em",{},"connection bank",": a group of flights that are on the ground at the same time. Each of them stands at a gate, and a connecting passenger walks from the gate of the arriving flight to the gate of the departing one. You decide which flight stands at which gate, and with that, how far your passengers walk.",[10,19,20],{},[21,22],"img",{"alt":23,"src":24},"A terminal with two piers that branch off a spine. Each pier has 12 pairs of gates that face each other. The gates are numbered 0 to 47, pier by pier, from the spine outwards. Two walks are drawn. The first stays within a pier, from gate 14 to gate 21, and is 240 m long. The second leads to the other pier by way of the spine, from gate 5 to gate 30, and is 720 m long.","\u002Fuse-cases\u002Fgate-assignment\u002Fgate-assignment.svg",[10,26,27],{},"This decision cannot be taken one flight at a time. The total walking is a sum over pairs of flights: the passengers who change from one flight to the other, times the distance between the two gates. The best gate for a flight therefore depends on where its partner flights stand. Operations research knows this as the quadratic assignment problem.",[10,29,30],{},"In this notebook, a bank of 48 flights shares a terminal of 48 gates. If the flights take the gates in timetable order, a connecting passenger walks 700 m on average. Quicopt returns a plan with 305 m in about a second. For comparison, we write the same decision as a mixed-integer linear program (MILP) and give it to HiGHS, an open-source solver, for 30 seconds. After those 30 seconds, HiGHS holds a plan with 643 m, and the most it can prove is that the walking is not negative.",[10,32,33],{},"The number of flights and the number of departures that each arrival connects to are set in one cell, so you can run every step on a bank of your own size.",[35,36,38],"h2",{"id":37},"parameters","Parameters",[10,40,41],{},"Three numbers describe the experiment. Every cell below reads them, so you can change them in this one cell and run the notebook again.",[43,44,49],"pre",{"className":45,"code":46,"language":47,"meta":48,"style":48},"language-python shiki shiki-themes github-dark","flights = 48               # flights in the bank; the terminal has one gate for each\npartner_departures = 4     # departures that the passengers of one arrival connect to\ntime_limit = 30            # seconds that each solver may take\n","python","",[50,51,52,73,87],"code",{"__ignoreMap":48},[53,54,57,61,65,69],"span",{"class":55,"line":56},"line",1,[53,58,60],{"class":59},"s95oV","flights ",[53,62,64],{"class":63},"snl16","=",[53,66,68],{"class":67},"sDLfK"," 48",[53,70,72],{"class":71},"sAwPA","               # flights in the bank; the terminal has one gate for each\n",[53,74,76,79,81,84],{"class":55,"line":75},2,[53,77,78],{"class":59},"partner_departures ",[53,80,64],{"class":63},[53,82,83],{"class":67}," 4",[53,85,86],{"class":71},"     # departures that the passengers of one arrival connect to\n",[53,88,90,93,95,98],{"class":55,"line":89},3,[53,91,92],{"class":59},"time_limit ",[53,94,64],{"class":63},[53,96,97],{"class":67}," 30",[53,99,100],{"class":71},"            # seconds that each solver may take\n",[35,102,104],{"id":103},"the-terminal","The terminal",[10,106,107],{},"The terminal has one gate for every flight of the bank. Its piers branch off a straight spine, 150 m apart. Each pier has 24 gates in 12 pairs that face each other. The first pair lies 60 m from the spine, and each further pair lies 70 m further out. The gates are numbered pier by pier, from the spine outwards, as in the picture above.",[10,109,110],{},"A walk within one pier is the distance along the pier plus 30 m. A walk to another pier leads in to the spine, along the spine and out again, and changing piers adds 100 m.",[43,112,114],{"className":45,"code":113,"language":47,"meta":48,"style":48},"import numpy as np\n\nGATES_PER_PIER = 24\n\n\ndef gate_positions(gates):\n    \"\"\"The pier of every gate, and how far out along its pier the gate lies.\n\n    Args:\n        gates: Number of gates. They fill one pier after the other.\n\n    Returns:\n        Two arrays with one entry per gate: the number of its pier, and the\n        metres from the spine along the pier to the gate.\n    \"\"\"\n    gate = np.arange(gates)\n    pier = gate \u002F\u002F GATES_PER_PIER\n    along_pier = 60.0 + 70.0 * ((gate % GATES_PER_PIER) \u002F\u002F 2)\n    return pier, along_pier\n\n\ndef walking_distances(gates):\n    \"\"\"Metres that a passenger walks between every two gates.\n\n    Args:\n        gates: Number of gates.\n\n    Returns:\n        Square array: entry [g, h] is the walk from gate g to gate h.\n    \"\"\"\n    pier, along_pier = gate_positions(gates)\n    same_pier = pier[:, None] == pier[None, :]                   # [g, h]: are gates g and h on one pier?\n    within_pier = np.abs(along_pier[:, None] - along_pier[None, :]) + 30.0\n    along_spine = 150.0 * np.abs(pier[:, None] - pier[None, :])\n    to_other_pier = along_pier[:, None] + along_spine + along_pier[None, :] + 100.0\n    distance = np.where(same_pier, within_pier, to_other_pier)\n    np.fill_diagonal(distance, 0.0)\n    return distance\n\n\ndistance = walking_distances(flights)\npier, along_pier = gate_positions(flights)\n\nprint(f\"gates: {flights}, piers: {pier.max() + 1}\")\nfor g, h in [(0, 1), (14, 21), (5, 30)]:\n    if h \u003C flights:\n        print(f\"from gate {g:2} to gate {h:2}: {distance[g, h]:5.0f} m\")\nprint(f\"longest walk between two gates: {distance.max():,.0f} m\")\n",[50,115,116,130,136,147,152,157,170,177,182,188,194,199,205,211,217,223,234,251,291,300,305,310,320,326,331,336,342,347,352,358,363,374,405,437,466,500,511,522,530,535,540,551,562,567,609,657,672,725],{"__ignoreMap":48},[53,117,118,121,124,127],{"class":55,"line":56},[53,119,120],{"class":63},"import",[53,122,123],{"class":59}," numpy ",[53,125,126],{"class":63},"as",[53,128,129],{"class":59}," np\n",[53,131,132],{"class":55,"line":75},[53,133,135],{"emptyLinePlaceholder":134},true,"\n",[53,137,138,141,144],{"class":55,"line":89},[53,139,140],{"class":67},"GATES_PER_PIER",[53,142,143],{"class":63}," =",[53,145,146],{"class":67}," 24\n",[53,148,150],{"class":55,"line":149},4,[53,151,135],{"emptyLinePlaceholder":134},[53,153,155],{"class":55,"line":154},5,[53,156,135],{"emptyLinePlaceholder":134},[53,158,160,163,167],{"class":55,"line":159},6,[53,161,162],{"class":63},"def",[53,164,166],{"class":165},"svObZ"," gate_positions",[53,168,169],{"class":59},"(gates):\n",[53,171,173],{"class":55,"line":172},7,[53,174,176],{"class":175},"sU2Wk","    \"\"\"The pier of every gate, and how far out along its pier the gate lies.\n",[53,178,180],{"class":55,"line":179},8,[53,181,135],{"emptyLinePlaceholder":134},[53,183,185],{"class":55,"line":184},9,[53,186,187],{"class":175},"    Args:\n",[53,189,191],{"class":55,"line":190},10,[53,192,193],{"class":175},"        gates: Number of gates. They fill one pier after the other.\n",[53,195,197],{"class":55,"line":196},11,[53,198,135],{"emptyLinePlaceholder":134},[53,200,202],{"class":55,"line":201},12,[53,203,204],{"class":175},"    Returns:\n",[53,206,208],{"class":55,"line":207},13,[53,209,210],{"class":175},"        Two arrays with one entry per gate: the number of its pier, and the\n",[53,212,214],{"class":55,"line":213},14,[53,215,216],{"class":175},"        metres from the spine along the pier to the gate.\n",[53,218,220],{"class":55,"line":219},15,[53,221,222],{"class":175},"    \"\"\"\n",[53,224,226,229,231],{"class":55,"line":225},16,[53,227,228],{"class":59},"    gate ",[53,230,64],{"class":63},[53,232,233],{"class":59}," np.arange(gates)\n",[53,235,237,240,242,245,248],{"class":55,"line":236},17,[53,238,239],{"class":59},"    pier ",[53,241,64],{"class":63},[53,243,244],{"class":59}," gate ",[53,246,247],{"class":63},"\u002F\u002F",[53,249,250],{"class":67}," GATES_PER_PIER\n",[53,252,254,257,259,262,265,268,271,274,277,280,283,285,288],{"class":55,"line":253},18,[53,255,256],{"class":59},"    along_pier ",[53,258,64],{"class":63},[53,260,261],{"class":67}," 60.0",[53,263,264],{"class":63}," +",[53,266,267],{"class":67}," 70.0",[53,269,270],{"class":63}," *",[53,272,273],{"class":59}," ((gate ",[53,275,276],{"class":63},"%",[53,278,279],{"class":67}," GATES_PER_PIER",[53,281,282],{"class":59},") ",[53,284,247],{"class":63},[53,286,287],{"class":67}," 2",[53,289,290],{"class":59},")\n",[53,292,294,297],{"class":55,"line":293},19,[53,295,296],{"class":63},"    return",[53,298,299],{"class":59}," pier, along_pier\n",[53,301,303],{"class":55,"line":302},20,[53,304,135],{"emptyLinePlaceholder":134},[53,306,308],{"class":55,"line":307},21,[53,309,135],{"emptyLinePlaceholder":134},[53,311,313,315,318],{"class":55,"line":312},22,[53,314,162],{"class":63},[53,316,317],{"class":165}," walking_distances",[53,319,169],{"class":59},[53,321,323],{"class":55,"line":322},23,[53,324,325],{"class":175},"    \"\"\"Metres that a passenger walks between every two gates.\n",[53,327,329],{"class":55,"line":328},24,[53,330,135],{"emptyLinePlaceholder":134},[53,332,334],{"class":55,"line":333},25,[53,335,187],{"class":175},[53,337,339],{"class":55,"line":338},26,[53,340,341],{"class":175},"        gates: Number of gates.\n",[53,343,345],{"class":55,"line":344},27,[53,346,135],{"emptyLinePlaceholder":134},[53,348,350],{"class":55,"line":349},28,[53,351,204],{"class":175},[53,353,355],{"class":55,"line":354},29,[53,356,357],{"class":175},"        Square array: entry [g, h] is the walk from gate g to gate h.\n",[53,359,361],{"class":55,"line":360},30,[53,362,222],{"class":175},[53,364,366,369,371],{"class":55,"line":365},31,[53,367,368],{"class":59},"    pier, along_pier ",[53,370,64],{"class":63},[53,372,373],{"class":59}," gate_positions(gates)\n",[53,375,377,380,382,385,388,391,394,397,399,402],{"class":55,"line":376},32,[53,378,379],{"class":59},"    same_pier ",[53,381,64],{"class":63},[53,383,384],{"class":59}," pier[:, ",[53,386,387],{"class":67},"None",[53,389,390],{"class":59},"] ",[53,392,393],{"class":63},"==",[53,395,396],{"class":59}," pier[",[53,398,387],{"class":67},[53,400,401],{"class":59},", :]                   ",[53,403,404],{"class":71},"# [g, h]: are gates g and h on one pier?\n",[53,406,408,411,413,416,418,420,423,426,428,431,434],{"class":55,"line":407},33,[53,409,410],{"class":59},"    within_pier ",[53,412,64],{"class":63},[53,414,415],{"class":59}," np.abs(along_pier[:, ",[53,417,387],{"class":67},[53,419,390],{"class":59},[53,421,422],{"class":63},"-",[53,424,425],{"class":59}," along_pier[",[53,427,387],{"class":67},[53,429,430],{"class":59},", :]) ",[53,432,433],{"class":63},"+",[53,435,436],{"class":67}," 30.0\n",[53,438,440,443,445,448,450,453,455,457,459,461,463],{"class":55,"line":439},34,[53,441,442],{"class":59},"    along_spine ",[53,444,64],{"class":63},[53,446,447],{"class":67}," 150.0",[53,449,270],{"class":63},[53,451,452],{"class":59}," np.abs(pier[:, ",[53,454,387],{"class":67},[53,456,390],{"class":59},[53,458,422],{"class":63},[53,460,396],{"class":59},[53,462,387],{"class":67},[53,464,465],{"class":59},", :])\n",[53,467,469,472,474,477,479,481,483,486,488,490,492,495,497],{"class":55,"line":468},35,[53,470,471],{"class":59},"    to_other_pier ",[53,473,64],{"class":63},[53,475,476],{"class":59}," along_pier[:, ",[53,478,387],{"class":67},[53,480,390],{"class":59},[53,482,433],{"class":63},[53,484,485],{"class":59}," along_spine ",[53,487,433],{"class":63},[53,489,425],{"class":59},[53,491,387],{"class":67},[53,493,494],{"class":59},", :] ",[53,496,433],{"class":63},[53,498,499],{"class":67}," 100.0\n",[53,501,503,506,508],{"class":55,"line":502},36,[53,504,505],{"class":59},"    distance ",[53,507,64],{"class":63},[53,509,510],{"class":59}," np.where(same_pier, within_pier, to_other_pier)\n",[53,512,514,517,520],{"class":55,"line":513},37,[53,515,516],{"class":59},"    np.fill_diagonal(distance, ",[53,518,519],{"class":67},"0.0",[53,521,290],{"class":59},[53,523,525,527],{"class":55,"line":524},38,[53,526,296],{"class":63},[53,528,529],{"class":59}," distance\n",[53,531,533],{"class":55,"line":532},39,[53,534,135],{"emptyLinePlaceholder":134},[53,536,538],{"class":55,"line":537},40,[53,539,135],{"emptyLinePlaceholder":134},[53,541,543,546,548],{"class":55,"line":542},41,[53,544,545],{"class":59},"distance ",[53,547,64],{"class":63},[53,549,550],{"class":59}," walking_distances(flights)\n",[53,552,554,557,559],{"class":55,"line":553},42,[53,555,556],{"class":59},"pier, along_pier ",[53,558,64],{"class":63},[53,560,561],{"class":59}," gate_positions(flights)\n",[53,563,565],{"class":55,"line":564},43,[53,566,135],{"emptyLinePlaceholder":134},[53,568,570,573,576,579,582,585,588,591,594,596,599,601,604,607],{"class":55,"line":569},44,[53,571,572],{"class":67},"print",[53,574,575],{"class":59},"(",[53,577,578],{"class":63},"f",[53,580,581],{"class":175},"\"gates: ",[53,583,584],{"class":67},"{",[53,586,587],{"class":59},"flights",[53,589,590],{"class":67},"}",[53,592,593],{"class":175},", piers: ",[53,595,584],{"class":67},[53,597,598],{"class":59},"pier.max() ",[53,600,433],{"class":63},[53,602,603],{"class":67}," 1}",[53,605,606],{"class":175},"\"",[53,608,290],{"class":59},[53,610,612,615,618,621,624,627,630,633,636,639,641,644,646,649,651,654],{"class":55,"line":611},45,[53,613,614],{"class":63},"for",[53,616,617],{"class":59}," g, h ",[53,619,620],{"class":63},"in",[53,622,623],{"class":59}," [(",[53,625,626],{"class":67},"0",[53,628,629],{"class":59},", ",[53,631,632],{"class":67},"1",[53,634,635],{"class":59},"), (",[53,637,638],{"class":67},"14",[53,640,629],{"class":59},[53,642,643],{"class":67},"21",[53,645,635],{"class":59},[53,647,648],{"class":67},"5",[53,650,629],{"class":59},[53,652,653],{"class":67},"30",[53,655,656],{"class":59},")]:\n",[53,658,660,663,666,669],{"class":55,"line":659},46,[53,661,662],{"class":63},"    if",[53,664,665],{"class":59}," h ",[53,667,668],{"class":63},"\u003C",[53,670,671],{"class":59}," flights:\n",[53,673,675,678,680,682,685,687,690,693,695,698,700,703,705,707,710,712,715,718,720,723],{"class":55,"line":674},47,[53,676,677],{"class":67},"        print",[53,679,575],{"class":59},[53,681,578],{"class":63},[53,683,684],{"class":175},"\"from gate ",[53,686,584],{"class":67},[53,688,689],{"class":59},"g",[53,691,692],{"class":63},":2",[53,694,590],{"class":67},[53,696,697],{"class":175}," to gate ",[53,699,584],{"class":67},[53,701,702],{"class":59},"h",[53,704,692],{"class":63},[53,706,590],{"class":67},[53,708,709],{"class":175},": ",[53,711,584],{"class":67},[53,713,714],{"class":59},"distance[g, h]",[53,716,717],{"class":63},":5.0f",[53,719,590],{"class":67},[53,721,722],{"class":175}," m\"",[53,724,290],{"class":59},[53,726,728,730,732,734,737,739,742,745,747,749],{"class":55,"line":727},48,[53,729,572],{"class":67},[53,731,575],{"class":59},[53,733,578],{"class":63},[53,735,736],{"class":175},"\"longest walk between two gates: ",[53,738,584],{"class":67},[53,740,741],{"class":59},"distance.max()",[53,743,744],{"class":63},":,.0f",[53,746,590],{"class":67},[53,748,722],{"class":175},[53,750,290],{"class":59},[752,753],"cell-output",{":lines":754,"label":755},"[\"gates: 48, piers: 2\",\"from gate  0 to gate  1:    30 m\",\"from gate 14 to gate 21:   240 m\",\"from gate  5 to gate 30:   720 m\",\"longest walk between two gates: 1,910 m\"]","Output",[10,757,758],{},"Gates 0 and 1 face each other. Gates 14 and 21 lie on the same pier, and gates 5 and 30 on different piers. The picture above shows these two walks.",[35,760,762],{"id":761},"the-connecting-passengers","The connecting passengers",[10,764,765,766,769,770,773,774,777,778,781],{},"Every flight of the bank lands, stands at its gate and takes off again. Some of its arriving passengers leave on another flight of the bank. The array entry ",[50,767,768],{},"transfers[i, j]"," counts the passengers who arrive on flight ",[50,771,772],{},"i"," and leave on flight ",[50,775,776],{},"j",". A pair of flights with at least one such passenger is a ",[14,779,780],{},"connection",".",[10,783,784,785,788],{},"We draw the passengers at random from a fixed seed, so you can reproduce every number on this page. The first third of the flights are long-haul flights, which bring 150 to 250 connecting passengers each. The others are short-haul flights and bring 30 to 80. The passengers of one arrival spread unevenly over ",[50,786,787],{},"partner_departures"," other flights.",[43,790,792],{"className":45,"code":791,"language":47,"meta":48,"style":48},"def transfer_passengers(flights, partner_departures, seed=0):\n    \"\"\"Connecting passengers between the flights of a bank, drawn at random.\n\n    Args:\n        flights: Number of flights in the bank.\n        partner_departures: Number of other flights over which the passengers\n            of one arrival spread.\n        seed: Seed of the random numbers. The same seed gives the same bank.\n\n    Returns:\n        Square array: entry [i, j] is the number of passengers who arrive on\n        flight i and leave on flight j.\n    \"\"\"\n    rng = np.random.default_rng(seed)\n    long_haul = np.arange(flights) \u003C flights \u002F\u002F 3\n    transfers = np.zeros((flights, flights))\n    for arrival in range(flights):\n        connecting = rng.uniform(150, 250) if long_haul[arrival] else rng.uniform(30, 80)\n        other_flights = [flight for flight in range(flights) if flight != arrival]\n        partners = rng.choice(other_flights, partner_departures, replace=False)\n        share = rng.lognormal(0, 1, partner_departures)          # uneven shares of the passengers\n        transfers[arrival, partners] = np.round(connecting * share \u002F share.sum())\n    return transfers\n\n\ntransfers = transfer_passengers(flights, partner_departures)\npassengers = transfers.sum()                       # all connecting passengers of the bank\narrival, departure = np.nonzero(transfers)         # connection k leads from flight arrival[k] to flight departure[k]\nlargest_first = np.argsort(-transfers[arrival, departure], kind=\"stable\")     # the connections, largest first\n\nprint(f\"{passengers:,.0f} connecting passengers on {len(arrival)} connections\")\nprint(\"the five largest connections:\")\nfor k in largest_first[:5]:\n    print(f\"  from flight {arrival[k]:2} to flight {departure[k]:2}: {transfers[arrival[k], departure[k]]:3.0f} passengers\")\n",[50,793,794,811,816,820,824,829,834,839,844,848,852,857,862,866,876,896,906,922,962,994,1015,1037,1059,1066,1070,1074,1084,1097,1110,1139,1143,1178,1189,1206],{"__ignoreMap":48},[53,795,796,798,801,804,806,808],{"class":55,"line":56},[53,797,162],{"class":63},[53,799,800],{"class":165}," transfer_passengers",[53,802,803],{"class":59},"(flights, partner_departures, seed",[53,805,64],{"class":63},[53,807,626],{"class":67},[53,809,810],{"class":59},"):\n",[53,812,813],{"class":55,"line":75},[53,814,815],{"class":175},"    \"\"\"Connecting passengers between the flights of a bank, drawn at random.\n",[53,817,818],{"class":55,"line":89},[53,819,135],{"emptyLinePlaceholder":134},[53,821,822],{"class":55,"line":149},[53,823,187],{"class":175},[53,825,826],{"class":55,"line":154},[53,827,828],{"class":175},"        flights: Number of flights in the bank.\n",[53,830,831],{"class":55,"line":159},[53,832,833],{"class":175},"        partner_departures: Number of other flights over which the passengers\n",[53,835,836],{"class":55,"line":172},[53,837,838],{"class":175},"            of one arrival spread.\n",[53,840,841],{"class":55,"line":179},[53,842,843],{"class":175},"        seed: Seed of the random numbers. The same seed gives the same bank.\n",[53,845,846],{"class":55,"line":184},[53,847,135],{"emptyLinePlaceholder":134},[53,849,850],{"class":55,"line":190},[53,851,204],{"class":175},[53,853,854],{"class":55,"line":196},[53,855,856],{"class":175},"        Square array: entry [i, j] is the number of passengers who arrive on\n",[53,858,859],{"class":55,"line":201},[53,860,861],{"class":175},"        flight i and leave on flight j.\n",[53,863,864],{"class":55,"line":207},[53,865,222],{"class":175},[53,867,868,871,873],{"class":55,"line":213},[53,869,870],{"class":59},"    rng ",[53,872,64],{"class":63},[53,874,875],{"class":59}," np.random.default_rng(seed)\n",[53,877,878,881,883,886,888,891,893],{"class":55,"line":219},[53,879,880],{"class":59},"    long_haul ",[53,882,64],{"class":63},[53,884,885],{"class":59}," np.arange(flights) ",[53,887,668],{"class":63},[53,889,890],{"class":59}," flights ",[53,892,247],{"class":63},[53,894,895],{"class":67}," 3\n",[53,897,898,901,903],{"class":55,"line":225},[53,899,900],{"class":59},"    transfers ",[53,902,64],{"class":63},[53,904,905],{"class":59}," np.zeros((flights, flights))\n",[53,907,908,911,914,916,919],{"class":55,"line":236},[53,909,910],{"class":63},"    for",[53,912,913],{"class":59}," arrival ",[53,915,620],{"class":63},[53,917,918],{"class":67}," range",[53,920,921],{"class":59},"(flights):\n",[53,923,924,927,929,932,935,937,940,942,945,948,951,953,955,957,960],{"class":55,"line":253},[53,925,926],{"class":59},"        connecting ",[53,928,64],{"class":63},[53,930,931],{"class":59}," rng.uniform(",[53,933,934],{"class":67},"150",[53,936,629],{"class":59},[53,938,939],{"class":67},"250",[53,941,282],{"class":59},[53,943,944],{"class":63},"if",[53,946,947],{"class":59}," long_haul[arrival] ",[53,949,950],{"class":63},"else",[53,952,931],{"class":59},[53,954,653],{"class":67},[53,956,629],{"class":59},[53,958,959],{"class":67},"80",[53,961,290],{"class":59},[53,963,964,967,969,972,974,977,979,981,984,986,988,991],{"class":55,"line":293},[53,965,966],{"class":59},"        other_flights ",[53,968,64],{"class":63},[53,970,971],{"class":59}," [flight ",[53,973,614],{"class":63},[53,975,976],{"class":59}," flight ",[53,978,620],{"class":63},[53,980,918],{"class":67},[53,982,983],{"class":59},"(flights) ",[53,985,944],{"class":63},[53,987,976],{"class":59},[53,989,990],{"class":63},"!=",[53,992,993],{"class":59}," arrival]\n",[53,995,996,999,1001,1004,1008,1010,1013],{"class":55,"line":302},[53,997,998],{"class":59},"        partners ",[53,1000,64],{"class":63},[53,1002,1003],{"class":59}," rng.choice(other_flights, partner_departures, ",[53,1005,1007],{"class":1006},"s9osk","replace",[53,1009,64],{"class":63},[53,1011,1012],{"class":67},"False",[53,1014,290],{"class":59},[53,1016,1017,1020,1022,1025,1027,1029,1031,1034],{"class":55,"line":307},[53,1018,1019],{"class":59},"        share ",[53,1021,64],{"class":63},[53,1023,1024],{"class":59}," rng.lognormal(",[53,1026,626],{"class":67},[53,1028,629],{"class":59},[53,1030,632],{"class":67},[53,1032,1033],{"class":59},", partner_departures)          ",[53,1035,1036],{"class":71},"# uneven shares of the passengers\n",[53,1038,1039,1042,1044,1047,1050,1053,1056],{"class":55,"line":312},[53,1040,1041],{"class":59},"        transfers[arrival, partners] ",[53,1043,64],{"class":63},[53,1045,1046],{"class":59}," np.round(connecting ",[53,1048,1049],{"class":63},"*",[53,1051,1052],{"class":59}," share ",[53,1054,1055],{"class":63},"\u002F",[53,1057,1058],{"class":59}," share.sum())\n",[53,1060,1061,1063],{"class":55,"line":322},[53,1062,296],{"class":63},[53,1064,1065],{"class":59}," transfers\n",[53,1067,1068],{"class":55,"line":328},[53,1069,135],{"emptyLinePlaceholder":134},[53,1071,1072],{"class":55,"line":333},[53,1073,135],{"emptyLinePlaceholder":134},[53,1075,1076,1079,1081],{"class":55,"line":338},[53,1077,1078],{"class":59},"transfers ",[53,1080,64],{"class":63},[53,1082,1083],{"class":59}," transfer_passengers(flights, partner_departures)\n",[53,1085,1086,1089,1091,1094],{"class":55,"line":344},[53,1087,1088],{"class":59},"passengers ",[53,1090,64],{"class":63},[53,1092,1093],{"class":59}," transfers.sum()                       ",[53,1095,1096],{"class":71},"# all connecting passengers of the bank\n",[53,1098,1099,1102,1104,1107],{"class":55,"line":349},[53,1100,1101],{"class":59},"arrival, departure ",[53,1103,64],{"class":63},[53,1105,1106],{"class":59}," np.nonzero(transfers)         ",[53,1108,1109],{"class":71},"# connection k leads from flight arrival[k] to flight departure[k]\n",[53,1111,1112,1115,1117,1120,1122,1125,1128,1130,1133,1136],{"class":55,"line":354},[53,1113,1114],{"class":59},"largest_first ",[53,1116,64],{"class":63},[53,1118,1119],{"class":59}," np.argsort(",[53,1121,422],{"class":63},[53,1123,1124],{"class":59},"transfers[arrival, departure], ",[53,1126,1127],{"class":1006},"kind",[53,1129,64],{"class":63},[53,1131,1132],{"class":175},"\"stable\"",[53,1134,1135],{"class":59},")     ",[53,1137,1138],{"class":71},"# the connections, largest first\n",[53,1140,1141],{"class":55,"line":360},[53,1142,135],{"emptyLinePlaceholder":134},[53,1144,1145,1147,1149,1151,1153,1155,1158,1160,1162,1165,1168,1171,1173,1176],{"class":55,"line":365},[53,1146,572],{"class":67},[53,1148,575],{"class":59},[53,1150,578],{"class":63},[53,1152,606],{"class":175},[53,1154,584],{"class":67},[53,1156,1157],{"class":59},"passengers",[53,1159,744],{"class":63},[53,1161,590],{"class":67},[53,1163,1164],{"class":175}," connecting passengers on ",[53,1166,1167],{"class":67},"{len",[53,1169,1170],{"class":59},"(arrival)",[53,1172,590],{"class":67},[53,1174,1175],{"class":175}," connections\"",[53,1177,290],{"class":59},[53,1179,1180,1182,1184,1187],{"class":55,"line":376},[53,1181,572],{"class":67},[53,1183,575],{"class":59},[53,1185,1186],{"class":175},"\"the five largest connections:\"",[53,1188,290],{"class":59},[53,1190,1191,1193,1196,1198,1201,1203],{"class":55,"line":407},[53,1192,614],{"class":63},[53,1194,1195],{"class":59}," k ",[53,1197,620],{"class":63},[53,1199,1200],{"class":59}," largest_first[:",[53,1202,648],{"class":67},[53,1204,1205],{"class":59},"]:\n",[53,1207,1208,1211,1213,1215,1218,1220,1223,1225,1227,1230,1232,1235,1237,1239,1241,1243,1246,1249,1251,1254],{"class":55,"line":439},[53,1209,1210],{"class":67},"    print",[53,1212,575],{"class":59},[53,1214,578],{"class":63},[53,1216,1217],{"class":175},"\"  from flight ",[53,1219,584],{"class":67},[53,1221,1222],{"class":59},"arrival[k]",[53,1224,692],{"class":63},[53,1226,590],{"class":67},[53,1228,1229],{"class":175}," to flight ",[53,1231,584],{"class":67},[53,1233,1234],{"class":59},"departure[k]",[53,1236,692],{"class":63},[53,1238,590],{"class":67},[53,1240,709],{"class":175},[53,1242,584],{"class":67},[53,1244,1245],{"class":59},"transfers[arrival[k], departure[k]]",[53,1247,1248],{"class":63},":3.0f",[53,1250,590],{"class":67},[53,1252,1253],{"class":175}," passengers\"",[53,1255,290],{"class":59},[752,1257],{":lines":1258,"label":755},"[\"4,976 connecting passengers on 191 connections\",\"the five largest connections:\",\"  from flight 10 to flight  5: 175 passengers\",\"  from flight  8 to flight 29: 154 passengers\",\"  from flight  3 to flight 46: 114 passengers\",\"  from flight  0 to flight 15:  96 passengers\",\"  from flight  2 to flight  4:  92 passengers\"]",[10,1260,1261],{},"With 48 arrivals and 4 partner departures each, 192 pairs of flights are drawn. One of them receives a share that rounds to no passenger, so the bank has 191 connections.",[35,1263,1265],{"id":1264},"the-walking-of-a-gate-plan","The walking of a gate plan",[10,1267,1268,1269,1272,1273,1276,1277,1279],{},"A gate plan gives every flight its gate. We write it as an array ",[50,1270,1271],{},"plan",", in which ",[50,1274,1275],{},"plan[i]"," is the gate of flight ",[50,1278,772],{},". Its total walking is the sum over all connections of the passengers times the metres between the two gates.",[10,1281,1282],{},"Two kinds of plan need no optimization. In timetable order, flight 0 stands at gate 0, flight 1 at gate 1, and so on. A random plan shuffles the flights over the gates. We draw 1,000 random plans.",[43,1284,1286],{"className":45,"code":1285,"language":47,"meta":48,"style":48},"def walking(plan, transfers, distance):\n    \"\"\"Total metres that the connecting passengers walk under a gate plan.\n\n    Args:\n        plan: Array with the gate of every flight: plan[i] is the gate of flight i.\n        transfers: Passengers between the flights, as transfer_passengers returns them.\n        distance: Metres between the gates, as walking_distances returns them.\n\n    Returns:\n        The sum over all connections of passengers times metres.\n    \"\"\"\n    between_flights = distance[plan][:, plan]      # [i, j]: metres between the gates of flights i and j\n    return float((transfers * between_flights).sum())\n\n\ndef show(label, metres):\n    \"\"\"Print the total walking of a plan and the average walk of a connecting passenger.\n\n    Args:\n        label: Name of the plan.\n        metres: Its total walking in metres.\n    \"\"\"\n    print(f\"{label:30} {metres:12,.0f} m in total  {metres \u002F passengers:6.0f} m per passenger\")\n\n\ntimetable_order = np.arange(flights)               # flight i stands at gate i\nrng = np.random.default_rng(1)                     # the seed of the random plans\nwalking_of_random_plans = [walking(rng.permutation(flights), transfers, distance) for _ in range(1000)]\n\nshow(\"timetable order\", walking(timetable_order, transfers, distance))\nshow(\"1,000 random plans, average\", np.mean(walking_of_random_plans))\nshow(\"1,000 random plans, best\", np.min(walking_of_random_plans))\n",[50,1287,1288,1298,1303,1307,1311,1316,1321,1326,1330,1334,1339,1343,1356,1371,1375,1379,1389,1394,1398,1402,1407,1412,1416,1470,1474,1478,1491,1509,1536,1540,1551,1561],{"__ignoreMap":48},[53,1289,1290,1292,1295],{"class":55,"line":56},[53,1291,162],{"class":63},[53,1293,1294],{"class":165}," walking",[53,1296,1297],{"class":59},"(plan, transfers, distance):\n",[53,1299,1300],{"class":55,"line":75},[53,1301,1302],{"class":175},"    \"\"\"Total metres that the connecting passengers walk under a gate plan.\n",[53,1304,1305],{"class":55,"line":89},[53,1306,135],{"emptyLinePlaceholder":134},[53,1308,1309],{"class":55,"line":149},[53,1310,187],{"class":175},[53,1312,1313],{"class":55,"line":154},[53,1314,1315],{"class":175},"        plan: Array with the gate of every flight: plan[i] is the gate of flight i.\n",[53,1317,1318],{"class":55,"line":159},[53,1319,1320],{"class":175},"        transfers: Passengers between the flights, as transfer_passengers returns them.\n",[53,1322,1323],{"class":55,"line":172},[53,1324,1325],{"class":175},"        distance: Metres between the gates, as walking_distances returns them.\n",[53,1327,1328],{"class":55,"line":179},[53,1329,135],{"emptyLinePlaceholder":134},[53,1331,1332],{"class":55,"line":184},[53,1333,204],{"class":175},[53,1335,1336],{"class":55,"line":190},[53,1337,1338],{"class":175},"        The sum over all connections of passengers times metres.\n",[53,1340,1341],{"class":55,"line":196},[53,1342,222],{"class":175},[53,1344,1345,1348,1350,1353],{"class":55,"line":201},[53,1346,1347],{"class":59},"    between_flights ",[53,1349,64],{"class":63},[53,1351,1352],{"class":59}," distance[plan][:, plan]      ",[53,1354,1355],{"class":71},"# [i, j]: metres between the gates of flights i and j\n",[53,1357,1358,1360,1363,1366,1368],{"class":55,"line":207},[53,1359,296],{"class":63},[53,1361,1362],{"class":67}," float",[53,1364,1365],{"class":59},"((transfers ",[53,1367,1049],{"class":63},[53,1369,1370],{"class":59}," between_flights).sum())\n",[53,1372,1373],{"class":55,"line":213},[53,1374,135],{"emptyLinePlaceholder":134},[53,1376,1377],{"class":55,"line":219},[53,1378,135],{"emptyLinePlaceholder":134},[53,1380,1381,1383,1386],{"class":55,"line":225},[53,1382,162],{"class":63},[53,1384,1385],{"class":165}," show",[53,1387,1388],{"class":59},"(label, metres):\n",[53,1390,1391],{"class":55,"line":236},[53,1392,1393],{"class":175},"    \"\"\"Print the total walking of a plan and the average walk of a connecting passenger.\n",[53,1395,1396],{"class":55,"line":253},[53,1397,135],{"emptyLinePlaceholder":134},[53,1399,1400],{"class":55,"line":293},[53,1401,187],{"class":175},[53,1403,1404],{"class":55,"line":302},[53,1405,1406],{"class":175},"        label: Name of the plan.\n",[53,1408,1409],{"class":55,"line":307},[53,1410,1411],{"class":175},"        metres: Its total walking in metres.\n",[53,1413,1414],{"class":55,"line":312},[53,1415,222],{"class":175},[53,1417,1418,1420,1422,1424,1426,1428,1431,1434,1436,1439,1442,1445,1447,1450,1452,1455,1457,1460,1463,1465,1468],{"class":55,"line":322},[53,1419,1210],{"class":67},[53,1421,575],{"class":59},[53,1423,578],{"class":63},[53,1425,606],{"class":175},[53,1427,584],{"class":67},[53,1429,1430],{"class":59},"label",[53,1432,1433],{"class":63},":30",[53,1435,590],{"class":67},[53,1437,1438],{"class":67}," {",[53,1440,1441],{"class":59},"metres",[53,1443,1444],{"class":63},":12,.0f",[53,1446,590],{"class":67},[53,1448,1449],{"class":175}," m in total  ",[53,1451,584],{"class":67},[53,1453,1454],{"class":59},"metres ",[53,1456,1055],{"class":63},[53,1458,1459],{"class":59}," passengers",[53,1461,1462],{"class":63},":6.0f",[53,1464,590],{"class":67},[53,1466,1467],{"class":175}," m per passenger\"",[53,1469,290],{"class":59},[53,1471,1472],{"class":55,"line":328},[53,1473,135],{"emptyLinePlaceholder":134},[53,1475,1476],{"class":55,"line":333},[53,1477,135],{"emptyLinePlaceholder":134},[53,1479,1480,1483,1485,1488],{"class":55,"line":338},[53,1481,1482],{"class":59},"timetable_order ",[53,1484,64],{"class":63},[53,1486,1487],{"class":59}," np.arange(flights)               ",[53,1489,1490],{"class":71},"# flight i stands at gate i\n",[53,1492,1493,1496,1498,1501,1503,1506],{"class":55,"line":344},[53,1494,1495],{"class":59},"rng ",[53,1497,64],{"class":63},[53,1499,1500],{"class":59}," np.random.default_rng(",[53,1502,632],{"class":67},[53,1504,1505],{"class":59},")                     ",[53,1507,1508],{"class":71},"# the seed of the random plans\n",[53,1510,1511,1514,1516,1519,1521,1524,1526,1528,1530,1533],{"class":55,"line":349},[53,1512,1513],{"class":59},"walking_of_random_plans ",[53,1515,64],{"class":63},[53,1517,1518],{"class":59}," [walking(rng.permutation(flights), transfers, distance) ",[53,1520,614],{"class":63},[53,1522,1523],{"class":59}," _ ",[53,1525,620],{"class":63},[53,1527,918],{"class":67},[53,1529,575],{"class":59},[53,1531,1532],{"class":67},"1000",[53,1534,1535],{"class":59},")]\n",[53,1537,1538],{"class":55,"line":354},[53,1539,135],{"emptyLinePlaceholder":134},[53,1541,1542,1545,1548],{"class":55,"line":360},[53,1543,1544],{"class":59},"show(",[53,1546,1547],{"class":175},"\"timetable order\"",[53,1549,1550],{"class":59},", walking(timetable_order, transfers, distance))\n",[53,1552,1553,1555,1558],{"class":55,"line":365},[53,1554,1544],{"class":59},[53,1556,1557],{"class":175},"\"1,000 random plans, average\"",[53,1559,1560],{"class":59},", np.mean(walking_of_random_plans))\n",[53,1562,1563,1565,1568],{"class":55,"line":376},[53,1564,1544],{"class":59},[53,1566,1567],{"class":175},"\"1,000 random plans, best\"",[53,1569,1570],{"class":59},", np.min(walking_of_random_plans))\n",[752,1572],{":lines":1573,"label":755},"[\"timetable order                   3,481,450 m in total     700 m per passenger\",\"1,000 random plans, average       3,678,339 m in total     739 m per passenger\",\"1,000 random plans, best          2,721,810 m in total     547 m per passenger\"]",[10,1575,1576],{},"In timetable order, a connecting passenger walks 700 m on average. Random plans need 739 m on average, and the best of the 1,000 needs 547 m.",[35,1578,1580],{"id":1579},"the-gate-plan-as-a-permutation","The gate plan as a permutation",[10,1582,1583,1584,1587,1588,1591,1592,1595,1596,1276,1599,1601],{},"A gate plan places 48 flights at 48 gates, one flight per gate. Such a placement is a permutation, and ",[50,1585,1586],{},"quicopt.structured.permutation"," declares one as the decision of a Pyomo model. A permutation in Quicopt places ",[14,1589,1590],{},"items"," in ",[14,1593,1594],{},"slots",". In this model the flights are the items and the gates are the slots, so ",[50,1597,1598],{},"gate.slot_of(i)",[50,1600,772],{},". Quicopt chooses these values, like decision variables.",[10,1603,1604,1605,1608,1609,1612,1613,1615,1616,781],{},"The walk between two flights depends on gates that are not chosen yet, and a NumPy array cannot be indexed by a decision. A ",[50,1606,1607],{},"lookup_table"," can: ",[50,1610,1611],{},"walk[gate.slot_of(i), gate.slot_of(j)]"," is the distance between the gates of flights ",[50,1614,772],{}," and ",[50,1617,776],{},[10,1619,1620],{},"The objective is then the sum from the previous section: for every connection, the passengers times the metres between the two gates. The model needs no constraints, because a permutation already gives every flight one gate and every gate one flight.",[10,1622,1623,1626,1627,1630],{},[50,1624,1625],{},"client.solve"," sends the model to the Quicopt service and returns its result. The service may take at most ",[50,1628,1629],{},"time_limit"," seconds.",[43,1632,1634],{"className":45,"code":1633,"language":47,"meta":48,"style":48},"import pyomo.environ as pyo\nfrom quicopt import Client\nfrom quicopt.structured import permutation, lookup_table\n\nclient = Client()                                      # the connection to the Quicopt service\n\n\ndef plan_with_quicopt(transfers, distance, time_limit):\n    \"\"\"Ask Quicopt for the gate plan with the least total walking.\n\n    Args:\n        transfers: Passengers between the flights.\n        distance: Metres between the gates.\n        time_limit: Seconds that the service may take.\n\n    Returns:\n        The service's result. Its structures[\"gate\"].slot_of lists the gate\n        of every flight.\n    \"\"\"\n    flights = len(transfers)\n    model = pyo.ConcreteModel()\n    walk = lookup_table(model, \"walk\", distance)       # walk[g, h]: metres between gates g and h\n    gate = permutation(model, \"gate\", flights)         # gate.slot_of(i): the gate of flight i\n    model.walking = pyo.Objective(sense=pyo.minimize, expr=sum(\n        float(transfers[i, j]) * walk[gate.slot_of(i), gate.slot_of(j)]\n        for i in range(flights) for j in range(flights) if transfers[i, j]))\n    return client.solve(model, time_limit=time_limit)\n\n\nresult = plan_with_quicopt(transfers, distance, time_limit)\nprint(result.display)\n",[50,1635,1636,1648,1661,1673,1677,1690,1694,1698,1708,1713,1717,1721,1726,1731,1736,1740,1744,1749,1754,1758,1771,1781,1800,1818,1847,1860,1890,1904,1908,1912,1922],{"__ignoreMap":48},[53,1637,1638,1640,1643,1645],{"class":55,"line":56},[53,1639,120],{"class":63},[53,1641,1642],{"class":59}," pyomo.environ ",[53,1644,126],{"class":63},[53,1646,1647],{"class":59}," pyo\n",[53,1649,1650,1653,1656,1658],{"class":55,"line":75},[53,1651,1652],{"class":63},"from",[53,1654,1655],{"class":59}," quicopt ",[53,1657,120],{"class":63},[53,1659,1660],{"class":59}," Client\n",[53,1662,1663,1665,1668,1670],{"class":55,"line":89},[53,1664,1652],{"class":63},[53,1666,1667],{"class":59}," quicopt.structured ",[53,1669,120],{"class":63},[53,1671,1672],{"class":59}," permutation, lookup_table\n",[53,1674,1675],{"class":55,"line":149},[53,1676,135],{"emptyLinePlaceholder":134},[53,1678,1679,1682,1684,1687],{"class":55,"line":154},[53,1680,1681],{"class":59},"client ",[53,1683,64],{"class":63},[53,1685,1686],{"class":59}," Client()                                      ",[53,1688,1689],{"class":71},"# the connection to the Quicopt service\n",[53,1691,1692],{"class":55,"line":159},[53,1693,135],{"emptyLinePlaceholder":134},[53,1695,1696],{"class":55,"line":172},[53,1697,135],{"emptyLinePlaceholder":134},[53,1699,1700,1702,1705],{"class":55,"line":179},[53,1701,162],{"class":63},[53,1703,1704],{"class":165}," plan_with_quicopt",[53,1706,1707],{"class":59},"(transfers, distance, time_limit):\n",[53,1709,1710],{"class":55,"line":184},[53,1711,1712],{"class":175},"    \"\"\"Ask Quicopt for the gate plan with the least total walking.\n",[53,1714,1715],{"class":55,"line":190},[53,1716,135],{"emptyLinePlaceholder":134},[53,1718,1719],{"class":55,"line":196},[53,1720,187],{"class":175},[53,1722,1723],{"class":55,"line":201},[53,1724,1725],{"class":175},"        transfers: Passengers between the flights.\n",[53,1727,1728],{"class":55,"line":207},[53,1729,1730],{"class":175},"        distance: Metres between the gates.\n",[53,1732,1733],{"class":55,"line":213},[53,1734,1735],{"class":175},"        time_limit: Seconds that the service may take.\n",[53,1737,1738],{"class":55,"line":219},[53,1739,135],{"emptyLinePlaceholder":134},[53,1741,1742],{"class":55,"line":225},[53,1743,204],{"class":175},[53,1745,1746],{"class":55,"line":236},[53,1747,1748],{"class":175},"        The service's result. Its structures[\"gate\"].slot_of lists the gate\n",[53,1750,1751],{"class":55,"line":253},[53,1752,1753],{"class":175},"        of every flight.\n",[53,1755,1756],{"class":55,"line":293},[53,1757,222],{"class":175},[53,1759,1760,1763,1765,1768],{"class":55,"line":302},[53,1761,1762],{"class":59},"    flights ",[53,1764,64],{"class":63},[53,1766,1767],{"class":67}," len",[53,1769,1770],{"class":59},"(transfers)\n",[53,1772,1773,1776,1778],{"class":55,"line":307},[53,1774,1775],{"class":59},"    model ",[53,1777,64],{"class":63},[53,1779,1780],{"class":59}," pyo.ConcreteModel()\n",[53,1782,1783,1786,1788,1791,1794,1797],{"class":55,"line":312},[53,1784,1785],{"class":59},"    walk ",[53,1787,64],{"class":63},[53,1789,1790],{"class":59}," lookup_table(model, ",[53,1792,1793],{"class":175},"\"walk\"",[53,1795,1796],{"class":59},", distance)       ",[53,1798,1799],{"class":71},"# walk[g, h]: metres between gates g and h\n",[53,1801,1802,1804,1806,1809,1812,1815],{"class":55,"line":322},[53,1803,228],{"class":59},[53,1805,64],{"class":63},[53,1807,1808],{"class":59}," permutation(model, ",[53,1810,1811],{"class":175},"\"gate\"",[53,1813,1814],{"class":59},", flights)         ",[53,1816,1817],{"class":71},"# gate.slot_of(i): the gate of flight i\n",[53,1819,1820,1823,1825,1828,1831,1833,1836,1839,1841,1844],{"class":55,"line":328},[53,1821,1822],{"class":59},"    model.walking ",[53,1824,64],{"class":63},[53,1826,1827],{"class":59}," pyo.Objective(",[53,1829,1830],{"class":1006},"sense",[53,1832,64],{"class":63},[53,1834,1835],{"class":59},"pyo.minimize, ",[53,1837,1838],{"class":1006},"expr",[53,1840,64],{"class":63},[53,1842,1843],{"class":67},"sum",[53,1845,1846],{"class":59},"(\n",[53,1848,1849,1852,1855,1857],{"class":55,"line":333},[53,1850,1851],{"class":67},"        float",[53,1853,1854],{"class":59},"(transfers[i, j]) ",[53,1856,1049],{"class":63},[53,1858,1859],{"class":59}," walk[gate.slot_of(i), gate.slot_of(j)]\n",[53,1861,1862,1865,1868,1870,1872,1874,1876,1879,1881,1883,1885,1887],{"class":55,"line":338},[53,1863,1864],{"class":63},"        for",[53,1866,1867],{"class":59}," i ",[53,1869,620],{"class":63},[53,1871,918],{"class":67},[53,1873,983],{"class":59},[53,1875,614],{"class":63},[53,1877,1878],{"class":59}," j ",[53,1880,620],{"class":63},[53,1882,918],{"class":67},[53,1884,983],{"class":59},[53,1886,944],{"class":63},[53,1888,1889],{"class":59}," transfers[i, j]))\n",[53,1891,1892,1894,1897,1899,1901],{"class":55,"line":344},[53,1893,296],{"class":63},[53,1895,1896],{"class":59}," client.solve(model, ",[53,1898,1629],{"class":1006},[53,1900,64],{"class":63},[53,1902,1903],{"class":59},"time_limit)\n",[53,1905,1906],{"class":55,"line":349},[53,1907,135],{"emptyLinePlaceholder":134},[53,1909,1910],{"class":55,"line":354},[53,1911,135],{"emptyLinePlaceholder":134},[53,1913,1914,1917,1919],{"class":55,"line":360},[53,1915,1916],{"class":59},"result ",[53,1918,64],{"class":63},[53,1920,1921],{"class":59}," plan_with_quicopt(transfers, distance, time_limit)\n",[53,1923,1924,1926],{"class":55,"line":365},[53,1925,572],{"class":67},[53,1927,1928],{"class":59},"(result.display)\n",[752,1930],{":lines":1931,"label":755},"[\"▄▀▀▀▄        ▄                     █\",\"█   █ █   █ ▄▄  ▄▀▀▀▄ ▄▀▀▀▄ █▀▀▀▄ ▀█▀▀\",\"█ ▀▄▀ █   █  █  █   ▄ █   █ █▄▄▄▀  █  ▄\",\" ▀▀ ▀  ▀▀▀▀ ▀▀▀  ▀▀▀   ▀▀▀  █       ▀▀\",\"\",\"├── shots\",\"│   └── 1 · primal   1518140   0.61s  ◀ best\",\"├── status:     heuristic\",\"├── feasible:   true\",\"├── objective:  1.51814e6\",\"├── x:          —  (0 variables)\",\"├── structures: gate: item_at=[20, 43, 11, 6, 36, 7, 21, 10, …]\",\"├── time_limit: 30 s\",\"└── solve_time: 0.6223 s\",\"\",\"    Intel Xeon Gold 6338N @ 2.20GHz · 16 cores, 1 core per shot\"]",[10,1933,1934,1935,1938,1939,1942,1943,1946],{},"The service was allowed 30 seconds and reports a solve time of less than one. The line ",[50,1936,1937],{},"status: heuristic"," says that Quicopt found the plan by a search and does not prove that no plan is better. The plan itself is listed under ",[50,1940,1941],{},"structures",". The line ",[50,1944,1945],{},"x"," is empty, because the model has no variables besides the permutation. The last lines name the hardware of the service, which used one core.",[10,1948,1949,1950,1953],{},"We check the returned plan against the data. It must use every gate exactly once, and its walking, recomputed with ",[50,1951,1952],{},"walking",", must equal the objective that Quicopt reports.",[43,1955,1957],{"className":45,"code":1956,"language":47,"meta":48,"style":48},"quicopt_plan = np.array(result.structures[\"gate\"].slot_of)       # quicopt_plan[i]: the gate of flight i\nassert sorted(quicopt_plan) == list(range(flights))              # every gate holds exactly one flight\nquicopt_walking = walking(quicopt_plan, transfers, distance)\n\nprint(f\"walking that Quicopt reports      {result.objective:12,.0f} m\")\nprint(f\"walking recomputed from the data  {quicopt_walking:12,.0f} m\\n\")\nshow(\"Quicopt's plan\", quicopt_walking)\nprint(f\"less than timetable order:               {1 - quicopt_walking \u002F walking(timetable_order, transfers, distance):.0%}\")\nprint(f\"less than the best of the random plans:  {1 - quicopt_walking \u002F np.min(walking_of_random_plans):.0%}\")\n",[50,1958,1959,1977,2004,2014,2018,2042,2072,2082,2116],{"__ignoreMap":48},[53,1960,1961,1964,1966,1969,1971,1974],{"class":55,"line":56},[53,1962,1963],{"class":59},"quicopt_plan ",[53,1965,64],{"class":63},[53,1967,1968],{"class":59}," np.array(result.structures[",[53,1970,1811],{"class":175},[53,1972,1973],{"class":59},"].slot_of)       ",[53,1975,1976],{"class":71},"# quicopt_plan[i]: the gate of flight i\n",[53,1978,1979,1982,1985,1988,1990,1993,1995,1998,2001],{"class":55,"line":75},[53,1980,1981],{"class":63},"assert",[53,1983,1984],{"class":67}," sorted",[53,1986,1987],{"class":59},"(quicopt_plan) ",[53,1989,393],{"class":63},[53,1991,1992],{"class":67}," list",[53,1994,575],{"class":59},[53,1996,1997],{"class":67},"range",[53,1999,2000],{"class":59},"(flights))              ",[53,2002,2003],{"class":71},"# every gate holds exactly one flight\n",[53,2005,2006,2009,2011],{"class":55,"line":89},[53,2007,2008],{"class":59},"quicopt_walking ",[53,2010,64],{"class":63},[53,2012,2013],{"class":59}," walking(quicopt_plan, transfers, distance)\n",[53,2015,2016],{"class":55,"line":149},[53,2017,135],{"emptyLinePlaceholder":134},[53,2019,2020,2022,2024,2026,2029,2031,2034,2036,2038,2040],{"class":55,"line":154},[53,2021,572],{"class":67},[53,2023,575],{"class":59},[53,2025,578],{"class":63},[53,2027,2028],{"class":175},"\"walking that Quicopt reports      ",[53,2030,584],{"class":67},[53,2032,2033],{"class":59},"result.objective",[53,2035,1444],{"class":63},[53,2037,590],{"class":67},[53,2039,722],{"class":175},[53,2041,290],{"class":59},[53,2043,2044,2046,2048,2050,2053,2055,2058,2060,2062,2065,2068,2070],{"class":55,"line":159},[53,2045,572],{"class":67},[53,2047,575],{"class":59},[53,2049,578],{"class":63},[53,2051,2052],{"class":175},"\"walking recomputed from the data  ",[53,2054,584],{"class":67},[53,2056,2057],{"class":59},"quicopt_walking",[53,2059,1444],{"class":63},[53,2061,590],{"class":67},[53,2063,2064],{"class":175}," m",[53,2066,2067],{"class":67},"\\n",[53,2069,606],{"class":175},[53,2071,290],{"class":59},[53,2073,2074,2076,2079],{"class":55,"line":172},[53,2075,1544],{"class":59},[53,2077,2078],{"class":175},"\"Quicopt's plan\"",[53,2080,2081],{"class":59},", quicopt_walking)\n",[53,2083,2084,2086,2088,2090,2093,2096,2099,2102,2104,2107,2110,2112,2114],{"class":55,"line":179},[53,2085,572],{"class":67},[53,2087,575],{"class":59},[53,2089,578],{"class":63},[53,2091,2092],{"class":175},"\"less than timetable order:               ",[53,2094,2095],{"class":67},"{1",[53,2097,2098],{"class":63}," -",[53,2100,2101],{"class":59}," quicopt_walking ",[53,2103,1055],{"class":63},[53,2105,2106],{"class":59}," walking(timetable_order, transfers, distance)",[53,2108,2109],{"class":63},":.0%",[53,2111,590],{"class":67},[53,2113,606],{"class":175},[53,2115,290],{"class":59},[53,2117,2118,2120,2122,2124,2127,2129,2131,2133,2135,2138,2140,2142,2144],{"class":55,"line":184},[53,2119,572],{"class":67},[53,2121,575],{"class":59},[53,2123,578],{"class":63},[53,2125,2126],{"class":175},"\"less than the best of the random plans:  ",[53,2128,2095],{"class":67},[53,2130,2098],{"class":63},[53,2132,2101],{"class":59},[53,2134,1055],{"class":63},[53,2136,2137],{"class":59}," np.min(walking_of_random_plans)",[53,2139,2109],{"class":63},[53,2141,590],{"class":67},[53,2143,606],{"class":175},[53,2145,290],{"class":59},[752,2147],{":lines":2148,"label":755},"[\"walking that Quicopt reports         1,518,140 m\",\"walking recomputed from the data     1,518,140 m\",\"\",\"Quicopt's plan                    1,518,140 m in total     305 m per passenger\",\"less than timetable order:               56%\",\"less than the best of the random plans:  44%\"]",[10,2150,2151],{},"The recomputed walking equals the reported objective. In Quicopt's plan, a connecting passenger walks 305 m on average. The plan needs 56% less walking than timetable order and 44% less than the best of the 1,000 random plans.",[35,2153,2155],{"id":2154},"the-plan-in-the-terminal","The plan in the terminal",[10,2157,2158],{},"The next cell draws the terminal twice, in timetable order and with Quicopt's plan. Each square is a gate. A darker square holds a flight with more connecting passengers. An orange line joins the two gates of a connection, and a wider line stands for more passengers. Only the largest eighth of the connections are drawn.",[43,2160,2162],{"className":45,"code":2161,"language":47,"meta":48,"style":48},"import matplotlib.pyplot as plt\nfrom matplotlib.colors import LinearSegmentedColormap\n\nBLUE, ORANGE, GREY = \"#2d5faa\", \"#eb6834\", \"#d9d9d6\"\nshades = LinearSegmentedColormap.from_list(\"shades\", [\"#e3e9f4\", BLUE])\n\npiers = pier.max() + 1\ngate_x = 150.0 * pier + np.where(np.arange(flights) % 2 == 0, -24.0, 24.0)     # the two gates of a pair, left and right of their pier\nflight_passengers = transfers.sum(axis=0) + transfers.sum(axis=1)              # passengers who arrive or leave on each flight\ndrawn = largest_first[:len(largest_first) \u002F\u002F 8]                                # the largest eighth of the connections\nprint(f\"the {len(drawn)} connections drawn carry {transfers[arrival[drawn], departure[drawn]].sum() \u002F passengers:.0%} of the connecting passengers\")\n\nfigure, panels = plt.subplots(1, 2, figsize=(min(13.0, 4.0 + 2.2 * piers), 5.6), sharey=True, constrained_layout=True)\nfor panel, plan, title in [(panels[0], timetable_order, \"Timetable order\"), (panels[1], quicopt_plan, \"Quicopt's plan\")]:\n    panel.plot([-60, 150 * (piers - 1) + 60], [0, 0], color=GREY, lw=5, solid_capstyle=\"round\")              # the spine\n    for p in range(piers):\n        panel.plot([150 * p, 150 * p], [0, along_pier.max() + 30], color=GREY, lw=5, solid_capstyle=\"round\")        # a pier\n    for k in drawn:\n        g, h = plan[arrival[k]], plan[departure[k]]              # the gates of the two flights of connection k\n        panel.plot([gate_x[g], gate_x[h]], [along_pier[g], along_pier[h]], color=ORANGE, alpha=0.6,\n                   lw=transfers[arrival[k], departure[k]] \u002F 25, solid_capstyle=\"round\")       # 1 point of width per 25 passengers\n    passengers_at_gate = np.empty(flights)\n    passengers_at_gate[plan] = flight_passengers                 # gate plan[i] holds flight i\n    squares = panel.scatter(gate_x, along_pier, c=passengers_at_gate, cmap=shades, vmin=0, vmax=flight_passengers.max(),\n                            marker=\"s\", s=70, edgecolor=\"white\", linewidth=0.8, zorder=3)\n    panel.set_title(f\"{title}\\n{walking(plan, transfers, distance) \u002F passengers:.0f} m per connecting passenger\",\n                    loc=\"left\", fontsize=10)\n    panel.set_xticks(150 * np.arange(piers), [f\"pier {p}\" for p in range(piers)])\n    panel.tick_params(length=0)\n    panel.set_frame_on(False)\npanels[0].set_ylabel(\"metres from the spine\")\nfigure.colorbar(squares, ax=panels, shrink=0.6, label=\"connecting passengers of the flight at the gate\")\nplt.show()\n",[50,2163,2164,2176,2188,2192,2222,2248,2252,2267,2312,2347,2373,2412,2416,2490,2522,2596,2610,2668,2679,2692,2716,2745,2755,2768,2811,2863,2897,2919,2956,2970,2979,2994,3025],{"__ignoreMap":48},[53,2165,2166,2168,2171,2173],{"class":55,"line":56},[53,2167,120],{"class":63},[53,2169,2170],{"class":59}," matplotlib.pyplot ",[53,2172,126],{"class":63},[53,2174,2175],{"class":59}," plt\n",[53,2177,2178,2180,2183,2185],{"class":55,"line":75},[53,2179,1652],{"class":63},[53,2181,2182],{"class":59}," matplotlib.colors ",[53,2184,120],{"class":63},[53,2186,2187],{"class":59}," LinearSegmentedColormap\n",[53,2189,2190],{"class":55,"line":89},[53,2191,135],{"emptyLinePlaceholder":134},[53,2193,2194,2197,2199,2202,2204,2207,2209,2212,2214,2217,2219],{"class":55,"line":149},[53,2195,2196],{"class":67},"BLUE",[53,2198,629],{"class":59},[53,2200,2201],{"class":67},"ORANGE",[53,2203,629],{"class":59},[53,2205,2206],{"class":67},"GREY",[53,2208,143],{"class":63},[53,2210,2211],{"class":175}," \"#2d5faa\"",[53,2213,629],{"class":59},[53,2215,2216],{"class":175},"\"#eb6834\"",[53,2218,629],{"class":59},[53,2220,2221],{"class":175},"\"#d9d9d6\"\n",[53,2223,2224,2227,2229,2232,2235,2238,2241,2243,2245],{"class":55,"line":154},[53,2225,2226],{"class":59},"shades ",[53,2228,64],{"class":63},[53,2230,2231],{"class":59}," LinearSegmentedColormap.from_list(",[53,2233,2234],{"class":175},"\"shades\"",[53,2236,2237],{"class":59},", [",[53,2239,2240],{"class":175},"\"#e3e9f4\"",[53,2242,629],{"class":59},[53,2244,2196],{"class":67},[53,2246,2247],{"class":59},"])\n",[53,2249,2250],{"class":55,"line":159},[53,2251,135],{"emptyLinePlaceholder":134},[53,2253,2254,2257,2259,2262,2264],{"class":55,"line":172},[53,2255,2256],{"class":59},"piers ",[53,2258,64],{"class":63},[53,2260,2261],{"class":59}," pier.max() ",[53,2263,433],{"class":63},[53,2265,2266],{"class":67}," 1\n",[53,2268,2269,2272,2274,2276,2278,2281,2283,2286,2288,2290,2293,2296,2298,2300,2303,2305,2307,2309],{"class":55,"line":179},[53,2270,2271],{"class":59},"gate_x ",[53,2273,64],{"class":63},[53,2275,447],{"class":67},[53,2277,270],{"class":63},[53,2279,2280],{"class":59}," pier ",[53,2282,433],{"class":63},[53,2284,2285],{"class":59}," np.where(np.arange(flights) ",[53,2287,276],{"class":63},[53,2289,287],{"class":67},[53,2291,2292],{"class":63}," ==",[53,2294,2295],{"class":67}," 0",[53,2297,629],{"class":59},[53,2299,422],{"class":63},[53,2301,2302],{"class":67},"24.0",[53,2304,629],{"class":59},[53,2306,2302],{"class":67},[53,2308,1135],{"class":59},[53,2310,2311],{"class":71},"# the two gates of a pair, left and right of their pier\n",[53,2313,2314,2317,2319,2322,2325,2327,2329,2331,2333,2335,2337,2339,2341,2344],{"class":55,"line":184},[53,2315,2316],{"class":59},"flight_passengers ",[53,2318,64],{"class":63},[53,2320,2321],{"class":59}," transfers.sum(",[53,2323,2324],{"class":1006},"axis",[53,2326,64],{"class":63},[53,2328,626],{"class":67},[53,2330,282],{"class":59},[53,2332,433],{"class":63},[53,2334,2321],{"class":59},[53,2336,2324],{"class":1006},[53,2338,64],{"class":63},[53,2340,632],{"class":67},[53,2342,2343],{"class":59},")              ",[53,2345,2346],{"class":71},"# passengers who arrive or leave on each flight\n",[53,2348,2349,2352,2354,2356,2359,2362,2364,2367,2370],{"class":55,"line":190},[53,2350,2351],{"class":59},"drawn ",[53,2353,64],{"class":63},[53,2355,1200],{"class":59},[53,2357,2358],{"class":67},"len",[53,2360,2361],{"class":59},"(largest_first) ",[53,2363,247],{"class":63},[53,2365,2366],{"class":67}," 8",[53,2368,2369],{"class":59},"]                                ",[53,2371,2372],{"class":71},"# the largest eighth of the connections\n",[53,2374,2375,2377,2379,2381,2384,2386,2389,2391,2394,2396,2399,2401,2403,2405,2407,2410],{"class":55,"line":196},[53,2376,572],{"class":67},[53,2378,575],{"class":59},[53,2380,578],{"class":63},[53,2382,2383],{"class":175},"\"the ",[53,2385,1167],{"class":67},[53,2387,2388],{"class":59},"(drawn)",[53,2390,590],{"class":67},[53,2392,2393],{"class":175}," connections drawn carry ",[53,2395,584],{"class":67},[53,2397,2398],{"class":59},"transfers[arrival[drawn], departure[drawn]].sum() ",[53,2400,1055],{"class":63},[53,2402,1459],{"class":59},[53,2404,2109],{"class":63},[53,2406,590],{"class":67},[53,2408,2409],{"class":175}," of the connecting passengers\"",[53,2411,290],{"class":59},[53,2413,2414],{"class":55,"line":201},[53,2415,135],{"emptyLinePlaceholder":134},[53,2417,2418,2421,2423,2426,2428,2430,2433,2435,2438,2440,2442,2445,2447,2450,2452,2455,2457,2460,2462,2465,2468,2471,2474,2476,2479,2481,2484,2486,2488],{"class":55,"line":207},[53,2419,2420],{"class":59},"figure, panels ",[53,2422,64],{"class":63},[53,2424,2425],{"class":59}," plt.subplots(",[53,2427,632],{"class":67},[53,2429,629],{"class":59},[53,2431,2432],{"class":67},"2",[53,2434,629],{"class":59},[53,2436,2437],{"class":1006},"figsize",[53,2439,64],{"class":63},[53,2441,575],{"class":59},[53,2443,2444],{"class":67},"min",[53,2446,575],{"class":59},[53,2448,2449],{"class":67},"13.0",[53,2451,629],{"class":59},[53,2453,2454],{"class":67},"4.0",[53,2456,264],{"class":63},[53,2458,2459],{"class":67}," 2.2",[53,2461,270],{"class":63},[53,2463,2464],{"class":59}," piers), ",[53,2466,2467],{"class":67},"5.6",[53,2469,2470],{"class":59},"), ",[53,2472,2473],{"class":1006},"sharey",[53,2475,64],{"class":63},[53,2477,2478],{"class":67},"True",[53,2480,629],{"class":59},[53,2482,2483],{"class":1006},"constrained_layout",[53,2485,64],{"class":63},[53,2487,2478],{"class":67},[53,2489,290],{"class":59},[53,2491,2492,2494,2497,2499,2502,2504,2507,2510,2513,2515,2518,2520],{"class":55,"line":213},[53,2493,614],{"class":63},[53,2495,2496],{"class":59}," panel, plan, title ",[53,2498,620],{"class":63},[53,2500,2501],{"class":59}," [(panels[",[53,2503,626],{"class":67},[53,2505,2506],{"class":59},"], timetable_order, ",[53,2508,2509],{"class":175},"\"Timetable order\"",[53,2511,2512],{"class":59},"), (panels[",[53,2514,632],{"class":67},[53,2516,2517],{"class":59},"], quicopt_plan, ",[53,2519,2078],{"class":175},[53,2521,656],{"class":59},[53,2523,2524,2527,2529,2532,2534,2536,2538,2541,2543,2546,2548,2550,2553,2556,2558,2560,2562,2565,2568,2570,2572,2574,2577,2579,2581,2583,2586,2588,2591,2593],{"class":55,"line":219},[53,2525,2526],{"class":59},"    panel.plot([",[53,2528,422],{"class":63},[53,2530,2531],{"class":67},"60",[53,2533,629],{"class":59},[53,2535,934],{"class":67},[53,2537,270],{"class":63},[53,2539,2540],{"class":59}," (piers ",[53,2542,422],{"class":63},[53,2544,2545],{"class":67}," 1",[53,2547,282],{"class":59},[53,2549,433],{"class":63},[53,2551,2552],{"class":67}," 60",[53,2554,2555],{"class":59},"], [",[53,2557,626],{"class":67},[53,2559,629],{"class":59},[53,2561,626],{"class":67},[53,2563,2564],{"class":59},"], ",[53,2566,2567],{"class":1006},"color",[53,2569,64],{"class":63},[53,2571,2206],{"class":67},[53,2573,629],{"class":59},[53,2575,2576],{"class":1006},"lw",[53,2578,64],{"class":63},[53,2580,648],{"class":67},[53,2582,629],{"class":59},[53,2584,2585],{"class":1006},"solid_capstyle",[53,2587,64],{"class":63},[53,2589,2590],{"class":175},"\"round\"",[53,2592,2343],{"class":59},[53,2594,2595],{"class":71},"# the spine\n",[53,2597,2598,2600,2603,2605,2607],{"class":55,"line":225},[53,2599,910],{"class":63},[53,2601,2602],{"class":59}," p ",[53,2604,620],{"class":63},[53,2606,918],{"class":67},[53,2608,2609],{"class":59},"(piers):\n",[53,2611,2612,2615,2617,2619,2622,2624,2626,2629,2631,2634,2636,2638,2640,2642,2644,2646,2648,2650,2652,2654,2656,2658,2660,2662,2665],{"class":55,"line":236},[53,2613,2614],{"class":59},"        panel.plot([",[53,2616,934],{"class":67},[53,2618,270],{"class":63},[53,2620,2621],{"class":59}," p, ",[53,2623,934],{"class":67},[53,2625,270],{"class":63},[53,2627,2628],{"class":59}," p], [",[53,2630,626],{"class":67},[53,2632,2633],{"class":59},", along_pier.max() ",[53,2635,433],{"class":63},[53,2637,97],{"class":67},[53,2639,2564],{"class":59},[53,2641,2567],{"class":1006},[53,2643,64],{"class":63},[53,2645,2206],{"class":67},[53,2647,629],{"class":59},[53,2649,2576],{"class":1006},[53,2651,64],{"class":63},[53,2653,648],{"class":67},[53,2655,629],{"class":59},[53,2657,2585],{"class":1006},[53,2659,64],{"class":63},[53,2661,2590],{"class":175},[53,2663,2664],{"class":59},")        ",[53,2666,2667],{"class":71},"# a pier\n",[53,2669,2670,2672,2674,2676],{"class":55,"line":253},[53,2671,910],{"class":63},[53,2673,1195],{"class":59},[53,2675,620],{"class":63},[53,2677,2678],{"class":59}," drawn:\n",[53,2680,2681,2684,2686,2689],{"class":55,"line":293},[53,2682,2683],{"class":59},"        g, h ",[53,2685,64],{"class":63},[53,2687,2688],{"class":59}," plan[arrival[k]], plan[departure[k]]              ",[53,2690,2691],{"class":71},"# the gates of the two flights of connection k\n",[53,2693,2694,2697,2699,2701,2703,2705,2708,2710,2713],{"class":55,"line":302},[53,2695,2696],{"class":59},"        panel.plot([gate_x[g], gate_x[h]], [along_pier[g], along_pier[h]], ",[53,2698,2567],{"class":1006},[53,2700,64],{"class":63},[53,2702,2201],{"class":67},[53,2704,629],{"class":59},[53,2706,2707],{"class":1006},"alpha",[53,2709,64],{"class":63},[53,2711,2712],{"class":67},"0.6",[53,2714,2715],{"class":59},",\n",[53,2717,2718,2721,2723,2726,2728,2731,2733,2735,2737,2739,2742],{"class":55,"line":307},[53,2719,2720],{"class":1006},"                   lw",[53,2722,64],{"class":63},[53,2724,2725],{"class":59},"transfers[arrival[k], departure[k]] ",[53,2727,1055],{"class":63},[53,2729,2730],{"class":67}," 25",[53,2732,629],{"class":59},[53,2734,2585],{"class":1006},[53,2736,64],{"class":63},[53,2738,2590],{"class":175},[53,2740,2741],{"class":59},")       ",[53,2743,2744],{"class":71},"# 1 point of width per 25 passengers\n",[53,2746,2747,2750,2752],{"class":55,"line":312},[53,2748,2749],{"class":59},"    passengers_at_gate ",[53,2751,64],{"class":63},[53,2753,2754],{"class":59}," np.empty(flights)\n",[53,2756,2757,2760,2762,2765],{"class":55,"line":322},[53,2758,2759],{"class":59},"    passengers_at_gate[plan] ",[53,2761,64],{"class":63},[53,2763,2764],{"class":59}," flight_passengers                 ",[53,2766,2767],{"class":71},"# gate plan[i] holds flight i\n",[53,2769,2770,2773,2775,2778,2781,2783,2786,2789,2791,2794,2797,2799,2801,2803,2806,2808],{"class":55,"line":328},[53,2771,2772],{"class":59},"    squares ",[53,2774,64],{"class":63},[53,2776,2777],{"class":59}," panel.scatter(gate_x, along_pier, ",[53,2779,2780],{"class":1006},"c",[53,2782,64],{"class":63},[53,2784,2785],{"class":59},"passengers_at_gate, ",[53,2787,2788],{"class":1006},"cmap",[53,2790,64],{"class":63},[53,2792,2793],{"class":59},"shades, ",[53,2795,2796],{"class":1006},"vmin",[53,2798,64],{"class":63},[53,2800,626],{"class":67},[53,2802,629],{"class":59},[53,2804,2805],{"class":1006},"vmax",[53,2807,64],{"class":63},[53,2809,2810],{"class":59},"flight_passengers.max(),\n",[53,2812,2813,2816,2818,2821,2823,2826,2828,2831,2833,2836,2838,2841,2843,2846,2848,2851,2853,2856,2858,2861],{"class":55,"line":333},[53,2814,2815],{"class":1006},"                            marker",[53,2817,64],{"class":63},[53,2819,2820],{"class":175},"\"s\"",[53,2822,629],{"class":59},[53,2824,2825],{"class":1006},"s",[53,2827,64],{"class":63},[53,2829,2830],{"class":67},"70",[53,2832,629],{"class":59},[53,2834,2835],{"class":1006},"edgecolor",[53,2837,64],{"class":63},[53,2839,2840],{"class":175},"\"white\"",[53,2842,629],{"class":59},[53,2844,2845],{"class":1006},"linewidth",[53,2847,64],{"class":63},[53,2849,2850],{"class":67},"0.8",[53,2852,629],{"class":59},[53,2854,2855],{"class":1006},"zorder",[53,2857,64],{"class":63},[53,2859,2860],{"class":67},"3",[53,2862,290],{"class":59},[53,2864,2865,2868,2870,2872,2874,2877,2880,2883,2885,2887,2890,2892,2895],{"class":55,"line":338},[53,2866,2867],{"class":59},"    panel.set_title(",[53,2869,578],{"class":63},[53,2871,606],{"class":175},[53,2873,584],{"class":67},[53,2875,2876],{"class":59},"title",[53,2878,2879],{"class":67},"}\\n{",[53,2881,2882],{"class":59},"walking(plan, transfers, distance) ",[53,2884,1055],{"class":63},[53,2886,1459],{"class":59},[53,2888,2889],{"class":63},":.0f",[53,2891,590],{"class":67},[53,2893,2894],{"class":175}," m per connecting passenger\"",[53,2896,2715],{"class":59},[53,2898,2899,2902,2904,2907,2909,2912,2914,2917],{"class":55,"line":344},[53,2900,2901],{"class":1006},"                    loc",[53,2903,64],{"class":63},[53,2905,2906],{"class":175},"\"left\"",[53,2908,629],{"class":59},[53,2910,2911],{"class":1006},"fontsize",[53,2913,64],{"class":63},[53,2915,2916],{"class":67},"10",[53,2918,290],{"class":59},[53,2920,2921,2924,2926,2928,2931,2933,2936,2938,2940,2942,2944,2947,2949,2951,2953],{"class":55,"line":349},[53,2922,2923],{"class":59},"    panel.set_xticks(",[53,2925,934],{"class":67},[53,2927,270],{"class":63},[53,2929,2930],{"class":59}," np.arange(piers), [",[53,2932,578],{"class":63},[53,2934,2935],{"class":175},"\"pier ",[53,2937,584],{"class":67},[53,2939,10],{"class":59},[53,2941,590],{"class":67},[53,2943,606],{"class":175},[53,2945,2946],{"class":63}," for",[53,2948,2602],{"class":59},[53,2950,620],{"class":63},[53,2952,918],{"class":67},[53,2954,2955],{"class":59},"(piers)])\n",[53,2957,2958,2961,2964,2966,2968],{"class":55,"line":354},[53,2959,2960],{"class":59},"    panel.tick_params(",[53,2962,2963],{"class":1006},"length",[53,2965,64],{"class":63},[53,2967,626],{"class":67},[53,2969,290],{"class":59},[53,2971,2972,2975,2977],{"class":55,"line":360},[53,2973,2974],{"class":59},"    panel.set_frame_on(",[53,2976,1012],{"class":67},[53,2978,290],{"class":59},[53,2980,2981,2984,2986,2989,2992],{"class":55,"line":365},[53,2982,2983],{"class":59},"panels[",[53,2985,626],{"class":67},[53,2987,2988],{"class":59},"].set_ylabel(",[53,2990,2991],{"class":175},"\"metres from the spine\"",[53,2993,290],{"class":59},[53,2995,2996,2999,3002,3004,3007,3010,3012,3014,3016,3018,3020,3023],{"class":55,"line":376},[53,2997,2998],{"class":59},"figure.colorbar(squares, ",[53,3000,3001],{"class":1006},"ax",[53,3003,64],{"class":63},[53,3005,3006],{"class":59},"panels, ",[53,3008,3009],{"class":1006},"shrink",[53,3011,64],{"class":63},[53,3013,2712],{"class":67},[53,3015,629],{"class":59},[53,3017,1430],{"class":1006},[53,3019,64],{"class":63},[53,3021,3022],{"class":175},"\"connecting passengers of the flight at the gate\"",[53,3024,290],{"class":59},[53,3026,3027],{"class":55,"line":407},[53,3028,3029],{"class":59},"plt.show()\n",[752,3031],{":lines":3032,"label":755},"[\"the 23 connections drawn carry 40% of the connecting passengers\"]",[10,3034,3035],{},[21,3036],{"alt":2155,"src":3037},"\u002Fuse-cases\u002Fgate-assignment\u002Fgate-assignment-1922091c-0.png",[10,3039,3040],{},"Two numbers summarize the picture: the share of the connecting passengers who change piers, and the share who walk at most 100 m, which is the walk to the next pair of gates on the same pier.",[43,3042,3044],{"className":45,"code":3043,"language":47,"meta":48,"style":48},"connection_passengers = transfers[arrival, departure]             # the passengers of every connection\nfor label, plan in [(\"timetable order\", timetable_order), (\"Quicopt's plan\", quicopt_plan)]:\n    metres = distance[plan[arrival], plan[departure]]             # the walk of every connection under this plan\n    changes_pier = pier[plan[arrival]] != pier[plan[departure]]\n    print(f\"{label:16} {connection_passengers[changes_pier].sum() \u002F passengers:4.0%} of the passengers change piers, \"\n          f\"{connection_passengers[metres \u003C= 100].sum() \u002F passengers:4.0%} walk at most 100 m\")\n",[50,3045,3046,3059,3080,3093,3108,3144],{"__ignoreMap":48},[53,3047,3048,3051,3053,3056],{"class":55,"line":56},[53,3049,3050],{"class":59},"connection_passengers ",[53,3052,64],{"class":63},[53,3054,3055],{"class":59}," transfers[arrival, departure]             ",[53,3057,3058],{"class":71},"# the passengers of every connection\n",[53,3060,3061,3063,3066,3068,3070,3072,3075,3077],{"class":55,"line":75},[53,3062,614],{"class":63},[53,3064,3065],{"class":59}," label, plan ",[53,3067,620],{"class":63},[53,3069,623],{"class":59},[53,3071,1547],{"class":175},[53,3073,3074],{"class":59},", timetable_order), (",[53,3076,2078],{"class":175},[53,3078,3079],{"class":59},", quicopt_plan)]:\n",[53,3081,3082,3085,3087,3090],{"class":55,"line":89},[53,3083,3084],{"class":59},"    metres ",[53,3086,64],{"class":63},[53,3088,3089],{"class":59}," distance[plan[arrival], plan[departure]]             ",[53,3091,3092],{"class":71},"# the walk of every connection under this plan\n",[53,3094,3095,3098,3100,3103,3105],{"class":55,"line":149},[53,3096,3097],{"class":59},"    changes_pier ",[53,3099,64],{"class":63},[53,3101,3102],{"class":59}," pier[plan[arrival]] ",[53,3104,990],{"class":63},[53,3106,3107],{"class":59}," pier[plan[departure]]\n",[53,3109,3110,3112,3114,3116,3118,3120,3122,3125,3127,3129,3132,3134,3136,3139,3141],{"class":55,"line":154},[53,3111,1210],{"class":67},[53,3113,575],{"class":59},[53,3115,578],{"class":63},[53,3117,606],{"class":175},[53,3119,584],{"class":67},[53,3121,1430],{"class":59},[53,3123,3124],{"class":63},":16",[53,3126,590],{"class":67},[53,3128,1438],{"class":67},[53,3130,3131],{"class":59},"connection_passengers[changes_pier].sum() ",[53,3133,1055],{"class":63},[53,3135,1459],{"class":59},[53,3137,3138],{"class":63},":4.0%",[53,3140,590],{"class":67},[53,3142,3143],{"class":175}," of the passengers change piers, \"\n",[53,3145,3146,3149,3151,3153,3156,3159,3162,3165,3167,3169,3171,3173,3176],{"class":55,"line":159},[53,3147,3148],{"class":63},"          f",[53,3150,606],{"class":175},[53,3152,584],{"class":67},[53,3154,3155],{"class":59},"connection_passengers[metres ",[53,3157,3158],{"class":63},"\u003C=",[53,3160,3161],{"class":67}," 100",[53,3163,3164],{"class":59},"].sum() ",[53,3166,1055],{"class":63},[53,3168,1459],{"class":59},[53,3170,3138],{"class":63},[53,3172,590],{"class":67},[53,3174,3175],{"class":175}," walk at most 100 m\"",[53,3177,290],{"class":59},[752,3179],{":lines":3180,"label":755},"[\"timetable order   48% of the passengers change piers,   7% walk at most 100 m\",\"Quicopt's plan    20% of the passengers change piers,  51% walk at most 100 m\"]",[10,3182,3183],{},"In timetable order, 48% of the connecting passengers change piers, and the large connections cross the terminal. In Quicopt's plan, 20% change piers, and 51% walk at most 100 m. Most of the connections drawn there join gates that face each other or lie a few pairs apart.",[35,3185,3187],{"id":3186},"the-same-decision-as-a-mixed-integer-program","The same decision as a mixed-integer program",[10,3189,3190,3191,3305,3306,3335,3336,3365,3366,3394,3395,3423],{},"Solvers such as HiGHS, Gurobi and CPLEX expect this decision as a mixed-integer program. The program has a 0\u002F1 variable ",[53,3192,3195,3226],{"className":3193},[3194],"katex",[53,3196,3199],{"className":3197},[3198],"katex-mathml",[3200,3201,3203],"math",{"xmlns":3202},"http:\u002F\u002Fwww.w3.org\u002F1998\u002FMath\u002FMathML",[3204,3205,3206,3221],"semantics",{},[3207,3208,3209],"mrow",{},[3210,3211,3212,3215],"msub",{},[3213,3214,1945],"mi",{},[3207,3216,3217,3219],{},[3213,3218,772],{},[3213,3220,689],{},[3222,3223,3225],"annotation",{"encoding":3224},"application\u002Fx-tex","x_{ig}",[53,3227,3231],{"className":3228,"ariaHidden":3230},[3229],"katex-html","true",[53,3232,3235,3240],{"className":3233},[3234],"base",[53,3236],{"className":3237,"style":3239},[3238],"strut","height:0.7167em;vertical-align:-0.2861em;",[53,3241,3244,3248],{"className":3242},[3243],"mord",[53,3245,1945],{"className":3246},[3243,3247],"mathnormal",[53,3249,3252],{"className":3250},[3251],"msupsub",[53,3253,3257,3296],{"className":3254},[3255,3256],"vlist-t","vlist-t2",[53,3258,3261,3291],{"className":3259},[3260],"vlist-r",[53,3262,3266],{"className":3263,"style":3265},[3264],"vlist","height:0.3117em;",[53,3267,3269,3274],{"style":3268},"top:-2.55em;margin-left:0em;margin-right:0.05em;",[53,3270],{"className":3271,"style":3273},[3272],"pstrut","height:2.7em;",[53,3275,3281],{"className":3276},[3277,3278,3279,3280],"sizing","reset-size6","size3","mtight",[53,3282,3284,3287],{"className":3283},[3243,3280],[53,3285,772],{"className":3286},[3243,3247,3280],[53,3288,689],{"className":3289,"style":3290},[3243,3247,3280],"margin-right:0.0359em;",[53,3292,3295],{"className":3293},[3294],"vlist-s","​",[53,3297,3299],{"className":3298},[3260],[53,3300,3303],{"className":3301,"style":3302},[3264],"height:0.2861em;",[53,3304],{}," for every flight ",[53,3307,3309,3322],{"className":3308},[3194],[53,3310,3312],{"className":3311},[3198],[3200,3313,3314],{"xmlns":3202},[3204,3315,3316,3320],{},[3207,3317,3318],{},[3213,3319,772],{},[3222,3321,772],{"encoding":3224},[53,3323,3325],{"className":3324,"ariaHidden":3230},[3229],[53,3326,3328,3332],{"className":3327},[3234],[53,3329],{"className":3330,"style":3331},[3238],"height:0.6595em;",[53,3333,772],{"className":3334},[3243,3247]," and every gate ",[53,3337,3339,3352],{"className":3338},[3194],[53,3340,3342],{"className":3341},[3198],[3200,3343,3344],{"xmlns":3202},[3204,3345,3346,3350],{},[3207,3347,3348],{},[3213,3349,689],{},[3222,3351,689],{"encoding":3224},[53,3353,3355],{"className":3354,"ariaHidden":3230},[3229],[53,3356,3358,3362],{"className":3357},[3234],[53,3359],{"className":3360,"style":3361},[3238],"height:0.625em;vertical-align:-0.1944em;",[53,3363,689],{"className":3364,"style":3290},[3243,3247],". The variable is 1 if flight ",[53,3367,3369,3382],{"className":3368},[3194],[53,3370,3372],{"className":3371},[3198],[3200,3373,3374],{"xmlns":3202},[3204,3375,3376,3380],{},[3207,3377,3378],{},[3213,3379,772],{},[3222,3381,772],{"encoding":3224},[53,3383,3385],{"className":3384,"ariaHidden":3230},[3229],[53,3386,3388,3391],{"className":3387},[3234],[53,3389],{"className":3390,"style":3331},[3238],[53,3392,772],{"className":3393},[3243,3247]," stands at gate ",[53,3396,3398,3411],{"className":3397},[3194],[53,3399,3401],{"className":3400},[3198],[3200,3402,3403],{"xmlns":3202},[3204,3404,3405,3409],{},[3207,3406,3407],{},[3213,3408,689],{},[3222,3410,689],{"encoding":3224},[53,3412,3414],{"className":3413,"ariaHidden":3230},[3229],[53,3415,3417,3420],{"className":3416},[3234],[53,3418],{"className":3419,"style":3361},[3238],[53,3421,689],{"className":3422,"style":3290},[3243,3247],". One row per flight and one row per gate make the plan one-to-one:",[10,3425,3426],{},[53,3427,3429,3512],{"className":3428},[3194],[53,3430,3432],{"className":3431},[3198],[3200,3433,3434],{"xmlns":3202},[3204,3435,3436,3509],{},[3207,3437,3438,3446,3456,3458,3461,3465,3469,3471,3474,3477,3479,3485,3495,3497,3499,3501,3504,3506],{},[3210,3439,3440,3444],{},[3441,3442,3443],"mo",{},"∑",[3213,3445,689],{},[3210,3447,3448,3450],{},[3213,3449,1945],{},[3207,3451,3452,3454],{},[3213,3453,772],{},[3213,3455,689],{},[3441,3457,64],{},[3459,3460,632],"mn",{},[3462,3463],"mspace",{"width":3464},"1em",[3466,3467,3468],"mtext",{},"for every flight ",[3213,3470,772],{},[3441,3472,3473],{"separator":3230},",",[3462,3475],{"width":3476},"2em",[3462,3478],{"width":3476},[3210,3480,3481,3483],{},[3441,3482,3443],{},[3213,3484,772],{},[3210,3486,3487,3489],{},[3213,3488,1945],{},[3207,3490,3491,3493],{},[3213,3492,772],{},[3213,3494,689],{},[3441,3496,64],{},[3459,3498,632],{},[3462,3500],{"width":3464},[3466,3502,3503],{},"for every gate ",[3213,3505,689],{},[3213,3507,781],{"mathvariant":3508},"normal",[3222,3510,3511],{"encoding":3224},"\\sum_{g} x_{ig} = 1 \\quad\\text{for every flight } i, \\qquad\\qquad \\sum_{i} x_{ig} = 1 \\quad\\text{for every gate } g.",[53,3513,3515,3633,3774],{"className":3514,"ariaHidden":3230},[3229],[53,3516,3518,3522,3572,3576,3622,3626,3630],{"className":3517},[3234],[53,3519],{"className":3520,"style":3521},[3238],"height:1.1858em;vertical-align:-0.4358em;",[53,3523,3526,3532],{"className":3524},[3525],"mop",[53,3527,3443],{"className":3528,"style":3531},[3525,3529,3530],"op-symbol","small-op","position:relative;top:0em;",[53,3533,3535],{"className":3534},[3251],[53,3536,3538,3563],{"className":3537},[3255,3256],[53,3539,3541,3560],{"className":3540},[3260],[53,3542,3545],{"className":3543,"style":3544},[3264],"height:0.0017em;",[53,3546,3548,3551],{"style":3547},"top:-2.4003em;margin-left:0em;margin-right:0.05em;",[53,3549],{"className":3550,"style":3273},[3272],[53,3552,3554],{"className":3553},[3277,3278,3279,3280],[53,3555,3557],{"className":3556},[3243,3280],[53,3558,689],{"className":3559,"style":3290},[3243,3247,3280],[53,3561,3295],{"className":3562},[3294],[53,3564,3566],{"className":3565},[3260],[53,3567,3570],{"className":3568,"style":3569},[3264],"height:0.4358em;",[53,3571],{},[53,3573],{"className":3574,"style":3575},[3462],"margin-right:0.1667em;",[53,3577,3579,3582],{"className":3578},[3243],[53,3580,1945],{"className":3581},[3243,3247],[53,3583,3585],{"className":3584},[3251],[53,3586,3588,3614],{"className":3587},[3255,3256],[53,3589,3591,3611],{"className":3590},[3260],[53,3592,3594],{"className":3593,"style":3265},[3264],[53,3595,3596,3599],{"style":3268},[53,3597],{"className":3598,"style":3273},[3272],[53,3600,3602],{"className":3601},[3277,3278,3279,3280],[53,3603,3605,3608],{"className":3604},[3243,3280],[53,3606,772],{"className":3607},[3243,3247,3280],[53,3609,689],{"className":3610,"style":3290},[3243,3247,3280],[53,3612,3295],{"className":3613},[3294],[53,3615,3617],{"className":3616},[3260],[53,3618,3620],{"className":3619,"style":3302},[3264],[53,3621],{},[53,3623],{"className":3624,"style":3625},[3462],"margin-right:0.2778em;",[53,3627,64],{"className":3628},[3629],"mrel",[53,3631],{"className":3632,"style":3625},[3462],[53,3634,3636,3640,3643,3647,3654,3657,3661,3665,3668,3671,3716,3719,3765,3768,3771],{"className":3635},[3234],[53,3637],{"className":3638,"style":3639},[3238],"height:1.0497em;vertical-align:-0.2997em;",[53,3641,632],{"className":3642},[3243],[53,3644],{"className":3645,"style":3646},[3462],"margin-right:1em;",[53,3648,3651],{"className":3649},[3243,3650],"text",[53,3652,3468],{"className":3653},[3243],[53,3655,772],{"className":3656},[3243,3247],[53,3658,3473],{"className":3659},[3660],"mpunct",[53,3662],{"className":3663,"style":3664},[3462],"margin-right:2em;",[53,3666],{"className":3667,"style":3664},[3462],[53,3669],{"className":3670,"style":3575},[3462],[53,3672,3674,3677],{"className":3673},[3525],[53,3675,3443],{"className":3676,"style":3531},[3525,3529,3530],[53,3678,3680],{"className":3679},[3251],[53,3681,3683,3707],{"className":3682},[3255,3256],[53,3684,3686,3704],{"className":3685},[3260],[53,3687,3690],{"className":3688,"style":3689},[3264],"height:0.162em;",[53,3691,3692,3695],{"style":3547},[53,3693],{"className":3694,"style":3273},[3272],[53,3696,3698],{"className":3697},[3277,3278,3279,3280],[53,3699,3701],{"className":3700},[3243,3280],[53,3702,772],{"className":3703},[3243,3247,3280],[53,3705,3295],{"className":3706},[3294],[53,3708,3710],{"className":3709},[3260],[53,3711,3714],{"className":3712,"style":3713},[3264],"height:0.2997em;",[53,3715],{},[53,3717],{"className":3718,"style":3575},[3462],[53,3720,3722,3725],{"className":3721},[3243],[53,3723,1945],{"className":3724},[3243,3247],[53,3726,3728],{"className":3727},[3251],[53,3729,3731,3757],{"className":3730},[3255,3256],[53,3732,3734,3754],{"className":3733},[3260],[53,3735,3737],{"className":3736,"style":3265},[3264],[53,3738,3739,3742],{"style":3268},[53,3740],{"className":3741,"style":3273},[3272],[53,3743,3745],{"className":3744},[3277,3278,3279,3280],[53,3746,3748,3751],{"className":3747},[3243,3280],[53,3749,772],{"className":3750},[3243,3247,3280],[53,3752,689],{"className":3753,"style":3290},[3243,3247,3280],[53,3755,3295],{"className":3756},[3294],[53,3758,3760],{"className":3759},[3260],[53,3761,3763],{"className":3762,"style":3302},[3264],[53,3764],{},[53,3766],{"className":3767,"style":3625},[3462],[53,3769,64],{"className":3770},[3629],[53,3772],{"className":3773,"style":3625},[3462],[53,3775,3777,3781,3784,3787,3793,3796],{"className":3776},[3234],[53,3778],{"className":3779,"style":3780},[3238],"height:0.8889em;vertical-align:-0.1944em;",[53,3782,632],{"className":3783},[3243],[53,3785],{"className":3786,"style":3646},[3462],[53,3788,3790],{"className":3789},[3243,3650],[53,3791,3503],{"className":3792},[3243],[53,3794,689],{"className":3795,"style":3290},[3243,3247],[53,3797,781],{"className":3798},[3243],[10,3800,3801,3802,3885,3886,1229,3914,3943,3944,3947,3948,4032,4033,1615,4061,3943,4090,4093],{},"Let ",[53,3803,3805,3828],{"className":3804},[3194],[53,3806,3808],{"className":3807},[3198],[3200,3809,3810],{"xmlns":3202},[3204,3811,3812,3825],{},[3207,3813,3814],{},[3210,3815,3816,3819],{},[3213,3817,3818],{},"T",[3207,3820,3821,3823],{},[3213,3822,772],{},[3213,3824,776],{},[3222,3826,3827],{"encoding":3224},"T_{ij}",[53,3829,3831],{"className":3830,"ariaHidden":3230},[3229],[53,3832,3834,3838],{"className":3833},[3234],[53,3835],{"className":3836,"style":3837},[3238],"height:0.9694em;vertical-align:-0.2861em;",[53,3839,3841,3845],{"className":3840},[3243],[53,3842,3818],{"className":3843,"style":3844},[3243,3247],"margin-right:0.1389em;",[53,3846,3848],{"className":3847},[3251],[53,3849,3851,3877],{"className":3850},[3255,3256],[53,3852,3854,3874],{"className":3853},[3260],[53,3855,3857],{"className":3856,"style":3265},[3264],[53,3858,3860,3863],{"style":3859},"top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;",[53,3861],{"className":3862,"style":3273},[3272],[53,3864,3866],{"className":3865},[3277,3278,3279,3280],[53,3867,3869],{"className":3868},[3243,3280],[53,3870,3873],{"className":3871,"style":3872},[3243,3247,3280],"margin-right:0.0572em;","ij",[53,3875,3295],{"className":3876},[3294],[53,3878,3880],{"className":3879},[3260],[53,3881,3883],{"className":3882,"style":3302},[3264],[53,3884],{}," be the passengers from flight ",[53,3887,3889,3902],{"className":3888},[3194],[53,3890,3892],{"className":3891},[3198],[3200,3893,3894],{"xmlns":3202},[3204,3895,3896,3900],{},[3207,3897,3898],{},[3213,3899,772],{},[3222,3901,772],{"encoding":3224},[53,3903,3905],{"className":3904,"ariaHidden":3230},[3229],[53,3906,3908,3911],{"className":3907},[3234],[53,3909],{"className":3910,"style":3331},[3238],[53,3912,772],{"className":3913},[3243,3247],[53,3915,3917,3930],{"className":3916},[3194],[53,3918,3920],{"className":3919},[3198],[3200,3921,3922],{"xmlns":3202},[3204,3923,3924,3928],{},[3207,3925,3926],{},[3213,3927,776],{},[3222,3929,776],{"encoding":3224},[53,3931,3933],{"className":3932,"ariaHidden":3230},[3229],[53,3934,3936,3940],{"className":3935},[3234],[53,3937],{"className":3938,"style":3939},[3238],"height:0.854em;vertical-align:-0.1944em;",[53,3941,776],{"className":3942,"style":3872},[3243,3247]," (",[50,3945,3946],{},"transfers",") and ",[53,3949,3951,3974],{"className":3950},[3194],[53,3952,3954],{"className":3953},[3198],[3200,3955,3956],{"xmlns":3202},[3204,3957,3958,3971],{},[3207,3959,3960],{},[3210,3961,3962,3965],{},[3213,3963,3964],{},"D",[3207,3966,3967,3969],{},[3213,3968,689],{},[3213,3970,702],{},[3222,3972,3973],{"encoding":3224},"D_{gh}",[53,3975,3977],{"className":3976,"ariaHidden":3230},[3229],[53,3978,3980,3983],{"className":3979},[3234],[53,3981],{"className":3982,"style":3837},[3238],[53,3984,3986,3990],{"className":3985},[3243],[53,3987,3964],{"className":3988,"style":3989},[3243,3247],"margin-right:0.0278em;",[53,3991,3993],{"className":3992},[3251],[53,3994,3996,4024],{"className":3995},[3255,3256],[53,3997,3999,4021],{"className":3998},[3260],[53,4000,4003],{"className":4001,"style":4002},[3264],"height:0.3361em;",[53,4004,4006,4009],{"style":4005},"top:-2.55em;margin-left:-0.0278em;margin-right:0.05em;",[53,4007],{"className":4008,"style":3273},[3272],[53,4010,4012],{"className":4011},[3277,3278,3279,3280],[53,4013,4015,4018],{"className":4014},[3243,3280],[53,4016,689],{"className":4017,"style":3290},[3243,3247,3280],[53,4019,702],{"className":4020},[3243,3247,3280],[53,4022,3295],{"className":4023},[3294],[53,4025,4027],{"className":4026},[3260],[53,4028,4030],{"className":4029,"style":3302},[3264],[53,4031],{}," the metres between gates ",[53,4034,4036,4049],{"className":4035},[3194],[53,4037,4039],{"className":4038},[3198],[3200,4040,4041],{"xmlns":3202},[3204,4042,4043,4047],{},[3207,4044,4045],{},[3213,4046,689],{},[3222,4048,689],{"encoding":3224},[53,4050,4052],{"className":4051,"ariaHidden":3230},[3229],[53,4053,4055,4058],{"className":4054},[3234],[53,4056],{"className":4057,"style":3361},[3238],[53,4059,689],{"className":4060,"style":3290},[3243,3247],[53,4062,4064,4077],{"className":4063},[3194],[53,4065,4067],{"className":4066},[3198],[3200,4068,4069],{"xmlns":3202},[3204,4070,4071,4075],{},[3207,4072,4073],{},[3213,4074,702],{},[3222,4076,702],{"encoding":3224},[53,4078,4080],{"className":4079,"ariaHidden":3230},[3229],[53,4081,4083,4087],{"className":4082},[3234],[53,4084],{"className":4085,"style":4086},[3238],"height:0.6944em;",[53,4088,702],{"className":4089},[3243,3247],[50,4091,4092],{},"distance","). The total walking is",[10,4095,4096],{},[53,4097,4099,4182],{"className":4098},[3194],[53,4100,4102],{"className":4101},[3198],[3200,4103,4104],{"xmlns":3202},[3204,4105,4106,4179],{},[3207,4107,4108,4120,4130,4142,4152,4155,4165,4167,4177],{},[3210,4109,4110,4112],{},[3441,4111,3443],{},[3207,4113,4114,4116,4118],{},[3213,4115,772],{},[3441,4117,3473],{"separator":3230},[3213,4119,776],{},[3210,4121,4122,4124],{},[3213,4123,3818],{},[3207,4125,4126,4128],{},[3213,4127,772],{},[3213,4129,776],{},[3210,4131,4132,4134],{},[3441,4133,3443],{},[3207,4135,4136,4138,4140],{},[3213,4137,689],{},[3441,4139,3473],{"separator":3230},[3213,4141,702],{},[3210,4143,4144,4146],{},[3213,4145,3964],{},[3207,4147,4148,4150],{},[3213,4149,689],{},[3213,4151,702],{},[3466,4153,4154],{}," ",[3210,4156,4157,4159],{},[3213,4158,1945],{},[3207,4160,4161,4163],{},[3213,4162,772],{},[3213,4164,689],{},[3466,4166,4154],{},[3210,4168,4169,4171],{},[3213,4170,1945],{},[3207,4172,4173,4175],{},[3213,4174,776],{},[3213,4176,702],{},[3213,4178,781],{"mathvariant":3508},[3222,4180,4181],{"encoding":3224},"\\sum_{i,j} T_{ij} \\sum_{g,h} D_{gh}\\, x_{ig}\\, x_{jh}.",[53,4183,4185],{"className":4184,"ariaHidden":3230},[3229],[53,4186,4188,4191,4240,4243,4286,4289,4339,4342,4388,4391,4437,4440,4486],{"className":4187},[3234],[53,4189],{"className":4190,"style":3521},[3238],[53,4192,4194,4197],{"className":4193},[3525],[53,4195,3443],{"className":4196,"style":3531},[3525,3529,3530],[53,4198,4200],{"className":4199},[3251],[53,4201,4203,4232],{"className":4202},[3255,3256],[53,4204,4206,4229],{"className":4205},[3260],[53,4207,4209],{"className":4208,"style":3689},[3264],[53,4210,4211,4214],{"style":3547},[53,4212],{"className":4213,"style":3273},[3272],[53,4215,4217],{"className":4216},[3277,3278,3279,3280],[53,4218,4220,4223,4226],{"className":4219},[3243,3280],[53,4221,772],{"className":4222},[3243,3247,3280],[53,4224,3473],{"className":4225},[3660,3280],[53,4227,776],{"className":4228,"style":3872},[3243,3247,3280],[53,4230,3295],{"className":4231},[3294],[53,4233,4235],{"className":4234},[3260],[53,4236,4238],{"className":4237,"style":3569},[3264],[53,4239],{},[53,4241],{"className":4242,"style":3575},[3462],[53,4244,4246,4249],{"className":4245},[3243],[53,4247,3818],{"className":4248,"style":3844},[3243,3247],[53,4250,4252],{"className":4251},[3251],[53,4253,4255,4278],{"className":4254},[3255,3256],[53,4256,4258,4275],{"className":4257},[3260],[53,4259,4261],{"className":4260,"style":3265},[3264],[53,4262,4263,4266],{"style":3859},[53,4264],{"className":4265,"style":3273},[3272],[53,4267,4269],{"className":4268},[3277,3278,3279,3280],[53,4270,4272],{"className":4271},[3243,3280],[53,4273,3873],{"className":4274,"style":3872},[3243,3247,3280],[53,4276,3295],{"className":4277},[3294],[53,4279,4281],{"className":4280},[3260],[53,4282,4284],{"className":4283,"style":3302},[3264],[53,4285],{},[53,4287],{"className":4288,"style":3575},[3462],[53,4290,4292,4295],{"className":4291},[3525],[53,4293,3443],{"className":4294,"style":3531},[3525,3529,3530],[53,4296,4298],{"className":4297},[3251],[53,4299,4301,4331],{"className":4300},[3255,3256],[53,4302,4304,4328],{"className":4303},[3260],[53,4305,4308],{"className":4306,"style":4307},[3264],"height:0.1864em;",[53,4309,4310,4313],{"style":3547},[53,4311],{"className":4312,"style":3273},[3272],[53,4314,4316],{"className":4315},[3277,3278,3279,3280],[53,4317,4319,4322,4325],{"className":4318},[3243,3280],[53,4320,689],{"className":4321,"style":3290},[3243,3247,3280],[53,4323,3473],{"className":4324},[3660,3280],[53,4326,702],{"className":4327},[3243,3247,3280],[53,4329,3295],{"className":4330},[3294],[53,4332,4334],{"className":4333},[3260],[53,4335,4337],{"className":4336,"style":3569},[3264],[53,4338],{},[53,4340],{"className":4341,"style":3575},[3462],[53,4343,4345,4348],{"className":4344},[3243],[53,4346,3964],{"className":4347,"style":3989},[3243,3247],[53,4349,4351],{"className":4350},[3251],[53,4352,4354,4380],{"className":4353},[3255,3256],[53,4355,4357,4377],{"className":4356},[3260],[53,4358,4360],{"className":4359,"style":4002},[3264],[53,4361,4362,4365],{"style":4005},[53,4363],{"className":4364,"style":3273},[3272],[53,4366,4368],{"className":4367},[3277,3278,3279,3280],[53,4369,4371,4374],{"className":4370},[3243,3280],[53,4372,689],{"className":4373,"style":3290},[3243,3247,3280],[53,4375,702],{"className":4376},[3243,3247,3280],[53,4378,3295],{"className":4379},[3294],[53,4381,4383],{"className":4382},[3260],[53,4384,4386],{"className":4385,"style":3302},[3264],[53,4387],{},[53,4389],{"className":4390,"style":3575},[3462],[53,4392,4394,4397],{"className":4393},[3243],[53,4395,1945],{"className":4396},[3243,3247],[53,4398,4400],{"className":4399},[3251],[53,4401,4403,4429],{"className":4402},[3255,3256],[53,4404,4406,4426],{"className":4405},[3260],[53,4407,4409],{"className":4408,"style":3265},[3264],[53,4410,4411,4414],{"style":3268},[53,4412],{"className":4413,"style":3273},[3272],[53,4415,4417],{"className":4416},[3277,3278,3279,3280],[53,4418,4420,4423],{"className":4419},[3243,3280],[53,4421,772],{"className":4422},[3243,3247,3280],[53,4424,689],{"className":4425,"style":3290},[3243,3247,3280],[53,4427,3295],{"className":4428},[3294],[53,4430,4432],{"className":4431},[3260],[53,4433,4435],{"className":4434,"style":3302},[3264],[53,4436],{},[53,4438],{"className":4439,"style":3575},[3462],[53,4441,4443,4446],{"className":4442},[3243],[53,4444,1945],{"className":4445},[3243,3247],[53,4447,4449],{"className":4448},[3251],[53,4450,4452,4478],{"className":4451},[3255,3256],[53,4453,4455,4475],{"className":4454},[3260],[53,4456,4458],{"className":4457,"style":4002},[3264],[53,4459,4460,4463],{"style":3268},[53,4461],{"className":4462,"style":3273},[3272],[53,4464,4466],{"className":4465},[3277,3278,3279,3280],[53,4467,4469,4472],{"className":4468},[3243,3280],[53,4470,776],{"className":4471,"style":3872},[3243,3247,3280],[53,4473,702],{"className":4474},[3243,3247,3280],[53,4476,3295],{"className":4477},[3294],[53,4479,4481],{"className":4480},[3260],[53,4482,4484],{"className":4483,"style":3302},[3264],[53,4485],{},[53,4487,781],{"className":4488},[3243],[10,4490,4491,4492,4600,4601,4629,4630,4658],{},"Every term is a product of two 0\u002F1 variables, so the objective is quadratic. HiGHS solves linear programs with integer variables, so the products have to be rewritten with linear rows. The linearization of Kaufman and Broeckx is a standard and compact way to do that. It adds one continuous variable ",[53,4493,4495,4523],{"className":4494},[3194],[53,4496,4498],{"className":4497},[3198],[3200,4499,4500],{"xmlns":3202},[3204,4501,4502,4520],{},[3207,4503,4504,4515,4518],{},[3210,4505,4506,4509],{},[3213,4507,4508],{},"w",[3207,4510,4511,4513],{},[3213,4512,772],{},[3213,4514,689],{},[3441,4516,4517],{},"≥",[3459,4519,626],{},[3222,4521,4522],{"encoding":3224},"w_{ig} \\ge 0",[53,4524,4526,4590],{"className":4525,"ariaHidden":3230},[3229],[53,4527,4529,4533,4581,4584,4587],{"className":4528},[3234],[53,4530],{"className":4531,"style":4532},[3238],"height:0.9221em;vertical-align:-0.2861em;",[53,4534,4536,4540],{"className":4535},[3243],[53,4537,4508],{"className":4538,"style":4539},[3243,3247],"margin-right:0.0269em;",[53,4541,4543],{"className":4542},[3251],[53,4544,4546,4573],{"className":4545},[3255,3256],[53,4547,4549,4570],{"className":4548},[3260],[53,4550,4552],{"className":4551,"style":3265},[3264],[53,4553,4555,4558],{"style":4554},"top:-2.55em;margin-left:-0.0269em;margin-right:0.05em;",[53,4556],{"className":4557,"style":3273},[3272],[53,4559,4561],{"className":4560},[3277,3278,3279,3280],[53,4562,4564,4567],{"className":4563},[3243,3280],[53,4565,772],{"className":4566},[3243,3247,3280],[53,4568,689],{"className":4569,"style":3290},[3243,3247,3280],[53,4571,3295],{"className":4572},[3294],[53,4574,4576],{"className":4575},[3260],[53,4577,4579],{"className":4578,"style":3302},[3264],[53,4580],{},[53,4582],{"className":4583,"style":3625},[3462],[53,4585,4517],{"className":4586},[3629],[53,4588],{"className":4589,"style":3625},[3462],[53,4591,4593,4597],{"className":4592},[3234],[53,4594],{"className":4595,"style":4596},[3238],"height:0.6444em;",[53,4598,626],{"className":4599},[3243]," and one row for every flight ",[53,4602,4604,4617],{"className":4603},[3194],[53,4605,4607],{"className":4606},[3198],[3200,4608,4609],{"xmlns":3202},[3204,4610,4611,4615],{},[3207,4612,4613],{},[3213,4614,772],{},[3222,4616,772],{"encoding":3224},[53,4618,4620],{"className":4619,"ariaHidden":3230},[3229],[53,4621,4623,4626],{"className":4622},[3234],[53,4624],{"className":4625,"style":3331},[3238],[53,4627,772],{"className":4628},[3243,3247]," and gate ",[53,4631,4633,4646],{"className":4632},[3194],[53,4634,4636],{"className":4635},[3198],[3200,4637,4638],{"xmlns":3202},[3204,4639,4640,4644],{},[3207,4641,4642],{},[3213,4643,689],{},[3222,4645,689],{"encoding":3224},[53,4647,4649],{"className":4648,"ariaHidden":3230},[3229],[53,4650,4652,4655],{"className":4651},[3234],[53,4653],{"className":4654,"style":3361},[3238],[53,4656,689],{"className":4657,"style":3290},[3243,3247],":",[10,4660,4661],{},[53,4662,4664,4782],{"className":4663},[3194],[53,4665,4667],{"className":4666},[3198],[3200,4668,4669],{"xmlns":3202},[3204,4670,4671,4779],{},[3207,4672,4673,4683,4686,4688,4690,4696,4702,4713,4715,4725,4727,4737,4739,4742,4744,4755,4757,4760,4762,4764,4774,4777],{},[3210,4674,4675,4677],{},[3213,4676,4508],{},[3207,4678,4679,4681],{},[3213,4680,772],{},[3213,4682,689],{},[3466,4684,4685],{},"  ",[3441,4687,4517],{},[3466,4689,4685],{},[3210,4691,4692,4694],{},[3441,4693,3443],{},[3213,4695,776],{},[3210,4697,4698,4700],{},[3441,4699,3443],{},[3213,4701,702],{},[3210,4703,4704,4707],{},[3213,4705,4706],{},"E",[3207,4708,4709,4711],{},[3213,4710,772],{},[3213,4712,776],{},[3466,4714,4154],{},[3210,4716,4717,4719],{},[3213,4718,3964],{},[3207,4720,4721,4723],{},[3213,4722,689],{},[3213,4724,702],{},[3466,4726,4154],{},[3210,4728,4729,4731],{},[3213,4730,1945],{},[3207,4732,4733,4735],{},[3213,4734,776],{},[3213,4736,702],{},[3466,4738,4685],{},[3441,4740,4741],{},"−",[3466,4743,4685],{},[3210,4745,4746,4749],{},[3213,4747,4748],{},"M",[3207,4750,4751,4753],{},[3213,4752,772],{},[3213,4754,689],{},[3466,4756,4154],{},[3441,4758,575],{"stretchy":4759},"false",[3459,4761,632],{},[3441,4763,4741],{},[3210,4765,4766,4768],{},[3213,4767,1945],{},[3207,4769,4770,4772],{},[3213,4771,772],{},[3213,4773,689],{},[3441,4775,4776],{"stretchy":4759},")",[3213,4778,781],{"mathvariant":3508},[3222,4780,4781],{"encoding":3224},"w_{ig} \\;\\ge\\; \\sum_{j}\\sum_{h} E_{ij}\\, D_{gh}\\, x_{jh} \\;-\\; M_{ig}\\,(1 - x_{ig}).",[53,4783,4785,4852,5110,5184],{"className":4784,"ariaHidden":3230},[3229],[53,4786,4788,4791,4837,4840,4843,4846,4849],{"className":4787},[3234],[53,4789],{"className":4790,"style":4532},[3238],[53,4792,4794,4797],{"className":4793},[3243],[53,4795,4508],{"className":4796,"style":4539},[3243,3247],[53,4798,4800],{"className":4799},[3251],[53,4801,4803,4829],{"className":4802},[3255,3256],[53,4804,4806,4826],{"className":4805},[3260],[53,4807,4809],{"className":4808,"style":3265},[3264],[53,4810,4811,4814],{"style":4554},[53,4812],{"className":4813,"style":3273},[3272],[53,4815,4817],{"className":4816},[3277,3278,3279,3280],[53,4818,4820,4823],{"className":4819},[3243,3280],[53,4821,772],{"className":4822},[3243,3247,3280],[53,4824,689],{"className":4825,"style":3290},[3243,3247,3280],[53,4827,3295],{"className":4828},[3294],[53,4830,4832],{"className":4831},[3260],[53,4833,4835],{"className":4834,"style":3302},[3264],[53,4836],{},[53,4838],{"className":4839,"style":3625},[3462],[53,4841],{"className":4842,"style":3625},[3462],[53,4844,4517],{"className":4845},[3629],[53,4847],{"className":4848,"style":3625},[3462],[53,4850],{"className":4851,"style":3625},[3462],[53,4853,4855,4858,4901,4904,4947,4950,4995,4998,5044,5047,5093,5096,5100,5104,5107],{"className":4854},[3234],[53,4856],{"className":4857,"style":3521},[3238],[53,4859,4861,4864],{"className":4860},[3525],[53,4862,3443],{"className":4863,"style":3531},[3525,3529,3530],[53,4865,4867],{"className":4866},[3251],[53,4868,4870,4893],{"className":4869},[3255,3256],[53,4871,4873,4890],{"className":4872},[3260],[53,4874,4876],{"className":4875,"style":3689},[3264],[53,4877,4878,4881],{"style":3547},[53,4879],{"className":4880,"style":3273},[3272],[53,4882,4884],{"className":4883},[3277,3278,3279,3280],[53,4885,4887],{"className":4886},[3243,3280],[53,4888,776],{"className":4889,"style":3872},[3243,3247,3280],[53,4891,3295],{"className":4892},[3294],[53,4894,4896],{"className":4895},[3260],[53,4897,4899],{"className":4898,"style":3569},[3264],[53,4900],{},[53,4902],{"className":4903,"style":3575},[3462],[53,4905,4907,4910],{"className":4906},[3525],[53,4908,3443],{"className":4909,"style":3531},[3525,3529,3530],[53,4911,4913],{"className":4912},[3251],[53,4914,4916,4939],{"className":4915},[3255,3256],[53,4917,4919,4936],{"className":4918},[3260],[53,4920,4922],{"className":4921,"style":4307},[3264],[53,4923,4924,4927],{"style":3547},[53,4925],{"className":4926,"style":3273},[3272],[53,4928,4930],{"className":4929},[3277,3278,3279,3280],[53,4931,4933],{"className":4932},[3243,3280],[53,4934,702],{"className":4935},[3243,3247,3280],[53,4937,3295],{"className":4938},[3294],[53,4940,4942],{"className":4941},[3260],[53,4943,4945],{"className":4944,"style":3713},[3264],[53,4946],{},[53,4948],{"className":4949,"style":3575},[3462],[53,4951,4953,4957],{"className":4952},[3243],[53,4954,4706],{"className":4955,"style":4956},[3243,3247],"margin-right:0.0576em;",[53,4958,4960],{"className":4959},[3251],[53,4961,4963,4987],{"className":4962},[3255,3256],[53,4964,4966,4984],{"className":4965},[3260],[53,4967,4969],{"className":4968,"style":3265},[3264],[53,4970,4972,4975],{"style":4971},"top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;",[53,4973],{"className":4974,"style":3273},[3272],[53,4976,4978],{"className":4977},[3277,3278,3279,3280],[53,4979,4981],{"className":4980},[3243,3280],[53,4982,3873],{"className":4983,"style":3872},[3243,3247,3280],[53,4985,3295],{"className":4986},[3294],[53,4988,4990],{"className":4989},[3260],[53,4991,4993],{"className":4992,"style":3302},[3264],[53,4994],{},[53,4996],{"className":4997,"style":3575},[3462],[53,4999,5001,5004],{"className":5000},[3243],[53,5002,3964],{"className":5003,"style":3989},[3243,3247],[53,5005,5007],{"className":5006},[3251],[53,5008,5010,5036],{"className":5009},[3255,3256],[53,5011,5013,5033],{"className":5012},[3260],[53,5014,5016],{"className":5015,"style":4002},[3264],[53,5017,5018,5021],{"style":4005},[53,5019],{"className":5020,"style":3273},[3272],[53,5022,5024],{"className":5023},[3277,3278,3279,3280],[53,5025,5027,5030],{"className":5026},[3243,3280],[53,5028,689],{"className":5029,"style":3290},[3243,3247,3280],[53,5031,702],{"className":5032},[3243,3247,3280],[53,5034,3295],{"className":5035},[3294],[53,5037,5039],{"className":5038},[3260],[53,5040,5042],{"className":5041,"style":3302},[3264],[53,5043],{},[53,5045],{"className":5046,"style":3575},[3462],[53,5048,5050,5053],{"className":5049},[3243],[53,5051,1945],{"className":5052},[3243,3247],[53,5054,5056],{"className":5055},[3251],[53,5057,5059,5085],{"className":5058},[3255,3256],[53,5060,5062,5082],{"className":5061},[3260],[53,5063,5065],{"className":5064,"style":4002},[3264],[53,5066,5067,5070],{"style":3268},[53,5068],{"className":5069,"style":3273},[3272],[53,5071,5073],{"className":5072},[3277,3278,3279,3280],[53,5074,5076,5079],{"className":5075},[3243,3280],[53,5077,776],{"className":5078,"style":3872},[3243,3247,3280],[53,5080,702],{"className":5081},[3243,3247,3280],[53,5083,3295],{"className":5084},[3294],[53,5086,5088],{"className":5087},[3260],[53,5089,5091],{"className":5090,"style":3302},[3264],[53,5092],{},[53,5094],{"className":5095,"style":3625},[3462],[53,5097],{"className":5098,"style":5099},[3462],"margin-right:0.2222em;",[53,5101,4741],{"className":5102},[5103],"mbin",[53,5105],{"className":5106,"style":3625},[3462],[53,5108],{"className":5109,"style":5099},[3462],[53,5111,5113,5117,5165,5168,5172,5175,5178,5181],{"className":5112},[3234],[53,5114],{"className":5115,"style":5116},[3238],"height:1.0361em;vertical-align:-0.2861em;",[53,5118,5120,5124],{"className":5119},[3243],[53,5121,4748],{"className":5122,"style":5123},[3243,3247],"margin-right:0.109em;",[53,5125,5127],{"className":5126},[3251],[53,5128,5130,5157],{"className":5129},[3255,3256],[53,5131,5133,5154],{"className":5132},[3260],[53,5134,5136],{"className":5135,"style":3265},[3264],[53,5137,5139,5142],{"style":5138},"top:-2.55em;margin-left:-0.109em;margin-right:0.05em;",[53,5140],{"className":5141,"style":3273},[3272],[53,5143,5145],{"className":5144},[3277,3278,3279,3280],[53,5146,5148,5151],{"className":5147},[3243,3280],[53,5149,772],{"className":5150},[3243,3247,3280],[53,5152,689],{"className":5153,"style":3290},[3243,3247,3280],[53,5155,3295],{"className":5156},[3294],[53,5158,5160],{"className":5159},[3260],[53,5161,5163],{"className":5162,"style":3302},[3264],[53,5164],{},[53,5166],{"className":5167,"style":3575},[3462],[53,5169,575],{"className":5170},[5171],"mopen",[53,5173,632],{"className":5174},[3243],[53,5176],{"className":5177,"style":5099},[3462],[53,5179,4741],{"className":5180},[5103],[53,5182],{"className":5183,"style":5099},[3462],[53,5185,5187,5190,5236,5240],{"className":5186},[3234],[53,5188],{"className":5189,"style":5116},[3238],[53,5191,5193,5196],{"className":5192},[3243],[53,5194,1945],{"className":5195},[3243,3247],[53,5197,5199],{"className":5198},[3251],[53,5200,5202,5228],{"className":5201},[3255,3256],[53,5203,5205,5225],{"className":5204},[3260],[53,5206,5208],{"className":5207,"style":3265},[3264],[53,5209,5210,5213],{"style":3268},[53,5211],{"className":5212,"style":3273},[3272],[53,5214,5216],{"className":5215},[3277,3278,3279,3280],[53,5217,5219,5222],{"className":5218},[3243,3280],[53,5220,772],{"className":5221},[3243,3247,3280],[53,5223,689],{"className":5224,"style":3290},[3243,3247,3280],[53,5226,3295],{"className":5227},[3294],[53,5229,5231],{"className":5230},[3260],[53,5232,5234],{"className":5233,"style":3302},[3264],[53,5235],{},[53,5237,4776],{"className":5238},[5239],"mclose",[53,5241,781],{"className":5242},[3243],[10,5244,5245,5246,5466,5467,1615,5495,5523,5524,3394,5552,5580,5581,5661,5662,5690,5691,5719,5720,5800,5801,5880,5881,5909,5910,781],{},"In this row, ",[53,5247,5249,5295],{"className":5248},[3194],[53,5250,5252],{"className":5251},[3198],[3200,5253,5254],{"xmlns":3202},[3204,5255,5256,5292],{},[3207,5257,5258,5268,5270,5280,5282],{},[3210,5259,5260,5262],{},[3213,5261,4706],{},[3207,5263,5264,5266],{},[3213,5265,772],{},[3213,5267,776],{},[3441,5269,64],{},[3210,5271,5272,5274],{},[3213,5273,3818],{},[3207,5275,5276,5278],{},[3213,5277,772],{},[3213,5279,776],{},[3441,5281,433],{},[3210,5283,5284,5286],{},[3213,5285,3818],{},[3207,5287,5288,5290],{},[3213,5289,776],{},[3213,5291,772],{},[3222,5293,5294],{"encoding":3224},"E_{ij} = T_{ij} + T_{ji}",[53,5296,5298,5356,5414],{"className":5297,"ariaHidden":3230},[3229],[53,5299,5301,5304,5347,5350,5353],{"className":5300},[3234],[53,5302],{"className":5303,"style":3837},[3238],[53,5305,5307,5310],{"className":5306},[3243],[53,5308,4706],{"className":5309,"style":4956},[3243,3247],[53,5311,5313],{"className":5312},[3251],[53,5314,5316,5339],{"className":5315},[3255,3256],[53,5317,5319,5336],{"className":5318},[3260],[53,5320,5322],{"className":5321,"style":3265},[3264],[53,5323,5324,5327],{"style":4971},[53,5325],{"className":5326,"style":3273},[3272],[53,5328,5330],{"className":5329},[3277,3278,3279,3280],[53,5331,5333],{"className":5332},[3243,3280],[53,5334,3873],{"className":5335,"style":3872},[3243,3247,3280],[53,5337,3295],{"className":5338},[3294],[53,5340,5342],{"className":5341},[3260],[53,5343,5345],{"className":5344,"style":3302},[3264],[53,5346],{},[53,5348],{"className":5349,"style":3625},[3462],[53,5351,64],{"className":5352},[3629],[53,5354],{"className":5355,"style":3625},[3462],[53,5357,5359,5362,5405,5408,5411],{"className":5358},[3234],[53,5360],{"className":5361,"style":3837},[3238],[53,5363,5365,5368],{"className":5364},[3243],[53,5366,3818],{"className":5367,"style":3844},[3243,3247],[53,5369,5371],{"className":5370},[3251],[53,5372,5374,5397],{"className":5373},[3255,3256],[53,5375,5377,5394],{"className":5376},[3260],[53,5378,5380],{"className":5379,"style":3265},[3264],[53,5381,5382,5385],{"style":3859},[53,5383],{"className":5384,"style":3273},[3272],[53,5386,5388],{"className":5387},[3277,3278,3279,3280],[53,5389,5391],{"className":5390},[3243,3280],[53,5392,3873],{"className":5393,"style":3872},[3243,3247,3280],[53,5395,3295],{"className":5396},[3294],[53,5398,5400],{"className":5399},[3260],[53,5401,5403],{"className":5402,"style":3302},[3264],[53,5404],{},[53,5406],{"className":5407,"style":5099},[3462],[53,5409,433],{"className":5410},[5103],[53,5412],{"className":5413,"style":5099},[3462],[53,5415,5417,5420],{"className":5416},[3234],[53,5418],{"className":5419,"style":3837},[3238],[53,5421,5423,5426],{"className":5422},[3243],[53,5424,3818],{"className":5425,"style":3844},[3243,3247],[53,5427,5429],{"className":5428},[3251],[53,5430,5432,5458],{"className":5431},[3255,3256],[53,5433,5435,5455],{"className":5434},[3260],[53,5436,5438],{"className":5437,"style":3265},[3264],[53,5439,5440,5443],{"style":3859},[53,5441],{"className":5442,"style":3273},[3272],[53,5444,5446],{"className":5445},[3277,3278,3279,3280],[53,5447,5449,5452],{"className":5448},[3243,3280],[53,5450,776],{"className":5451,"style":3872},[3243,3247,3280],[53,5453,772],{"className":5454},[3243,3247,3280],[53,5456,3295],{"className":5457},[3294],[53,5459,5461],{"className":5460},[3260],[53,5462,5464],{"className":5463,"style":3302},[3264],[53,5465],{}," counts the passengers between flights ",[53,5468,5470,5483],{"className":5469},[3194],[53,5471,5473],{"className":5472},[3198],[3200,5474,5475],{"xmlns":3202},[3204,5476,5477,5481],{},[3207,5478,5479],{},[3213,5480,772],{},[3222,5482,772],{"encoding":3224},[53,5484,5486],{"className":5485,"ariaHidden":3230},[3229],[53,5487,5489,5492],{"className":5488},[3234],[53,5490],{"className":5491,"style":3331},[3238],[53,5493,772],{"className":5494},[3243,3247],[53,5496,5498,5511],{"className":5497},[3194],[53,5499,5501],{"className":5500},[3198],[3200,5502,5503],{"xmlns":3202},[3204,5504,5505,5509],{},[3207,5506,5507],{},[3213,5508,776],{},[3222,5510,776],{"encoding":3224},[53,5512,5514],{"className":5513,"ariaHidden":3230},[3229],[53,5515,5517,5520],{"className":5516},[3234],[53,5518],{"className":5519,"style":3939},[3238],[53,5521,776],{"className":5522,"style":3872},[3243,3247]," in both directions. Passengers walk the same distance in both directions. If flight ",[53,5525,5527,5540],{"className":5526},[3194],[53,5528,5530],{"className":5529},[3198],[3200,5531,5532],{"xmlns":3202},[3204,5533,5534,5538],{},[3207,5535,5536],{},[3213,5537,772],{},[3222,5539,772],{"encoding":3224},[53,5541,5543],{"className":5542,"ariaHidden":3230},[3229],[53,5544,5546,5549],{"className":5545},[3234],[53,5547],{"className":5548,"style":3331},[3238],[53,5550,772],{"className":5551},[3243,3247],[53,5553,5555,5568],{"className":5554},[3194],[53,5556,5558],{"className":5557},[3198],[3200,5559,5560],{"xmlns":3202},[3204,5561,5562,5566],{},[3207,5563,5564],{},[3213,5565,689],{},[3222,5567,689],{"encoding":3224},[53,5569,5571],{"className":5570,"ariaHidden":3230},[3229],[53,5572,5574,5577],{"className":5573},[3234],[53,5575],{"className":5576,"style":3361},[3238],[53,5578,689],{"className":5579,"style":3290},[3243,3247],", the row makes ",[53,5582,5584,5606],{"className":5583},[3194],[53,5585,5587],{"className":5586},[3198],[3200,5588,5589],{"xmlns":3202},[3204,5590,5591,5603],{},[3207,5592,5593],{},[3210,5594,5595,5597],{},[3213,5596,4508],{},[3207,5598,5599,5601],{},[3213,5600,772],{},[3213,5602,689],{},[3222,5604,5605],{"encoding":3224},"w_{ig}",[53,5607,5609],{"className":5608,"ariaHidden":3230},[3229],[53,5610,5612,5615],{"className":5611},[3234],[53,5613],{"className":5614,"style":3239},[3238],[53,5616,5618,5621],{"className":5617},[3243],[53,5619,4508],{"className":5620,"style":4539},[3243,3247],[53,5622,5624],{"className":5623},[3251],[53,5625,5627,5653],{"className":5626},[3255,3256],[53,5628,5630,5650],{"className":5629},[3260],[53,5631,5633],{"className":5632,"style":3265},[3264],[53,5634,5635,5638],{"style":4554},[53,5636],{"className":5637,"style":3273},[3272],[53,5639,5641],{"className":5640},[3277,3278,3279,3280],[53,5642,5644,5647],{"className":5643},[3243,3280],[53,5645,772],{"className":5646},[3243,3247,3280],[53,5648,689],{"className":5649,"style":3290},[3243,3247,3280],[53,5651,3295],{"className":5652},[3294],[53,5654,5656],{"className":5655},[3260],[53,5657,5659],{"className":5658,"style":3302},[3264],[53,5660],{}," at least the metres that the passengers of flight ",[53,5663,5665,5678],{"className":5664},[3194],[53,5666,5668],{"className":5667},[3198],[3200,5669,5670],{"xmlns":3202},[3204,5671,5672,5676],{},[3207,5673,5674],{},[3213,5675,772],{},[3222,5677,772],{"encoding":3224},[53,5679,5681],{"className":5680,"ariaHidden":3230},[3229],[53,5682,5684,5687],{"className":5683},[3234],[53,5685],{"className":5686,"style":3331},[3238],[53,5688,772],{"className":5689},[3243,3247]," walk, on arrival and on departure. If flight ",[53,5692,5694,5707],{"className":5693},[3194],[53,5695,5697],{"className":5696},[3198],[3200,5698,5699],{"xmlns":3202},[3204,5700,5701,5705],{},[3207,5702,5703],{},[3213,5704,772],{},[3222,5706,772],{"encoding":3224},[53,5708,5710],{"className":5709,"ariaHidden":3230},[3229],[53,5711,5713,5716],{"className":5712},[3234],[53,5714],{"className":5715,"style":3331},[3238],[53,5717,772],{"className":5718},[3243,3247]," stands elsewhere, the constant ",[53,5721,5723,5745],{"className":5722},[3194],[53,5724,5726],{"className":5725},[3198],[3200,5727,5728],{"xmlns":3202},[3204,5729,5730,5742],{},[3207,5731,5732],{},[3210,5733,5734,5736],{},[3213,5735,4748],{},[3207,5737,5738,5740],{},[3213,5739,772],{},[3213,5741,689],{},[3222,5743,5744],{"encoding":3224},"M_{ig}",[53,5746,5748],{"className":5747,"ariaHidden":3230},[3229],[53,5749,5751,5754],{"className":5750},[3234],[53,5752],{"className":5753,"style":3837},[3238],[53,5755,5757,5760],{"className":5756},[3243],[53,5758,4748],{"className":5759,"style":5123},[3243,3247],[53,5761,5763],{"className":5762},[3251],[53,5764,5766,5792],{"className":5765},[3255,3256],[53,5767,5769,5789],{"className":5768},[3260],[53,5770,5772],{"className":5771,"style":3265},[3264],[53,5773,5774,5777],{"style":5138},[53,5775],{"className":5776,"style":3273},[3272],[53,5778,5780],{"className":5779},[3277,3278,3279,3280],[53,5781,5783,5786],{"className":5782},[3243,3280],[53,5784,772],{"className":5785},[3243,3247,3280],[53,5787,689],{"className":5788,"style":3290},[3243,3247,3280],[53,5790,3295],{"className":5791},[3294],[53,5793,5795],{"className":5794},[3260],[53,5796,5798],{"className":5797,"style":3302},[3264],[53,5799],{}," switches the row off. ",[53,5802,5804,5825],{"className":5803},[3194],[53,5805,5807],{"className":5806},[3198],[3200,5808,5809],{"xmlns":3202},[3204,5810,5811,5823],{},[3207,5812,5813],{},[3210,5814,5815,5817],{},[3213,5816,4748],{},[3207,5818,5819,5821],{},[3213,5820,772],{},[3213,5822,689],{},[3222,5824,5744],{"encoding":3224},[53,5826,5828],{"className":5827,"ariaHidden":3230},[3229],[53,5829,5831,5834],{"className":5830},[3234],[53,5832],{"className":5833,"style":3837},[3238],[53,5835,5837,5840],{"className":5836},[3243],[53,5838,4748],{"className":5839,"style":5123},[3243,3247],[53,5841,5843],{"className":5842},[3251],[53,5844,5846,5872],{"className":5845},[3255,3256],[53,5847,5849,5869],{"className":5848},[3260],[53,5850,5852],{"className":5851,"style":3265},[3264],[53,5853,5854,5857],{"style":5138},[53,5855],{"className":5856,"style":3273},[3272],[53,5858,5860],{"className":5859},[3277,3278,3279,3280],[53,5861,5863,5866],{"className":5862},[3243,3280],[53,5864,772],{"className":5865},[3243,3247,3280],[53,5867,689],{"className":5868,"style":3290},[3243,3247,3280],[53,5870,3295],{"className":5871},[3294],[53,5873,5875],{"className":5874},[3260],[53,5876,5878],{"className":5877,"style":3302},[3264],[53,5879],{}," is the walk of these passengers if all of them had to reach the gate furthest from ",[53,5882,5884,5897],{"className":5883},[3194],[53,5885,5887],{"className":5886},[3198],[3200,5888,5889],{"xmlns":3202},[3204,5890,5891,5895],{},[3207,5892,5893],{},[3213,5894,689],{},[3222,5896,689],{"encoding":3224},[53,5898,5900],{"className":5899,"ariaHidden":3230},[3229],[53,5901,5903,5906],{"className":5902},[3234],[53,5904],{"className":5905,"style":3361},[3238],[53,5907,689],{"className":5908,"style":3290},[3243,3247],". No plan asks for more. Such a row is known as a big-M row. Every passenger is counted at two flights, on arrival and on departure, so the program minimizes ",[53,5911,5913,5957],{"className":5912},[3194],[53,5914,5916],{"className":5915},[3198],[3200,5917,5918],{"xmlns":3202},[3204,5919,5920,5954],{},[3207,5921,5922,5932,5944],{},[5923,5924,5925],"mstyle",{"scriptlevel":626,"displaystyle":4759},[5926,5927,5928,5930],"mfrac",{},[3459,5929,632],{},[3459,5931,2432],{},[3210,5933,5934,5936],{},[3441,5935,3443],{},[3207,5937,5938,5940,5942],{},[3213,5939,772],{},[3441,5941,3473],{"separator":3230},[3213,5943,689],{},[3210,5945,5946,5948],{},[3213,5947,4508],{},[3207,5949,5950,5952],{},[3213,5951,772],{},[3213,5953,689],{},[3222,5955,5956],{"encoding":3224},"\\tfrac{1}{2} \\sum_{i,g} w_{ig}",[53,5958,5960],{"className":5959,"ariaHidden":3230},[3229],[53,5961,5963,5967,6044,6047,6096,6099],{"className":5962},[3234],[53,5964],{"className":5965,"style":5966},[3238],"height:1.2809em;vertical-align:-0.4358em;",[53,5968,5970,5974,6041],{"className":5969},[3243],[53,5971],{"className":5972},[5171,5973],"nulldelimiter",[53,5975,5977],{"className":5976},[5926],[53,5978,5980,6032],{"className":5979},[3255,3256],[53,5981,5983,6029],{"className":5982},[3260],[53,5984,5987,6003,6014],{"className":5985,"style":5986},[3264],"height:0.8451em;",[53,5988,5990,5994],{"style":5989},"top:-2.655em;",[53,5991],{"className":5992,"style":5993},[3272],"height:3em;",[53,5995,5997],{"className":5996},[3277,3278,3279,3280],[53,5998,6000],{"className":5999},[3243,3280],[53,6001,2432],{"className":6002},[3243,3280],[53,6004,6006,6009],{"style":6005},"top:-3.23em;",[53,6007],{"className":6008,"style":5993},[3272],[53,6010],{"className":6011,"style":6013},[6012],"frac-line","border-bottom-width:0.04em;",[53,6015,6017,6020],{"style":6016},"top:-3.394em;",[53,6018],{"className":6019,"style":5993},[3272],[53,6021,6023],{"className":6022},[3277,3278,3279,3280],[53,6024,6026],{"className":6025},[3243,3280],[53,6027,632],{"className":6028},[3243,3280],[53,6030,3295],{"className":6031},[3294],[53,6033,6035],{"className":6034},[3260],[53,6036,6039],{"className":6037,"style":6038},[3264],"height:0.345em;",[53,6040],{},[53,6042],{"className":6043},[5239,5973],[53,6045],{"className":6046,"style":3575},[3462],[53,6048,6050,6053],{"className":6049},[3525],[53,6051,3443],{"className":6052,"style":3531},[3525,3529,3530],[53,6054,6056],{"className":6055},[3251],[53,6057,6059,6088],{"className":6058},[3255,3256],[53,6060,6062,6085],{"className":6061},[3260],[53,6063,6065],{"className":6064,"style":3689},[3264],[53,6066,6067,6070],{"style":3547},[53,6068],{"className":6069,"style":3273},[3272],[53,6071,6073],{"className":6072},[3277,3278,3279,3280],[53,6074,6076,6079,6082],{"className":6075},[3243,3280],[53,6077,772],{"className":6078},[3243,3247,3280],[53,6080,3473],{"className":6081},[3660,3280],[53,6083,689],{"className":6084,"style":3290},[3243,3247,3280],[53,6086,3295],{"className":6087},[3294],[53,6089,6091],{"className":6090},[3260],[53,6092,6094],{"className":6093,"style":3569},[3264],[53,6095],{},[53,6097],{"className":6098,"style":3575},[3462],[53,6100,6102,6105],{"className":6101},[3243],[53,6103,4508],{"className":6104,"style":4539},[3243,3247],[53,6106,6108],{"className":6107},[3251],[53,6109,6111,6137],{"className":6110},[3255,3256],[53,6112,6114,6134],{"className":6113},[3260],[53,6115,6117],{"className":6116,"style":3265},[3264],[53,6118,6119,6122],{"style":4554},[53,6120],{"className":6121,"style":3273},[3272],[53,6123,6125],{"className":6124},[3277,3278,3279,3280],[53,6126,6128,6131],{"className":6127},[3243,3280],[53,6129,772],{"className":6130},[3243,3247,3280],[53,6132,689],{"className":6133,"style":3290},[3243,3247,3280],[53,6135,3295],{"className":6136},[3294],[53,6138,6140],{"className":6139},[3260],[53,6141,6143],{"className":6142,"style":3302},[3264],[53,6144],{},[10,6146,6147],{},"The size of this program can be counted without building it:",[43,6149,6151],{"className":45,"code":6150,"language":47,"meta":48,"style":48},"def linearized_size(transfers):\n    \"\"\"Size of the linearized program for a bank, counted without building it.\n\n    Args:\n        transfers: Passengers between the flights.\n\n    Returns:\n        The numbers of columns, rows and nonzero coefficients.\n    \"\"\"\n    flights = len(transfers)\n    exchange = transfers + transfers.T                  # E[i, j]: passengers between flights i and j, both directions\n    partner_pairs = np.count_nonzero(exchange)          # pairs (i, j) with E[i, j] > 0\n    columns = 2 * flights**2                            # x[i, g] and w[i, g]\n    rows = 2 * flights + flights**2                     # one per flight, one per gate, one per w[i, g]\n    one_to_one = 2 * flights**2                         # nonzeros of the rows per flight and per gate\n    # the row of w[i, g] holds w[i, g], x[i, g], and x[j, h] for every partner j of i and every other gate h\n    walking_rows = 2 * flights**2 + partner_pairs * flights * (flights - 1)\n    return columns, rows, one_to_one + walking_rows\n\n\ncolumns, rows, nonzeros = linearized_size(transfers)\nprint(f\"{columns:,} columns, {columns \u002F\u002F 2:,} of them 0\u002F1\")\nprint(f\"{rows:,} rows\")\nprint(f\"{nonzeros:,} nonzeros\")\n",[50,6152,6153,6163,6168,6172,6176,6180,6184,6188,6193,6197,6207,6225,6238,6260,6284,6304,6309,6346,6358,6362,6366,6376,6417,6441],{"__ignoreMap":48},[53,6154,6155,6157,6160],{"class":55,"line":56},[53,6156,162],{"class":63},[53,6158,6159],{"class":165}," linearized_size",[53,6161,6162],{"class":59},"(transfers):\n",[53,6164,6165],{"class":55,"line":75},[53,6166,6167],{"class":175},"    \"\"\"Size of the linearized program for a bank, counted without building it.\n",[53,6169,6170],{"class":55,"line":89},[53,6171,135],{"emptyLinePlaceholder":134},[53,6173,6174],{"class":55,"line":149},[53,6175,187],{"class":175},[53,6177,6178],{"class":55,"line":154},[53,6179,1725],{"class":175},[53,6181,6182],{"class":55,"line":159},[53,6183,135],{"emptyLinePlaceholder":134},[53,6185,6186],{"class":55,"line":172},[53,6187,204],{"class":175},[53,6189,6190],{"class":55,"line":179},[53,6191,6192],{"class":175},"        The numbers of columns, rows and nonzero coefficients.\n",[53,6194,6195],{"class":55,"line":184},[53,6196,222],{"class":175},[53,6198,6199,6201,6203,6205],{"class":55,"line":190},[53,6200,1762],{"class":59},[53,6202,64],{"class":63},[53,6204,1767],{"class":67},[53,6206,1770],{"class":59},[53,6208,6209,6212,6214,6217,6219,6222],{"class":55,"line":196},[53,6210,6211],{"class":59},"    exchange ",[53,6213,64],{"class":63},[53,6215,6216],{"class":59}," transfers ",[53,6218,433],{"class":63},[53,6220,6221],{"class":59}," transfers.T                  ",[53,6223,6224],{"class":71},"# E[i, j]: passengers between flights i and j, both directions\n",[53,6226,6227,6230,6232,6235],{"class":55,"line":201},[53,6228,6229],{"class":59},"    partner_pairs ",[53,6231,64],{"class":63},[53,6233,6234],{"class":59}," np.count_nonzero(exchange)          ",[53,6236,6237],{"class":71},"# pairs (i, j) with E[i, j] > 0\n",[53,6239,6240,6243,6245,6247,6249,6252,6255,6257],{"class":55,"line":207},[53,6241,6242],{"class":59},"    columns ",[53,6244,64],{"class":63},[53,6246,287],{"class":67},[53,6248,270],{"class":63},[53,6250,6251],{"class":59}," flights",[53,6253,6254],{"class":63},"**",[53,6256,2432],{"class":67},[53,6258,6259],{"class":71},"                            # x[i, g] and w[i, g]\n",[53,6261,6262,6265,6267,6269,6271,6273,6275,6277,6279,6281],{"class":55,"line":213},[53,6263,6264],{"class":59},"    rows ",[53,6266,64],{"class":63},[53,6268,287],{"class":67},[53,6270,270],{"class":63},[53,6272,890],{"class":59},[53,6274,433],{"class":63},[53,6276,6251],{"class":59},[53,6278,6254],{"class":63},[53,6280,2432],{"class":67},[53,6282,6283],{"class":71},"                     # one per flight, one per gate, one per w[i, g]\n",[53,6285,6286,6289,6291,6293,6295,6297,6299,6301],{"class":55,"line":219},[53,6287,6288],{"class":59},"    one_to_one ",[53,6290,64],{"class":63},[53,6292,287],{"class":67},[53,6294,270],{"class":63},[53,6296,6251],{"class":59},[53,6298,6254],{"class":63},[53,6300,2432],{"class":67},[53,6302,6303],{"class":71},"                         # nonzeros of the rows per flight and per gate\n",[53,6305,6306],{"class":55,"line":225},[53,6307,6308],{"class":71},"    # the row of w[i, g] holds w[i, g], x[i, g], and x[j, h] for every partner j of i and every other gate h\n",[53,6310,6311,6314,6316,6318,6320,6322,6324,6326,6328,6331,6333,6335,6337,6340,6342,6344],{"class":55,"line":236},[53,6312,6313],{"class":59},"    walking_rows ",[53,6315,64],{"class":63},[53,6317,287],{"class":67},[53,6319,270],{"class":63},[53,6321,6251],{"class":59},[53,6323,6254],{"class":63},[53,6325,2432],{"class":67},[53,6327,264],{"class":63},[53,6329,6330],{"class":59}," partner_pairs ",[53,6332,1049],{"class":63},[53,6334,890],{"class":59},[53,6336,1049],{"class":63},[53,6338,6339],{"class":59}," (flights ",[53,6341,422],{"class":63},[53,6343,2545],{"class":67},[53,6345,290],{"class":59},[53,6347,6348,6350,6353,6355],{"class":55,"line":253},[53,6349,296],{"class":63},[53,6351,6352],{"class":59}," columns, rows, one_to_one ",[53,6354,433],{"class":63},[53,6356,6357],{"class":59}," walking_rows\n",[53,6359,6360],{"class":55,"line":293},[53,6361,135],{"emptyLinePlaceholder":134},[53,6363,6364],{"class":55,"line":302},[53,6365,135],{"emptyLinePlaceholder":134},[53,6367,6368,6371,6373],{"class":55,"line":307},[53,6369,6370],{"class":59},"columns, rows, nonzeros ",[53,6372,64],{"class":63},[53,6374,6375],{"class":59}," linearized_size(transfers)\n",[53,6377,6378,6380,6382,6384,6386,6388,6391,6394,6396,6399,6401,6404,6406,6408,6410,6412,6415],{"class":55,"line":312},[53,6379,572],{"class":67},[53,6381,575],{"class":59},[53,6383,578],{"class":63},[53,6385,606],{"class":175},[53,6387,584],{"class":67},[53,6389,6390],{"class":59},"columns",[53,6392,6393],{"class":63},":,",[53,6395,590],{"class":67},[53,6397,6398],{"class":175}," columns, ",[53,6400,584],{"class":67},[53,6402,6403],{"class":59},"columns ",[53,6405,247],{"class":63},[53,6407,287],{"class":67},[53,6409,6393],{"class":63},[53,6411,590],{"class":67},[53,6413,6414],{"class":175}," of them 0\u002F1\"",[53,6416,290],{"class":59},[53,6418,6419,6421,6423,6425,6427,6429,6432,6434,6436,6439],{"class":55,"line":322},[53,6420,572],{"class":67},[53,6422,575],{"class":59},[53,6424,578],{"class":63},[53,6426,606],{"class":175},[53,6428,584],{"class":67},[53,6430,6431],{"class":59},"rows",[53,6433,6393],{"class":63},[53,6435,590],{"class":67},[53,6437,6438],{"class":175}," rows\"",[53,6440,290],{"class":59},[53,6442,6443,6445,6447,6449,6451,6453,6456,6458,6460,6463],{"class":55,"line":328},[53,6444,572],{"class":67},[53,6446,575],{"class":59},[53,6448,578],{"class":63},[53,6450,606],{"class":175},[53,6452,584],{"class":67},[53,6454,6455],{"class":59},"nonzeros",[53,6457,6393],{"class":63},[53,6459,590],{"class":67},[53,6461,6462],{"class":175}," nonzeros\"",[53,6464,290],{"class":59},[752,6466],{":lines":6467,"label":755},"[\"4,608 columns, 2,304 of them 0\u002F1\",\"2,400 rows\",\"821,376 nonzeros\"]",[10,6469,6470,6471,6550,6551,6579],{},"Almost all of the 821,376 nonzero coefficients sit in the rows for ",[53,6472,6474,6495],{"className":6473},[3194],[53,6475,6477],{"className":6476},[3198],[3200,6478,6479],{"xmlns":3202},[3204,6480,6481,6493],{},[3207,6482,6483],{},[3210,6484,6485,6487],{},[3213,6486,4508],{},[3207,6488,6489,6491],{},[3213,6490,772],{},[3213,6492,689],{},[3222,6494,5605],{"encoding":3224},[53,6496,6498],{"className":6497,"ariaHidden":3230},[3229],[53,6499,6501,6504],{"className":6500},[3234],[53,6502],{"className":6503,"style":3239},[3238],[53,6505,6507,6510],{"className":6506},[3243],[53,6508,4508],{"className":6509,"style":4539},[3243,3247],[53,6511,6513],{"className":6512},[3251],[53,6514,6516,6542],{"className":6515},[3255,3256],[53,6517,6519,6539],{"className":6518},[3260],[53,6520,6522],{"className":6521,"style":3265},[3264],[53,6523,6524,6527],{"style":4554},[53,6525],{"className":6526,"style":3273},[3272],[53,6528,6530],{"className":6529},[3277,3278,3279,3280],[53,6531,6533,6536],{"className":6532},[3243,3280],[53,6534,772],{"className":6535},[3243,3247,3280],[53,6537,689],{"className":6538,"style":3290},[3243,3247,3280],[53,6540,3295],{"className":6541},[3294],[53,6543,6545],{"className":6544},[3260],[53,6546,6548],{"className":6547,"style":3302},[3264],[53,6549],{},". Each of these rows holds one coefficient for every partner flight of ",[53,6552,6554,6567],{"className":6553},[3194],[53,6555,6557],{"className":6556},[3198],[3200,6558,6559],{"xmlns":3202},[3204,6560,6561,6565],{},[3207,6562,6563],{},[3213,6564,772],{},[3222,6566,772],{"encoding":3224},[53,6568,6570],{"className":6569,"ariaHidden":3230},[3229],[53,6571,6573,6576],{"className":6572},[3234],[53,6574],{"className":6575,"style":3331},[3238],[53,6577,772],{"className":6578},[3243,3247]," at every other gate.",[10,6581,6582,6583,6586],{},"We write the program with ",[50,6584,6585],{},"highspy",", the Python interface of HiGHS, and give HiGHS the same 30 seconds. HiGHS runs on one thread, because the service also used one core. Besides a plan, HiGHS returns a lower bound. No plan can walk less than the lower bound, so the gap between the bound and a plan's walking tells how far that plan can be from the best one.",[10,6588,6589],{},"For a bank of more than 60 flights, the cell prints a notice and skips HiGHS, because the program becomes too large to build in a notebook.",[43,6591,6593],{"className":45,"code":6592,"language":47,"meta":48,"style":48},"import highspy\n\nLARGEST_BANK_FOR_HIGHS = 60        # flights; a larger bank's linearized program is not built here\n\n\ndef plan_with_highs(transfers, distance, time_limit):\n    \"\"\"Build the linearized program and solve it with HiGHS on one thread.\n\n    Args:\n        transfers: Passengers between the flights.\n        distance: Metres between the gates.\n        time_limit: Seconds that HiGHS may take.\n\n    Returns:\n        The best plan that HiGHS found in the time (None if it found none),\n        and its lower bound on the total walking.\n    \"\"\"\n    flights = len(transfers)\n    F = G = range(flights)                                   # the flights i, j and the gates g, h\n    exchange = transfers + transfers.T                       # E[i, j]\n    milp = highspy.Highs()\n    milp.setOptionValue(\"output_flag\", False)                # no solver log\n    milp.setOptionValue(\"time_limit\", float(time_limit))\n    milp.setOptionValue(\"threads\", 1)\n    at = milp.addBinaries(F, G)                              # x[i, g] = 1: flight i stands at gate g\n    walk = milp.addVariables(F, G)                           # w[i, g] >= 0\n    milp.addConstrs(milp.qsum(at[i, g] for g in G) == 1 for i in F)      # every flight stands at one gate\n    milp.addConstrs(milp.qsum(at[i, g] for i in F) == 1 for g in G)      # every gate holds one flight\n    for i in F:\n        partners = np.flatnonzero(exchange[i])               # the flights j with E[i, j] > 0\n        for g in G:\n            longest = float(exchange[i].sum() * distance[g].max())       # M[i, g]\n            walked = milp.qsum(float(exchange[i, j] * distance[g, h]) * at[j, h]\n                               for j in partners for h in G if h != g)\n            milp.addConstr(walk[i, g] >= walked - longest * (1 - at[i, g]))\n    milp.minimize(0.5 * milp.qsum(walk[i, g] for i in F for g in G))\n    info = milp.getInfo()\n    lower_bound = info.mip_dual_bound\n    if info.primal_solution_status != highspy.SolutionStatus.kSolutionStatusFeasible:\n        return None, lower_bound\n    value = milp.vals(at)                                    # the values of x[i, g] in the best plan\n    plan = np.array([max(G, key=lambda g: value[i, g]) for i in F])      # the gate g with x[i, g] = 1\n    return plan, lower_bound\n\n\nif flights \u003C= LARGEST_BANK_FOR_HIGHS:\n    highs_plan, lower_bound = plan_with_highs(transfers, distance, time_limit)\n    show(\"timetable order\", walking(timetable_order, transfers, distance))\n    if highs_plan is None:\n        print(f\"HiGHS found no plan in {time_limit} s\")\n    else:\n        assert sorted(highs_plan) == list(range(flights))        # every gate holds exactly one flight\n        show(f\"HiGHS after {time_limit} s\", walking(highs_plan, transfers, distance))\n    show(f\"Quicopt after {result.solve_time_seconds:.1f} s\", quicopt_walking)\n    print(f\"\\nHiGHS's lower bound on the total walking: {lower_bound:,.0f} m\")\nelse:\n    print(f\"{flights} flights are more than {LARGEST_BANK_FOR_HIGHS}: the linearized program is not built\")\n",[50,6594,6595,6602,6606,6618,6622,6626,6635,6640,6644,6648,6652,6656,6661,6665,6669,6674,6679,6683,6693,6713,6729,6739,6757,6772,6785,6798,6810,6841,6870,6881,6893,6904,6924,6949,6978,7005,7036,7046,7056,7068,7079,7092,7129,7136,7140,7144,7158,7168,7177,7192,7215,7223,7247,7269,7293,7322,7329],{"__ignoreMap":48},[53,6596,6597,6599],{"class":55,"line":56},[53,6598,120],{"class":63},[53,6600,6601],{"class":59}," highspy\n",[53,6603,6604],{"class":55,"line":75},[53,6605,135],{"emptyLinePlaceholder":134},[53,6607,6608,6611,6613,6615],{"class":55,"line":89},[53,6609,6610],{"class":67},"LARGEST_BANK_FOR_HIGHS",[53,6612,143],{"class":63},[53,6614,2552],{"class":67},[53,6616,6617],{"class":71},"        # flights; a larger bank's linearized program is not built here\n",[53,6619,6620],{"class":55,"line":149},[53,6621,135],{"emptyLinePlaceholder":134},[53,6623,6624],{"class":55,"line":154},[53,6625,135],{"emptyLinePlaceholder":134},[53,6627,6628,6630,6633],{"class":55,"line":159},[53,6629,162],{"class":63},[53,6631,6632],{"class":165}," plan_with_highs",[53,6634,1707],{"class":59},[53,6636,6637],{"class":55,"line":172},[53,6638,6639],{"class":175},"    \"\"\"Build the linearized program and solve it with HiGHS on one thread.\n",[53,6641,6642],{"class":55,"line":179},[53,6643,135],{"emptyLinePlaceholder":134},[53,6645,6646],{"class":55,"line":184},[53,6647,187],{"class":175},[53,6649,6650],{"class":55,"line":190},[53,6651,1725],{"class":175},[53,6653,6654],{"class":55,"line":196},[53,6655,1730],{"class":175},[53,6657,6658],{"class":55,"line":201},[53,6659,6660],{"class":175},"        time_limit: Seconds that HiGHS may take.\n",[53,6662,6663],{"class":55,"line":207},[53,6664,135],{"emptyLinePlaceholder":134},[53,6666,6667],{"class":55,"line":213},[53,6668,204],{"class":175},[53,6670,6671],{"class":55,"line":219},[53,6672,6673],{"class":175},"        The best plan that HiGHS found in the time (None if it found none),\n",[53,6675,6676],{"class":55,"line":225},[53,6677,6678],{"class":175},"        and its lower bound on the total walking.\n",[53,6680,6681],{"class":55,"line":236},[53,6682,222],{"class":175},[53,6684,6685,6687,6689,6691],{"class":55,"line":253},[53,6686,1762],{"class":59},[53,6688,64],{"class":63},[53,6690,1767],{"class":67},[53,6692,1770],{"class":59},[53,6694,6695,6698,6700,6703,6705,6707,6710],{"class":55,"line":293},[53,6696,6697],{"class":59},"    F ",[53,6699,64],{"class":63},[53,6701,6702],{"class":59}," G ",[53,6704,64],{"class":63},[53,6706,918],{"class":67},[53,6708,6709],{"class":59},"(flights)                                   ",[53,6711,6712],{"class":71},"# the flights i, j and the gates g, h\n",[53,6714,6715,6717,6719,6721,6723,6726],{"class":55,"line":302},[53,6716,6211],{"class":59},[53,6718,64],{"class":63},[53,6720,6216],{"class":59},[53,6722,433],{"class":63},[53,6724,6725],{"class":59}," transfers.T                       ",[53,6727,6728],{"class":71},"# E[i, j]\n",[53,6730,6731,6734,6736],{"class":55,"line":307},[53,6732,6733],{"class":59},"    milp ",[53,6735,64],{"class":63},[53,6737,6738],{"class":59}," highspy.Highs()\n",[53,6740,6741,6744,6747,6749,6751,6754],{"class":55,"line":312},[53,6742,6743],{"class":59},"    milp.setOptionValue(",[53,6745,6746],{"class":175},"\"output_flag\"",[53,6748,629],{"class":59},[53,6750,1012],{"class":67},[53,6752,6753],{"class":59},")                ",[53,6755,6756],{"class":71},"# no solver log\n",[53,6758,6759,6761,6764,6766,6769],{"class":55,"line":322},[53,6760,6743],{"class":59},[53,6762,6763],{"class":175},"\"time_limit\"",[53,6765,629],{"class":59},[53,6767,6768],{"class":67},"float",[53,6770,6771],{"class":59},"(time_limit))\n",[53,6773,6774,6776,6779,6781,6783],{"class":55,"line":328},[53,6775,6743],{"class":59},[53,6777,6778],{"class":175},"\"threads\"",[53,6780,629],{"class":59},[53,6782,632],{"class":67},[53,6784,290],{"class":59},[53,6786,6787,6790,6792,6795],{"class":55,"line":333},[53,6788,6789],{"class":59},"    at ",[53,6791,64],{"class":63},[53,6793,6794],{"class":59}," milp.addBinaries(F, G)                              ",[53,6796,6797],{"class":71},"# x[i, g] = 1: flight i stands at gate g\n",[53,6799,6800,6802,6804,6807],{"class":55,"line":338},[53,6801,1785],{"class":59},[53,6803,64],{"class":63},[53,6805,6806],{"class":59}," milp.addVariables(F, G)                           ",[53,6808,6809],{"class":71},"# w[i, g] >= 0\n",[53,6811,6812,6815,6817,6820,6822,6825,6827,6829,6831,6833,6835,6838],{"class":55,"line":344},[53,6813,6814],{"class":59},"    milp.addConstrs(milp.qsum(at[i, g] ",[53,6816,614],{"class":63},[53,6818,6819],{"class":59}," g ",[53,6821,620],{"class":63},[53,6823,6824],{"class":59}," G) ",[53,6826,393],{"class":63},[53,6828,2545],{"class":67},[53,6830,2946],{"class":63},[53,6832,1867],{"class":59},[53,6834,620],{"class":63},[53,6836,6837],{"class":59}," F)      ",[53,6839,6840],{"class":71},"# every flight stands at one gate\n",[53,6842,6843,6845,6847,6849,6851,6854,6856,6858,6860,6862,6864,6867],{"class":55,"line":349},[53,6844,6814],{"class":59},[53,6846,614],{"class":63},[53,6848,1867],{"class":59},[53,6850,620],{"class":63},[53,6852,6853],{"class":59}," F) ",[53,6855,393],{"class":63},[53,6857,2545],{"class":67},[53,6859,2946],{"class":63},[53,6861,6819],{"class":59},[53,6863,620],{"class":63},[53,6865,6866],{"class":59}," G)      ",[53,6868,6869],{"class":71},"# every gate holds one flight\n",[53,6871,6872,6874,6876,6878],{"class":55,"line":354},[53,6873,910],{"class":63},[53,6875,1867],{"class":59},[53,6877,620],{"class":63},[53,6879,6880],{"class":59}," F:\n",[53,6882,6883,6885,6887,6890],{"class":55,"line":360},[53,6884,998],{"class":59},[53,6886,64],{"class":63},[53,6888,6889],{"class":59}," np.flatnonzero(exchange[i])               ",[53,6891,6892],{"class":71},"# the flights j with E[i, j] > 0\n",[53,6894,6895,6897,6899,6901],{"class":55,"line":365},[53,6896,1864],{"class":63},[53,6898,6819],{"class":59},[53,6900,620],{"class":63},[53,6902,6903],{"class":59}," G:\n",[53,6905,6906,6909,6911,6913,6916,6918,6921],{"class":55,"line":376},[53,6907,6908],{"class":59},"            longest ",[53,6910,64],{"class":63},[53,6912,1362],{"class":67},[53,6914,6915],{"class":59},"(exchange[i].sum() ",[53,6917,1049],{"class":63},[53,6919,6920],{"class":59}," distance[g].max())       ",[53,6922,6923],{"class":71},"# M[i, g]\n",[53,6925,6926,6929,6931,6934,6936,6939,6941,6944,6946],{"class":55,"line":407},[53,6927,6928],{"class":59},"            walked ",[53,6930,64],{"class":63},[53,6932,6933],{"class":59}," milp.qsum(",[53,6935,6768],{"class":67},[53,6937,6938],{"class":59},"(exchange[i, j] ",[53,6940,1049],{"class":63},[53,6942,6943],{"class":59}," distance[g, h]) ",[53,6945,1049],{"class":63},[53,6947,6948],{"class":59}," at[j, h]\n",[53,6950,6951,6954,6956,6958,6961,6963,6965,6967,6969,6971,6973,6975],{"class":55,"line":439},[53,6952,6953],{"class":63},"                               for",[53,6955,1878],{"class":59},[53,6957,620],{"class":63},[53,6959,6960],{"class":59}," partners ",[53,6962,614],{"class":63},[53,6964,665],{"class":59},[53,6966,620],{"class":63},[53,6968,6702],{"class":59},[53,6970,944],{"class":63},[53,6972,665],{"class":59},[53,6974,990],{"class":63},[53,6976,6977],{"class":59}," g)\n",[53,6979,6980,6983,6986,6989,6991,6994,6996,6998,7000,7002],{"class":55,"line":468},[53,6981,6982],{"class":59},"            milp.addConstr(walk[i, g] ",[53,6984,6985],{"class":63},">=",[53,6987,6988],{"class":59}," walked ",[53,6990,422],{"class":63},[53,6992,6993],{"class":59}," longest ",[53,6995,1049],{"class":63},[53,6997,3943],{"class":59},[53,6999,632],{"class":67},[53,7001,2098],{"class":63},[53,7003,7004],{"class":59}," at[i, g]))\n",[53,7006,7007,7010,7013,7015,7018,7020,7022,7024,7027,7029,7031,7033],{"class":55,"line":502},[53,7008,7009],{"class":59},"    milp.minimize(",[53,7011,7012],{"class":67},"0.5",[53,7014,270],{"class":63},[53,7016,7017],{"class":59}," milp.qsum(walk[i, g] ",[53,7019,614],{"class":63},[53,7021,1867],{"class":59},[53,7023,620],{"class":63},[53,7025,7026],{"class":59}," F ",[53,7028,614],{"class":63},[53,7030,6819],{"class":59},[53,7032,620],{"class":63},[53,7034,7035],{"class":59}," G))\n",[53,7037,7038,7041,7043],{"class":55,"line":513},[53,7039,7040],{"class":59},"    info ",[53,7042,64],{"class":63},[53,7044,7045],{"class":59}," milp.getInfo()\n",[53,7047,7048,7051,7053],{"class":55,"line":524},[53,7049,7050],{"class":59},"    lower_bound ",[53,7052,64],{"class":63},[53,7054,7055],{"class":59}," info.mip_dual_bound\n",[53,7057,7058,7060,7063,7065],{"class":55,"line":532},[53,7059,662],{"class":63},[53,7061,7062],{"class":59}," info.primal_solution_status ",[53,7064,990],{"class":63},[53,7066,7067],{"class":59}," highspy.SolutionStatus.kSolutionStatusFeasible:\n",[53,7069,7070,7073,7076],{"class":55,"line":537},[53,7071,7072],{"class":63},"        return",[53,7074,7075],{"class":67}," None",[53,7077,7078],{"class":59},", lower_bound\n",[53,7080,7081,7084,7086,7089],{"class":55,"line":542},[53,7082,7083],{"class":59},"    value ",[53,7085,64],{"class":63},[53,7087,7088],{"class":59}," milp.vals(at)                                    ",[53,7090,7091],{"class":71},"# the values of x[i, g] in the best plan\n",[53,7093,7094,7097,7099,7102,7105,7108,7111,7114,7117,7119,7121,7123,7126],{"class":55,"line":553},[53,7095,7096],{"class":59},"    plan ",[53,7098,64],{"class":63},[53,7100,7101],{"class":59}," np.array([",[53,7103,7104],{"class":67},"max",[53,7106,7107],{"class":59},"(G, ",[53,7109,7110],{"class":1006},"key",[53,7112,7113],{"class":63},"=lambda",[53,7115,7116],{"class":59}," g: value[i, g]) ",[53,7118,614],{"class":63},[53,7120,1867],{"class":59},[53,7122,620],{"class":63},[53,7124,7125],{"class":59}," F])      ",[53,7127,7128],{"class":71},"# the gate g with x[i, g] = 1\n",[53,7130,7131,7133],{"class":55,"line":564},[53,7132,296],{"class":63},[53,7134,7135],{"class":59}," plan, lower_bound\n",[53,7137,7138],{"class":55,"line":569},[53,7139,135],{"emptyLinePlaceholder":134},[53,7141,7142],{"class":55,"line":611},[53,7143,135],{"emptyLinePlaceholder":134},[53,7145,7146,7148,7150,7152,7155],{"class":55,"line":659},[53,7147,944],{"class":63},[53,7149,890],{"class":59},[53,7151,3158],{"class":63},[53,7153,7154],{"class":67}," LARGEST_BANK_FOR_HIGHS",[53,7156,7157],{"class":59},":\n",[53,7159,7160,7163,7165],{"class":55,"line":674},[53,7161,7162],{"class":59},"    highs_plan, lower_bound ",[53,7164,64],{"class":63},[53,7166,7167],{"class":59}," plan_with_highs(transfers, distance, time_limit)\n",[53,7169,7170,7173,7175],{"class":55,"line":727},[53,7171,7172],{"class":59},"    show(",[53,7174,1547],{"class":175},[53,7176,1550],{"class":59},[53,7178,7180,7182,7185,7188,7190],{"class":55,"line":7179},49,[53,7181,662],{"class":63},[53,7183,7184],{"class":59}," highs_plan ",[53,7186,7187],{"class":63},"is",[53,7189,7075],{"class":67},[53,7191,7157],{"class":59},[53,7193,7195,7197,7199,7201,7204,7206,7208,7210,7213],{"class":55,"line":7194},50,[53,7196,677],{"class":67},[53,7198,575],{"class":59},[53,7200,578],{"class":63},[53,7202,7203],{"class":175},"\"HiGHS found no plan in ",[53,7205,584],{"class":67},[53,7207,1629],{"class":59},[53,7209,590],{"class":67},[53,7211,7212],{"class":175}," s\"",[53,7214,290],{"class":59},[53,7216,7218,7221],{"class":55,"line":7217},51,[53,7219,7220],{"class":63},"    else",[53,7222,7157],{"class":59},[53,7224,7226,7229,7231,7234,7236,7238,7240,7242,7245],{"class":55,"line":7225},52,[53,7227,7228],{"class":63},"        assert",[53,7230,1984],{"class":67},[53,7232,7233],{"class":59},"(highs_plan) ",[53,7235,393],{"class":63},[53,7237,1992],{"class":67},[53,7239,575],{"class":59},[53,7241,1997],{"class":67},[53,7243,7244],{"class":59},"(flights))        ",[53,7246,2003],{"class":71},[53,7248,7250,7253,7255,7258,7260,7262,7264,7266],{"class":55,"line":7249},53,[53,7251,7252],{"class":59},"        show(",[53,7254,578],{"class":63},[53,7256,7257],{"class":175},"\"HiGHS after ",[53,7259,584],{"class":67},[53,7261,1629],{"class":59},[53,7263,590],{"class":67},[53,7265,7212],{"class":175},[53,7267,7268],{"class":59},", walking(highs_plan, transfers, distance))\n",[53,7270,7272,7274,7276,7279,7281,7284,7287,7289,7291],{"class":55,"line":7271},54,[53,7273,7172],{"class":59},[53,7275,578],{"class":63},[53,7277,7278],{"class":175},"\"Quicopt after ",[53,7280,584],{"class":67},[53,7282,7283],{"class":59},"result.solve_time_seconds",[53,7285,7286],{"class":63},":.1f",[53,7288,590],{"class":67},[53,7290,7212],{"class":175},[53,7292,2081],{"class":59},[53,7294,7296,7298,7300,7302,7304,7306,7309,7311,7314,7316,7318,7320],{"class":55,"line":7295},55,[53,7297,1210],{"class":67},[53,7299,575],{"class":59},[53,7301,578],{"class":63},[53,7303,606],{"class":175},[53,7305,2067],{"class":67},[53,7307,7308],{"class":175},"HiGHS's lower bound on the total walking: ",[53,7310,584],{"class":67},[53,7312,7313],{"class":59},"lower_bound",[53,7315,744],{"class":63},[53,7317,590],{"class":67},[53,7319,722],{"class":175},[53,7321,290],{"class":59},[53,7323,7325,7327],{"class":55,"line":7324},56,[53,7326,950],{"class":63},[53,7328,7157],{"class":59},[53,7330,7332,7334,7336,7338,7340,7342,7344,7346,7349,7352,7355],{"class":55,"line":7331},57,[53,7333,1210],{"class":67},[53,7335,575],{"class":59},[53,7337,578],{"class":63},[53,7339,606],{"class":175},[53,7341,584],{"class":67},[53,7343,587],{"class":59},[53,7345,590],{"class":67},[53,7347,7348],{"class":175}," flights are more than ",[53,7350,7351],{"class":67},"{LARGEST_BANK_FOR_HIGHS}",[53,7353,7354],{"class":175},": the linearized program is not built\"",[53,7356,290],{"class":59},[752,7358],{":lines":7359,"label":755},"[\"timetable order                   3,481,450 m in total     700 m per passenger\",\"HiGHS after 30 s                  3,200,870 m in total     643 m per passenger\",\"Quicopt after 0.6 s               1,518,140 m in total     305 m per passenger\",\"\",\"HiGHS's lower bound on the total walking: 0 m\"]",[10,7361,7362],{},"After 30 seconds, HiGHS holds a plan with 643 m per passenger, against 700 m in timetable order and 305 m in Quicopt's plan. HiGHS's lower bound is 0, so HiGHS has proven no more than that the walking is not negative. A bound of 0 also leaves open how far Quicopt's plan is from the best one.",[10,7364,7365,7366,7369],{},"This section compares Quicopt with one open-source solver on one linearization. HiGHS stops at the time limit, so its plan depends on the speed of your machine and changes from run to run, while Quicopt ran on the hardware of the service. Other solvers and other formulations may do better, and ",[50,7367,7368],{},"plan_with_highs"," is the function to change if you want to try one.",[35,7371,7373],{"id":7372},"larger-banks","Larger banks",[10,7375,7376],{},"The Quicopt model does not change with the size of the bank. Only its two arrays grow. Below, the same function plans three banks of 48, 96 and 192 flights, whose arrivals connect to 4, 5 and 6 departures. For each bank, the table also states how many nonzero coefficients the linearized program would have.",[43,7378,7380],{"className":45,"code":7379,"language":47,"meta":48,"style":48},"banks = [(48, 4), (96, 5), (192, 6)]       # the flights and the partner departures of each bank\n\nprint(\"flights  connections   m per passenger in    m per passenger in   Quicopt's    nonzeros of the\")\nprint(\"                       timetable order       Quicopt's plan       solve time   linearized program\")\nfor bank_flights, bank_partners in banks:\n    bank_transfers = transfer_passengers(bank_flights, bank_partners)\n    bank_distance = walking_distances(bank_flights)\n    bank_result = plan_with_quicopt(bank_transfers, bank_distance, time_limit)\n    bank_plan = np.array(bank_result.structures[\"gate\"].slot_of)\n    assert sorted(bank_plan) == list(range(bank_flights))        # every gate holds exactly one flight\n    in_timetable_order = walking(np.arange(bank_flights), bank_transfers, bank_distance) \u002F bank_transfers.sum()\n    in_quicopts_plan = walking(bank_plan, bank_transfers, bank_distance) \u002F bank_transfers.sum()\n    print(f\"{bank_flights:7}  {np.count_nonzero(bank_transfers):11,}   {in_timetable_order:15,.0f}       {in_quicopts_plan:14,.0f}\"\n          f\"       {bank_result.solve_time_seconds:7.1f} s   {linearized_size(bank_transfers)[2]:18,}\")\n",[50,7381,7382,7424,7428,7439,7450,7462,7472,7482,7492,7507,7530,7545,7559,7615],{"__ignoreMap":48},[53,7383,7384,7387,7389,7391,7394,7396,7399,7401,7404,7406,7408,7410,7413,7415,7418,7421],{"class":55,"line":56},[53,7385,7386],{"class":59},"banks ",[53,7388,64],{"class":63},[53,7390,623],{"class":59},[53,7392,7393],{"class":67},"48",[53,7395,629],{"class":59},[53,7397,7398],{"class":67},"4",[53,7400,635],{"class":59},[53,7402,7403],{"class":67},"96",[53,7405,629],{"class":59},[53,7407,648],{"class":67},[53,7409,635],{"class":59},[53,7411,7412],{"class":67},"192",[53,7414,629],{"class":59},[53,7416,7417],{"class":67},"6",[53,7419,7420],{"class":59},")]       ",[53,7422,7423],{"class":71},"# the flights and the partner departures of each bank\n",[53,7425,7426],{"class":55,"line":75},[53,7427,135],{"emptyLinePlaceholder":134},[53,7429,7430,7432,7434,7437],{"class":55,"line":89},[53,7431,572],{"class":67},[53,7433,575],{"class":59},[53,7435,7436],{"class":175},"\"flights  connections   m per passenger in    m per passenger in   Quicopt's    nonzeros of the\"",[53,7438,290],{"class":59},[53,7440,7441,7443,7445,7448],{"class":55,"line":149},[53,7442,572],{"class":67},[53,7444,575],{"class":59},[53,7446,7447],{"class":175},"\"                       timetable order       Quicopt's plan       solve time   linearized program\"",[53,7449,290],{"class":59},[53,7451,7452,7454,7457,7459],{"class":55,"line":154},[53,7453,614],{"class":63},[53,7455,7456],{"class":59}," bank_flights, bank_partners ",[53,7458,620],{"class":63},[53,7460,7461],{"class":59}," banks:\n",[53,7463,7464,7467,7469],{"class":55,"line":159},[53,7465,7466],{"class":59},"    bank_transfers ",[53,7468,64],{"class":63},[53,7470,7471],{"class":59}," transfer_passengers(bank_flights, bank_partners)\n",[53,7473,7474,7477,7479],{"class":55,"line":172},[53,7475,7476],{"class":59},"    bank_distance ",[53,7478,64],{"class":63},[53,7480,7481],{"class":59}," walking_distances(bank_flights)\n",[53,7483,7484,7487,7489],{"class":55,"line":179},[53,7485,7486],{"class":59},"    bank_result ",[53,7488,64],{"class":63},[53,7490,7491],{"class":59}," plan_with_quicopt(bank_transfers, bank_distance, time_limit)\n",[53,7493,7494,7497,7499,7502,7504],{"class":55,"line":184},[53,7495,7496],{"class":59},"    bank_plan ",[53,7498,64],{"class":63},[53,7500,7501],{"class":59}," np.array(bank_result.structures[",[53,7503,1811],{"class":175},[53,7505,7506],{"class":59},"].slot_of)\n",[53,7508,7509,7512,7514,7517,7519,7521,7523,7525,7528],{"class":55,"line":190},[53,7510,7511],{"class":63},"    assert",[53,7513,1984],{"class":67},[53,7515,7516],{"class":59},"(bank_plan) ",[53,7518,393],{"class":63},[53,7520,1992],{"class":67},[53,7522,575],{"class":59},[53,7524,1997],{"class":67},[53,7526,7527],{"class":59},"(bank_flights))        ",[53,7529,2003],{"class":71},[53,7531,7532,7535,7537,7540,7542],{"class":55,"line":196},[53,7533,7534],{"class":59},"    in_timetable_order ",[53,7536,64],{"class":63},[53,7538,7539],{"class":59}," walking(np.arange(bank_flights), bank_transfers, bank_distance) ",[53,7541,1055],{"class":63},[53,7543,7544],{"class":59}," bank_transfers.sum()\n",[53,7546,7547,7550,7552,7555,7557],{"class":55,"line":201},[53,7548,7549],{"class":59},"    in_quicopts_plan ",[53,7551,64],{"class":63},[53,7553,7554],{"class":59}," walking(bank_plan, bank_transfers, bank_distance) ",[53,7556,1055],{"class":63},[53,7558,7544],{"class":59},[53,7560,7561,7563,7565,7567,7569,7571,7574,7577,7579,7582,7585,7588,7590,7593,7596,7599,7601,7604,7607,7610,7612],{"class":55,"line":207},[53,7562,1210],{"class":67},[53,7564,575],{"class":59},[53,7566,578],{"class":63},[53,7568,606],{"class":175},[53,7570,584],{"class":67},[53,7572,7573],{"class":59},"bank_flights",[53,7575,7576],{"class":63},":7",[53,7578,590],{"class":67},[53,7580,7581],{"class":67},"  {",[53,7583,7584],{"class":59},"np.count_nonzero(bank_transfers)",[53,7586,7587],{"class":63},":11,",[53,7589,590],{"class":67},[53,7591,7592],{"class":67},"   {",[53,7594,7595],{"class":59},"in_timetable_order",[53,7597,7598],{"class":63},":15,.0f",[53,7600,590],{"class":67},[53,7602,7603],{"class":67},"       {",[53,7605,7606],{"class":59},"in_quicopts_plan",[53,7608,7609],{"class":63},":14,.0f",[53,7611,590],{"class":67},[53,7613,7614],{"class":175},"\"\n",[53,7616,7617,7619,7622,7624,7627,7630,7632,7635,7637,7640,7642,7645,7648,7650,7652],{"class":55,"line":213},[53,7618,3148],{"class":63},[53,7620,7621],{"class":175},"\"       ",[53,7623,584],{"class":67},[53,7625,7626],{"class":59},"bank_result.solve_time_seconds",[53,7628,7629],{"class":63},":7.1f",[53,7631,590],{"class":67},[53,7633,7634],{"class":175}," s   ",[53,7636,584],{"class":67},[53,7638,7639],{"class":59},"linearized_size(bank_transfers)[",[53,7641,2432],{"class":67},[53,7643,7644],{"class":59},"]",[53,7646,7647],{"class":63},":18,",[53,7649,590],{"class":67},[53,7651,606],{"class":175},[53,7653,290],{"class":59},[752,7655],{":lines":7656,"label":755},"[\"flights  connections   m per passenger in    m per passenger in   Quicopt's    nonzeros of the\",\"                       timetable order       Quicopt's plan       solve time   linearized program\",\"     48          191               700                  305           0.7 s              821,376\",\"     96          478               980                  464           7.8 s            8,518,464\",\"    192        1,146             1,306                  711           5.1 s           83,099,520\"]",[10,7658,7659],{},"For 96 flights, a connecting passenger walks 464 m in Quicopt's plan, against 980 m in timetable order. For 192 flights, it is 711 m against 1,306 m. Each plan comes back in less than ten seconds. The linearized program for the largest bank would have 83 million nonzero coefficients.",[10,7661,7662,7666,7667,7670],{},[7663,7664,7665],"strong",{},"Reference:"," L. Kaufman, F. Broeckx, ",[14,7668,7669],{},"An algorithm for the quadratic assignment problem using Benders' decomposition",", European Journal of Operational Research, 1978.",[7672,7673,7674],"style",{},"html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .s9osk, html code.shiki .s9osk{--shiki-default:#FFAB70}",{"title":48,"searchDepth":75,"depth":75,"links":7676},[7677,7678,7679,7680,7681,7682,7683,7684],{"id":37,"depth":75,"text":38},{"id":103,"depth":75,"text":104},{"id":761,"depth":75,"text":762},{"id":1264,"depth":75,"text":1265},{"id":1579,"depth":75,"text":1580},{"id":2154,"depth":75,"text":2155},{"id":3186,"depth":75,"text":3187},{"id":7372,"depth":75,"text":7373},"At a hub airport, flights arrive and leave in waves, so that passengers can change from one flight to another. One such wave is called a connection bank: a group of flights that are on the ground at the same time. Each of them stands at a gate, and a connecting passenger walks from the gate of the arriving flight to the gate of the departing one. You decide which flight stands at which gate, and with that, how far your passengers walk.","md",null,{},false,"\u002Fuse-cases\u002Fgate-assignment",{"title":5,"description":7685},"use-cases\u002Fgate-assignment","B4Rm_48vSdW_Jpdq2eJaY7VbmyKsHrQiIz-zE_Z8_nc",1795110669073]