mcpField
O
optimization-ml-hybrid

optimization-ml-hybrid

github.com/kishorkukrejaデータ・データベース8451 回インストール3 週間前に更新
リポジトリ

optimization-ml-hybrid について

サプライチェーン向けに、機械学習と数理最適化を組み合わせるスキルです。予測値や学習したパラメーター、ヒューリスティックをモデルに取り込み、エンドツーエンド学習やニューラルネットワークによる初期解生成、GNNルーティングも扱います。

主な機能

  1. 01ML予測を最適化モデルに入力
  2. 02データから最適化パラメーターを学習
  3. 03エンドツーエンドの微分可能な最適化層
  4. 04ニューラルネットワークで初期解を生成
  5. 05GNNでルーティングのヒューリスティックを学習

活用シーン

  1. 01需要予測を生産計画に反映
  2. 02履歴データから安全在庫パラメーターを推定
  3. 03最適化の初期候補を生成
  4. 04ルーティング問題のヒューリスティックを学習

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/kishorkukreja/awesome-supply-chain --skill optimization-ml-hybrid

インストール後、Claude Code で/optimization-ml-hybridを入力して読み込まれたか確認します。

詳細

最適化と機械学習のハイブリッドアプローチ

サプライチェーン向けに、機械学習と数理最適化を組み合わせる専門家です。目標は、機械学習の予測を最適化モデルに統合し、最適化パラメーターを学習して、エンドツーエンドの学習システムを構築することです。

主なパターン

1. 予測してから最適化
# Step 1: ML predicts demand
demand_forecast = ml_model.predict(features)

# Step 2: Optimization uses forecast
optimal_production = optimize_production(demand_forecast)
2. 最適化パラメーターへの機械学習の活用
# Learn optimal parameters from data
safety_stock = ml_model.predict([sku_features, demand_history])

# Use in inventory optimization
reorder_point = expected_demand_during_leadtime + safety_stock
3. エンドツーエンド学習
# Differentiable optimization layer
class OptimizationLayer(nn.Module):
    def forward(self, predictions):
        # Solve optimization with predictions
        # Backpropagate through optimization
        return optimal_decisions

スマートな予測先行型最適化

from sklearn.ensemble import RandomForestRegressor
from pulp import *

class PredictThenOptimize:
    """
    ML forecasting + Optimization planning
    """
    
    def __init__(self):
        self.ml_model = RandomForestRegressor()
        self.opt_model = None
    
    def train_ml(self, X_train, y_train):
        """Train ML forecast model"""
        self.ml_model.fit(X_train, y_train)
    
    def optimize_with_forecast(self, features, costs):
        """Optimize using ML predictions"""
        
        # Step 1: Predict demand
        demand_forecast = self.ml_model.predict(features)
        
        # Step 2: Optimize production
        model = LpProblem("Production", LpMinimize)
        
        products = range(len(demand_forecast))
        produce = LpVariable.dicts("Prod", products, lowBound=0)
        
        # Objective: minimize cost
        model += lpSum([costs[i] * produce[i] for i in products])
        
        # Constraints: meet forecasted demand
        for i in products:
            model += produce[i] >= demand_forecast[i]
        
        model.solve()
        
        return {i: produce[i].varValue for i in products}

最適化ヒューリスティクスの学習

class MLOptimizationHeuristic:
    """
    Learn when to apply optimization heuristics
    """
    
    def __init__(self):
        self.classifier = RandomForestClassifier()
    
    def train(self, problem_features, best_heuristic_labels):
        """
        Learn which heuristic works best for problem instance
        """
        self.classifier.fit(problem_features, best_heuristic_labels)
    
    def select_heuristic(self, problem_instance):
        """Predict best heuristic for new problem"""
        features = extract_features(problem_instance)
        heuristic_id = self.classifier.predict([features])[0]
        
        return HEURISTICS[heuristic_id]

ニューラルネットワークによるウォームスタート

def neural_warm_start(model, problem_instance):
    """
    Use NN to generate initial solution for optimization
    """
    
    # NN predicts good initial solution
    features = extract_features(problem_instance)
    initial_solution = nn_model.predict(features)
    
    # Use as warm start in MIP
    for var_name, value in initial_solution.items():
        model.variables[var_name].setInitialValue(value)
    
    model.solve()

ルーティングのためのグラフニューラルネットワーク

class GNNRouter:
    """
    GNN to learn routing heuristics
    """
    
    def __init__(self):
        self.gnn = GraphNeuralNetwork()
    
    def embed_vrp_instance(self, customers, depot):
        """Convert VRP to graph"""
        
        # Nodes: customers + depot
        # Edges: distances
        graph = create_graph(customers, depot)
        
        return graph
    
    def predict_route(self, graph):
        """
        GNN predicts edge probabilities
        Use to construct route
        """
        
        edge_probs = self.gnn(graph)
        route = construct_route_from_probs(edge_probs)
        
        return route

ツールとライブラリ

  • cvxpylayers:微分可能な最適化
  • OptNet:ニューラルネットワーク層としての最適化
  • qpth:PyTorch 用 QP 層
  • SciPy + PyTorch:カスタム統合

関連スキル

  • optimization-modeling:数理計画法
  • ml-supply-chain:機械学習
  • **metaheuristic-optimization`:ヒューリスティクス
  • reinforcement-learning-supply-chain:強化学習の統合

コメント