优化算法

This commit is contained in:
2025-11-26 22:41:38 +08:00
parent 5ad403bf86
commit 5bd52df240

View File

@@ -171,10 +171,9 @@ func (r *recipeGenerateManagerImpl) GenerateRecipe(ctx context.Context, pigType
continue
}
// 只有当 MaxAdditionRatio >= 0 时才添加约束。
// 如果 MaxAdditionRatio 为 0表示该原料最大添加比例为 0%,即不能添加
// 如果 MaxAdditionRatio 为正数,则为实际限制。
if mat.MaxAdditionRatio >= 0 {
// 只有当 MaxAdditionRatio > 0 时才添加约束。
// 如果 MaxAdditionRatio 为 0 或负数,则表示该原料没有最大添加比例限制
if mat.MaxAdditionRatio > 0 {
materialColIndex, ok := materialIndex[mat.ID]
if !ok {
return nil, fmt.Errorf("内部错误:未找到原料 %d (%s) 的列索引", mat.ID, mat.Name)