PySCIPOpt  5.1.1
Python Interface for the SCIP Optimization Suite
kmedian Namespace Reference

Functions

def distance (x1, y1, x2, y2)
 
def kmedian (I, J, c, k)
 
def make_data (n, m, same=True)
 

Variables

 c
 
 client = set(i for i in I if i not in facilities and i not in other)
 
list edges = [(i, j) for (i, j) in x if model.getVal(x[i, j]) > EPS]
 
int EPS = 1.e-6
 
list facilities = [j for j in y if model.getVal(y[j]) > EPS]
 
 False
 
 G = NX.Graph()
 
 I
 
 J
 
int k = 20
 
int m = n
 
def model = kmedian(I, J, c, k)
 
int n = 200
 
 node_color
 
 node_size
 
 nodelist
 
 other = set(j for j in J if j not in facilities)
 
dictionary position = {}
 
 same
 
 with_labels
 
 x
 
 x_pos
 
 y
 
 y_pos
 

Function Documentation

◆ distance()

def kmedian.distance (   x1,
  y1,
  x2,
  y2 
)
return distance of two points

Definition at line 45 of file kmedian.py.

◆ kmedian()

def kmedian.kmedian (   I,
  J,
  c,
  k 
)
kmedian -- minimize total cost of servicing customers from k facilities
Parameters:
    - I: set of customers
    - J: set of potential facilities
    - c[i,j]: cost of servicing customer i from facility j
    - k: number of facilities to be used
Returns a model, ready to be solved.

Definition at line 15 of file kmedian.py.

References pyscipopt.expr.quicksum().

◆ make_data()

def kmedian.make_data (   n,
  m,
  same = True 
)
creates example data set

Definition at line 50 of file kmedian.py.

References distance().

Variable Documentation

◆ c

c

Definition at line 75 of file kmedian.py.

◆ client

client = set(i for i in I if i not in facilities and i not in other)

Definition at line 99 of file kmedian.py.

◆ edges

list edges = [(i, j) for (i, j) in x if model.getVal(x[i, j]) > EPS]

Definition at line 82 of file kmedian.py.

◆ EPS

int EPS = 1.e-6

Definition at line 80 of file kmedian.py.

◆ facilities

facilities = [j for j in y if model.getVal(y[j]) > EPS]

Definition at line 83 of file kmedian.py.

◆ False

False

Definition at line 110 of file kmedian.py.

◆ G

G = NX.Graph()

Definition at line 95 of file kmedian.py.

◆ I

I

Definition at line 75 of file kmedian.py.

◆ J

J

Definition at line 75 of file kmedian.py.

◆ k

int k = 20

Definition at line 76 of file kmedian.py.

◆ m

m = n

Definition at line 74 of file kmedian.py.

◆ model

def model = kmedian(I, J, c, k)

Definition at line 77 of file kmedian.py.

◆ n

n = 200

Definition at line 73 of file kmedian.py.

◆ node_color

node_color

Definition at line 110 of file kmedian.py.

◆ node_size

node_size

Definition at line 111 of file kmedian.py.

◆ nodelist

nodelist

Definition at line 110 of file kmedian.py.

◆ other

other = set(j for j in J if j not in facilities)

Definition at line 98 of file kmedian.py.

◆ position

position = {}

Definition at line 106 of file kmedian.py.

◆ same

same

Definition at line 75 of file kmedian.py.

◆ with_labels

with_labels

Definition at line 110 of file kmedian.py.

◆ x

x

Definition at line 81 of file kmedian.py.

◆ x_pos

x_pos

Definition at line 75 of file kmedian.py.

◆ y

y

Definition at line 81 of file kmedian.py.

◆ y_pos

y_pos

Definition at line 75 of file kmedian.py.