Classic OR Examples¶
The examples on this page are considered classic OR examples. Historically, we have published the code for these examples on the Examples page in our documentation.
For this AI modeling project, we have translated these models back into problem descriptions. Note that the model generated by the LLM might not reflect Gurobi’s best practices. For the best practices we recommend looking at the model code in the Examples page.
Facility¶
Simple facility location model: given a set of plants and a set of warehouses, with transportation costs between them, this example finds the least expensive set of plants to open in order to satisfy product demand.
The reference Python code showing Gurobi best practices can be found in our documentation here.

A company currently ships its product from 5 plants to 4 warehouses.
It is considering closing one or more plants to reduce cost.
Objective: Which plant(s) should the company close, in order to minimize transportation and fixed costs?
Constraints:
- The demand for the warehouses 1-4 is 15, 18, 14, 20 products respectively (per thousand)
- The capacity for the plants 1-5 is 20, 22, 17, 19, 18 products respectively (per thousand)
- The fixed costs for the plants 1-5 is 12000, 15000, 17000, 13000, 16000 respectively
Data:
Transportation Costs (per 1000 products) can be found in facility.csv with the following columns: Warehouse,Plant 1,Plant 2,Plant 3,Plant 4,Plant 5
Warehouse,Plant 1,Plant 2,Plant 3,Plant 4,Plant 5
1,4000,2000,3000,2500,4500
2,2500,2600,3400,3000,4000
3,1200,1800,2600,4100,3000
4,2200,2600,3100,3700,3200
🔢 Problem Definition
We need to determine which plant(s) should be closed to minimize the total costs, which include both transportation costs and fixed costs associated with keeping plants open. The problem can be formulated as a Mixed-Integer Linear Programming (MILP) problem.
Decision Variables
\(x_{ij}\): Amount of products shipped from plant \(i\) to warehouse \(j\) (continuous variable)
\(y_i\): Binary variable indicating whether plant \(i\) is open (1 if open, 0 if closed)
Parameters
\(c_{ij}\): Transportation cost per 1000 products from plant \(i\) to warehouse \(j\)
\(f_i\): Fixed cost of keeping plant \(i\) open
\(d_j\): Demand at warehouse \(j\)
\(s_i\): Capacity of plant \(i\)
Objective Function
Minimize the total cost, which is the sum of the transportation costs and the fixed costs for the open plants:
Constraints
Demand fulfillment: The total products shipped to each warehouse must meet the demand.
Capacity constraints: The total products shipped from each plant must not exceed its capacity and can only ship if the plant is open.
Non-negativity and binary constraints:
import pandas as pd
from gurobipy import Model, GRB
# Load the transportation cost data from the CSV file
file_path = '/mnt/data/facility.csv'
facility_data = pd.read_csv(file_path)
# Data
demands = [15, 18, 14, 20] # Demand for warehouses 1-4 (in thousands)
capacities = [20, 22, 17, 19, 18] # Capacity of plants 1-5 (in thousands)
fixed_costs = [12000, 15000, 17000, 13000, 16000] # Fixed costs for plants 1-5
# Transportation costs (per 1000 products)
transportation_costs = facility_data.iloc[:, 1:].values
# Model
model = Model("Facility Location")
# Decision variables: x[wp] is the amount shipped from plant p to warehouse w
x = model.addVars(len(demands), len(capacities), vtype=GRB.CONTINUOUS, name="x")
# Decision variables: y[p] is 1 if plant p is open, 0 otherwise
y = model.addVars(len(capacities), vtype=GRB.BINARY, name="y")
# Objective: Minimize transportation and fixed costs
model.setObjective(
sum(transportation_costs[w, p] * x[w, p] for w in range(len(demands)) for p in range(len(capacities))) +
sum(fixed_costs[p] * y[p] for p in range(len(capacities))),
GRB.MINIMIZE
)
# Constraints
# 1. Demand satisfaction constraints
for w in range(len(demands)):
model.addConstr(sum(x[w, p] for p in range(len(capacities))) == demands[w], name=f"Demand_{w}")
# 2. Capacity constraints
for p in range(len(capacities)):
model.addConstr(sum(x[w, p] for w in range(len(demands))) <= capacities[p] * y[p], name=f"Capacity_{p}")
# Optimize model
model.optimize()
# Extract solution
solution_x = model.getAttr('x', x)
solution_y = model.getAttr('x', y)
# Prepare results for display
result_df = pd.DataFrame({
'Plant': [f'Plant {p+1}' for p in range(len(capacities))],
'Open (1/0)': [solution_y[p] for p in range(len(capacities))],
'Fixed Cost': fixed_costs,
'Capacity': capacities
})
# Display the result
print(result_df)
Diet¶
Builds and solves the classic diet problem.
The reference Python code showing Gurobi best practices can be found in our documentation here.
I want to optimize my diet.
Objective: I want to minimize the cost of food while upholding my dietary needs
Constraints:
- I want to eat between 1800 and 2200 calories per day
- At least 91 gram of protein
- At most 65 gram of fat
- At most 1779 mg of sodium
- Portions are non-divisible
Data:
The food I want to choose between can be found in diet.csv with the following columns: food, price, calories, protein, fat, sodium
food,price,calories,protein,fat,sodium
hamburger,2.49,410,24,26,730
chicken,2.89,420,32,10,1190
hot dog,1.50,560,20,32,1800
fries,1.89,380,4,19,270
macaroni,2.09,320,12,10,930
pizza,1.99,320,15,12,820
salad,2.49,320,31,12,1230
milk,0.89,100,8,2.5,125
ice cream,1.59,330,8,10,180
🔢 Problem Definition
We want to minimize the total cost of a diet while meeting specific dietary constraints. The mathematical model is defined as follows:
- Decision Variables:
Let \(x_i\) be the number of portions of food item \(i\) consumed, where \(i\) belongs to the set of available food items. Since portions are non-divisible, \(x_i\) must be an integer.
- Parameters:
\(c_i\): cost of one portion of food item \(i\)
\(cal_i\): calories in one portion of food item \(i\)
\(p_i\): protein content in one portion of food item \(i\)
\(f_i\): fat content in one portion of food item \(i\)
\(s_i\): sodium content in one portion of food item \(i\)
- Objective Function:
Minimize the total cost:
\[\text{Minimize } \sum_{i} c_i \cdot x_i\]
Constraints:
Caloric intake between 1800 and 2200 calories:
\[1800 \leq \sum_{i} cal_i \cdot x_i \leq 2200\]Protein intake at least 91 grams:
\[\sum_{i} p_i \cdot x_i \geq 91\]Fat intake at most 65 grams:
\[\sum_{i} f_i \cdot x_i \leq 65\]Sodium intake at most 1779 mg:
\[\sum_{i} s_i \cdot x_i \leq 1779\]Non-divisible portions:
\[x_i \in \mathbb{Z}_+ \quad \text{(non-negative integers)}\]
import pandas as pd
from gurobipy import Model, GRB
# Load the diet data
diet_data = pd.read_csv('/mnt/data/diet.csv')
# Extract data
foods = diet_data['food'].tolist()
prices = diet_data['price'].tolist()
calories = diet_data['calories'].tolist()
proteins = diet_data['protein'].tolist()
fats = diet_data['fat'].tolist()
sodiums = diet_data['sodium'].tolist()
# Number of food items
n = len(foods)
# Create a model
model = Model("Diet Optimization")
# Decision variables: number of portions of each food item
x = model.addVars(n, vtype=GRB.INTEGER, name="x")
# Objective: Minimize total cost
model.setObjective(sum(prices[i] * x[i] for i in range(n)), GRB.MINIMIZE)
# Constraints:
# 1. Caloric intake between 1800 and 2200 calories
model.addConstr(sum(calories[i] * x[i] for i in range(n)) >= 1800, "MinCalories")
model.addConstr(sum(calories[i] * x[i] for i in range(n)) <= 2200, "MaxCalories")
# 2. Protein intake at least 91 grams
model.addConstr(sum(proteins[i] * x[i] for i in range(n)) >= 91, "MinProtein")
# 3. Fat intake at most 65 grams
model.addConstr(sum(fats[i] * x[i] for i in range(n)) <= 65, "MaxFat")
# 4. Sodium intake at most 1779 mg
model.addConstr(sum(sodiums[i] * x[i] for i in range(n)) <= 1779, "MaxSodium")
# Optimize the model
model.optimize()
# Extract results
solution = {
"Food": [],
"Portions": [],
"Total Cost": model.objVal
}
for i in range(n):
if x[i].X > 0.001: # Only show foods that are included in the solution
solution["Food"].append(foods[i])
solution["Portions"].append(x[i].X)
solution_df = pd.DataFrame(solution)
solution_df['Total Cost'] = model.objVal
Sudoku¶
A simple sudoku solving problem.
The reference Python code showing Gurobi best practices can be found in our documentation here.

Solve the following sudoku, the periods indicate empty cells:
.284763..
...839.2.
7..512.8.
..179..4.
3........
..9...1..
.5..8....
..692...5
..2645..8
🔢 Problem Definition
A Sudoku puzzle is a 9x9 grid divided into nine 3x3 subgrids, where each row, column, and subgrid must contain the digits 1 through 9 exactly once. The problem is to fill in the missing digits (represented by periods in the input) while satisfying these constraints.
Let \(x_{i,j,k}\) be a binary variable that is 1 if the cell \((i,j)\) contains the digit \(k\), and 0 otherwise.
Objective:
Minimize 0 (this is a feasibility problem, so there is no objective function to minimize).
Constraints:
Each cell \((i,j)\) must contain exactly one digit:
\[\sum_{k=1}^{9} x_{i,j,k} = 1 \quad \forall i,j\]Each digit \(k\) must appear exactly once in each row \(i\):
\[\sum_{j=1}^{9} x_{i,j,k} = 1 \quad \forall i,k\]Each digit \(k\) must appear exactly once in each column \(j\):
\[\sum_{i=1}^{9} x_{i,j,k} = 1 \quad \forall j,k\]Each digit \(k\) must appear exactly once in each 3x3 subgrid:
\[\sum_{i \in S_r, j \in S_c} x_{i,j,k} = 1 \quad \forall k, \text{ for each } 3 \times 3 \text{ subgrid } S_r \times S_c\]
Given the input grid, certain variables \(x_{i,j,k}\) will be fixed to 1 based on the known digits.
import gurobipy as gp
from gurobipy import GRB
# Sudoku puzzle
sudoku = [
[0, 2, 8, 4, 7, 6, 3, 0, 0],
[0, 0, 0, 8, 3, 9, 0, 2, 0],
[7, 0, 0, 5, 1, 2, 0, 8, 0],
[0, 0, 1, 7, 9, 0, 0, 4, 0],
[3, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 9, 0, 0, 0, 1, 0, 0],
[0, 5, 0, 0, 8, 0, 0, 0, 0],
[0, 0, 6, 9, 2, 0, 0, 0, 5],
[0, 0, 2, 6, 4, 5, 0, 0, 8]
]
# Initialize model
model = gp.Model()
# Decision variables: x[i,j,k] = 1 means cell (i,j) contains number k+1
x = model.addVars(9, 9, 9, vtype=GRB.BINARY, name="x")
# Constraints
# Each cell contains exactly one number
model.addConstrs((gp.quicksum(x[i, j, k] for k in range(9)) == 1 for i in range(9) for j in range(9)), name="Cell")
# Each number appears exactly once in each row
model.addConstrs((gp.quicksum(x[i, j, k] for j in range(9)) == 1 for i in range(9) for k in range(9)), name="Row")
# Each number appears exactly once in each column
model.addConstrs((gp.quicksum(x[i, j, k] for i in range(9)) == 1 for j in range(9) for k in range(9)), name="Column")
# Each number appears exactly once in each 3x3 subgrid
model.addConstrs((
gp.quicksum(x[i, j, k] for i in range(bi*3, bi*3+3) for j in range(bj*3, bj*3+3)) == 1
for k in range(9) for bi in range(3) for bj in range(3)), name="Subgrid")
# Pre-filled cells
for i in range(9):
for j in range(9):
if sudoku[i][j] != 0:
model.addConstr(x[i, j, sudoku[i][j] - 1] == 1)
# Optimize model
model.optimize()
# Extract solution
solution = [[0 for _ in range(9)] for _ in range(9)]
for i in range(9):
for j in range(9):
for k in range(9):
if x[i, j, k].X > 0.5:
solution[i][j] = k + 1
Workforce¶
Assigning workers optimally to fit a work schedule.
The reference Python code showing Gurobi best practices can be found in our documentation here.
We have also described this use-case in our OptiMods toolbox, which is a convenient data-driven API for running particular problem types like this one! See the Workforce Scheduling or OptiMods to learn more.

Assign workers to shifts while minimizing costs.
Shift requirements:
Mon1: 3
Tue2: 2
Wed3: 4
Thu4: 2
Fri5: 5
Sat6: 4
Sun7: 3
Mon8: 2
Tue9: 2
Wed10: 3
Thu11: 4
Fri12: 4
Sat13: 7
Sun14: 5
Workers and their pay:
Amy: 10
Bob: 12
Cathy: 10
Dan: 8
Ed: 8
Fred: 9
Gu: 11
Availability:
Amy: Tue2,Wed3,Fri5,Sun7,Tue9,Wed10,Thu11,Fri12,Sat13,Sun14
Bob: Mon1,Tue2,Fri5,Sat6,Mon8,Thu11,Sat13
Cathy: Wed3,Thu4,Fri5,Sun7,Mon8,Tue9,Wed10,Thu11,Fri12,Sat13,Sun14
Dan: Tue2,Wed3,Fri5,Sat6,Mon8,Tue9,Wed10,Thu11,Fri12,Sat13,Sun14
Ed: Mon1,Tue2,Wed3,Thu4,Fri5,Sun7,Mon8,Tue9,Thu11,Sat13,Sun14
Fred: Mon1,Tue2,Wed3,Sat6,Mon8,Tue9,Fri12,Sat13,Sun14
Gu: Mon1,Tue2,Wed3,Fri5,Sat6,Sun7,Mon8,Tue9,Wed10,Thu11,Fri12,Sat13,Sun14
🔢 Problem Definition
We need to assign workers to shifts while minimizing the total cost of the assignments. The problem is formulated as a mixed-integer linear program (MILP) with the following details:
Sets
\(S = \{1, 2, \dots, 14\}\): Set of shifts, where each number corresponds to a specific day (e.g., 1 = Mon1, 2 = Tue2, …, 14 = Sun14).
\(W = \{\text{Amy}, \text{Bob}, \text{Cathy}, \text{Dan}, \text{Ed}, \text{Fred}, \text{Gu}\}\): Set of workers.
Parameters
\(c_w\): Cost of assigning worker \(w\) to a shift.
Amy: 10
Bob: 12
Cathy: 10
Dan: 8
Ed: 8
Fred: 9
Gu: 11
\(r_s\): Number of workers required for shift \(s\).
\(r_1 = 3, r_2 = 2, \dots, r_{14} = 5\)
\(a_{w,s}\): Availability of worker \(w\) for shift \(s\).
Binary value: 1 if worker \(w\) is available for shift \(s\), 0 otherwise.
Decision Variables
\(x_{w,s}\): Binary variable indicating whether worker \(w\) is assigned to shift \(s\) (1 if assigned, 0 otherwise).
Objective
Minimize the total cost:
Constraints
Shift Requirement: The number of workers assigned to each shift must meet the requirement:
\[\sum_{w \in W} x_{w,s} \geq r_s \quad \forall s \in S\]Availability: A worker can only be assigned to a shift if they are available:
\[x_{w,s} \leq a_{w,s} \quad \forall w \in W, \forall s \in S\]
import gurobipy as gp
from gurobipy import GRB
# Sets of shifts and workers
shifts = list(range(1, 15)) # Shift numbers 1 through 14
workers = ["Amy", "Bob", "Cathy", "Dan", "Ed", "Fred", "Gu"]
# Cost per worker
cost = {
"Amy": 10,
"Bob": 12,
"Cathy": 10,
"Dan": 8,
"Ed": 8,
"Fred": 9,
"Gu": 11
}
# Shift requirements
shift_requirements = {
1: 3, 2: 2, 3: 4, 4: 2, 5: 5, 6: 4, 7: 3,
8: 2, 9: 2, 10: 3, 11: 4, 12: 4, 13: 7, 14: 5
}
# Worker availability for each shift
availability = {
"Amy": [2, 3, 5, 7, 9, 10, 11, 12, 13, 14],
"Bob": [1, 2, 5, 6, 8, 11, 13],
"Cathy": [3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14],
"Dan": [2, 3, 5, 6, 8, 9, 10, 11, 12, 13, 14],
"Ed": [1, 2, 3, 4, 5, 7, 8, 9, 11, 13, 14],
"Fred": [1, 2, 3, 6, 8, 9, 12, 13, 14],
"Gu": [1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
}
# Create the optimization model
m = gp.Model("shift_scheduling")
# Decision variables: x[w,s] = 1 if worker w is assigned to shift s
x = m.addVars(workers, shifts, vtype=GRB.BINARY, name="x")
# Objective: minimize the total cost
m.setObjective(gp.quicksum(cost[w] * x[w, s] for w in workers for s in shifts), GRB.MINIMIZE)
# Constraints:
# Shift requirement constraints
for s in shifts:
m.addConstr(gp.quicksum(x[w, s] for w in workers) >= shift_requirements[s], name=f"shift_req_{s}")
# Worker availability constraints
for w in workers:
for s in shifts:
if s not in availability[w]:
m.addConstr(x[w, s] == 0, name=f"availability_{w}_{s}")
# Solve the model
m.optimize()
# Extract results
assignment = {w: [] for w in workers}
for w in workers:
for s in shifts:
if x[w, s].X > 0.5:
assignment[w].append(s)
total_cost = m.objVal
Portfolio Optimization¶
This example solves a financial portfolio optimization model, using historical return data.
The reference Python code showing Gurobi best practices can be found in our documentation here.

I have data on some stocks that I enclosed in a csv.
The columns are the stocks and rows are their value at different time points.
Step 1: I want to calculate the minimum risk portfolio
Step 2: Solve for efficient frontier by varying the expected return.
Step 3: Create a plot with the following
- Volatility versus expected return for individual stocks (in blue dots) and include an annotation with the stock name
- Volatility versus expected return for minimum risk portfolio (in green dots)
- Efficient frontier showing the volatility (green line)
Make sure you set: `model.setParam("OutputFlag", 0)`, to suppress Gurobi output.
,AA,BB,CC,DD,EE,FF,GG,HH,II,JJ
0,-0.000601195612674,0.00235338594971,-0.0752335718293,0.0132986457962,0.013729458857,-0.0300331025108,0.0097098478981,0.0607366596922,-0.0128692023155,-0.0221373498858
1,0.0191767846723,0.0500080797498,0.0413445093224,-0.0118638458107,-0.0118797818094,-0.0135939386481,-0.00732870527613,-0.0266736509577,0.00987573185266,0.0128089335267
2,-0.0203332000076,0.0266382125763,-0.0389990672811,-0.017777519562,0.0127868199621,-0.00596770228189,-0.0223268641586,-0.023152572415,-0.00700707699816,-0.0380340562197
3,0.0014206991819,-0.0538128052695,-0.0133465260905,-0.00262984903161,-0.0636934739858,-0.0411177352489,0.0225883214158,-0.0123480666579,0.0187356648257,-0.058372513909
4,0.00864771267018,0.114835959861,0.00361711846446,0.00789413132211,0.0412976559192,0.0198546937033,0.0208700535229,0.0640898336902,-0.0111530482356,0.0243334775592
5,0.00577363510133,0.0146318448214,0.00602181447036,0.0153296094,-0.065888295148,0.0202097222191,-0.0183697568534,0.00293514155882,-0.0276862876386,-0.0205926634095
6,0.0432486801673,0.0908105558426,0.0280267736573,0.0397475367342,0.0173493845462,0.0387304042098,-0.00355793010651,0.0306599394785,0.0518154616057,0.0591557584395
7,0.00035530109459,0.0560587804076,-0.0352906853643,0.0393892543934,0.0454316864314,-0.0259102974168,0.0314200540614,0.0371417632181,0.0458965751594,0.0178062199922
8,0.0113584690751,0.0100309028542,0.00263098105616,0.0105587832648,0.0182473171858,-0.0191336020928,0.0271227108439,0.0278796680076,-0.00237372043701,0.02140333684
9,0.00751644560006,0.106341791652,-0.025436461795,0.0088468020241,0.00840227993962,0.0014094192731,0.0263823212723,0.00957274705883,0.00421714395417,0.00208387694357
10,-0.0141644967957,0.0119751707846,0.00719056361301,0.0225967591058,-0.00574240835454,-0.0151349813909,0.0345343582522,-0.0132891993884,0.00862133055587,-0.00983114836391
11,0.00451033311878,-0.0193238647214,-0.0840954566359,0.00234651679624,-0.0337741313685,0.000900736791595,-0.0115577063549,-0.00309579273421,0.0016479524886,-0.0170176076657
12,-0.000528830057118,-0.0710183734529,-0.0194490936012,-0.00203494094379,-0.0362482340344,0.0137987358803,-0.0254533685141,0.0118716665894,-0.0217349592006,-0.0115644186494
13,0.00574272738462,0.0222947634929,-0.0262350515238,0.0293337672764,-0.00292241750327,0.0249997929323,0.00681989964224,0.0202693081912,-0.00952844289155,-0.0461254719181
14,0.000775603728123,0.0663566202073,0.0119678176139,0.031922497404,0.0520153322051,0.00722809039319,0.00443949547091,0.0229378881757,-0.0350944252828,0.0637218202195
15,0.0246643410379,0.0588993602597,-0.0177819841826,-0.0043462795266,0.110429669948,0.000875830219215,0.0346651243375,-0.0193787054386,0.0329532881392,0.0552448588082
16,-0.00236028993862,0.0690374542955,-0.0251213875914,0.0199393265771,-0.0136877558657,-0.0370947579145,-0.00931578995568,-0.0217677102803,0.0716781880876,0.0427598646548
17,-0.0244476331116,-0.0586158832898,-0.00180135997708,-0.0243665704994,0.00193592651335,0.00630783861274,-0.001109818567,0.00728533891996,-0.0259409125882,-0.0520375376121
18,-0.00262488262575,0.0580227606829,0.0104953421358,-0.00577469567005,0.0305333690204,-0.0633128694918,-0.00846823821347,0.0184237881312,-0.0150212348922,0.000152581949387
19,-0.00584594063823,0.0351716906205,-0.0811014946643,0.0101584375734,-0.00126127655781,0.0131934126194,-0.0183605796107,-0.0353993889868,-0.0224772739805,0.0188106196483
20,0.0120799513092,0.0155573850289,0.0351879566059,-0.0151916663599,-0.00169449493653,0.0173752887017,0.0269103408286,0.0265183345407,0.00792528027642,-0.000771381520351
21,-0.020868708632,-0.0155255559646,-0.0133991537663,-0.020051892969,-0.0201505596052,-0.0271871731101,-0.0178030995666,0.0415754244751,-0.00971827582764,-0.0129416129243
22,0.0135951629031,0.0302550139619,-0.0503993250112,0.0146273283873,0.0135624477723,-0.0207174765109,0.018563520564,0.03962682453,0.0141243313957,0.00651754187996
23,-0.0111132130847,0.150177550604,0.0583841477061,0.0155170933266,0.0461747440063,0.0137709123175,0.00175429681632,-0.0265533788848,0.00583847906841,0.10698113115
24,-0.033788224374,0.0078483728137,-0.00106697618867,0.0157993994088,-0.0347025275892,-0.00887940978653,-0.0469771590076,-0.0138541566144,0.0332277416607,0.0144962074184
25,0.0226370121649,-0.00971287247341,-0.0328794841828,-0.00994364786251,0.056286748799,-0.0199632860517,0.0156101467236,-0.0116378765833,0.0328761884981,-0.00118481406866
26,0.0235649770703,-0.0884683361872,-0.010690526855,0.0391492923603,0.055471577731,0.0232646908808,0.0162042663702,0.026003741128,-0.0114224429025,-0.0168796215255
27,0.0209361014708,0.0871100040442,-0.0384399773968,0.0240042263424,0.054017754017,-0.0175055414066,0.00807068095964,0.0157463860856,-0.0094916562545,0.0590428279111
28,-0.0246475821594,0.0552670826116,-0.0390119310809,0.0371551092996,-0.0251616322643,0.010205167865,0.0104372794775,-0.0260232339743,0.0156343390593,0.00291212800981
29,-0.0134395887063,-0.0270182008736,-0.0564606314735,-0.00117376392637,-0.0112796801112,-0.0418051571465,0.00881379405622,-0.0302220635604,0.0106535909292,-0.020405493104
30,-0.0398247997375,-0.054404384123,-0.0176457036458,-0.0307172063708,-0.0415078951594,-0.0572796780427,-0.0534832229033,0.0124993385493,-0.0321260376802,-0.0890153427327
31,0.0253270508986,0.0836083820024,0.0625502073884,0.0283979539678,0.0680211988382,0.082852630928,0.0340101870304,-0.000830555929471,-0.0128190150415,0.0301866731582
32,0.0093313079267,-0.00333779725378,-0.0280005476527,-0.00619433170409,-0.0259575183145,-0.0204634846641,0.0133229439252,0.00284599156265,-0.0403840806678,0.00405840030583
33,0.00153938656825,0.00761990815315,0.0233546371432,0.0036929127085,0.0420311215561,0.0178452682105,-0.00557249325236,-0.00592848730419,-0.0141366459198,0.0124887252093
34,0.0111782073623,-0.0555158122222,0.0018320292481,-0.0250754410617,-0.0259776133048,0.0110836763089,-0.0428773574964,-0.00909771943193,-0.0357905597354,0.0490816214052
35,-0.026555628498,-0.043944730246,0.0418455382054,0.00658988973256,0.0360172026391,-0.00538974423306,-0.0170750019262,-0.0657582931427,-0.0203619499199,-0.0188457322732
36,-0.00416041668116,0.0113994807744,-0.061612379468,0.0245240519607,-0.00495322456221,-0.0169355758333,0.0295143005822,0.00995166589752,0.0320142625631,-0.000725017996171
37,-0.00491300387844,0.0004925489191,-0.00557184740424,-0.0326012303189,0.0343401436975,0.0222343104863,-0.00754361936013,-0.0134257314287,0.00795966715953,0.00936645289031
38,-0.00582526334303,-0.0569862851559,-0.0564762916584,-0.030698135831,-0.037157066296,-0.0525554409332,-0.0266221586509,0.00891711407665,-0.0608642798496,-0.0930451227166
39,0.00853871777087,0.0360837829527,-0.0330162597141,-0.00729477747578,0.0149571876967,-0.0058044804773,0.00886465823849,0.032508135605,-0.00992231966056,-0.000364353375674
40,-0.0131241509519,-0.0647138168666,-0.0208018648108,-0.0153778249873,-0.0179471393844,-0.0222123875869,-0.0162861236195,-0.0470799782768,0.00188570244088,-0.0178517590735
41,-0.0123746045878,0.0934671112935,0.0383520429906,-0.00911972493661,-0.0504787530754,-0.0178312467923,-0.00311787201536,0.0324377275872,-0.0501079206081,-0.0325095583007
42,0.00810593335715,-0.0288208281307,-0.0280294957606,-0.00953710049288,-0.0526702132745,0.00898948771877,0.00155510783698,-0.00976703281149,-0.00979850354042,0.00925329565297
43,-0.00478016363034,0.0121194767053,-0.0228118363707,0.0340340966197,0.00527771710415,-0.036733757849,0.0207548749843,0.0143339099402,0.0392627065912,0.0172404332565
44,-0.000401536690365,-0.0102517455577,0.0911860763658,0.0227502629313,0.0337661224974,0.0216158283057,-0.013426872461,0.0274490145855,-0.0312261929242,-0.00114668299086
45,-0.0112471669918,0.0231274677052,0.00876296902022,0.0415411520656,0.0109315904622,0.00141815052443,0.00195992371988,0.00624828069496,0.0497514210205,0.0563684065873
46,-0.00785199112119,0.0336057853269,0.0256775651417,-0.00433747944473,0.0139675261933,0.0424416070257,-0.026210454052,-0.000335031911618,-0.0118870225042,0.0212446314063
47,-0.00958020726683,-0.00796078100473,0.0518361236658,-0.0164301073785,0.0388964116744,-0.0103104727731,0.0284053230151,0.0204853947639,0.000878926732503,-0.0470166263287
48,-0.0220780015871,-0.00730156059547,0.0185154355528,0.0385891539377,-0.0238660149882,0.0105462301084,0.0197346357769,-0.00874181683309,-0.0220881705934,-0.00781024871402
49,0.0012261223914,0.0417298226881,-0.00311253126991,0.0199072037983,-0.00718010098764,0.00228001260927,0.00953164268362,0.041415401198,-0.0239908414102,0.024393881168
50,0.0136953369744,0.0405732305449,-0.0366222934746,0.0104597266228,-0.0466993631745,-0.0200181705685,0.00748731559885,0.026079083893,0.0245115496893,0.00675897198107
51,-0.0117470373079,-0.0369734598884,-0.0141743004236,0.00591971566015,-0.0349086099812,-0.0564534252667,-0.0421779989804,-0.00287209363147,0.0456952269712,-0.031964037124
52,-0.013734117216,0.0266817916815,-0.0256560054993,0.0165810430196,0.0390837433195,0.00288332273785,-0.0117078615002,0.00460277854998,0.00677263073962,0.00293707109402
53,0.000859516200072,-0.0033925247879,-0.0104001432544,0.0165066709617,-0.008477333519,-0.000629745450747,0.0168871272418,0.011578545097,0.00544070231114,0.0127721755296
54,0.0124719768086,0.0283409504649,0.0995663365988,-0.0257098779938,-0.0842878918806,0.0318133160371,0.0255670784854,0.0346813810958,0.0146309099981,0.0162059815522
55,-0.00146477712014,0.0372280401709,-0.0112624736101,0.0239703425876,0.0380043313631,0.0399029219937,-0.0196856821445,-0.0111088539447,0.000892581220323,0.0113485378525
56,-0.0128089665896,-0.0452010658715,-0.0675690818602,0.0146290360586,-0.010242425355,-0.00865843895533,-0.0409995130257,0.0365394698693,0.00304325782526,-0.0563249266418
57,0.00427496666572,-0.047706601455,-0.0272120135569,0.0229903051361,0.0073931694611,-0.0398560606835,-0.0114010471297,0.0218240281096,0.0256155670188,0.0160743096557
58,0.00949545564434,0.0282158599398,0.00458023386977,0.00582137755406,0.0403206436898,0.0119937419502,0.00323441065094,-0.0106306164002,0.0387570921,0.0530010732163
59,-0.00365653550232,-0.0245872635602,0.00153680341324,0.0119935712303,-0.010950854066,0.0225006432562,-0.0342666510951,-0.0147557629921,0.0457029051603,0.00612236298854
60,0.0220336600873,-0.0555772480231,-0.0195786030758,0.0191997580204,-0.0153332493592,0.0267004481431,0.019634918775,0.0008170428246,0.000377315225716,-0.0226859460878
61,0.0155483358961,0.0685224796302,0.0896479717783,0.0324317155205,0.0743496198176,0.0468225726767,0.0414082709277,-0.00895265476834,-0.00306748034653,0.0541049540785
62,0.00203394198923,-0.0149803621042,-0.147151677724,-0.0235735274873,-0.0272614922437,-0.0363751561909,-0.042973120351,-0.0194731220829,0.00392861039659,0.00767341024523
63,0.0113945250886,-0.0157103147662,-0.0468401376592,0.000251602686739,0.0179382569183,-0.0277100708137,0.00255342799629,-0.00888871375186,0.0108180759353,0.0300020800319
64,0.0225828454549,0.104800696848,-0.0168964530126,0.0532157944127,0.0160901971623,0.0613012110134,0.0209172639217,-0.0403910733649,0.000389296955857,0.0505687041596
65,0.00433855331562,-0.0224656847887,-0.00835796494433,-0.0101720443053,0.000236696958563,-0.0130596962591,-0.0189973000959,0.00515135808611,0.0208109183032,0.0126358747975
66,-0.0177159182143,0.032152100147,0.0343070869244,-0.00597159396484,-0.00699118424441,0.0013938898973,-0.0113180420892,-0.011993219445,-0.0502404070312,0.0169131149803
67,-0.00669847476031,0.0436781932292,-0.00414565940744,0.0440347696375,-0.0512988708529,-0.0209029581485,-0.017076440822,-0.00709770662018,-0.034247465617,-0.0593859873517
68,-0.0145258965669,-0.00666905010122,-0.0390752317293,-0.0158482387243,0.0157499032023,-0.0148534288978,-0.000404587272793,0.0222560795346,-0.0276405963668,-0.0271090462685
69,-0.00679443904448,-0.0428472993431,-0.00768853614532,-0.0257565147828,-0.0315698235885,-0.012935794639,-0.0169540404704,-0.0797778394962,-0.0150766392385,0.0329854580324
70,0.0173185959116,-0.0810431495283,-0.0372203286063,-0.0169769158028,-0.019963916734,0.00687285163192,-0.00808762953534,0.00516476043606,0.0287371427882,-0.05054918077
71,-0.00231367057888,-0.0155309228638,-0.131896652984,-0.0441737728962,-0.0602742173894,-0.0396555067633,-0.00283223496263,0.0119108083186,0.0148420697474,-0.00872891550393
72,0.0222481043686,0.105614930363,0.0404948085566,0.0387117043439,-0.0223764643542,0.0444385231436,0.0297411450543,0.0256397078231,0.0256289926939,0.107195334093
73,-0.0165712798179,-0.00466231551591,0.0110599218735,-0.0190970906107,0.0339775033499,-0.013488422908,-0.0402283625422,0.0180755266829,-0.0409484353032,-0.0423354056555
74,0.00776075560668,-0.0676099557089,-0.0892443028223,-0.00645153023262,-0.0248041302905,-0.0085352220473,0.000177125079175,0.0307795451691,0.0106119070803,-0.0218462886788
75,0.00192141744359,-0.0181088903712,0.0544243507419,0.0459838125059,-0.0200223417489,0.03014208682,0.022291160251,0.0540571366581,-0.0165236075056,0.00662873101203
76,-0.00463731336859,-0.0243540590881,-0.00872560165745,0.0153989172873,-0.0660180306306,-0.0447059654054,-0.0257437550602,0.00536374818394,-0.043202624552,-0.0131008458462
77,0.0426106702311,-0.014590616484,-0.00253515752435,-0.0111344735878,0.0028702500429,0.0110852953201,0.00548107494598,0.0133708017866,-0.0109833279546,-0.00371474517324
78,0.0215648952904,0.017358170343,-0.0212820632497,-0.00425263899084,0.0445611593383,-0.00203730035675,0.00981348981138,-0.00855033865046,0.0154763370302,0.04124259123
79,0.0136757135077,-0.00886009893898,-0.0443894372316,0.0155744078883,0.0279887006976,0.0446220767722,-0.00810113970803,0.00726531155589,0.0400056783731,-0.0158828635493
80,0.00617965807988,0.0391553746241,-0.00563587948894,0.00435128155518,-0.000327600031684,0.0285507457967,-0.00136760604234,-0.0306476134199,0.00843318132705,0.0277065818078
81,0.00827057057041,-0.0406268574783,0.0049875883545,0.022918184092,-0.00235032744903,0.0402478285038,-9.76524597488e-05,0.014401320653,0.0114682671725,-0.0105229252516
82,-0.0171304476187,-0.0774606497046,-0.012709046315,-0.0295041125752,-0.0314981292873,-0.0420222919753,-0.00193758401261,0.0213678825332,0.0372127756967,-0.0480749217609
83,0.0150852508966,0.0488717328487,0.0419301702878,0.0180709736005,0.0519211951837,0.00166737356529,0.0329475562931,0.00620317810547,0.0273878541307,0.0640109929692
84,-0.00234317814202,-0.131000826976,-0.101786031759,-0.0158208463293,-0.0517289409271,-0.0303578710494,-0.0336882260695,-0.00718892815772,-0.0328151914253,-0.0473617615543
85,-0.00469100415108,-0.0372411975932,-0.129341529598,0.00636833561262,-0.0391265122785,-0.0466927100375,-0.0482767009172,0.0177872440129,-0.00581183933716,-0.0273265584143
86,0.00194209898258,0.0922130485918,0.0143845322655,0.0141031169795,0.014930339186,0.0474799437237,0.0254578868426,-0.00111809518388,-0.0103928692031,0.0732712129516
87,0.00852593205056,0.0283145537587,-0.0205590001943,0.0280684825812,0.0324216650513,-0.000391094750257,0.0315510806969,0.00741739765887,0.0111745706166,0.0369644178823
88,0.0276521115285,0.0573597802546,-0.0182329546701,0.0112824553055,-0.0208931115075,-0.0135208795174,-0.00842659947773,-0.0111678976202,-0.039977673438,0.019838624559
89,0.0133737485075,0.0356613644229,-0.021183783905,0.0166909170005,0.00735430277261,-0.00934654615339,0.0148053988014,0.0198957906964,0.0207449891192,0.0187984902406
90,-0.00464066765461,0.0905187369886,-0.0095270294586,0.0529117399694,0.0322632453484,0.0254147706543,0.057717992841,0.0165116208246,0.0311542466156,0.050631076275
91,-0.00958514018475,-0.0419536836106,-0.0562355469128,0.0141683091632,-0.015332902517,-0.0343942827824,-0.0128481703279,-0.01012527375,-0.0113831527825,-0.0159566153624
92,-0.0154444194986,-0.00463812455342,-0.0389457359554,-0.0306297125483,-0.023474293459,-0.0498275500804,-0.0164569407278,0.0203158577674,-0.0488782681896,-0.0211180563087
93,0.00791224522103,0.0589577670721,-0.079215384525,0.0371219395571,0.0311890140869,-0.0387765139678,-0.0187417878661,0.00733509345329,-0.0095587204861,0.0404868729587
94,0.00637331209611,-0.0454962770709,-0.0411645530645,-0.035917659176,-0.0502549787842,-0.00748960221654,0.0158062312598,0.0109178445203,0.0269393900122,-0.0853155014669
95,0.00674563449838,0.0444804439167,-0.018471514801,0.000637020358839,-0.0473410349858,0.00672359156109,-0.00230801655769,0.00158917462629,-0.0237819444807,0.0292431807514
96,-0.0141545458531,0.00657094547191,-0.0452581696177,0.0304796414817,-0.0335523763742,-0.0173574323624,-0.00325302931385,-0.00683327599315,-0.0653763422483,-0.0233755042159
97,0.000565614545811,0.0663893347746,0.070505943287,-0.0100746303188,0.045345161443,0.0417993698146,0.0380145442141,0.008118843984,0.0348871238014,0.0292281718744
98,0.0140224246204,0.0430606717283,0.0558233450016,-0.00624807096714,0.0329659928864,-0.0190051304967,0.00386061941105,0.0678955947631,0.0121987966718,0.0104672205989
99,-0.0161839108359,-0.0548710508816,0.00584642382054,-0.000897682800248,-0.0287175395297,-0.0371382529065,-0.0175839750161,-0.0275357100644,-0.0586787152323,-0.0123192505218
100,0.0132959473637,0.0338044725341,0.0163444239605,0.0187086960495,0.0312431839806,0.0124969622951,0.0112636741721,-0.00234449751727,0.0548205850873,0.0263391942855
101,-0.0147997501425,0.0437752946042,0.040781428402,0.0594774394737,0.0690929479687,0.0508115914412,0.00157226993495,-0.0160494194639,0.04096062739,0.047691396104
102,0.0260224473089,-0.00238749660454,-0.0836257673833,0.0134971928401,-0.0615093657142,-0.0262332511357,0.0147942930585,0.0226885377967,0.00895658252485,-0.0160696988829
103,0.0285873703369,-0.00307137213223,-0.16800355775,0.00262385703369,0.00112690147466,-0.0568386677264,-0.0118279329151,0.00890282606686,-0.0141076590856,0.00955242022118
104,0.0118011001579,-0.0196070158158,-0.0166025987006,-0.012751463328,0.000634810545695,-0.0685349682875,-0.000854610164438,0.0123902619738,-0.0545441166093,-0.0608166312159
105,0.0404444423477,-0.0329211125393,-0.0222161857951,0.0185541976858,0.00208911037475,-0.0132738071043,0.0484023939711,0.0114363011749,0.046753641993,-0.00615835024913
106,0.0234588363246,0.0253452971005,-0.0239170770181,-0.00145409787956,0.0748557928761,0.014920269516,0.0185433607694,-0.0251972571579,-0.0169222003814,0.0420542353099
107,0.0247077067434,0.0605220788793,0.0177521115278,0.0361231860077,0.0264687560828,0.0190926988153,0.0426128581649,0.0269596712726,0.0168366319727,-0.0185333721714
108,0.000332739447088,0.147248936319,0.0698571798048,0.00296577666956,-0.00333926493611,0.0209370482395,0.0563181258749,0.0470159028297,0.00957792792925,0.0413978080846
109,-0.0175121144217,-0.0142125718255,-0.0727049920963,-0.0318840155041,-3.95531797144e-05,-0.0410406656704,-0.0077347758262,-0.0414980620274,-0.0102308319052,-0.0472560060648
110,-0.0138621958466,-0.0880030345748,-0.0796076159063,-0.0215730558278,0.00256376045751,-0.00723145118673,-0.01034031056,-0.0223134139507,-0.00332024568674,-0.0348016947263
111,-0.0179554948684,0.0147998202055,0.0101233818894,-0.00544715350323,-0.0310559012443,-0.0439644490737,0.00689069164163,-0.00023407304828,0.0293995480998,-0.00444044152883
112,0.00240279195468,0.032770899666,-0.0603341631484,0.0380231210505,0.0442660570463,-0.00277677629889,-0.00951064541567,0.0095671627931,-0.00221082414652,-0.0129116358561
113,-0.0133935015991,0.0812547709933,-0.00956759243453,0.0177818161702,0.00840115166451,0.0220177936762,0.0164155946764,-0.00539185030718,-0.0161690120079,0.0268346901375
114,0.00912224311037,-0.0132939255915,-0.0501218597963,-0.0565740182097,-0.0978538308588,-0.0442292009066,-0.0162777423444,0.0139564827791,-0.047419659698,-0.00892654534634
115,-0.0252338676178,0.00300935099355,0.0366883525469,0.00312243085007,0.0399928905495,0.00296661921003,-0.00300802015966,0.00171897141357,-0.018642164887,-0.00426892153947
116,0.00121702001279,0.0982069083595,0.019313671039,0.0310798282591,0.0327636263077,0.0136587095537,0.0453452802313,0.0158840109655,0.0190867348302,0.0643062803684
117,0.0128834747226,-0.116963246124,-0.0367895224649,-0.0508833225863,-0.0617201716407,-0.0256247160125,-0.0161605767975,-0.00650396106086,-0.0225851920986,-0.0414592973344
118,0.00710385478522,0.00469208071947,0.0385179655573,-0.0103869324172,-0.0275229725943,-0.0259903010321,-0.00468695555094,0.020275647607,-0.00201903355572,-0.0130841109055
119,0.0126322227916,0.0685522824773,0.0363532479658,0.029001500499,0.0301726496617,0.0165624110906,0.0114669511995,0.0642257129501,-0.00645504172495,0.0174002656212
120,0.00470140388013,0.0542290174718,0.00320237793011,0.0383331720313,0.0188238372507,-0.0214110410801,-0.0203916615719,0.00325773897743,0.000629985678288,0.0323721828199
121,0.0211568308866,0.0206487766194,0.0140806002128,-0.00850914997278,0.000389500331556,0.0119338955641,0.0260255357349,0.0098228156757,0.0151964603331,-0.00447928462256
122,0.0135429933148,-0.0247595481416,0.00956566838792,-0.00451081370241,-0.0206418534454,0.0306214337765,0.0207588696553,0.0168163094176,-0.0443835019286,0.019175703187
123,-0.0148444436435,0.0635625015745,-0.0236193388171,0.0273926014504,0.0165262512201,0.00273104362343,0.0244512411639,0.0144476819756,0.00119923737738,0.0363231443211
124,-0.00460503704601,0.0157942105516,0.00692951169659,0.0117371074636,-0.0129339048329,-0.00315563755716,-0.0294355677226,0.0245799527345,0.0247597757778,0.00493156938062
125,-0.00239004983426,0.0546163529133,-0.0581000256321,0.0332563732032,-0.0433307387632,-0.0509945424093,0.0474866335484,0.0193377029246,0.0220077760472,0.0204443280168
126,-0.00114206615915,0.158306229828,0.123788939019,0.0680035590645,0.0955900264611,0.0413714969378,0.0526286798014,0.0158141898025,0.0108859049352,0.0873148923624
127,0.00918699125778,0.0268106893674,0.0123259573235,0.00289469569457,0.017293269762,-0.01173545728,-0.00220814423738,-0.00983525509868,-0.00702565916994,0.0343799164289
128,-0.0211450840091,-0.0308176642477,-0.00284018824938,0.0182500651817,-0.0488275938466,0.0123583963398,0.00281122492132,-0.0111327807423,-0.0254472102431,-0.0582176696412
129,-0.00896314067088,0.00673605244916,0.0194533087939,-0.0167588481733,0.025147395633,-0.0182207045897,-0.014696363295,0.00534081025339,-0.0257914966243,-0.00593063235113
130,-0.00154800983195,0.0172865726774,-0.0543186404092,-0.0111114073182,-0.0505901831815,-0.0147013219694,-0.00905318181931,0.000715900839321,-0.015985075389,0.00702654062081
131,0.0542198475254,0.0940877958148,0.0268822262277,0.0170252578522,0.052953449251,0.0279344883635,0.0460964259261,0.0305491402962,0.0560375304243,0.0867012202983
132,0.0173518293389,0.0636564556607,0.0756550920895,0.0171401871597,0.0345606817964,-0.0021477481125,-0.0138497941504,-0.0416543652157,0.00211921316506,0.0718262467583
133,-0.00376410694025,0.0275698356721,-0.0449563207643,0.0035204684828,-0.027258392891,0.0325854900665,-0.0174944283409,0.00964848821514,-0.0347724309915,0.0040743378406
134,0.00632100975764,0.027650602179,-0.0387023317702,0.0309871775368,-0.00690902898478,0.015270085831,-0.0216085033572,0.0338545094837,0.00896319797536,0.0329124406549
135,-0.00532772320458,0.0281747071256,0.0132423924339,-0.0198223405443,0.0403683284334,-0.0167400213059,0.0143824699081,0.0112880133379,-0.0519922780128,-0.0428764928901
136,-0.0347948456692,-0.0379744854966,-0.0826591805549,0.00982008939479,-0.0192163966178,-0.0549134055043,-0.0111055560153,-0.0112550774677,-0.014196544821,-0.016886295095
137,-0.0104662120037,0.00136991495892,-0.0648578824842,-0.00635435641094,-0.097955347375,-0.0251615623899,-0.0281153416711,0.0118656049346,-0.0113369812922,-0.0124182306577
138,-0.0273051255595,-0.0345769180877,-0.0477739433127,-0.00426296618519,-0.0380956023349,-0.0247136897514,0.00209230449195,-0.0393102243638,-0.0127901240819,0.0083551746126
139,-0.0221161909248,-0.0536248259291,0.012356293333,-0.0410190202235,0.0121279004066,0.00153945476096,-0.011838176693,-0.0244367691825,-0.00871163152672,-0.027114324923
140,0.00418905187179,0.117506977879,0.0477832186357,-0.0232448904662,0.00435907441932,0.0281349534687,0.0172719761186,0.0210950614541,-0.00557472067728,0.0735476595613
141,-0.0236076028009,0.0296630593726,0.0215764594285,0.00136440441551,0.0133194608226,-0.0377055137331,-0.0299606489648,0.0362912401571,0.0194768855984,0.0148451216686
142,-0.0205146281898,0.0436701419244,-0.0182806003401,-0.0431277648861,-0.0184104855424,-0.0280049994363,-0.0178742884678,-0.0195956802669,-0.0502814376707,-0.00068256657849
143,0.0298754453007,0.0155711531141,0.0373997166276,0.00875805440018,0.0116342806368,0.0311483537817,0.040031553011,0.03009003298,-9.27680666521e-05,0.0024879922546
144,0.0111108311173,0.0696479518058,-0.0879373731306,0.00805396410704,0.0189272348951,-0.0192832270757,0.000305701384436,0.0124468509799,0.00367118769916,0.0455750497781
145,-0.00322019024633,0.0486675374701,0.00174589476867,-0.0181188761556,0.0338903010957,0.00540347880761,-0.00203178796441,0.0169610416268,-0.0216483964398,-0.00651910576751
146,-0.0095033894911,0.022186513726,-0.0190167276787,0.0546437924439,0.0204303922843,-0.0211591400411,-0.00812763486295,0.0275392217599,0.0162368404897,0.0193157748944
147,-0.00212868262627,-0.00850103411825,-0.0231856866024,-0.0267574759091,-0.0437504081389,-0.0113220458429,0.00194201685474,-0.00549282314335,-0.0508657081638,0.018789586058
148,0.00608044804716,0.020973142567,-0.0152306221132,0.00206702626692,0.04375747884,-0.0106643163278,0.0152987822222,0.0295311209973,-0.0110330077858,-0.00371842500165
149,0.0148614484821,0.0903859546031,0.0160975241118,0.0297629440383,0.0190256929037,0.0305452701217,0.0187930952658,0.0252805608667,0.0214655318708,0.04548081993
150,0.00577278965602,0.0390378067233,-0.0229247165096,-0.0121621388573,0.0020618014266,0.000634175050785,-0.00688478893129,0.0379516061789,-0.0143019987466,0.00368504906878
151,0.0126775352319,-0.0214098608538,-0.0714634550719,-0.00968323773777,-0.0611218548016,-0.0234290792181,0.0182282760716,-0.00871964745833,0.000304633664898,0.00866300022997
152,-0.0328624258456,-0.0290081992587,0.0343941067768,0.0172977957792,-0.0269597385545,-0.0179287388504,-0.00689760744287,0.0311464560705,0.0175202168023,-0.0381523776049
153,0.0139185620933,0.0207398990261,-0.00372942271576,0.00226064396129,-0.038146334704,0.00815186367592,-0.0056189907687,-0.0075067509915,-0.0309628746676,0.0101571216707
154,-0.00039115069619,-0.0337720061925,-0.00423100163625,-0.0161933995529,-0.0172973885969,0.0354882629505,0.00815773441701,0.0191279833643,0.0229784035931,-0.0543351964376
155,-0.0143811196387,0.0790938835542,-0.0281899469378,0.015849495654,0.00919533757646,0.000703532094339,-0.0135454202274,0.0403085796937,0.00264722831192,0.0605041150113
156,0.0132930096865,-0.0246068157574,-0.0609676282579,-0.0127970917385,-0.0603141967842,-0.0100046417344,-0.0138681830775,0.0215927787236,0.00199645831239,0.0141465227257
157,0.0067545713289,0.0838768036614,0.0355801977752,0.0326754217851,0.00874723382515,-0.0323462651414,0.0157239493374,0.0197196489115,-0.00491014648432,-0.00429294624536
158,-0.00340809812086,-0.00592962407131,-0.00459510591453,0.0256623570233,0.065421579492,0.018557571417,-0.0165853625056,-0.00884893237346,-0.0104205892001,0.023649991638
159,0.00355914243332,0.00246869650326,0.000920654065702,-0.0032359735816,0.00673252281362,0.0586079820417,-0.00222661287953,-0.026980536736,-0.020106476997,0.0318912591587
160,0.0116085864156,0.0880653386553,-0.0108402344872,0.0508491190674,0.0820082615952,0.0140466020265,0.0168586215285,-0.0375260501263,0.0691626491433,0.0908077135573
161,0.00221973797975,0.016615071983,-0.0497596413379,0.0104920427926,0.0379418905067,0.0359090597156,0.0376458523047,0.00095721803398,0.0034293011929,0.0318220296157
162,-0.00026950914781,-0.0703896008844,-0.153795854172,-0.00471999678914,-0.0680096752183,-0.037159695594,-0.0175484184143,0.00396526883576,-0.00185092988074,-0.099001483714
163,-0.00106675272985,-0.0727003340923,0.0039870206585,-0.00965241357154,-0.013204444358,0.0171715087436,-0.0360535370145,-0.000598847236921,-0.0538655539245,-0.0218573176724
164,0.0231768057235,0.0140403454738,-0.0164924141543,-0.0352845135448,0.0032298355157,-0.0188627046695,-0.0110822532839,-0.0332405390023,0.040445800559,-0.00165166255256
165,0.0085337374003,0.0168126999626,-0.0598680374521,0.00805068311786,-0.0327621151469,-0.0749505085803,0.00156472338577,-0.0191279195806,-0.0160207219192,-0.00479386429228
166,0.0176780687168,0.054352522108,0.023420804098,0.00670815844712,0.0589355236289,0.0281350045289,0.0144074827198,-0.0364457321769,0.00582277269261,0.0222093103509
167,-0.000368228915606,-0.0308315929464,-0.0896352453673,-0.0341979093077,-0.0419283747394,-0.0365889879419,-0.00118070193727,-0.0164144039225,-0.0264727142172,-0.0510546988163
168,-0.0201044827462,0.0157154659328,0.00932531455813,0.0349603143396,0.00159368393463,0.0307686046336,0.0151338371108,-0.0428192594597,0.0192209190662,-0.0161303270599
169,-0.00485700569954,0.0509228034283,0.021643852893,0.0344486417617,0.0427277341097,0.0564780383048,0.00464688130268,0.00681174464005,0.0218514704898,0.053444079298
170,-0.0243154868025,0.0154667294812,-0.041878933243,-0.0371302064364,0.00204402876325,-0.00940266019344,-0.0225751097337,0.00933970541041,-0.0347613960252,0.0181044045387
171,0.000133675662093,-0.0283926230008,-0.0226252919251,0.00305396456686,-0.0437480424796,-0.02067838228,-0.00418716623719,0.0518487302197,-0.0073638419476,-0.0512733990947
172,0.00391238934562,-0.0020501554164,0.0393567870375,0.0231767812949,0.0148636189847,-0.0414247149185,-0.0177750348433,0.0100082644279,0.0260572722061,0.00206681277585
173,0.0164955582883,0.0638733305127,0.0170834543023,0.0889772935147,0.00812193376865,0.0255587991817,0.0208340105489,0.00993533187304,0.0239654222713,0.0824033092333
174,-0.0201018496478,0.020666024112,0.0261815782983,0.0384872904268,0.0250482752822,-0.0217406750329,-0.0242551821989,-0.0458411922435,-0.000537415088529,-0.016690593387
175,-0.007599291757,0.00167919963571,0.0649181892298,0.0114341244813,0.0222332055082,0.0118455396183,-0.0148684674345,0.0494862832788,-0.0142570087138,-0.0449441305386
176,0.0010710903635,-0.0376642544144,-0.0583676244466,-0.00582917309876,-0.0343269378727,-0.0325217014848,-0.00385135574438,0.00558090602194,-0.0471472151279,-0.0626266011102
177,0.0211933230501,0.103919578526,0.0426499344096,0.000444716507095,0.0499467603455,0.0426381286534,0.0556178034143,0.012285655168,0.0181490434733,0.0418885521436
178,-0.0141682453933,0.14279691498,0.010314303298,0.0364989413402,0.0320701592849,0.0282105649967,0.00142567603099,0.00365308786929,-0.0215657898021,0.0775658823589
179,0.00585145661042,-0.0774427154531,-0.0250178493558,-0.0307303067223,0.0398669476858,-0.00842010131006,-0.02664526272,0.0300882661753,-0.0315116402396,-0.0984142587913
180,-0.00660621913102,0.0805108315965,0.051132572835,0.0180343705358,-0.0306403480498,0.00183031956307,0.0316864456905,-0.00757930145959,-0.0126108768716,0.0659287554174
181,0.0123861135249,-0.0700272206939,-0.0338321279205,-0.0300639592438,-0.0250084551204,-0.0430006509408,0.00293897758843,-0.0207795615832,-0.0157212751205,-0.00238991765966
182,-0.00364226064724,0.0264422213735,0.0246958255631,0.0512285590113,0.034379658627,0.0494302908816,0.0153804724528,0.0226077178571,0.0275502635883,0.0143993588946
183,-0.0070074869175,0.0446512148546,-0.0351152624579,0.0129734103768,-0.0042519917291,-0.0265614009451,-0.000639926866433,-0.0270793559006,0.0119043723642,0.0164329134836
184,-0.0361174564225,-0.0777268868356,-0.154839369504,-0.0189046006286,-0.0628015696316,-0.0644833813661,-0.0536748708835,-0.031507300306,-0.00432697743804,-0.0839490801486
185,0.0100567524958,0.00019396762061,0.0314141346688,0.0262232510206,0.0225494563387,0.00222753520941,0.0319352430246,0.0389520327437,0.00521416336586,-0.0139325020076
186,0.00100830894276,-0.0267898082822,-0.0350585761381,-0.0237186231775,0.00723266436212,0.0131063567413,0.0480792967656,-0.00859952993736,0.000141340219666,0.00981462234835
187,0.00892758378887,0.110761379029,0.0417863657379,0.0244828232,0.0593973299689,0.0378598926483,0.011335075556,-0.0337547236565,0.000860598024398,0.0929089149884
188,-0.00320632839208,-0.113500817377,-0.0892771048445,-0.0311823474975,-0.0773877945857,-0.0387559936479,0.00252068890795,-0.00753222578095,-0.0320391001923,-0.0511029241406
189,-0.0194864691591,-0.073584973649,-0.0667019762917,-0.00191288527374,-0.0778167711062,-0.0524433204801,-0.0138571740065,-0.0116819497252,-0.021626741758,-0.0753243543813
190,-0.0034446340564,0.0885649782584,0.0477715025777,0.0228182580107,0.0266754393783,0.00490940987079,0.010768586383,0.00816641808439,0.0151045649785,0.0403778333478
191,0.0304089247227,0.0555945583475,-0.0157955911523,0.0505311736363,-0.0144052894057,-0.0225561229128,0.0260873085418,0.0128863874839,0.00529754765846,0.0188286338608
192,0.0178173969118,0.0191268832876,-0.0052362053561,0.0345778763275,0.0177210759681,-0.0175794532481,0.0143036770565,0.0363914446639,0.015084306031,0.000364830741081
193,-0.0150592743175,0.0668003043103,-0.0279175100301,-0.00154059092518,-0.0119782926893,0.0020518648559,0.0182554698886,0.0248923407231,0.00629796562043,0.0232549744978
194,0.0314829174754,0.0540049833067,-0.0504168534535,0.0358571544535,-0.0178394872009,0.043975416697,0.0175202687386,0.0135081519747,-0.000590425599158,0.0536040685158
195,0.0191291688885,0.0839316907612,-0.0512565026645,0.0212424591254,0.00986443089194,-0.00342679435595,0.0232225717601,0.00935997527046,0.0453478587482,0.0330865657052
196,0.00757981131026,-0.00200064014636,-0.0623030517561,0.0155776904553,0.0283076483089,-0.00540582173255,0.00972047239452,-0.0063353228281,0.026920581172,-0.00619014953326
197,0.00484717534986,0.0897128539884,0.0166871552261,0.0342232654936,0.0618591178324,-0.012322511374,0.0217882312148,-0.00585092956038,0.0231951796394,0.0776989487439
198,-0.000543567669053,-0.0232781973611,0.00630103338351,-0.00110642921443,-0.0611295966023,-0.00434401906195,-4.05347423099e-05,0.0471554445668,-0.00849712041514,-0.0164480982254
199,0.0145716930581,-0.0194233145784,-0.0871748520566,0.0269046507687,-0.0338902240975,-0.0300790724752,-0.0209047478305,0.0539220138041,-0.0161570459851,0.0117280744541
200,0.0288463228085,-0.0161027012566,0.0357043106354,0.0204668856403,0.0739255793402,0.0289854260536,0.0395012520798,0.0150707970221,-0.00621023174594,0.0353427296036
201,-0.0164155590184,-0.0551250165546,-0.0225838073959,-0.000555947797888,0.0169563457161,-0.0372854854734,-0.0281696580393,-0.0287690707939,0.0264545723512,-0.0592703540613
202,0.0110636113386,0.155037504569,0.0663495604272,0.0297044919906,0.0737965910298,0.0403811172153,0.0810922680755,0.0105638691917,0.0212979429993,0.100983951446
203,-0.0167077695946,-0.0566294226376,-0.125517089442,-0.0284767272057,-0.0616861537746,-0.0301024311004,-0.00672779789355,0.00399280045636,-0.0270957272041,-0.0775088037151
204,-0.00894342431824,-0.013960553438,0.0840560304137,-0.0213370855308,0.00510213640092,-0.00971246735269,-0.0434620987328,0.0147424422813,0.0114088039387,0.0375352111239
205,0.0219841025144,0.144654775758,0.0393847734656,0.0358401918706,0.0408538671258,0.0504430335569,0.0420481255964,0.0106578036712,0.0221180591518,0.0855110473573
206,-0.00849773464514,-0.0225006415573,-0.0716307650578,0.0162004453574,0.00511492656912,-0.0162452017333,0.0227598000481,-0.0172042391919,-0.00753377693835,-0.0162405662012
207,0.0245302693108,0.0921555326716,0.0057466445892,0.0701938989207,0.054189408727,-0.0122158058119,0.0332292207956,0.0376174154673,-0.00142954912055,0.0513908932548
208,-0.00875822478818,0.0449247305404,0.0244219397579,0.0337205966461,0.0498098282842,0.0421068113007,0.00852029420537,0.0125088500957,0.00149267510713,-0.015697056123
209,0.00775446871564,0.0710442556377,-0.0494464581334,-0.000926680032504,-0.0253120892689,-0.0124074971547,-0.0266919864056,0.0499779598739,-0.0505925253228,0.0202451399879
210,0.00963494468183,0.0924419393324,0.0692949964192,0.00238613539262,0.0291662822207,0.00493567608382,0.0384030896935,0.0123285830566,-0.00933981394972,0.0149317339727
211,-0.0292138621687,-0.0363232090328,-0.0271381599404,-0.0345622935675,-0.0357522948628,-0.0388451304075,-0.0216778295289,-0.011004333959,0.00897359240869,-0.0251238067639
212,-0.0169999810475,-0.059046450806,-0.017479190032,-0.0156083138916,-0.00435907674518,-0.0405710369582,0.00760265571437,0.0374677161471,-0.0136287379025,-0.0992783148102
213,0.014238833919,0.0494954285929,0.0511189189079,0.042025393944,0.0479755081309,0.0609528656521,-0.00314346141408,0.0299154189221,0.0186226655052,0.0172214787247
214,0.0187092695557,0.0271207275842,-0.0784923439809,-0.00198589951308,-0.0261924429292,-0.0598150230877,-0.00149912875624,-0.0557856300155,0.0498555752956,0.0369793113843
215,0.0244388979793,0.00322416764312,0.0595554204396,0.0069949789591,0.0440373521044,0.0100376625834,0.0219341348959,-0.00252138329003,0.0173149089645,-0.017431837054
216,-0.00325325053934,-0.00385029217947,0.0298201690801,0.00949783961686,0.0278575032467,-0.0154390437231,0.00827149712687,-0.0131457739013,0.00304427906842,0.0344135993016
217,0.00368985906995,0.11343753441,0.00810228263455,0.0535147092488,0.0439309612139,0.0351088957643,0.0326664962196,-0.00425117555087,0.00910509177892,0.0533778422271
218,-0.0277954571427,0.0419926810121,0.0120808142366,0.000611396191647,-0.00236928786519,-0.0183114422438,0.00481991843422,-0.0325344923076,0.0294359301766,0.0350788593376
219,-0.00021448703465,-0.0195944659888,-0.0678124633849,-0.0233566718564,-0.0574769042671,-0.00696837534232,-0.0198407797095,-0.00782933816414,-0.00416117972673,-0.0214019029022
220,0.00565125198602,-0.0207687411824,-0.00104738668378,0.022719014101,0.0246985908118,-0.0194040138322,0.0258319046652,0.00340839954431,0.0213976456412,-0.00170962362444
221,-0.0166940242661,-0.0185242155898,-0.135301395682,-0.0171335534539,-0.00317747061823,-0.0459108682576,-0.0611811489508,0.00103815412063,-0.0180934950241,-0.025842146867
222,-0.00819664098315,-0.0360577319552,-0.0308136957421,0.0273945104585,0.0490899201098,-0.0687740012559,0.000675251128785,0.00715124432573,0.00547582229829,-0.0365017418888
223,0.0159342249515,0.0454595176282,0.0115292013597,0.0187625397098,0.00184545427065,0.028202677808,-0.0130238670858,0.0238103440187,-0.0121391624724,0.0334447466953
224,-0.014968719135,-0.0794930216958,0.00915874410238,0.0328872275685,-0.0713111057024,-0.0380092679194,-0.00441383186167,0.0227937439914,-0.00413483711084,-0.0827712111207
225,0.0115603852315,0.0113323422803,-0.0200397086678,0.00907466059989,-0.0160006740379,-0.0169506479704,0.031819359288,0.0243022601342,-0.0186234084713,-0.0180519541456
226,0.00104053759548,0.0680767942225,0.100300767069,-0.0154044639815,0.0162128381012,0.0267100164091,0.023766499113,0.00868139686351,-0.0241409772373,0.0128873305401
227,0.00366379466702,0.00724867347152,-0.0696691412661,0.0172969589525,-0.0128253738317,-0.0485676817611,-0.0044970416062,0.00214773824609,-0.0384097143926,0.0192673383498
228,0.0242293332232,-0.027510205978,-0.0290562310304,-0.0107337555868,-0.0148241206307,-0.0356154306135,0.00407580371318,-0.00724392681755,-0.00235977988539,0.0576224387449
229,-0.0162536710595,0.0781895726054,-0.0112613983559,0.0177922745559,0.0132281462301,-0.0135175846526,-0.00547209100092,-0.00745955301018,0.0130345478357,0.0132269250589
230,0.00699898290742,0.0321448068513,-0.0181476936427,-0.00543541296959,0.00685882042265,0.0235259642608,0.0179863620739,0.0232785409168,-0.00771917091517,0.0156363628828
231,0.0275565451779,-0.0125953748062,-0.049622545529,0.0314362178407,0.066209760876,0.0373221023525,0.00679332068142,-0.0309461330804,0.0405730743524,0.047364754991
232,-0.00314920406065,-0.0497748419869,-0.0422830553818,-0.0301920173599,-0.0293371146653,-0.0487403092063,0.0281128992302,0.00285952290914,0.0307588516047,-0.0635889200147
233,-0.0184657147251,0.0373743466061,-0.011873785843,0.0172564721567,0.032540216331,0.0185758419584,0.0119607935012,0.00491742352159,0.00298849235787,-0.0398284795945
234,0.0124055180811,-0.00441727735813,-0.0476003646755,0.0163962833597,0.0518650476559,-0.0169239922855,-0.00117566575505,-0.0148741861179,0.00102411621072,0.0117102315443
235,0.00795511492544,0.0667233862063,0.0203149349699,0.0473713132328,0.0188260634762,-0.00907525328751,0.0146514132377,0.0285712079789,0.00942694163004,0.0139489256419
236,0.0302956302386,-0.00980867764652,-0.0215067940474,0.00494975757555,-0.0206142100432,0.00590715241634,0.0110086330736,0.0480209619151,-0.0235648823994,-0.0275092479915
237,0.0438419499379,-0.00419664305707,-0.017771614197,-0.0262794663427,0.0323836080137,0.0317937879917,0.0299295250572,0.0151548053479,-0.016363574959,0.0253814172511
238,-0.0117595370238,0.0599618793496,-0.0202178309257,0.0120918040413,0.0220242183667,0.0143512732546,-0.0203787598209,-0.0237187097827,-0.0427974967362,0.00291288993253
239,-0.00383556484179,0.0351375179666,-0.101647507667,0.00801262895286,0.0167933139952,-0.0337208521984,-0.00942433768664,-0.0182724948936,0.0275587832793,0.0262813806343
240,0.00738202668306,-0.000723899050193,-0.00244401288274,0.014529222699,-0.0197745767262,0.0088534486308,-0.00737222477727,-0.00765407887341,0.0180153691306,-0.0171351731272
241,-0.00336166301819,-0.106912961984,-0.0823652236904,-0.00861292291173,-0.0238688873379,-0.056669749413,-0.00513445121393,0.0407865432964,-0.0230198171301,-0.0677917492557
242,0.00435908156545,-0.0297626190704,-0.0419860294512,-0.00653395142632,-0.0224812797222,0.00225673454232,-0.0152197823572,0.0145218794577,-0.017109360952,-0.0602469501054
243,-0.0184016736973,-0.0542106063048,-0.0757878001377,0.0186139067649,-0.00975503420924,-0.0579821483208,-0.00782919937977,-0.0135570672022,0.0225764155924,-0.0367934326869
244,-0.0162371774179,0.0155802828731,-0.0269697323035,0.000445373738539,-0.00673053329249,-0.0546038512993,-0.0061051050623,-0.00589343815956,-0.0134561335945,-0.0322033725215
🔢 Problem Definition
Given the stock data, our goal is to determine the minimum risk portfolio and the efficient frontier.
Step 1: Minimum Risk Portfolio
We need to formulate an optimization model to minimize the portfolio’s risk (volatility), given by the portfolio variance. The portfolio variance can be expressed as:
where:
\(\mathbf{w}\) is the vector of weights of the stocks in the portfolio.
\(\Sigma\) is the covariance matrix of the stock returns.
The constraints are:
The sum of the weights \(\mathbf{w}\) should equal 1 (i.e., \(\sum_{i} w_i = 1\)).
The weights should be non-negative (i.e., \(w_i \geq 0\)).
Step 2: Efficient Frontier
The efficient frontier is obtained by varying the expected return and solving the optimization model for minimum risk. The objective function changes to:
Subject to:
\(\sum_{i} w_i \mu_i = \mu_{\text{target}}\) (Expected return constraint)
\(\sum_{i} w_i = 1\)
\(w_i \geq 0\)
where \(\mu_{\text{target}}\) is the target return that we vary.
Step 3: Visualization
We will plot:
Volatility versus expected return for individual stocks.
Volatility versus expected return for the minimum risk portfolio.
The efficient frontier showing the volatility against expected return.
import pandas as pd
import numpy as np
from gurobipy import Model, GRB, quicksum
import matplotlib.pyplot as plt
# Load the CSV file
file_path = '/mnt/data/portfolio.csv'
stock_data = pd.read_csv(file_path)
# Calculate daily returns and covariance matrix
returns = stock_data.drop(columns='Unnamed: 0')
cov_matrix = returns.cov()
mean_returns = returns.mean()
# Number of stocks
num_stocks = len(returns.columns)
# Create Gurobi model
model = Model()
# Suppress Gurobi output
model.setParam("OutputFlag", 0)
# Add variables for the weights of the stocks
weights = model.addVars(num_stocks, lb=0, ub=1, vtype=GRB.CONTINUOUS, name="weights")
# Set the objective to minimize variance (portfolio risk)
portfolio_variance = quicksum(weights[i] * cov_matrix.iloc[i, j] * weights[j]
for i in range(num_stocks) for j in range(num_stocks))
model.setObjective(portfolio_variance, GRB.MINIMIZE)
# Add constraint: sum of weights equals 1
model.addConstr(quicksum(weights[i] for i in range(num_stocks)) == 1, "budget")
# Solve for the minimum risk portfolio
model.optimize()
# Extract the weights of the minimum risk portfolio
min_risk_weights = np.array([weights[i].x for i in range(num_stocks)])
min_risk_return = np.dot(min_risk_weights, mean_returns)
min_risk_variance = portfolio_variance.getValue()
# Define a range of target returns
target_returns = np.linspace(mean_returns.min(), mean_returns.max(), 100)
# Arrays to store the results
portfolio_returns = []
portfolio_volatilities = []
# Solve for each target return
for target in target_returns:
model.reset()
# Remove the previous target return constraint if it exists
if model.getConstrByName("target_return"):
model.remove(model.getConstrByName("target_return"))
model.addConstr(quicksum(weights[i] * mean_returns[i] for i in range(num_stocks)) == target, "target_return")
model.optimize()
# Store results
portfolio_returns.append(target)
portfolio_volatilities.append(np.sqrt(portfolio_variance.getValue()))
# Calculate individual stock returns and volatilities
individual_returns = mean_returns.values
individual_volatilities = np.sqrt(np.diag(cov_matrix))
# Plotting the results
plt.figure(figsize=(10, 6))
plt.scatter(individual_volatilities, individual_returns, color='blue', label='Individual Stocks')
for i, txt in enumerate(returns.columns):
plt.annotate(txt, (individual_volatilities[i], individual_returns[i]), fontsize=8)
plt.scatter([np.sqrt(min_risk_variance)], [min_risk_return], color='green', label='Minimum Risk Portfolio')
plt.plot(portfolio_volatilities, portfolio_returns, color='green', linestyle='-', label='Efficient Frontier')
plt.xlabel('Volatility (Standard Deviation)')
plt.ylabel('Expected Return')
plt.title('Efficient Frontier and Individual Stocks')
plt.legend()
plt.grid(True)
plt.show()