A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://scipopt.github.io/PySCIPOpt/docs/html/transp__nofn_8py_source.html below:

PySCIPOpt: examples/finished/transp_nofn.py Source File

Go to the documentation of this file. 4 Model for solving a transportation problem: 5 minimize the total transportation cost for satisfying demand at 6 customers, from capacitated facilities. 11  c[i,j] - unit transportation cost on arc (i,j) 12  d[i] - demand at node i 15 Copyright (c) by Joao Pedro PEDROSO and Mikio KUBO, 2012 18 from

pyscipopt

import

Model, quicksum

20

d = {1: 80, 2: 270, 3: 250, 4: 160, 5: 180}

23

M = {1: 500, 2: 500, 3: 500}

26

c = {(1, 1): 4, (1, 2): 6, (1, 3): 9,

27

(2, 1): 5, (2, 2): 4, (2, 3): 7,

28

(3, 1): 6, (3, 2): 3, (3, 3): 4,

29

(4, 1): 8, (4, 2): 5, (4, 3): 3,

30

(5, 1): 10, (5, 2): 8, (5, 3): 4,

33

model = Model(

"transportation"

)

40

x[i, j] = model.addVar(vtype=

"C"

, name=

"x(%s,%s)"

% (i, j))

44

model.addCons(sum(x[i, j]

for

j

in

J

if

(i, j)

in

x) == d[i], name=

"Demand(%s)"

% i)

48

model.addCons(sum(x[i, j]

for

i

in

I

if

(i, j)

in

x) <= M[j], name=

"Capacity(%s)"

% j)

51

model.setObjective(

quicksum

(c[i, j] * x[i, j]

for

(i, j)

in

x),

"minimize"

)

55

print(

"Optimal value:"

, model.getObjVal())

60  if

model.getVal(x[i, j]) > EPS:

61

print(

"sending quantity %10s from factory %3s to customer %3s"

% (model.getVal(x[i, j]), j, i))


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4