java:Iterative Algorithms
项目结构/** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:10 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : Settings.java * explain : 学习 类 **/ package Iterative.config; public final class Settings { private Settings() {} public static final double DIAMOND_WEIGHT_CARAT 0.5; public static final double DIAMOND_WEIGHT_COLOR 0.3; public static final double DIAMOND_WEIGHT_CLARITY 0.2; public static final double PRICE_ITER_STEP 0.01; public static final double MIN_MARKUP_COEFF 1.3; public static final double MAX_MARKUP_COEFF 2.2; } /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:46 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : Diamond.java * explain : 学习 类 **/ package Iterative.model; import Iterative.config.Settings; import java.util.Map; public class Diamond { private String stoneId; private double carat; private String color; private String clarity; private double costPrice; public double calcComprehensiveScore() { MapString, Double colorMap Map.of( D, 100.0, E, 96.0, F, 92.0, G, 88.0, H, 84.0, I, 78.0 ); MapString, Double clarityMap Map.of( FL, 100.0, VVS1, 95.0, VVS2, 90.0, VS1, 85.0, VS2, 80.0, SI1, 70.0 ); double cScore carat * 100; double colScore colorMap.getOrDefault(color, 60.0); double claScore clarityMap.getOrDefault(clarity, 60.0); return cScore * Settings.DIAMOND_WEIGHT_CARAT colScore * Settings.DIAMOND_WEIGHT_COLOR claScore * Settings.DIAMOND_WEIGHT_CLARITY; } // getter setter public String getStoneId() { return stoneId; } public void setStoneId(String stoneId) { this.stoneId stoneId; } public double getCarat() { return carat; } public void setCarat(double carat) { this.carat carat; } public String getColor() { return color; } public void setColor(String color) { this.color color; } public String getClarity() { return clarity; } public void setClarity(String clarity) { this.clarity clarity; } public double getCostPrice() { return costPrice; } public void setCostPrice(double costPrice) { this.costPrice costPrice; } } /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:47 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : JadeBlank.java * explain : 学习 类 **/ package Iterative.model; public class JadeBlank { private String blankId; private double length; private double width; private double thick; private double costPrice; private double usableRate; public String getBlankId() { return blankId; } public void setBlankId(String blankId) { this.blankId blankId; } public double getLength() { return length; } public void setLength(double length) { this.length length; } public double getWidth() { return width; } public void setWidth(double width) { this.width width; } public double getThick() { return thick; } public void setThick(double thick) { this.thick thick; } public double getCostPrice() { return costPrice; } public void setCostPrice(double costPrice) { this.costPrice costPrice; } public double getUsableRate() { return usableRate; } public void setUsableRate(double usableRate) { this.usableRate usableRate; } } /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:47 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : Product.java * explain : 学习 类 **/ package Iterative.model; public class Product { private String productId; private String name; private double cost; public String getProductId() { return productId; } public void setProductId(String productId) { this.productId productId; } public String getName() { return name; } public void setName(String name) { this.name name; } public double getCost() { return cost; } public void setCost(double cost) { this.cost cost; } } /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:47 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : RingMount.java * explain : 学习 类 **/ package Iterative.model; public class RingMount { private String mountId; private String material; private double costPrice; public String getMountId() { return mountId; } public void setMountId(String mountId) { this.mountId mountId; } public String getMaterial() { return material; } public void setMaterial(String material) { this.material material; } public double getCostPrice() { return costPrice; } public void setCostPrice(double costPrice) { this.costPrice costPrice; } } /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:52 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : BaseRepository.java * explain : 学习 类 **/ package Iterative.repository; import java.util.List; public interface BaseRepositoryT { ListT listAll(); } /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:53 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : DiamondRepository.java * explain : 学习 类 **/ package Iterative.repository; import Iterative.model.Diamond; import java.util.List; public class DiamondRepository implements BaseRepositoryDiamond { private final ListDiamond storage; public DiamondRepository() { Diamond d1 new Diamond(); d1.setStoneId(D001); d1.setCarat(0.52); d1.setColor(H); d1.setClarity(VS1); d1.setCostPrice(24800); Diamond d2 new Diamond(); d2.setStoneId(D002); d2.setCarat(0.48); d2.setColor(G); d2.setClarity(VS2); d2.setCostPrice(22100); Diamond d3 new Diamond(); d3.setStoneId(D003); d3.setCarat(0.55); d3.setColor(I); d3.setClarity(SI1); d3.setCostPrice(21300); storage List.of(d1, d2, d3); } Override public ListDiamond listAll() { return List.copyOf(storage); } } /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:54 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : JadeRepository.java * explain : 学习 类 **/ package Iterative.repository; import Iterative.model.JadeBlank; import java.util.List; public class JadeRepository implements BaseRepositoryJadeBlank { private final ListJadeBlank storage; public JadeRepository() { JadeBlank j1 new JadeBlank(); j1.setBlankId(J001); j1.setLength(32.5); j1.setWidth(21.2); j1.setThick(7.3); j1.setCostPrice(6800); j1.setUsableRate(0.86); JadeBlank j2 new JadeBlank(); j2.setBlankId(J002); j2.setLength(30.1); j2.setWidth(19.8); j2.setThick(6.9); j2.setCostPrice(6200); j2.setUsableRate(0.91); JadeBlank j3 new JadeBlank(); j3.setBlankId(J003); j3.setLength(36.0); j3.setWidth(24.1); j3.setThick(8.2); j3.setCostPrice(7500); j3.setUsableRate(0.79); storage List.of(j1, j2, j3); } Override public ListJadeBlank listAll() { return List.copyOf(storage); } } /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:53 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : RingMountRepository.java * explain : 学习 类 **/ package Iterative.repository; import Iterative.model.RingMount; import java.util.List; public class RingMountRepository implements BaseRepositoryRingMount { private final ListRingMount storage; public RingMountRepository() { RingMount m1 new RingMount(); m1.setMountId(M001); m1.setMaterial(18K); m1.setCostPrice(4200); RingMount m2 new RingMount(); m2.setMountId(M002); m2.setMaterial(铂金); m2.setCostPrice(5600); storage List.of(m1, m2); } Override public ListRingMount listAll() { return List.copyOf(storage); } } /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:48 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : DiamondRecommendRequest.java * explain : 学习 类 **/ package Iterative.schema.request; public record DiamondRecommendRequest(double budget, String material) {} /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:48 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : JadeMatchRequest.java * explain : 学习 类 **/ package Iterative.schema.request; public record JadeMatchRequest( double minL, double maxL, double minW, double maxW, double minT, double maxT, double priceMin, double priceMax ) {} /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:49 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : PriceOptRequest.java * explain : 学习 类 **/ package Iterative.schema.request; public record PriceOptRequest(double baseCost, double minCoeff, double maxCoeff, double step) {} /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:49 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : DiamondComboResult.java * explain : 学习 类 **/ package Iterative.schema.response; import Iterative.model.Diamond; import Iterative.model.RingMount; public record DiamondComboResult(Diamond diamond, RingMount mount, double totalCost, double score) {} /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:50 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : JadeMatchResult.java * explain : 学习 类 **/ package Iterative.schema.response; import Iterative.model.JadeBlank; public class JadeMatchResult { private final String blankId; private final double length; private final double width; private final double thick; private final double costPrice; private final double usableRate; public JadeMatchResult(JadeBlank blank) { this.blankId blank.getBlankId(); this.length blank.getLength(); this.width blank.getWidth(); this.thick blank.getThick(); this.costPrice blank.getCostPrice(); this.usableRate blank.getUsableRate(); } public String getBlankId() { return blankId; } public double getLength() { return length; } public double getWidth() { return width; } public double getThick() { return thick; } public double getCostPrice() { return costPrice; } public double getUsableRate() { return usableRate; } } /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:50 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : PriceOptResult.java * explain : 学习 类 **/ package Iterative.schema.response; public record PriceOptResult(double bestCoeff, double bestSellPrice, double maxGrossProfit) {} /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:54 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : DiamondRecommendService.java * explain : 学习 类 **/ package Iterative.service; import Iterative.model.Diamond; import Iterative.model.RingMount; import Iterative.repository.BaseRepository; import Iterative.schema.request.DiamondRecommendRequest; import Iterative.schema.response.DiamondComboResult; import java.util.List; public class DiamondRecommendService { private final BaseRepositoryDiamond diamondRepo; private final BaseRepositoryRingMount mountRepo; public DiamondRecommendService(BaseRepositoryDiamond diamondRepo, BaseRepositoryRingMount mountRepo) { this.diamondRepo diamondRepo; this.mountRepo mountRepo; } public DiamondComboResult findBestCombo(DiamondRecommendRequest req) { ListDiamond diamonds diamondRepo.listAll(); ListRingMount mounts mountRepo.listAll(); DiamondComboResult best null; double bestScore -1.0; for (Diamond dia : diamonds) { for (RingMount mount : mounts) { if (!mount.getMaterial().equals(req.material())) { continue; } double total dia.getCostPrice() mount.getCostPrice(); if (total req.budget()) { continue; } double score dia.calcComprehensiveScore(); if (score bestScore) { bestScore score; best new DiamondComboResult(dia, mount, total, score); } } } return best; } } /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 20:24 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : JadeCustomService.java * explain : 学习 类 **/ package Iterative.service; import Iterative.algorithm.IterativeMatcher; import Iterative.model.JadeBlank; import Iterative.repository.BaseRepository; import Iterative.schema.request.JadeMatchRequest; import Iterative.schema.response.JadeMatchResult; import java.util.List; public class JadeCustomService { private final BaseRepositoryJadeBlank jadeRepo; private final IterativeMatcher matcher; public JadeCustomService(BaseRepositoryJadeBlank jadeRepo) { this.jadeRepo jadeRepo; this.matcher new IterativeMatcher(); } public JadeMatchResult matchOptimalBlank(JadeMatchRequest req) { ListJadeBlank blanks jadeRepo.listAll(); JadeBlank best matcher.findOptimal( blanks, item - { boolean condSize req.minL() item.getLength() item.getLength() req.maxL() req.minW() item.getWidth() item.getWidth() req.maxW() req.minT() item.getThick() item.getThick() req.maxT(); boolean condPrice req.priceMin() item.getCostPrice() item.getCostPrice() req.priceMax(); return condSize condPrice; }, JadeBlank::getUsableRate ); return best null ? null : new JadeMatchResult(best); } } /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 20:37 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : ProductPricingService.java * explain : 学习 类 **/ package Iterative.service; import Iterative.algorithm.IterativeOptimizer; import Iterative.config.Settings; import Iterative.schema.request.PriceOptRequest; import Iterative.schema.response.PriceOptResult; public class ProductPricingService { private final IterativeOptimizer optimizer; public ProductPricingService() { this.optimizer new IterativeOptimizer(); } public PriceOptResult calcOptimalPrice(PriceOptRequest req) { double baseCost req.baseCost(); IterativeOptimizer.Result res optimizer.optimize( req.minCoeff(), req.maxCoeff(), req.step(), coeff - { double sellPrice baseCost * coeff; double volume Math.max(0, 120 - sellPrice / 45); return (sellPrice - baseCost) * volume; } ); double bestSellPrice Math.round(baseCost * res.bestParam() * 100.0) / 100.0; return new PriceOptResult(res.bestParam(), bestSellPrice, res.maxTarget()); } } /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:50 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : IterativeMatcher.java * explain : 学习 类 **/ package Iterative.algorithm; import java.util.List; import java.util.function.Function; import java.util.function.Predicate; /** * 通用迭代匹配器 Iterative Algorithms */ public class IterativeMatcher { public T T findOptimal(ListT candidates, PredicateT filter, FunctionT, Double scoreFunc) { int bestIndex -1; double bestScore -1e18; for (int i 0; i candidates.size(); i) { T item candidates.get(i); if (!filter.test(item)) { continue; } double s scoreFunc.apply(item); if (s bestScore) { bestScore s; bestIndex i; } } if (bestIndex 0) { return null; } return candidates.get(bestIndex); } } /** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 19:51 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : IterativeOptimizer.java * explain : 学习 类 **/ package Iterative.algorithm; import java.util.function.Function; public class IterativeOptimizer { public Result optimize(double start, double end, double step, FunctionDouble, Double evalFunc) { double bestParam start; double maxTarget Double.NEGATIVE_INFINITY; double current start; while (current end) { double val evalFunc.apply(current); if (val maxTarget) { maxTarget val; bestParam current; } current step; } // 保留两位小数 bestParam Math.round(bestParam * 100.0) / 100.0; maxTarget Math.round(maxTarget * 100.0) / 100.0; return new Result(bestParam, maxTarget); } public record Result(double bestParam, double maxTarget) {} }调用/** * encoding: utf-8 * 版权所有 2026 ©涂聚文有限公司 ® * 许可信息查看言語成了邀功盡責的功臣還需要行爲每日來值班嗎 * 描述Iterative Algorithms * Author : geovindu,Geovin Du 涂聚文. * IDE : IntelliJ IDEA 2024.3.6 Java 17 * # database : Oracle21c,MySQL 9.0,SQL Server 2019,PostgreSQL 17.1 Neo4j * # OS : window10 * Datetime : 2026 - 2026/7/25 - 20:35 * User : geovindu * Product : IntelliJ IDEA * Project : JavaAlgorithms * File : IterativeBll.java * explain : 学习 类 **/ package Bll; import Iterative.config.Settings; import Iterative.repository.DiamondRepository; import Iterative.repository.JadeRepository; import Iterative.repository.RingMountRepository; import Iterative.schema.request.DiamondRecommendRequest; import Iterative.schema.request.JadeMatchRequest; import Iterative.schema.request.PriceOptRequest; import Iterative.service.DiamondRecommendService; import Iterative.service.JadeCustomService; import Iterative.service.ProductPricingService; public class IterativeBll { static void demoRecommend() { var diaRepo new DiamondRepository(); var mountRepo new RingMountRepository(); var svc new DiamondRecommendService(diaRepo, mountRepo); var req new DiamondRecommendRequest(30000, 18K); var res svc.findBestCombo(req); if (res ! null) { System.out.println( 钻戒最优组合 ); System.out.printf(主石:%s, %.2fct%n, res.diamond().getStoneId(), res.diamond().getCarat()); System.out.printf(戒托:%s%n, res.mount().getMountId()); System.out.printf(合计成本:%.2f,综合评分:%.2f%n, res.totalCost(), res.score()); } } static void demoJadeMatch() { var repo new JadeRepository(); var svc new JadeCustomService(repo); var req new JadeMatchRequest( 28, 33, 18, 22, 6, 8, 5000, 7000 ); var res svc.matchOptimalBlank(req); if (res ! null) { System.out.println(\n 匹配翡翠毛料 ); System.out.printf(毛料ID:%s,利用率:%.2f%n, res.getBlankId(), res.getUsableRate()); } } static void demoPricing() { var svc new ProductPricingService(); var req new PriceOptRequest(1680, Settings.MIN_MARKUP_COEFF, Settings.MAX_MARKUP_COEFF, Settings.PRICE_ITER_STEP); var res svc.calcOptimalPrice(req); System.out.println(\n 动态定价结果 ); System.out.printf(最优加价系数:%.2f%n, res.bestCoeff()); System.out.printf(建议售价:%.2f%n, res.bestSellPrice()); System.out.printf(预期最大毛利:%.2f%n, res.maxGrossProfit()); } public void Demo() { demoRecommend(); demoJadeMatch(); demoPricing(); } }输出

相关新闻

3分钟快速上手:GitHub中文插件完全指南

3分钟快速上手:GitHub中文插件完全指南

3分钟快速上手:GitHub中文插件完全指南 【免费下载链接】github-chinese GitHub 汉化插件,GitHub 中文化界面。 (GitHub Translation To Chinese) 项目地址: https://gitcode.com/gh_mirrors/gi/github-chinese 还在为GitHub全英文界面而烦恼吗&a…

2026/10/14 15:58:50 阅读更多 →
ThinkPad风扇控制革命:TPFanCtrl2让你的笔记本静如处子,动如脱兔

ThinkPad风扇控制革命:TPFanCtrl2让你的笔记本静如处子,动如脱兔

ThinkPad风扇控制革命:TPFanCtrl2让你的笔记本静如处子,动如脱兔 【免费下载链接】TPFanCtrl2 ThinkPad Fan Control 2 (Dual Fan) for Windows 10 and 11 项目地址: https://gitcode.com/gh_mirrors/tp/TPFanCtrl2 作为一名ThinkPad用户&#xf…

2026/10/14 15:58:54 阅读更多 →
Windows 11优化终极指南:3步让你的系统重获流畅体验

Windows 11优化终极指南:3步让你的系统重获流畅体验

Windows 11优化终极指南:3步让你的系统重获流畅体验 【免费下载链接】Win11Debloat A simple, lightweight PowerShell script that allows you to remove pre-installed apps, disable telemetry, as well as perform various other changes to declutter and cust…

2026/10/14 15:59:23 阅读更多 →

最新新闻

Zabbix 6.0从零搭建监控系统:安装部署与告警配置实战指南

Zabbix 6.0从零搭建监控系统:安装部署与告警配置实战指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/16 1:12:35 阅读更多 →
锂电串联主动均衡原理与MP2642GR-Z+PIC18F45K80实战设计

锂电串联主动均衡原理与MP2642GR-Z+PIC18F45K80实战设计

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/16 1:12:35 阅读更多 →
Haar特征与积分图详解:从手算示例到Python实现

Haar特征与积分图详解:从手算示例到Python实现

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/16 1:12:35 阅读更多 →
C++实现精确分数计算器:从Fraction类到运算符重载

C++实现精确分数计算器:从Fraction类到运算符重载

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/16 1:12:35 阅读更多 →
STM32时钟系统寄存器与库函数配置实战:从HSI到72MHz HSE

STM32时钟系统寄存器与库函数配置实战:从HSI到72MHz HSE

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/16 1:12:35 阅读更多 →
Redis内存管理:过期删除与淘汰策略实战解析

Redis内存管理:过期删除与淘汰策略实战解析

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/16 1:11:35 阅读更多 →

日新闻

个人 AI Agent 平台接入 TaoToken:统一 Key 与 API 通道的配置大纲

个人 AI Agent 平台接入 TaoToken:统一 Key 与 API 通道的配置大纲

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/16 0:00:05 阅读更多 →
信号与系统频域分析作业解题指南

信号与系统频域分析作业解题指南

1. 作业背景与核心要求解析信号与系统作为电子信息类专业的核心基础课,其作业设计往往直接关联课程的核心知识框架。2026年春季第六次作业的布置,通常对应着课程进展到频域分析的关键阶段。根据常规教学进度推测,本次作业可能涉及以下核心内容…

2026/10/16 0:00:05 阅读更多 →
Django MVT实战:从零构建图书借阅系统,彻底搞懂Model-View-Template分层

Django MVT实战:从零构建图书借阅系统,彻底搞懂Model-View-Template分层

1. 从一个"四不像"的练手项目说起如果你已经看完了Django的官方教程前几章,跟着敲完了投票应用,大概会有一种"我好像会了,又好像什么都不会"的割裂感。教程里每个知识点都是拆开的——这一章讲模型,下一章讲视…

2026/10/16 0:00:05 阅读更多 →

周新闻

流感时间序列预测实战:ARIMA/LSTM全流程拆解与避坑指南

流感时间序列预测实战:ARIMA/LSTM全流程拆解与避坑指南

简介:基于 ARIMA、LSTM、Transformer 等模型的流感时间序列预测 Python 源码,面向计算机相关专业课程设计与期末大作业学生,以及项目实战学习者。内容覆盖预处理、平稳性检验、定阶、残差分析、多模型对比预测的完整时序建模流程,…

2026/10/15 16:18:54 阅读更多 →
影刀RPA新手教程:键盘模拟输入实战——输入文本与模拟按键的区别

影刀RPA新手教程:键盘模拟输入实战——输入文本与模拟按键的区别

影刀RPA新手教程:键盘模拟输入实战——输入文本与模拟按键的区别 做影刀RPA自动化,十个新手有八个栽在"往输入框里填东西"这件事上:要么填不进去,要么填了一半,要么直接把原来内容追加在后面。这背后的根因&…

2026/10/15 19:41:51 阅读更多 →
影刀RPA新手教程:阅文起点小说数据采集实战——书籍信息与章节内容

影刀RPA新手教程:阅文起点小说数据采集实战——书籍信息与章节内容

影刀RPA新手教程:阅文起点小说数据采集实战——书籍信息与章节内容 1. 认识影刀:什么场景该用RPA采小说数据 起点中文网的页面结构相对稳定——分类榜单、书籍详情、章节内容三块独立页面,跳转链路清晰。这种场景非常适合影刀自动化&#x…

2026/10/15 13:48:15 阅读更多 →

月新闻

我发现了一个新思路:用 Remotion + Claude Code 像写代码一样自动化生成短视频

我发现了一个新思路:用 Remotion + Claude Code 像写代码一样自动化生成短视频

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/15 0:14:36 阅读更多 →
Windows下 Codex 中 Chrome 和 Computer Use 插件不可用问题排查及解决参考方式:TaoToken 统一 Key 配置与验证

Windows下 Codex 中 Chrome 和 Computer Use 插件不可用问题排查及解决参考方式:TaoToken 统一 Key 配置与验证

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/14 22:45:47 阅读更多 →
黑夜航拍船只数据集训练YOLOV5模型全流程解析

黑夜航拍船只数据集训练YOLOV5模型全流程解析

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/15 9:49:14 阅读更多 →