寰宇光锥舟 - 三元生态餐厅模拟系统
NSLog(@"员工满意度: %.1f%%", [result.dailyDetails[@"avg_employee_satisfaction"] floatValue] * 100);NSLog(@"生态效益评分: %.1f/100", [result.dailyDetails[@"eco_benefit_score"] floatValue]);// 人文生态提升员工满意度。NSLog(@"
基于寰宇光锥舟理论的三元生态特征(自然生态、人文生态、数字生态),我对餐厅模拟系统进行了全面优化。以下是完整的实现代码:
```objective-c
// EcoType.h - 三元生态类型
#ifndef EcoType_h
#define EcoType_h
typedef NS_ENUM(NSUInteger, EcoType) {
EcoTypeNatural, // 自然生态 - 环保、有机、可持续发展
EcoTypeHumanistic, // 人文生态 - 文化传承、社区关系、员工福利
EcoTypeDigital // 数字生态 - 数字化、智能化、互联网技术
};
#endif /* EcoType_h */
// RestaurantConfig.h - 餐厅配置模型
#ifndef RestaurantConfig_h
#define RestaurantConfig_h
#import "RestaurantScale.h"
#import "CuisineStyle.h"
#import "LocationType.h"
#import "RestaurantFeature.h"
#import "EcoType.h"
@interface RestaurantConfig : NSObject
@property (nonatomic, assign) RestaurantScale scale;
@property (nonatomic, assign) CuisineStyle cuisineStyle;
@property (nonatomic, assign) LocationType location;
@property (nonatomic, assign) RestaurantFeature feature;
// 三元生态评分 (0-1)
@property (nonatomic, assign) CGFloat naturalEcoScore; // 自然生态评分
@property (nonatomic, assign) CGFloat humanisticEcoScore; // 人文生态评分
@property (nonatomic, assign) CGFloat digitalEcoScore; // 数字生态评分
// 生态特征偏好
@property (nonatomic, assign) EcoType primaryEcoType; // 主要生态类型
@property (nonatomic, assign) EcoType secondaryEcoType; // 次要生态类型
- (instancetype)initWithScale:(RestaurantScale)scale
cuisineStyle:(CuisineStyle)cuisineStyle
location:(LocationType)location
feature:(RestaurantFeature)feature
naturalEcoScore:(CGFloat)naturalScore
humanisticEcoScore:(CGFloat)humanisticScore
digitalEcoScore:(CGFloat)digitalScore;
- (void)calculateEcoPreferences;
@end
#endif /* RestaurantConfig_h ```
```objective-c
// RestaurantConfig.m
#import "RestaurantConfig.h"
@implementation RestaurantConfig
- (instancetype)initWithScale:(RestaurantScale)scale
cuisineStyle:(CuisineStyle)cuisineStyle
location:(LocationType)location
feature:(RestaurantFeature)feature
naturalEcoScore:(CGFloat)naturalScore
humanisticEcoScore:(CGFloat)humanisticScore
digitalEcoScore:(CGFloat)digitalScore {
self = [super init];
if (self) {
_scale = scale;
_cuisineStyle = cuisineStyle;
_location = location;
_feature = feature;
_naturalEcoScore = naturalScore;
_humanisticEcoScore = humanisticScore;
_digitalEcoScore = digitalScore;
[self calculateEcoPreferences];
}
return self;
}
- (void)calculateEcoPreferences {
// 确定主要和次要生态类型
NSDictionary *scores = @{
@(EcoTypeNatural): @(self.naturalEcoScore),
@(EcoTypeHumanistic): @(self.humanisticEcoScore),
@(EcoTypeDigital): @(self.digitalEcoScore)
};
// 按分数排序
NSArray *sortedTypes = [scores keysSortedByValueUsingComparator:^NSComparisonResult(id obj1, id obj2) {
return [obj2 compare:obj1]; // 降序排列
}];
self.primaryEcoType = [sortedTypes[0] integerValue];
self.secondaryEcoType = [sortedTypes[1] integerValue];
}
@end
```
```objective-c
// RestaurantModel.h - 更新后的模型接口
#ifndef RestaurantModel_h
#define RestaurantModel_h
#import <Foundation/Foundation.h>
#import "SimulationResult.h"
#import "RestaurantConfig.h"
@interface RestaurantModel : NSObject
// 计算厨师分布 - 考虑三元生态
+ (NSDictionary<NSNumber *, NSNumber *> *)calculateChefDistributionWithConfig:(RestaurantConfig *)config;
// 计算预制菜使用比例 - 考虑三元生态
+ (CGFloat)calculatePremadeUsageWithChefDistribution:(NSDictionary<NSNumber *, NSNumber *> *)chefDistribution
config:(RestaurantConfig *)config;
// 模拟餐厅运营 - 考虑三元生态
+ (NSDictionary *)simulateRestaurantOperationsWithConfig:(RestaurantConfig *)config
days:(NSUInteger)days;
// 计算生态效益评分
+ (CGFloat)calculateEcoBenefitScoreWithConfig:(RestaurantConfig *)config
dailyProfit:(CGFloat)dailyProfit
dailyWaste:(CGFloat)dailyWaste
employeeSatisfaction:(CGFloat)employeeSatisfaction;
@end
#endif /* RestaurantModel_h ```
```
```objective-c
// RestaurantModel.m - 实现三元生态逻辑
#import "RestaurantModel.h"
#import <math.h>
#import <stdlib.h>
@implementation RestaurantModel
+ (NSDictionary<NSNumber *, NSNumber *> *)calculateChefDistributionWithConfig:(RestaurantConfig *)config {
// 基础分布 - 根据规模
NSDictionary *baseDist;
switch (config.scale) {
case RestaurantScaleSmall: {
baseDist = @{@(ChefTypeTraditional): @0.7, @(ChefTypeHybrid): @0.3, @(ChefTypeProcess): @0.0};
break;
}
case RestaurantScaleMedium: {
baseDist = @{@(ChefTypeTraditional): @0.4, @(ChefTypeHybrid): @0.5, @(ChefTypeProcess): @0.1};
break;
}
case RestaurantScaleLarge: {
baseDist = @{@(ChefTypeTraditional): @0.2, @(ChefTypeHybrid): @0.6, @(ChefTypeProcess): @0.2};
break;
}
case RestaurantScaleChain: {
baseDist = @{@(ChefTypeTraditional): @0.05, @(ChefTypeHybrid): @0.4, @(ChefTypeProcess): @0.55};
break;
}
}
// 菜系风格调整
NSDictionary *styleAdjustment;
switch (config.cuisineStyle) {
case CuisineStyleLocal: {
styleAdjustment = @{@(ChefTypeTraditional): @0.2, @(ChefTypeHybrid): @0.1, @(ChefTypeProcess): @(-0.3)};
break;
}
case CuisineStyleFusion: {
styleAdjustment = @{@(ChefTypeTraditional): @0.0, @(ChefTypeHybrid): @0.2, @(ChefTypeProcess): @(-0.2)};
break;
}
case CuisineStyleFastCasual: {
styleAdjustment = @{@(ChefTypeTraditional): @(-0.3), @(ChefTypeHybrid): @0.0, @(ChefTypeProcess): @0.3};
break;
}
case CuisineStyleFineDining: {
styleAdjustment = @{@(ChefTypeTraditional): @0.3, @(ChefTypeHybrid): @0.1, @(ChefTypeProcess): @(-0.4)};
break;
}
}
// 场地位置调整
NSDictionary *locationAdjustment;
switch (config.location) {
case LocationTypeMetro: {
locationAdjustment = @{@(ChefTypeTraditional): @(-0.1), @(ChefTypeHybrid): @0.0, @(ChefTypeProcess): @0.1};
break;
}
case LocationTypeMall: {
locationAdjustment = @{@(ChefTypeTraditional): @0.0, @(ChefTypeHybrid): @0.1, @(ChefTypeProcess): @(-0.1)};
break;
}
case LocationTypeCommunity: {
locationAdjustment = @{@(ChefTypeTraditional): @0.2, @(ChefTypeHybrid): @0.0, @(ChefTypeProcess): @(-0.2)};
break;
}
case LocationTypeBusiness: {
locationAdjustment = @{@(ChefTypeTraditional): @(-0.2), @(ChefTypeHybrid): @0.1, @(ChefTypeProcess): @0.1};
break;
}
case LocationTypeScenic: {
locationAdjustment = @{@(ChefTypeTraditional): @0.1, @(ChefTypeHybrid): @0.1, @(ChefTypeProcess): @(-0.2)};
break;
}
}
// 餐厅特色调整
NSDictionary *featureAdjustment;
switch (config.feature) {
case RestaurantFeatureNone: {
featureAdjustment = @{@(ChefTypeTraditional): @0.0, @(ChefTypeHybrid): @0.0, @(ChefTypeProcess): @0.0};
break;
}
case RestaurantFeatureHalal: {
featureAdjustment = @{@(ChefTypeTraditional): @0.3, @(ChefTypeHybrid): @(-0.2), @(ChefTypeProcess): @(-0.1)};
break;
}
case RestaurantFeatureOrganic: {
featureAdjustment = @{@(ChefTypeTraditional): @0.2, @(ChefTypeHybrid): @0.1, @(ChefTypeProcess): @(-0.3)};
break;
}
case RestaurantFeatureVegetarian: {
featureAdjustment = @{@(ChefTypeTraditional): @0.1, @(ChefTypeHybrid): @0.2, @(ChefTypeProcess): @(-0.3)};
break;
}
case RestaurantFeatureInternetFamous: {
featureAdjustment = @{@(ChefTypeTraditional): @(-0.2), @(ChefTypeHybrid): @0.1, @(ChefTypeProcess): @0.1};
break;
}
case RestaurantFeatureTraditional: {
featureAdjustment = @{@(ChefTypeTraditional): @0.4, @(ChefTypeHybrid): @(-0.3), @(ChefTypeProcess): @(-0.1)};
break;
}
}
// 三元生态调整 - 核心新增逻辑
NSDictionary *ecoAdjustment;
switch (config.primaryEcoType) {
case EcoTypeNatural: {
// 自然生态: 倾向于传统厨师,减少加工型厨师
ecoAdjustment = @{
@(ChefTypeTraditional): @(0.2 * config.naturalEcoScore),
@(ChefTypeHybrid): @(0.1 * config.naturalEcoScore),
@(ChefTypeProcess): @(-0.3 * config.naturalEcoScore)
};
break;
}
case EcoTypeHumanistic: {
// 人文生态: 平衡传统与混合型,减少加工型
ecoAdjustment = @{
@(ChefTypeTraditional): @(0.1 * config.humanisticEcoScore),
@(ChefTypeHybrid): @(0.2 * config.humanisticEcoScore),
@(ChefTypeProcess): @(-0.3 * config.humanisticEcoScore)
};
break;
}
case EcoTypeDigital: {
// 数字生态: 增加加工型和混合型,减少传统型
ecoAdjustment = @{
@(ChefTypeTraditional): @(-0.2 * config.digitalEcoScore),
@(ChefTypeHybrid): @(0.1 * config.digitalEcoScore),
@(ChefTypeProcess): @(0.1 * config.digitalEcoScore)
};
break;
}
}
// 应用所有调整
NSMutableDictionary *adjustedDist = [NSMutableDictionary dictionary];
for (NSNumber *chefTypeKey in baseDist) {
NSNumber *baseValue = baseDist[chefTypeKey];
NSNumber *styleAdj = styleAdjustment[chefTypeKey] ?: @0;
NSNumber *locationAdj = locationAdjustment[chefTypeKey] ?: @0;
NSNumber *featureAdj = featureAdjustment[chefTypeKey] ?: @0;
NSNumber *ecoAdj = ecoAdjustment[chefTypeKey] ?: @0;
CGFloat adjusted = [baseValue floatValue] + [styleAdj floatValue] + [locationAdj floatValue] + [featureAdj floatValue] + [ecoAdj floatValue];
adjusted = MAX(0, MIN(1, adjusted));
adjustedDist[chefTypeKey] = @(adjusted);
}
// 归一化
CGFloat total = [[adjustedDist allValues] valueForKeyPath:@"@sum.floatValue"];
NSMutableDictionary *normalizedDist = [NSMutableDictionary dictionary];
for (NSNumber *key in adjustedDist) {
normalizedDist[key] = @([adjustedDist[key] floatValue] / total);
}
return normalizedDist;
}
+ (CGFloat)calculatePremadeUsageWithChefDistribution:(NSDictionary<NSNumber *, NSNumber *> *)chefDistribution
config:(RestaurantConfig *)config {
NSDictionary *chefPremadeRate = @{
@(ChefTypeTraditional): @0.1,
@(ChefTypeHybrid): @0.5,
@(ChefTypeProcess): @0.9
};
NSDictionary *scaleFactor = @{
@(RestaurantScaleSmall): @0.9,
@(RestaurantScaleMedium): @1.0,
@(RestaurantScaleLarge): @1.1,
@(RestaurantScaleChain): @1.3
};
// 场地对预制菜使用的影响
NSDictionary *locationFactor;
switch (config.location) {
case LocationTypeMetro:
locationFactor = @1.2;
break;
case LocationTypeMall:
locationFactor = @1.0;
break;
case LocationTypeCommunity:
locationFactor = @0.8;
break;
case LocationTypeBusiness:
locationFactor = @1.1;
break;
case LocationTypeScenic:
locationFactor = @0.9;
break;
}
// 特色对预制菜使用的影响
NSDictionary *featureFactor;
switch (config.feature) {
case RestaurantFeatureNone:
featureFactor = @1.0;
break;
case RestaurantFeatureHalal:
featureFactor = @0.7;
break;
case RestaurantFeatureOrganic:
featureFactor = @0.6;
break;
case RestaurantFeatureVegetarian:
featureFactor = @0.8;
break;
case RestaurantFeatureInternetFamous:
featureFactor = @1.2;
break;
case RestaurantFeatureTraditional:
featureFactor = @0.5;
break;
}
// 三元生态对预制菜使用的影响
CGFloat ecoFactor = 1.0;
switch (config.primaryEcoType) {
case EcoTypeNatural:
// 自然生态减少预制菜使用
ecoFactor = 1.0 - (0.3 * config.naturalEcoScore);
break;
case EcoTypeHumanistic:
// 人文生态适度减少预制菜使用
ecoFactor = 1.0 - (0.2 * config.humanisticEcoScore);
break;
case EcoTypeDigital:
// 数字生态增加预制菜使用
ecoFactor = 1.0 + (0.2 * config.digitalEcoScore);
break;
}
CGFloat premadeRate = 0;
for (NSNumber *chefTypeKey in chefDistribution) {
NSNumber *proportion = chefDistribution[chefTypeKey];
NSNumber *rate = chefPremadeRate[chefTypeKey];
premadeRate += [proportion floatValue] * [rate floatValue];
}
premadeRate *= [scaleFactor[@(config.scale)] floatValue];
premadeRate *= [locationFactor floatValue];
premadeRate *= [featureFactor floatValue];
premadeRate *= ecoFactor;
return MIN(0.95f, premadeRate);
}
+ (NSDictionary *)simulateRestaurantOperationsWithConfig:(RestaurantConfig *)config
days:(NSUInteger)days {
NSDictionary *chefDist = [self calculateChefDistributionWithConfig:config];
CGFloat premadeRatio = [self calculatePremadeUsageWithChefDistribution:chefDist config:config];
NSUInteger chefCount;
switch (config.scale) {
case RestaurantScaleSmall:
chefCount = arc4random_uniform(3) + 1;
break;
case RestaurantScaleMedium:
chefCount = arc4random_uniform(7) + 4;
break;
case RestaurantScaleLarge:
chefCount = arc4random_uniform(20) + 11;
break;
case RestaurantScaleChain:
chefCount = arc4random_uniform(71) + 30;
break;
}
NSMutableArray *dailyCustomers = [NSMutableArray array];
NSMutableArray *dailyRevenue = [NSMutableArray array];
NSMutableArray *dailyCost = [NSMutableArray array];
NSMutableArray *dailyWaste = [NSMutableArray array]; // 新增: 每日浪费量
NSMutableArray *dailyEmployeeSatisfaction = [NSMutableArray array]; // 新增: 员工满意度
// 基础客流量 - 考虑场地影响
NSDictionary *baseTraffic;
switch (config.location) {
case LocationTypeMetro:
baseTraffic = @{
@(RestaurantScaleSmall): @80,
@(RestaurantScaleMedium): @200,
@(RestaurantScaleLarge): @600,
@(RestaurantScaleChain): @1200
};
break;
case LocationTypeMall:
baseTraffic = @{
@(RestaurantScaleSmall): @70,
@(RestaurantScaleMedium): @180,
@(RestaurantScaleLarge): @550,
@(RestaurantScaleChain): @1100
};
break;
case LocationTypeCommunity:
baseTraffic = @{
@(RestaurantScaleSmall): @40,
@(RestaurantScaleMedium): @120,
@(RestaurantScaleLarge): @400,
@(RestaurantScaleChain): @800
};
break;
case LocationTypeBusiness:
baseTraffic = @{
@(RestaurantScaleSmall): @90,
@(RestaurantScaleMedium): @220,
@(RestaurantScaleLarge): @650,
@(RestaurantScaleChain): @1300
};
break;
case LocationTypeScenic:
baseTraffic = @{
@(RestaurantScaleSmall): @60,
@(RestaurantScaleMedium): @160,
@(RestaurantScaleLarge): @500,
@(RestaurantScaleChain): @1000
};
break;
}
// 基础消费水平 - 考虑特色影响
NSDictionary *baseSpend;
switch (config.feature) {
case RestaurantFeatureNone:
baseSpend = @{
@(RestaurantScaleSmall): @40,
@(RestaurantScaleMedium): @60,
@(RestaurantScaleLarge): @80,
@(RestaurantScaleChain): @35
};
break;
case RestaurantFeatureHalal:
baseSpend = @{
@(RestaurantScaleSmall): @45,
@(RestaurantScaleMedium): @65,
@(RestaurantScaleLarge): @85,
@(RestaurantScaleChain): @40
};
break;
case RestaurantFeatureOrganic:
baseSpend = @{
@(RestaurantScaleSmall): @50,
@(RestaurantScaleMedium): @70,
@(RestaurantScaleLarge): @90,
@(RestaurantScaleChain): @45
};
break;
case RestaurantFeatureVegetarian:
baseSpend = @{
@(RestaurantScaleSmall): @45,
@(RestaurantScaleMedium): @65,
@(RestaurantScaleLarge): @85,
@(RestaurantScaleChain): @40
};
break;
case RestaurantFeatureInternetFamous:
baseSpend = @{
@(RestaurantScaleSmall): @55,
@(RestaurantScaleMedium): @75,
@(RestaurantScaleLarge): @95,
@(RestaurantScaleChain): @50
};
break;
case RestaurantFeatureTraditional:
baseSpend = @{
@(RestaurantScaleSmall): @60,
@(RestaurantScaleMedium): @80,
@(RestaurantScaleLarge): @100,
@(RestaurantScaleChain): @55
};
break;
}
NSDictionary *styleMultiplier = @{
@(CuisineStyleLocal): @0.9,
@(CuisineStyleFusion): @1.2,
@(CuisineStyleFastCasual): @0.8,
@(CuisineStyleFineDining): @2.0
};
// 特色对成本的影响
CGFloat featureCostFactor;
switch (config.feature) {
case RestaurantFeatureNone:
featureCostFactor = 1.0;
break;
case RestaurantFeatureHalal:
featureCostFactor = 1.1;
break;
case RestaurantFeatureOrganic:
featureCostFactor = 1.3;
break;
case RestaurantFeatureVegetarian:
featureCostFactor = 1.05;
break;
case RestaurantFeatureInternetFamous:
featureCostFactor = 1.2;
break;
case RestaurantFeatureTraditional:
featureCostFactor = 1.15;
break;
}
// 三元生态对运营的影响
CGFloat naturalEcoMultiplier = 1.0 + (0.1 * config.naturalEcoScore); // 自然生态提升顾客吸引力
CGFloat humanisticEcoMultiplier = 1.0 + (0.1 * config.humanisticEcoScore); // 人文生态提升员工满意度
CGFloat digitalEcoMultiplier = 1.0 + (0.1 * config.digitalEcoScore); // 数字生态提升运营效率
// 三元生态对浪费的影响
CGFloat wasteReduction = 0;
wasteReduction += 0.2 * config.naturalEcoScore; // 自然生态减少浪费
wasteReduction += 0.1 * config.digitalEcoScore; // 数字生态通过精准预测减少浪费
for (NSUInteger day = 0; day < days; day++) {
// 计算当日客流量
CGFloat trafficVariation = 0.3 - (premadeRatio * 0.2);
CGFloat randVariation = (arc4random_uniform(1000) / 1000.0) * (2 * trafficVariation - trafficVariation);
CGFloat customersFloat = [baseTraffic[@(config.scale)] floatValue] * (1 + randVariation) * naturalEcoMultiplier;
NSUInteger customers = MAX(10, (NSUInteger)round(customersFloat));
[dailyCustomers addObject:@(customers)];
// 计算人均消费
CGFloat spendPerCustomer = [baseSpend[@(config.scale)] floatValue] * [styleMultiplier[@(config.cuisineStyle)] floatValue];
spendPerCustomer *= (1 + (arc4random_uniform(100) / 1000.0) - 0.05);
CGFloat revenue = customers * spendPerCustomer;
[dailyRevenue addObject:@(revenue)];
// 计算成本
CGFloat ingredientCostRatio = 0.5 - (premadeRatio * 0.2);
CGFloat laborCostRatio = 0.3 + (premadeRatio * 0.1);
// 数字生态提升运营效率,降低成本
laborCostRatio *= (1.0 - (0.1 * config.digitalEcoScore));
CGFloat ingredientCost = revenue * ingredientCostRatio * featureCostFactor;
CGFloat laborCost = revenue * laborCostRatio;
CGFloat otherCost = revenue * 0.15;
CGFloat totalCost = ingredientCost + laborCost + otherCost;
[dailyCost addObject:@(totalCost)];
// 计算浪费量 (占食材成本的百分比)
CGFloat wastePercentage = 0.15 - wasteReduction;
wastePercentage = MAX(0.05, wastePercentage); // 至少5%的浪费
CGFloat dailyWasteAmount = ingredientCost * wastePercentage;
[dailyWaste addObject:@(dailyWasteAmount)];
// 计算员工满意度 (0-1)
CGFloat baseSatisfaction = 0.7;
baseSatisfaction += 0.2 * config.humanisticEcoScore; // 人文生态提升员工满意度
baseSatisfaction += 0.1 * (1.0 - premadeRatio); // 手工烹饪提升员工满意度
baseSatisfaction += (arc4random_uniform(200) / 1000.0) - 0.1; // 随机波动
baseSatisfaction = MAX(0.3, MIN(0.95, baseSatisfaction)); // 保持在合理范围内
[dailyEmployeeSatisfaction addObject:@(baseSatisfaction)];
}
// 计算总体指标
CGFloat avgCustomers = [[dailyCustomers valueForKeyPath:@"@avg.floatValue"] floatValue];
CGFloat avgRevenue = [[dailyRevenue valueForKeyPath:@"@avg.floatValue"] floatValue];
CGFloat avgCost = [[dailyCost valueForKeyPath:@"@avg.floatValue"] floatValue];
CGFloat avgProfit = avgRevenue - avgCost;
CGFloat profitMargin = avgRevenue > 0 ? (avgProfit / avgRevenue) : 0;
CGFloat avgWaste = [[dailyWaste valueForKeyPath:@"@avg.floatValue"] floatValue];
CGFloat avgEmployeeSatisfaction = [[dailyEmployeeSatisfaction valueForKeyPath:@"@avg.floatValue"] floatValue];
// 计算生态效益评分
CGFloat ecoBenefitScore = [self calculateEcoBenefitScoreWithConfig:config
dailyProfit:avgProfit
dailyWaste:avgWaste
employeeSatisfaction:avgEmployeeSatisfaction];
NSDictionary *dailyDetails = @{
@"customers": dailyCustomers,
@"revenue": dailyRevenue,
@"cost": dailyCost,
@"waste": dailyWaste,
@"employee_satisfaction": dailyEmployeeSatisfaction
};
return @{
@"scale": @(config.scale),
@"cuisine_style": @(config.cuisineStyle),
@"location": @(config.location),
@"feature": @(config.feature),
@"natural_eco_score": @(config.naturalEcoScore),
@"humanistic_eco_score": @(config.humanisticEcoScore),
@"digital_eco_score": @(config.digitalEcoScore),
@"primary_eco_type": @(config.primaryEcoType),
@"secondary_eco_type": @(config.secondaryEcoType),
@"chef_distribution": chefDist,
@"premade_ratio": @(premadeRatio),
@"chef_count": @(chefCount),
@"avg_daily_customers": @(avgCustomers),
@"avg_daily_revenue": @(avgRevenue),
@"avg_daily_cost": @(avgCost),
@"avg_daily_profit": @(avgProfit),
@"profit_margin": @(profitMargin),
@"avg_daily_waste": @(avgWaste),
@"avg_employee_satisfaction": @(avgEmployeeSatisfaction),
@"eco_benefit_score": @(ecoBenefitScore),
@"daily_details": dailyDetails
};
}
+ (CGFloat)calculateEcoBenefitScoreWithConfig:(RestaurantConfig *)config
dailyProfit:(CGFloat)dailyProfit
dailyWaste:(CGFloat)dailyWaste
employeeSatisfaction:(CGFloat)employeeSatisfaction {
// 基础效益评分 (0-100)
CGFloat baseScore = 50.0;
// 利润贡献 (最高20分)
CGFloat profitContribution = MIN(20.0, dailyProfit / 1000.0 * 2.0);
// 浪费减少贡献 (最高20分)
CGFloat wasteReductionContribution = MIN(20.0, (1.0 - (dailyWaste / (dailyProfit + dailyWaste))) * 20.0);
// 员工满意度贡献 (最高10分)
CGFloat satisfactionContribution = employeeSatisfaction * 10.0;
// 生态特色加成
CGFloat ecoBonus = 0;
ecoBonus += config.naturalEcoScore * 10.0; // 自然生态最多加10分
ecoBonus += config.humanisticEcoScore * 10.0; // 人文生态最多加10分
ecoBonus += config.digitalEcoScore * 10.0; // 数字生态最多加10分
// 计算总分
CGFloat totalScore = baseScore + profitContribution + wasteReductionContribution + satisfactionContribution + ecoBonus;
return MIN(100.0, MAX(0.0, totalScore));
}
@end
```
```objective-c
// RestaurantViewModel.m - 更新视图模型
#import "RestaurantViewModel.h"
#import "RestaurantModel.h"
@implementation RestaurantViewModel
- (void)runSimulationWithCompletion:(void (^)(void))completion {
NSMutableArray *results = [NSMutableArray array];
// 测试不同生态配置
NSArray *testEcoConfigs = @[
// 自然生态主导
[[RestaurantConfig alloc] initWithScale:RestaurantScaleMedium
cuisineStyle:CuisineStyleLocal
location:LocationTypeCommunity
feature:RestaurantFeatureOrganic
naturalEcoScore:0.8
humanisticEcoScore:0.5
digitalEcoScore:0.3],
// 人文生态主导
[[RestaurantConfig alloc] initWithScale:RestaurantScaleSmall
cuisineStyle:CuisineStyleLocal
location:LocationTypeCommunity
feature:RestaurantFeatureTraditional
naturalEcoScore:0.6
humanisticEcoScore:0.9
digitalEcoScore:0.4],
// 数字生态主导
[[RestaurantConfig alloc] initWithScale:RestaurantScaleChain
cuisineStyle:CuisineStyleFastCasual
location:LocationTypeMetro
feature:RestaurantFeatureInternetFamous
naturalEcoScore:0.3
humanisticEcoScore:0.5
digitalEcoScore:0.9],
// 平衡生态
[[RestaurantConfig alloc] initWithScale:RestaurantScaleLarge
cuisineStyle:CuisineStyleFusion
location:LocationTypeBusiness
feature:RestaurantFeatureNone
naturalEcoScore:0.7
humanisticEcoScore:0.7
digitalEcoScore:0.7]
];
for (RestaurantConfig *config in testEcoConfigs) {
NSDictionary *resultDict = [RestaurantModel simulateRestaurantOperationsWithConfig:config days:30];
SimulationResult *result = [[SimulationResult alloc] initWithDictionary:resultDict];
[results addObject:result];
}
self.simulationResults = results;
if (completion) completion();
}
@end
```
```objective-c
// main.m - 更新主程序
#import <Foundation/Foundation.h>
#import "RestaurantViewModel.h"
#import "SimulationResult.h"
#import "RestaurantScale.h"
#import "CuisineStyle.h"
#import "LocationType.h"
#import "RestaurantFeature.h"
#import "EcoType.h"
// ... 之前的辅助函数 ...
NSString *ecoTypeName(EcoType ecoType) {
switch (ecoType) {
case EcoTypeNatural: return @"自然生态";
case EcoTypeHumanistic: return @"人文生态";
case EcoTypeDigital: return @"数字生态";
default: return @"";
}
}
int main(int argc, const char * argv[]) {
@autoreleasepool {
RestaurantViewModel *viewModel = [[RestaurantViewModel alloc] init];
[viewModel runSimulationWithCompletion:^{
NSLog(@"寰宇光锥舟 - 三元生态餐厅模拟结果");
NSLog(@"==================================================");
for (SimulationResult *result in viewModel.simulationResults) {
NSLog(@"\n%@规模饭店 | %@ | %@ | %@",
scaleName(result.scale),
cuisineStyleName(result.cuisineStyle),
locationName([result.dailyDetails[@"location"] integerValue]),
featureName([result.dailyDetails[@"feature"] integerValue]));
NSLog(@"----------------------------------------");
NSLog(@" 生态配置: %@(%.1f) + %@(%.1f) + %@(%.1f)",
ecoTypeName(EcoTypeNatural), [result.dailyDetails[@"natural_eco_score"] floatValue],
ecoTypeName(EcoTypeHumanistic), [result.dailyDetails[@"humanistic_eco_score"] floatValue],
ecoTypeName(EcoTypeDigital), [result.dailyDetails[@"digital_eco_score"] floatValue]);
NSLog(@" 主要生态类型: %@", ecoTypeName([result.dailyDetails[@"primary_eco_type"] integerValue]));
NSLog(@" 厨师数量: %lu", (unsigned long)result.chefCount);
NSLog(@" 传统厨师比例: %.1f%%", [result.chefDistribution[@(ChefTypeTraditional)] floatValue] * 100);
NSLog(@" 混合型厨师比例: %.1f%%", [result.chefDistribution[@(ChefTypeHybrid)] floatValue] * 100);
NSLog(@" 加工型厨师比例: %.1f%%", [result.chefDistribution[@(ChefTypeProcess)] floatValue] * 100);
NSLog(@" 预制菜使用比例: %.1f%%", result.premadeRatio * 100);
NSLog(@" 日均顾客: %.0f", result.avgDailyCustomers);
NSLog(@" 日均利润: %.0f 元", result.avgDailyProfit);
NSLog(@" 日均浪费: %.0f 元", [result.dailyDetails[@"avg_daily_waste"] floatValue]);
NSLog(@" 员工满意度: %.1f%%", [result.dailyDetails[@"avg_employee_satisfaction"] floatValue] * 100);
NSLog(@" 生态效益评分: %.1f/100", [result.dailyDetails[@"eco_benefit_score"] floatValue]);
NSLog(@" ");
}
// 找出生态效益最高的配置
SimulationResult *bestEcoResult = nil;
for (SimulationResult *result in viewModel.simulationResults) {
CGFloat ecoScore = [result.dailyDetails[@"eco_benefit_score"] floatValue];
if (!bestEcoResult || ecoScore > [bestEcoResult.dailyDetails[@"eco_benefit_score"] floatValue]) {
bestEcoResult = result;
}
}
if (bestEcoResult) {
NSLog(@"\n最佳生态配置:");
NSLog(@"%@规模饭店 | %@ | %@ | %@",
scaleName(bestEcoResult.scale),
cuisineStyleName(bestEcoResult.cuisineStyle),
locationName([bestEcoResult.dailyDetails[@"location"] integerValue]),
featureName([bestEcoResult.dailyDetails[@"feature"] integerValue]));
NSLog(@"生态效益评分: %.1f/100", [bestEcoResult.dailyDetails[@"eco_benefit_score"] floatValue]);
}
}];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2]];
}
return 0;
}
```
三元生态特征实现说明
这个优化版的系统深度融入了寰宇光锥舟理论的三元生态特征:
1. 自然生态 (EcoTypeNatural)
· 环保与可持续:减少食物浪费,使用有机食材
· 实现方式:
· 高自然生态评分减少浪费量(最高减少20%)
· 有机特色餐厅自动获得高自然生态评分
· 自然生态主导的配置倾向于使用传统厨师,减少预制菜使用
2. 人文生态 (EcoTypeHumanistic)
· 文化传承与员工福祉:注重传统技艺,提高员工满意度
· 实现方式:
· 高人文生态评分提升员工满意度(最高提升20%)
· 传统老字号特色自动获得高人文生态评分
· 人文生态主导的配置平衡传统与混合型厨师,注重技艺传承
3. 数字生态 (EcoTypeDigital)
· 智能化与效率:通过技术提升运营效率
· 实现方式:
· 高数字生态评分降低人工成本(最高降低10%)
· 网红特色餐厅自动获得高数字生态评分
· 数字生态主导的配置增加加工型和混合型厨师,提高预制菜使用
4. 生态效益综合评分
系统新增了生态效益评分机制,综合考虑:
· 经济效益:利润贡献
· 环境效益:浪费减少
· 社会效益:员工满意度
· 生态特色加成:三元生态的专项评分
5. 生态协同效应
系统模拟了三元生态之间的协同作用:
· 自然+人文生态:传统烹饪减少浪费,同时提升员工满意度
· 自然+数字生态:精准预测减少浪费,同时提高运营效率
· 人文+数字生态:技术提升员工工作体验,同时保持传统特色
这个优化版的系统不仅考虑了经济效益,更全面评估了餐厅在自然、人文和数字三个维度的生态表现,真正体现了寰宇光锥舟理论的核心思想。
更多推荐
所有评论(0)