当前位置: 首页 > news >正文

网站建设的几大要素网站群系统破解版

网站建设的几大要素,网站群系统破解版,石材网站模板,成都商城网站开发代码功能说明 条件类#xff1a;Condition 类用于定义每个条件的范围#xff0c;并提供一个方法 is_satisfied 来检查输入值是否满足该条件。 算法选择器类#xff1a;AlgorithmSelector 类负责应用条件并记录不满足的条件。它提供方法 apply_condition 用于更新可用算法Condition 类用于定义每个条件的范围并提供一个方法 is_satisfied 来检查输入值是否满足该条件。 算法选择器类AlgorithmSelector 类负责应用条件并记录不满足的条件。它提供方法 apply_condition 用于更新可用算法get_selected_algorithm 用于返回选中的算法以及 log_failed_conditions 方法用于输出失败的条件信息。 规则定义rules 字典中定义了每个条件的范围以及对应的适用算法。通过这种方式您可以轻松扩展或修改条件和算法的对应关系。 选择算法select_algorithm 函数根据输入值和启用的开关选择合适的算法。它将输入值传递给 AlgorithmSelector 进行处理并最终返回符合条件的算法编号。 可扩展性 添加新条件要添加新条件只需在 rules 字典中添加新的条件范围和适用算法。修改条件可以直接修改 rules 中的条件范围或对应的算法集合。启用/禁用条件可以通过开关参数灵活地启用或禁用某些条件。 class Condition:def __init__(self, min_value, max_value, name):self.min_value min_valueself.max_value max_valueself.name namedef is_satisfied(self, input_value):return self.min_value input_value self.max_valueclass AlgorithmSelector:def __init__(self):self.algorithms set(range(8)) # 假设有8个算法self.failed_conditions []def apply_condition(self, condition, input_value, applicable_algorithms):if condition.is_satisfied(input_value):self.algorithms.intersection_update(applicable_algorithms)else:self.failed_conditions.append(fCondition {condition.name} failed. fInput value: {input_value}, fexpected range: [{condition.min_value}, {condition.max_value}))def get_selected_algorithm(self):return next(iter(self.algorithms), -1) # 返回第一个符合条件的算法若无则返回-1def log_failed_conditions(self):if not self.failed_conditions:print(All conditions passed.)else:print(Failed conditions:)for condition in self.failed_conditions:print(f - {condition})# 定义每个条件的范围和适用的算法 rules {ISO: [(Condition(0, 200, ISO 0-200), {0}),(Condition(200, 800, ISO 200-800), {1, 2}),(Condition(800, float(inf), ISO 800), {2}),],Facelv: [(Condition(0, 2, Facelv 0-2), {0, 3}),(Condition(2, 5, Facelv 2-5), {3}),],Zoom: [(Condition(0, 2.0, Zoom 0-2.0), {1}),(Condition(2.0, 3.0, Zoom 2.0-3.0), {4}),(Condition(3.0, float(inf), Zoom 3.0), {4, 5}),],Face Count: [(Condition(0, 2, Face Count 0-2), {2}),(Condition(3, 5, Face Count 3-5), {2, 4}),(Condition(6, float(inf), Face Count 6), {4, 6}),],Face Size: [(Condition(0, 50, Face Size 0-50), {3}),(Condition(50, 100, Face Size 50-100), {5}),(Condition(100, float(inf), Face Size 100), {3, 7}),], }def select_algorithm(iso, facelv, zoom, face_count, face_size,use_isoTrue, use_facelvTrue, use_zoomTrue, use_face_countTrue, use_face_sizeFalse):selector AlgorithmSelector()# 输入值列表和条件启用的开关inputs [iso, facelv, zoom, face_count, face_size]switches [use_iso, use_facelv, use_zoom, use_face_count, use_face_size]# 遍历每个条件for i, (condition_name, conditions) in enumerate(rules.items()):if switches[i]: # 如果该条件启用for condition, applicable_algorithms in conditions:selector.apply_condition(condition, inputs[i], applicable_algorithms)# 输出不满足的条件selector.log_failed_conditions()# 返回选择的算法return selector.get_selected_algorithm()# 示例输入 iso 300 facelv 3 zoom 2.5 face_count 4 face_size 75# 启用/禁用各条件的开关 selected_algorithm select_algorithm(iso, facelv, zoom, face_count, face_size,use_isoTrue,use_facelvTrue,use_zoomTrue,use_face_countTrue,use_face_sizeFalse)if selected_algorithm ! -1:print(f根据条件选择的算法是: {selected_algorithm}) else:print(未找到符合条件的算法。)C实现 #include iostream #include vector #include set #include limits #include stringclass Condition { public:Condition(double min_value, double max_value, const std::string name): min_value(min_value), max_value(max_value), name(name) {}bool isSatisfied(double input_value) const {return min_value input_value input_value max_value;}const std::string getName() const {return name;}private:double min_value;double max_value;std::string name; };class AlgorithmSelector { public:AlgorithmSelector() : algorithms({0, 1, 2, 3, 4, 5, 6, 7}) {}void applyCondition(const Condition condition, double input_value, const std::setint applicable_algorithms) {if (condition.isSatisfied(input_value)) {intersectAlgorithms(applicable_algorithms);} else {failed_conditions.push_back(Condition condition.getName() failed. Input value: std::to_string(input_value) , expected range: [ std::to_string(condition.getMin()) , std::to_string(condition.getMax()) ));}}int getSelectedAlgorithm() const {return algorithms.empty() ? -1 : *algorithms.begin(); // 返回第一个符合条件的算法若无则返回-1}void logFailedConditions() const {if (failed_conditions.empty()) {std::cout All conditions passed. std::endl;} else {std::cout Failed conditions: std::endl;for (const auto condition : failed_conditions) {std::cout - condition std::endl;}}}private:std::setint algorithms;std::vectorstd::string failed_conditions;void intersectAlgorithms(const std::setint applicable_algorithms) {std::setint intersection;for (const auto algo : algorithms) {if (applicable_algorithms.count(algo) 0) {intersection.insert(algo);}}algorithms intersection; // 更新可用算法} };// 定义每个条件的范围和适用的算法 const std::vectorstd::pairCondition, std::setint rules[] {{{0, 200, ISO 0-200}, {0}},{{200, 800, ISO 200-800}, {1, 2}},{{800, std::numeric_limitsdouble::infinity(), ISO 800}, {2}},{{0, 2, Facelv 0-2}, {0, 3}},{{2, 5, Facelv 2-5}, {3}},{{0, 2.0, Zoom 0-2.0}, {1}},{{2.0, 3.0, Zoom 2.0-3.0}, {4}},{{3.0, std::numeric_limitsdouble::infinity(), Zoom 3.0}, {4, 5}},{{0, 2, Face Count 0-2}, {2}},{{3, 5, Face Count 3-5}, {2, 4}},{{6, std::numeric_limitsdouble::infinity(), Face Count 6}, {4, 6}},{{0, 50, Face Size 0-50}, {3}},{{50, 100, Face Size 50-100}, {5}},{{100, std::numeric_limitsdouble::infinity(), Face Size 100}, {3, 7}} };int selectAlgorithm(double iso, double facelv, double zoom, double face_count, double face_size,bool use_iso true, bool use_facelv true, bool use_zoom true, bool use_face_count true, bool use_face_size true) {AlgorithmSelector selector;// 输入值和启用的开关std::vectordouble inputs {iso, facelv, zoom, face_count, face_size};std::vectorbool switches {use_iso, use_facelv, use_zoom, use_face_count, use_face_size};// 遍历每个条件for (size_t i 0; i switches.size(); i) {if (switches[i]) { // 如果该条件启用for (const auto rule : rules[i]) {selector.applyCondition(rule.first, inputs[i], rule.second);}}}// 输出不满足的条件selector.logFailedConditions();// 返回选择的算法return selector.getSelectedAlgorithm(); }int main() {// 示例输入double iso 300;double facelv 3;double zoom 2.5;double face_count 4;double face_size 75;// 启用/禁用各条件的开关int selected_algorithm selectAlgorithm(iso, facelv, zoom, face_count, face_size,true, true, true, true, false);if (selected_algorithm ! -1) {std::cout 根据条件选择的算法是: selected_algorithm std::endl;} else {std::cout 未找到符合条件的算法。 std::endl;}return 0; }比较有意思的实现 #include iostream #include vector #include set #include algorithm #include iterator// 定义规则结构 struct Rule {std::vectorstd::pairdouble, double ranges; // 条件范围std::vectorstd::setint actions; // 对应算法的集合 };// 定义规则表适应同一条件多个范围对应多个算法的情况 std::vectorRule rules {{ {{0, 200}, {200, 800}, {800, 1e9}}, {{0}, {1, 2}, {2}} }, // iso规则{ {{0, 2}, {2, 5}}, {{0, 3}, {3}} }, // facelv规则{ {{0, 2.0}, {2.0, 3.0}, {3.0, 1e9}}, {{1}, {4}, {4, 5}} }, // zoom规则{ {{0, 2}, {3, 5}, {6, 1e9}}, {{2}, {2, 4}, {4, 6}} }, // face_count规则{ {{0, 50}, {50, 100}, {100, 1e9}}, {{3}, {5}, {3, 7}} } // face_size规则 };// 根据输入条件和开关选择最优算法 int select_algorithm(double iso, double facelv, double zoom, double face_count, double face_size,bool use_iso, bool use_facelv, bool use_zoom, bool use_face_count, bool use_face_size) {std::setint selected_actions {0, 1, 2, 3, 4, 5, 6, 7}; // 初始假设有8种算法// 输入条件值std::vectordouble inputs {iso, facelv, zoom, face_count, face_size};// 各条件是否启用的开关std::vectorbool switches {use_iso, use_facelv, use_zoom, use_face_count, use_face_size};// 遍历每个条件for (int i 0; i rules.size(); i) {if (!switches[i]) continue; // 如果该条件未启用跳过const Rule rule rules[i];std::setint current_matching_actions; // 用于存储该条件下匹配的算法// 遍历每个范围找到满足当前条件的所有算法集合for (int j 0; j rule.ranges.size(); j) {if (inputs[i] rule.ranges[j].first inputs[i] rule.ranges[j].second) {current_matching_actions.insert(rule.actions[j].begin(), rule.actions[j].end());}}// 如果当前条件有匹配的算法取交集if (!current_matching_actions.empty()) {std::setint intersection;std::set_intersection(selected_actions.begin(), selected_actions.end(),current_matching_actions.begin(), current_matching_actions.end(),std::inserter(intersection, intersection.begin()));selected_actions intersection;}}// 返回第一个符合条件的算法return selected_actions.empty() ? -1 : *selected_actions.begin(); }int main() {// 示例输入double iso 300;double facelv 3;double zoom 2.5;double face_count 4;double face_size 75;// 启用/禁用各条件的开关bool use_iso true;bool use_facelv true;bool use_zoom true;bool use_face_count true;bool use_face_size false; // 例如不使用face_size条件// 调用选择函数int selected_algorithm select_algorithm(iso, facelv, zoom, face_count, face_size,use_iso, use_facelv, use_zoom, use_face_count, use_face_size);if (selected_algorithm ! -1) {std::cout 根据条件选择的算法是: selected_algorithm std::endl;} else {std::cout 未找到符合条件的算法。 std::endl;}return 0; }
http://www.dnsts.com.cn/news/101023.html

相关文章:

  • 企业网站设计要求网站建设所需要的软件
  • 万网 网站建设方案书网站创建一般创建哪种类型
  • 泉州营销型网站建设网站建设需要知识
  • 运维网站建设做网站用哪几个端口 比较好
  • 网站建设专家价格移动端 pc网站开发
  • 佛山网站建设玲念建站电商网站开发意义
  • 天津市建设与管理网站做设计的兼职网站有哪些
  • 免费的求职简历模板网站精准推广
  • 在凡科网申请的网站设置网页访问密码wordpress怎么和手机连接数据库
  • 个人业务网站后台给公司做个网站多少钱
  • 自行创建网站的平台北京做网站需要多少钱
  • 网站内容建设要求 age06阿里云万网域名查询
  • 高密做网站seo排名优化软件有用吗
  • 公司网站建设找谁一级a做爰片完整网站
  • 网站建设用什么框架好怎么做一个网站的logo设计图
  • 那个网站做logo兼职网络运营策划
  • 嘉兴网站制作网站建设自助设计网站
  • 一个网站开发的流程图wordpress平铺图片
  • 建设部网站危房鉴定标准规定p2p贷款网站开发
  • jsp商务网站开发推广发帖网站
  • 如何删除自己建的网站公司注册资金实缴和认缴的区别
  • 高权重网站出售深圳几个区
  • 网站备案流程多少钱90设计网官网登录
  • 济宁网站定制公司wordpress安装脚本打不开
  • 达州 网站建设福州网站建设哪家好
  • 做网站用虚拟主机好不好广州网站建设360网站优化
  • 网站怎样做权重自己做的网站在浏览器上显示不安全吗
  • 网站建设与运行电视剧排行榜
  • 宁波网站制作怎样网页设计与制作教程杨选辉
  • 客户端 网站开发 手机软件开发网站系统改教程