<jupyter_start><jupyter_text>Multiple Type Experiment<jupyter_code>import warnings;
warnings.filterwarnings('ignore');

from time import sleep
from tqdm.auto import tqdm

import sys
import importlib
import numpy as np
import nbformat
# import plotly.express
# import plotly.express as px
import pandas as pd
import cvxpy as cp
import scipy.optimize as optimization
import matplotlib.pyplot as plt
import seaborn as sns<jupyter_output><empty_output><jupyter_text>CVXPY Code<jupyter_code>def generate_cvxpy_solve(num_types, num_resources):
    x = cp.Variable(shape=(num_types,num_resources))

    sizes = cp.Parameter(num_types, nonneg=True)
    weights = cp.Parameter((num_types, num_resources), nonneg=True)
    budget = cp.Parameter(num_resources, nonneg=True)


    objective = cp.Maximize(cp.log(cp.sum(cp.multiply(x, weights), axis=1)) @ sizes)


    constraints = []
    constraints += [0 <= x]
    for i in range(num_resources):
        constraints += [x[:, i] @ sizes <= budget[i]]
    # constraints += [x @ sizes <= budget]

    prob = cp.Problem(objective, constraints)
    
    def solver(true_sizes, true_weights, true_budget, constraints):
        sizes.value = true_sizes
        weights.value = true_weights
        budget.value = true_budget
        
        prob.solve(solver=cp.MOSEK)
        
        return prob.value, np.around(x.value, 5), constraints
    
    return prob, solver, constraints<jupyter_output><empty_output><jupyter_text>Simple Test<jupyter_code>epsi

prob, solver, constraints = generate_cvxpy_solve(2, 2)

val, sol, cons = solver(np.asarray([1., 1.]), np.asarray([[1, epsilon],[2,1]]), np.asarray([1,1]), constraints)
print(sol)<jupyter_output>[[0. 1.]
 [1. 0.]]<jupyter_text>Sensitivity of EG Program<jupyter_code>eps_list = np.arange(0, 2, 0.01)
# true_weights = np.asarray([[1,1,1],[1,1,1]])
true_budget = np.asarray([1., 1.])


sol_array = np.zeros((len(eps_list), 2))

index = 0
for eps in eps_list:
    # print('Calculating difference in allocations for: ' + str(eps))
    weights = np.asarray([[1, eps],[2,1]])
    sizes = np.asarray([1., 1.])
    
    val, sol, cons = solver(sizes, weights, true_budget, constraints)
    print(sol[0])
    sol_array[index, :] = sol[0]
plt.plot(sol_array[:, 1])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13776408450704225, 'fraction_numerical': 0.01716549295774648, 'mean_word_length': 4.373522458628842, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '107410', 'license': 'MIT', 'n_tokens_mistral': 846, 'n_tokens_neox': 823, 'n_words': 173, 'path': 'older_model/single type/test_example.ipynb', 'repo_name': 'seanrsinclair/Online-Resource-Allocation', 'size': '2272'}