/**
 * Calculates the Return on Investment (ROI) for a marketing campaign.
 *
 * @param userSegments A set of user segments targeted by the campaign.
 * @param campaignCost The total cost of the marketing campaign.
 * @param revenuePerSegment A map where keys are user segments and values are the revenue generated by each segment.
 * @return The ROI of the marketing campaign.
 */
fun calculateCampaignROI(userSegments: Set<String>, campaignCost: Double, revenuePerSegment: Map<String, Double>): Double {

    // Initialize total revenue
    var totalRevenue = 0.0

    // Iterate over each user segment
    for (segment in userSegments) {
        // Check if the segment exists in the revenuePerSegment map
        if (segment in revenuePerSegment) {
            val segmentRevenue = revenuePerSegment[segment] ?: 0.0
            totalRevenue += segmentRevenue
        }
    }

    // Calculate ROI using the formula: (Total Revenue - Campaign Cost) / Campaign Cost
    val roi = (totalRevenue - campaignCost) / campaignCost

    return roi
}
/**
 * Calculates the Return on Investment (ROI) for a marketing campaign.
 *
 * @param userSegments A set of user segments targeted by the campaign.
 * @param campaignCost The total cost of the marketing campaign.
 * @param revenuePerSegment A map where keys are user segments and values are the revenue generated by each segment.
 * @return The ROI of the marketing campaign.
 */
fun calculateCampaignROI(userSegments: Set<String>, campaignCost: Double, revenuePerSegment: Map<String, Double>): Double {
/**
 * Calculates the Return on Investment (ROI) for a marketing campaign.
 *
 * @param userSegments A set of user segments targeted by the campaign.
 * @param campaignCost The total cost of the marketing campaign.
 * @param revenuePerSegment A map where keys are user segments and values are the revenue generated by each segment.
 * @return The ROI of the marketing campaign.
 */
fun calculateCampaignROI(userSegments: Set<String>, campaignCost: Double, revenuePerSegment: Map<String, Double>): Double {

    // Initialize total revenue
    var totalRevenue = 0.0

    // Iterate over each user segment
    for (segment in userSegments) {
        // Check if the segment exists in the revenuePerSegment map
        if (segment in revenuePerSegment) {
            val segmentRevenue = revenuePerSegment[segment] ?: 0.0
            totalRevenue += segmentRevenue
        }
    }

    // Calculate ROI using the formula: (Total Revenue - Campaign Cost) / Campaign Cost
    val roi = (totalRevenue - campaignCost) / campaignCost

    return roi
}