work 3 sla program
work 3 sla program
work 3 sla program
import logging
import matplotlib.pyplot as plt
import pandas as pd
# Configure logging
logging.basicConfig(filename='resource_management_framework_multi_csp.log', level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s')
# Embedded configuration
config = {
"csp_list": [
{
"name": "CSP1",
"num_requests": 10,
"ram_cost": 30,
"min_ram_size_mb": 1024,
"max_ram_size_mb": 2048,
"min_days": 15,
"max_days": 45,
"min_sla_percentage": 10,
"max_sla_percentage": 30,
"min_vms": 2,
"max_vms": 6,
"energy_cost_per_vm": 5
},
{
"name": "CSP2",
"num_requests": 10,
"ram_cost": 22,
"min_ram_size_mb": 512,
"max_ram_size_mb": 2048,
"min_days": 20,
"max_days": 50,
"min_sla_percentage": 15,
"max_sla_percentage": 25,
"min_vms": 2,
"max_vms": 8,
"energy_cost_per_vm": 3 # Reduced energy cost for CSP2
},
{
"name": "CSP3",
"num_requests": 10,
"ram_cost": 25,
"min_ram_size_mb": 512,
"max_ram_size_mb": 1024,
"min_days": 10,
"max_days": 30,
"min_sla_percentage": 5,
"max_sla_percentage": 20,
"min_vms": 1,
"max_vms": 5,
"energy_cost_per_vm": 6
},
{
"name": "CSP4",
"num_requests": 10,
"ram_cost": 40,
"min_ram_size_mb": 2048,
"max_ram_size_mb": 4096,
"min_days": 25,
"max_days": 70,
"min_sla_percentage": 20,
"max_sla_percentage": 35,
"min_vms": 3,
"max_vms": 12,
"energy_cost_per_vm": 7
},
{
"name": "CSP5",
"num_requests": 10,
"ram_cost": 28,
"min_ram_size_mb": 1024,
"max_ram_size_mb": 2048,
"min_days": 30,
"max_days": 60,
"min_sla_percentage": 10,
"max_sla_percentage": 30,
"min_vms": 1,
"max_vms": 6,
"energy_cost_per_vm": 4
},
{
"name": "CSP6",
"num_requests": 10,
"ram_cost": 32,
"min_ram_size_mb": 512,
"max_ram_size_mb": 1024,
"min_days": 15,
"max_days": 45,
"min_sla_percentage": 10,
"max_sla_percentage": 25,
"min_vms": 2,
"max_vms": 7,
"energy_cost_per_vm": 5
}
]
}
request['extended_service_days'] = round(extended_days, 2)
request['penalty_cost'] = round(penalty_cost, 2)
request['allocated_vms'] = allocated_vms
request['allocated_ram_mb'] = allocated_ram_mb
request['energy_consumption'] = round(energy_consumption, 2)
request['total_vm_cost'] = round(total_vm_cost, 2)
return request
def simulate_resource_management(config):
evaluations = []
return evaluations
def display_results(results):
df = pd.DataFrame(results)
# Visualization
fig, ax1 = plt.subplots(figsize=(14, 10))
fig.tight_layout()
plt.savefig('csp_evaluation_plot.png', format='png', dpi=300, bbox_inches='tight')
plt.show()
# Main execution
if __name__ == "__main__":
# Run simulation
results = simulate_resource_management(config)
# Display results
display_results(results)