You are on page 1of 13

Ritu Raj Singh CSBS 2001331560021

Program 1: Write a program to simulate a customer service encounter. The


program should consider various factors like customer behavior, service
provider efficiency, and service quality. Analyze the results to identify areas
for improvement.

Input:
import random

class Customer:
def __init__(self, patience_level):
self.patience_level = patience_level

def is_satisfied(self):
return self.patience_level > 0

class ServiceProvider:
def __init__(self, efficiency):
self.efficiency = efficiency

def process_request(self):
# Simulating the processing of customer request
return random.random() < self.efficiency

def simulate_customer_service(customer_count, initial_patience,


efficiency):
customers = [Customer(initial_patience) for _ in
range(customer_count)]
service_provider = ServiceProvider(efficiency)

for minute in range(1, 11): # Simulate 10 minutes of customer


service
print(f"\nMinute {minute}")

for customer in customers:


if customer.is_satisfied():
# Customer is still waiting
if random.random() < 0.3:
# 30% chance that customer loses patience
print("Customer loses patience and leaves.")
customer.patience_level = 0
else:
# Process customer request
if service_provider.process_request():
print("Customer request processed
successfully.")
customer.patience_level -= 1

1
Ritu Raj Singh CSBS 2001331560021

else:
print("Service provider error. Customer is
unhappy.")
customer.patience_level = 0
else:
print("Customer has already left.")

print("\nSimulation Results:")
unsatisfied_customers = sum(1 for customer in customers if not
customer.is_satisfied())
print(f"Unsatisfied customers: {unsatisfied_customers}")
print(f"Satisfied customers: {customer_count -
unsatisfied_customers}")

# Example usage
simulate_customer_service(customer_count=5, initial_patience=3,
efficiency=0.8)

Output:

2
Ritu Raj Singh CSBS 2001331560021

Program 2: Develop a program that helps design a service process for a


specific scenario (e.g., restaurant, hospital, or transportation service.
Implement the program to optimize the service process, considering
customer needs and operational efficiency.

Input:
import random
import queue

class Customer:
def __init__(self, name):
self.name = name

class Restaurant:
def __init__(self):
self.customers_queue = queue.Queue()

def welcome_customer(self, customer):


print(f"Welcome, {customer.name}! Please have a seat.")
self.customers_queue.put(customer)

def take_order(self, customer):


print(f"{customer.name}, what would you like to order?")
# Simulate order placement, e.g., take input or select from a
menu
order = input("Enter your order: ")
print(f"{customer.name}'s order for {order} received.")

def prepare_food(self, customer):


print(f"Preparing food for {customer.name}.")
# Simulate food preparation time
preparation_time = random.randint(5, 15)
print(f"Food will be ready in {preparation_time} minutes.")
return preparation_time

def serve_food(self, customer):


print(f"Food is ready for {customer.name}. Enjoy your meal!")

def simulate_restaurant_service(customers):
restaurant = Restaurant()

for customer in customers:


restaurant.welcome_customer(customer)
restaurant.take_order(customer)
preparation_time = restaurant.prepare_food(customer)

3
Ritu Raj Singh CSBS 2001331560021

# Simulate waiting for food to be prepared


for _ in range(preparation_time):
print(".", end="", flush=True)
time.sleep(1)
print()

restaurant.serve_food(customer)
print()

if __name__ == "__main__":
# Example usage
customer_names = ["Alice", "Bob", "Charlie", "David"]
customers = [Customer(name) for name in customer_names]

simulate_restaurant_service(customers)

Output:

4
Ritu Raj Singh CSBS 2001331560021

Program 3: Create a program to conduct a SERVQUAL assessment for a


service organization. The program should gather customer feedback on
service dimensions and calculate the service quality gaps. Interpret the
results and suggest improvements.

Input:
class SERVQUALAssessment:
def __init__(self, service_dimensions):
self.service_dimensions = service_dimensions
self.customer_expectations = {}
self.customer_perceptions = {}

def collect_customer_feedback(self):
print("Please rate the service on a scale of 1 to 5 (1:
Strongly Disagree, 5: Strongly Agree)")

for dimension in self.service_dimensions:


expectation = int(input(f"What is your expectation for
{dimension}? "))
perception = int(input(f"How would you rate the actual
service for {dimension}? "))

self.customer_expectations[dimension] = expectation
self.customer_perceptions[dimension] = perception

def calculate_service_quality_gaps(self):
service_quality_gaps = {}

for dimension in self.service_dimensions:


gap = self.customer_expectations[dimension] -
self.customer_perceptions[dimension]
service_quality_gaps[dimension] = gap

return service_quality_gaps

def interpret_results(self, service_quality_gaps):


print("\nService Quality Gaps:")
for dimension, gap in service_quality_gaps.items():
print(f"{dimension}: Gap = {gap}")

overall_service_quality_gap =
sum(service_quality_gaps.values()) / len(service_quality_gaps)
print(f"\nOverall Service Quality Gap:
{overall_service_quality_gap}")

if overall_service_quality_gap > 0:

5
Ritu Raj Singh CSBS 2001331560021

print("There are areas for improvement. Consider addressing


customer expectations.")

elif overall_service_quality_gap < 0:


print("Congratulations! The service organization is
exceeding customer expectations.")

else:
print("The service organization is meeting customer
expectations in all dimensions.")

if __name__ == "__main__":
# Example usage
service_dimensions = ["Reliability", "Responsiveness", "Assurance",
"Empathy", "Tangibles"]
servqual_assessment = SERVQUALAssessment(service_dimensions)

# Collect customer feedback


servqual_assessment.collect_customer_feedback()

# Calculate service quality gaps


service_quality_gaps =
servqual_assessment.calculate_service_quality_gaps()

# Interpret the results and suggest improvements


servqual_assessment.interpret_results(service_quality_gaps)

Output:

6
Ritu Raj Singh CSBS 2001331560021

Program 4: Design a program that presents different service failure scenarios.


Implement a service recovery mechanism within the program and evaluate
its effectiveness in restoring customer satisfaction.

Input:
import random

class ServiceFailureSimulator:
def __init__(self):
self.customer_satisfaction = 5 # Initial customer satisfaction
level (on a scale of 1 to 5)

def simulate_service_failure(self):
# Simulate different service failure scenarios
failure_scenario = random.choice(["Delayed service", "Incorrect
order", "Rude behavior", "System outage"])

print(f"Service Failure Scenario: {failure_scenario}")

# Implement service recovery mechanism


recovery_strategy =
self.choose_recovery_strategy(failure_scenario)
print(f"Service Recovery Strategy: {recovery_strategy}")

# Evaluate the effectiveness of the recovery


satisfaction_change = self.evaluate_recovery(recovery_strategy)
print(f"Customer Satisfaction Change: {satisfaction_change}")

def choose_recovery_strategy(self, failure_scenario):


# Implement different recovery strategies based on the failure
scenario
if failure_scenario == "Delayed service":
return "Apologize and offer a discount for the next
service."

elif failure_scenario == "Incorrect order":


return "Apologize, replace the incorrect order, and offer a
discount for the inconvenience."

elif failure_scenario == "Rude behavior":


return "Apologize, reassign the customer to another service
provider, and offer a discount."

elif failure_scenario == "System outage":


return "Apologize, inform about the issue, and provide an
estimated resolution time."

7
Ritu Raj Singh CSBS 2001331560021

def evaluate_recovery(self, recovery_strategy):


# Simulate the effectiveness of the recovery strategy on
customer satisfaction
satisfaction_change = random.randint(-2, 2)
self.customer_satisfaction = max(1, min(5,
self.customer_satisfaction + satisfaction_change))
return satisfaction_change

def get_customer_satisfaction(self):
return self.customer_satisfaction

if __name__ == "__main__":
service_failure_simulator = ServiceFailureSimulator()

# Simulate multiple service failure scenarios


for _ in range(5):
print("\n--------------------")
service_failure_simulator.simulate_service_failure()
print(f"Current Customer Satisfaction:
{service_failure_simulator.get_customer_satisfaction()}\n")

Output:

8
Ritu Raj Singh CSBS 2001331560021

Program 5: Write a program to model service capacity planning for a specific


service industry (e.g., a call center or a hotel). Use optimization algorithms to
find the optimal number of resources needed to meet service demand while
minimizing costs.

Input:
from pulp import LpProblem, LpVariable, lpSum, LpMinimize

def service_capacity_planning(call_demand, cost_per_agent,


capacity_per_agent, max_agents):
# Create a linear programming problem
model = LpProblem(name="Service_Capacity_Planning",
sense=LpMinimize)

# Decision variables: number of agents to hire


agents = LpVariable.dicts("Agents", range(1, max_agents + 1),
lowBound=0, cat="Integer")

# Objective function: minimize the total cost


model += lpSum(cost_per_agent * agents[i] for i in range(1,
max_agents + 1)), "Total_Cost"

# Constraints: meet the call demand with the available capacity


for i in range(1, max_agents + 1):
model += lpSum(capacity_per_agent * agents[j] for j in range(1,
i + 1)) >= call_demand, f"Meet_Demand_{i}"

# Solve the linear programming problem


model.solve()

# Print the results


print(f"Optimal Number of Agents: {int(sum(agents[i].varValue for i
in range(1, max_agents + 1)))}")
print(f"Total Cost: ${round(model.objective.value(), 2)}")

if __name__ == "__main__":
# Example usage
call_demand = 1000 # Number of calls per time period
cost_per_agent = 5000 # Cost of hiring one agent
capacity_per_agent = 20 # Capacity of one agent (number of calls
they can handle)
max_agents = 50 # Maximum number of agents to consider hiring

service_capacity_planning(call_demand, cost_per_agent,
capacity_per_agent, max_agents)

9
Ritu Raj Singh CSBS 2001331560021

Output:

10
Ritu Raj Singh CSBS 2001331560021

Program 6: Develop a program that addresses the Vehicle Routing Problem


(VRP) for a fleet of vehicles. Implement optimization algorithms (e.g., genetic
algorithms or ant colony optimization) to find the most efficient routes for
delivery or service operations.

Input:
import numpy as np
import random
from deap import base, creator, tools, algorithms

# Define the VRP problem parameters


NUM_VEHICLES = 3
CAPACITY = 20
NUM_CUSTOMERS = 10
CUSTOMER_LOCATIONS = [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10), (11,
12), (13, 14), (15, 16), (17, 18), (19, 20)]

# Define the genetic algorithm parameters


POPULATION_SIZE = 50
NUM_GENERATIONS = 100

# Create a fitness class to minimize the total distance


creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", list, fitness=creator.FitnessMin)

# Initialize the genetic algorithm toolbox


toolbox = base.Toolbox()

# Create a function to generate individuals (routes)


toolbox.register("individual", tools.initIterate, creator.Individual,
lambda: random.sample(range(1, NUM_CUSTOMERS + 1), NUM_CUSTOMERS))
toolbox.register("population", tools.initRepeat, list,
toolbox.individual, n=POPULATION_SIZE)

# Define the representation of individuals (routes)


toolbox.register("mate", tools.cxOrdered)
toolbox.register("mutate", tools.mutShuffleIndexes, indpb=0.05)
toolbox.register("select", tools.selTournament, tournsize=3)

# Define the evaluation function (total distance)


def evaluate(individual):
total_distance = 0
current_capacity = CAPACITY
current_location = (0, 0) # Starting location

for customer_index in individual:

11
Ritu Raj Singh CSBS 2001331560021

customer_location = CUSTOMER_LOCATIONS[customer_index - 1]
distance = ((customer_location[0] - current_location[0])**2 +
(customer_location[1] - current_location[1])**2)**0.5

if current_capacity < 0:
total_distance += 1000 # Penalize if the capacity is
exceeded
else:
total_distance += distance

current_capacity -= 1 # Assuming each customer has a demand of


1
current_location = customer_location

return total_distance,

toolbox.register("evaluate", evaluate)

if __name__ == "__main__":
# Create the initial population
population = toolbox.population()

# Evaluate the entire population


fitnesses = list(map(toolbox.evaluate, population))
for ind, fit in zip(population, fitnesses):
ind.fitness.values = fit

# Use the genetic algorithm to evolve the population


algorithms.eaMuPlusLambda(population, toolbox, mu=POPULATION_SIZE,
lambda_=POPULATION_SIZE * 2,
cxpb=0.7, mutpb=0.2,
ngen=NUM_GENERATIONS, stats=None, halloffame=None, verbose=True)

# Print the best individual (route) found


best_individual = tools.selBest(population, k=1)[0]
print("Best Route:", best_individual)
print("Total Distance:", best_individual.fitness.values[0])

12
Ritu Raj Singh CSBS 2001331560021

Output:

13

You might also like