Main

View or edit on GitHub

This page is synchronized from trase/models/brazil/soy_supply_sheds/main.ipynb. Last modified on 2026-03-21 22:30 CET by Trase Admin. Please view or edit the original file there; changes should be reflected here after a midnight build (CET time), or manually triggering it with a GitHub action (link).

from trase.tools.sps import SupplyChain

sc = SupplyChain("brazil/soy_supply_sheds", year=2023)
# sc.preparation()
sc.load()
df_solution = sc.run()
df_solution.to_csv("df_solution.csv")
df_solution
total supply 152144238.0
total exports 117047810.62339666
exports fraction 0.7693213503320229
demand from crushing facilities 53105366.599999994
total cnpj silos demand 47144706.89093893
supply_trase_id
BR-1100015      4824.0
BR-1100023     46230.0
BR-1100031    100000.0
BR-1100049     16420.0
BR-1100056    140000.0
                ...   
BR-5222005    139618.0
BR-5222054    106400.0
BR-5222203      2275.0
BR-5222302     63000.0
BR-5300108    306000.0
Name: supply_vol, Length: 2603, dtype: float64
trase_id
BR-1301902    1.837562e+06
BR-1400100    9.884180e+02
BR-1503606    1.975940e+06
BR-1506195    1.445858e+06
BR-1506807    1.826703e+06
                  ...     
BR-5221601    1.560651e+05
BR-5222005    3.506573e+05
BR-5222054    9.670006e+04
BR-5222302    1.513780e+04
BR-5300108    1.794624e+05
Name: vol, Length: 1283, dtype: float64
municipality_origin  municipality_destination
BR-5300108           BR-1100023                  2380.3820
                     BR-1100031                  2004.4742
                     BR-1100049                  2099.0798
                     BR-1100056                  1997.8156
                     BR-1100064                  1960.4832
                                                   ...    
BR-2930907           BR-5222005                   837.1615
                     BR-5222054                  1052.7345
                     BR-5222302                   837.4516
                     BR-5300108                   679.3913
                     BR-5006275                  1441.9475
Name: cost, Length: 4380635, dtype: float64


/mnt/custom-file-systems/efs/fs-049d752ef37739434/shared/shared_repos/TRASE/trase/models/brazil/soy_supply_sheds/lp.py:264: FutureWarning: The provided callable <built-in function sum> is currently using np.sum. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string np.sum instead.
  .apply(sum)
/mnt/custom-file-systems/efs/fs-049d752ef37739434/shared/shared_repos/TRASE/trase/models/brazil/soy_supply_sheds/lp.py:335: FutureWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.
  infeasible = df.groupby("sink_group").apply(


GLPSOL--GLPK LP/MIP Solver 5.0
Parameter(s) specified in the command line:
 --cpxlp /tmp/20f0b82afdb04c07ac604381c79313a1-pulp.lp -o /tmp/20f0b82afdb04c07ac604381c79313a1-pulp.sol
Reading problem data from '/tmp/20f0b82afdb04c07ac604381c79313a1-pulp.lp'...
3886 rows, 3339649 columns, 6679298 non-zeros
2003551 lines were read
GLPK Simplex Optimizer 5.0
3886 rows, 3339649 columns, 6679298 non-zeros
Preprocessing...
3886 rows, 3339649 columns, 6679298 non-zeros
Scaling...
 A: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00
Problem data seem to be well scaled
Constructing initial basis...
Size of triangular part is 3886
      0: obj =   4.757172538e+10 inf =   7.209e+07 (606)
    136: obj =   4.888060341e+10 inf =   6.913e+07 (567)
    272: obj =   4.982124204e+10 inf =   6.612e+07 (536) 1
    408: obj =   5.152558375e+10 inf =   6.293e+07 (523) 1
    539: obj =   5.996721891e+10 inf =   5.799e+07 (470)
    674: obj =   7.062229376e+10 inf =   5.285e+07 (369) 1
    801: obj =   8.554081717e+10 inf =   4.472e+07 (292) 2
    937: obj =   9.726220455e+10 inf =   3.954e+07 (218)
   1072: obj =   9.956612440e+10 inf =   3.851e+07 (216) 1
   1211: obj =   1.037496610e+11 inf =   3.588e+07 (207)
   1353: obj =   1.073389109e+11 inf =   3.385e+07 (202)
   1492: obj =   1.137643949e+11 inf =   3.021e+07 (167)
   1627: obj =   1.160766595e+11 inf =   2.861e+07 (148)
   1781: obj =   1.173338116e+11 inf =   2.454e+07 (124) 1
   1940: obj =   1.236621170e+11 inf =   1.731e+07 (70) 1
   2090: obj =   1.291497511e+11 inf =   1.400e+07 (18) 1
   2275: obj =   1.297282634e+11 inf =   9.070e+06 (10)
   2481: obj =   1.279540821e+11 inf =   7.672e+06 (10)
   2660: obj =   1.282503606e+11 inf =   0.000e+00 (0) 1
*  2754: obj =   1.274192544e+11 inf =   0.000e+00 (1341946) 1
*  2863: obj =   1.240195606e+11 inf =   0.000e+00 (1218366)
*  2986: obj =   1.189622708e+11 inf =   0.000e+00 (1270930) 1
*  3092: obj =   1.158271123e+11 inf =   0.000e+00 (1612738) 1
*  3187: obj =   1.124566747e+11 inf =   0.000e+00 (1486791) 1
*  3288: obj =   1.090260954e+11 inf =   0.000e+00 (1261649) 1
*  3406: obj =   1.030686039e+11 inf =   0.000e+00 (1021528) 1
*  3519: obj =   9.728001319e+10 inf =   0.000e+00 (1185861)
*  3628: obj =   9.295101883e+10 inf =   0.000e+00 (1072099) 1
*  3740: obj =   8.824616835e+10 inf =   0.000e+00 (1383309) 1
*  3849: obj =   8.443715284e+10 inf =   0.000e+00 (1038849) 1
*  3983: obj =   7.972084099e+10 inf =   0.000e+00 (801267)
*  4102: obj =   7.758036248e+10 inf =   0.000e+00 (829405) 1
*  4198: obj =   7.676754457e+10 inf =   0.000e+00 (1282211) 1
*  4286: obj =   7.570331590e+10 inf =   0.000e+00 (1137046) 1
*  4392: obj =   7.209034683e+10 inf =   0.000e+00 (747216)
*  4518: obj =   6.912220480e+10 inf =   0.000e+00 (631785) 1
*  4643: obj =   6.720425494e+10 inf =   0.000e+00 (722642) 1
*  4733: obj =   6.603381016e+10 inf =   0.000e+00 (885738) 1
*  4837: obj =   6.473204287e+10 inf =   0.000e+00 (624519)
*  4930: obj =   6.386111444e+10 inf =   0.000e+00 (818024) 1
*  5038: obj =   6.310304144e+10 inf =   0.000e+00 (985084) 1
*  5122: obj =   6.259997639e+10 inf =   0.000e+00 (1094407) 1
*  5213: obj =   6.166732617e+10 inf =   0.000e+00 (641553)
*  5331: obj =   6.099776515e+10 inf =   0.000e+00 (781076) 1
*  5445: obj =   6.023477306e+10 inf =   0.000e+00 (467049) 1
*  5547: obj =   5.974278367e+10 inf =   0.000e+00 (565465) 1
*  5637: obj =   5.939421781e+10 inf =   0.000e+00 (762753) 1
*  5749: obj =   5.896836980e+10 inf =   0.000e+00 (435746) 1
*  5876: obj =   5.844432888e+10 inf =   0.000e+00 (211501)
*  5999: obj =   5.803417522e+10 inf =   0.000e+00 (207481) 1
*  6095: obj =   5.794094727e+10 inf =   0.000e+00 (330716) 1
*  6180: obj =   5.786217647e+10 inf =   0.000e+00 (511011) 1
*  6269: obj =   5.778064185e+10 inf =   0.000e+00 (269080) 1
*  6370: obj =   5.766948408e+10 inf =   0.000e+00 (522423) 1
*  6457: obj =   5.760554797e+10 inf =   0.000e+00 (452550) 1
*  6566: obj =   5.747418993e+10 inf =   0.000e+00 (150638)
*  6672: obj =   5.737941393e+10 inf =   0.000e+00 (155774) 1
*  6850: obj =   5.718280346e+10 inf =   0.000e+00 (110374) 1
*  7016: obj =   5.705113237e+10 inf =   0.000e+00 (241132) 1
*  7111: obj =   5.701557576e+10 inf =   0.000e+00 (201766) 1
*  7205: obj =   5.697060836e+10 inf =   0.000e+00 (161299) 1
*  7301: obj =   5.693509250e+10 inf =   0.000e+00 (149658) 1
*  7402: obj =   5.690758152e+10 inf =   0.000e+00 (121375) 1
*  7512: obj =   5.687879128e+10 inf =   0.000e+00 (103655) 1
*  7674: obj =   5.679545959e+10 inf =   0.000e+00 (48124) 1
*  7851: obj =   5.673402090e+10 inf =   0.000e+00 (40114) 1
*  8004: obj =   5.668679427e+10 inf =   0.000e+00 (42731) 1
*  8112: obj =   5.667512480e+10 inf =   0.000e+00 (105773) 1
*  8214: obj =   5.665762292e+10 inf =   0.000e+00 (110093) 1
*  8317: obj =   5.664452900e+10 inf =   0.000e+00 (46675) 1
*  8437: obj =   5.662203441e+10 inf =   0.000e+00 (62565) 1
*  8581: obj =   5.660011552e+10 inf =   0.000e+00 (29487) 1
*  8731: obj =   5.657938380e+10 inf =   0.000e+00 (23837) 1
*  8905: obj =   5.656186504e+10 inf =   0.000e+00 (23390) 1
*  9052: obj =   5.655318902e+10 inf =   0.000e+00 (27793) 1
*  9164: obj =   5.654828312e+10 inf =   0.000e+00 (22375) 1
*  9321: obj =   5.654014415e+10 inf =   0.000e+00 (15901) 1
*  9463: obj =   5.653714359e+10 inf =   0.000e+00 (18827) 1
*  9605: obj =   5.653520917e+10 inf =   0.000e+00 (16004) 1
*  9762: obj =   5.653397107e+10 inf =   0.000e+00 (9754) 1
*  9932: obj =   5.653374417e+10 inf =   0.000e+00 (7446) 1
* 10065: obj =   5.653374378e+10 inf =   0.000e+00 (9264) 1
* 10168: obj =   5.653374351e+10 inf =   0.000e+00 (6907) 1
* 10321: obj =   5.653374323e+10 inf =   0.000e+00 (1835) 1
* 10486: obj =   5.653374299e+10 inf =   0.000e+00 (1635) 1
* 10641: obj =   5.653374279e+10 inf =   0.000e+00 (312) 1
* 10785: obj =   5.653374267e+10 inf =   0.000e+00 (0) 1
OPTIMAL LP SOLUTION FOUND
Time used:   435.6 secs
Memory used: 2329.0 Mb (2442182140 bytes)
Writing basic solution to '/tmp/20f0b82afdb04c07ac604381c79313a1-pulp.sol'...


/mnt/custom-file-systems/efs/fs-049d752ef37739434/shared/shared_repos/TRASE/trase/models/brazil/soy_supply_sheds/lp.py:521: FutureWarning: The provided callable <built-in function sum> is currently using np.sum. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string np.sum instead.
  df_allocation.groupby(["source"])["quantity"].apply(sum).to_frame()
supply_trase_id trase_id vol
0 BR-1100015 BR-1301902 4824.000000
1 BR-1100023 BR-1301902 46230.000000
2 BR-1100031 BR-1100031 30275.600000
3 BR-1100031 BR-1100304 58429.500000
4 BR-1100031 BR-4124400 11294.893542
... ... ... ...
3880 BR-5222302 BR-5212303 32724.397907
3881 BR-5222302 BR-5217302 15137.800000
3882 BR-5222302 BR-5222302 15137.800000
3883 BR-5300108 BR-3550308 126538.000000
3884 BR-5300108 BR-5300108 179462.000000

3885 rows × 3 columns