# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# ## Generate data for the Budget Scenario Problem

# This function creates the model to solve the Budget Scenario problem   
# using a Particle Swarm algorithm, BPSO coded by Seyedali Mirjalili.    
#                                                                        
# Data used here is from Priority List - Revisited  by N. Order (2009)   
#                                                                        
# Developer: <NAME>                                                 
# Contact Info: <EMAIL>                           
# Created 20/03/2020                                                     
# Adapted to deal with modifications on the model, the idea we feed the
# model with the number of the initiative we want to remove from the model,
# that way I can call this function inside of  loop on the main code.
#
# <NAME> - 29/04/2020

# +
import numpy as np
import math
import random

## Defeine the vector to fill up
NumIn = 15 #total number of initiatives
NumInOrder = 15 #number of original Initiatives in Order data
Cost = np.ones(NumIn)*math.nan
S1 = np.ones(NumIn)*math.nan
S2 = np.ones(NumIn)*math.nan
S3 = np.ones(NumIn)*math.nan
S4 = np.ones(NumIn)*math.nan

Initiative = np.array(['O','M','N','D','J','I','B','L','E','A','H','G','C','K','F']);
Cost[0:NumInOrder] = [1,1,3,4,7,6,8,11,13,12,14,17,14,20,16];        # cost of each initiative
S1[0:NumInOrder] = [10,7,6,8,4,8,8,10,8,7,1,9,5,6,1];                # score for scenario 1
S2[0:NumInOrder] = [1,1,3,7,3,7,8,5,4,2,5,5,7,4,7];                  # score for scenario 2
S3[0:NumInOrder]  = [8,3,5,1,7,4,3,6,9,9,9,8,5,9,9];                  # score for scenario 3
S4[0:NumInOrder]  = [2,4,6,2,9,1,10,9,7,1,9,4,7,4,1];                 # score for scenario 4

# Generate the uniformly random data to increase
for ind in range(NumInOrder, NumIn):
    S1[ind]=random.randint(1,9)
    S2[ind]=random.randint(1,9)
    S3[ind]=random.randint(1,9)
    S4[ind]=random.randint(1,9)
    Cost[ind] = random.randint(7,50)

ScenarioMatrix = np.array([S1,S2,S3,S4])

# Saving the generated data
nameSave = 'data' +str(NumIn)+'in'
np.save(nameSave, [Cost, S1, S2, S3, S4])
# -

# Load the data
nameload = 'data' +str(NumIn)+'in.npy'
data = np.load(nameload)
data



StarcoderdataJupyterScriptsDedupFiltered