Skip to content

2423gen-stack/microforce-shift

Repository files navigation

Microforce Shift Scheduler (PoC)

English Version | 日本語版


🇬🇧 English Version

A Proof of Concept (PoC) model that resolves the NP-Hard shift scheduling problem (Nurse Rostering Problem) in effectively O(1) time by leveraging a "Semantic Engine (LLM)" rather than traditional search algorithms.

Overview

This project is a scheduling tool designed to instantly construct an optimal solution (a matrix) by fully comprehending natural language rules—including complex human relations and unique workplace policies—that are otherwise impossible to hardcode.

In the currently deployed demo, input conditions are fixed (pre-loaded) to ensure the safety of public access. However, by running this repository in your local environment, you can test its astonishing processing power with any complex conditions you desire.

Why Existing Shift Management SaaS "Doesn't Work"

Most existing shift management tools, which businesses pay thousands to tens of thousands of yen monthly to use, can collect availability requests via smartphone, but they fundamentally fail to automate the core intellectual task: "who to place where." As a result, store managers are forced into a late-night puzzle game in the backroom, spending hours manually dragging and dropping blocks on a screen while groaning, "A and B don't get along, so I can't put them together," or "If I put C here, they'll exceed the 40-hour legal limit."

Existing mathematical optimization solvers (like Gurobi or CPLEX) understand numerical constraints but fail to interpret "ambiguous, human-like constraints." Attempting to define such rules within traditional settings screens becomes impractically complex.

The Magic: Abandoning the Search Space for Semantic Optimization

This tool does not perform maze-like searches (combinatorial explosion) such as backtracking. Instead of navigating the vast ocean of combinations—30 staff members × 7 days × multiple shifts—it oversees the constraints from the high-dimensional semantic space of an LLM (Gemini). It pinpoints "the single point where all conditions intersect without contradiction" with an O(1) inference latency. The "30 seconds" it takes in the demo is not computing (searching) time; it is merely the generation time required for the API to type out the resulting string.

The True Significance of "Placing AI Behind an API"

The true value of next-generation architecture lies not in using AI as a chatbot, but in embedding AI behind an API as a pure reasoning engine within the system.

This allows unstructured, natural language rules (e.g., "Don't schedule A with B"), which were absolutely impossible to implement in traditional systems, to be poured from the frontend through an API. The AI interprets them and instantly returns a strict JSON structure (matrix) that the system can directly render. Integrating AI not as a "chat partner," but as a "highly flexible, ultra-fast black-box function replacing traditional algorithms"—this is the core purpose of this system.

Future Potential: Conversational Capability as a "Vice-Manager"

While this PoC focuses on the sheer amazement of "solving it in one shot," the true potential of this architecture lies in its behavior when conditions are "Unsatisfiable."

Traditional software coldly halts with an "Error: Infeasible" when given contradictory rules (e.g., forcing everyone to take a day off). However, this engine, which understands the meaning of words, can easily be extended to return suggestions to the frontend instead of crashing:

"To satisfy Rule D during Friday's dinner peak, you are short 1 core member. We could ask Staff X (who normally cannot work late) as a one-time exception, or we could shift Staff Y (who requested weekends) to Friday. Which offer would you like to make?"

This signifies an evolution from a mere puzzle-solving tool to a "brilliant vice-manager" who thinks and proposes solutions alongside the store manager.

How to Run Locally

You can instantly spin up a production-equivalent environment using Docker.

  1. Clone this repository.
  2. Obtain a Gemini API key (capable of using models like gemini-flash-latest) from Google AI Studio.
  3. Create a .env file in the root directory and place your API key:
    GEMINI_API_KEY=AIzaSyYourAPIKeyHere...
  4. Start the container with Docker Compose:
    docker-compose up -d --build
  5. Access http://localhost:8081 in your browser.
  6. (To test custom conditions) Edit the sampleConstraints array in frontend/js/app.js to throw your own grueling constraints at the engine.


🇯🇵 日本語版

NP困難なシフトスケジューリング問題(ナース・スケジューリング問題)を、探索アルゴリズムではなく「セマンティック・エンジン(LLM)」によってO(1)で解き伏せるための概念実証(Proof of Concept)モデル。

概要 (Overview)

本プロジェクトは、店舗や現場における「複雑な人間関係や独自のルールが絡むシフト作成」を、自然言語のまま丸呑みして瞬時に最適解(マトリクス)を構築するスケジューリング・ツールです。

現在のデモ稼働版では、パブリックアクセスの安全性を担保するため入力条件を固定(プリロード)していますが、ローカル環境で本リポジトリを稼働させることで、任意の複雑な条件でその驚異的な処理能力を検証することができます。

なぜ既存のシフト管理SaaSは「使えない」のか?

数千円〜数万円を支払って導入する既存のシフト管理ツールの大半は、希望休をスマホから集めることはできても、「誰をどこに配置するか」という最も知的な作業はシステムで完結できません。 結局、店長は深夜のバックヤードで**「AさんとBさんは仲が悪いからダメ」「ここでCさんを入れると週40時間の法定上限を超える」とウンウン唸りながら、画面上のブロックを何時間も手作業で入れ替えるパズルゲーム**を強要されています。

既存の数理最適化ソルバー(GurobiやCPLEX等)は、数字の制約は理解できても「人間臭い曖昧な制約」を解釈できないため、設定画面でのルール定義自体が非現実的なほど複雑化してしまうからです。

The Magic: 探索空間の放棄とセマンティックな最適化

本ツールは、バックトラッキングのような迷路の探索(組み合わせ爆発)を行いません。 スタッフ30名×7日間×複数シフトという広大な組み合わせの海を、LLM(Gemini)の高次元意味空間で俯瞰し、「すべての条件が矛盾なく交差する一点」をO(1)の推論レイテンシで直接ピンポイントに確定させます。 デモでかかっている「30秒」という時間は、計算(探索)している時間ではなく、単にAPIが解答の文字列をタイピングしている生成時間に過ぎません。

本プロジェクトにおける「API越しにAIを配置する」真の意義

チャットボットとしてAIを使うのではなく、**「APIの裏側に推論エンジンとしてAIを配置し、システムに組み込むこと」**にこそ、次世代アーキテクチャの真価があります。

従来のシステムでは絶対に実装不可能だった「不定形の自然言語ルール(AさんはBさんと組ませないで等)」をフロントエンドからAPI経由で流し込み、AIがそれを解釈して、システムが直接レンダリング可能な「厳密なJSON構造(マトリクス)」として即座に返却する。 AIを「おしゃべり相手」ではなく「従来のアルゴリズムを代替する、柔軟で超高速なブラックボックスの関数」としてソフトウェアの部品に組み込むこと。これが本システムの存在意義です。

Future Potential: 限界を超えた「副店長」としての対話能力

本PoCは「一発で解が出る驚き」にフォーカスしていますが、このアーキテクチャの真のポテンシャルは**「条件が破綻している(Unsatisfiable)時の振る舞い」**にあります。

従来のソフトは、全員を休みにするなどの矛盾したルールを入れると「エラー:計算不能」と冷酷に停止します。 しかし、言葉の意味を理解する本エンジンであれば、エラーで停止する代わりに以下のようなサジェストをフロントエンドに返す拡張が極めて容易です。

「金曜日のディナーピークで、ルールDを満たすためのコアメンバーが1名不足しています。本来は深夜不可のスタッフXさんにこの日だけ特例でお願いするか、土日希望のスタッフYさんを金曜にずらすことができれば解決しますが、どちらにオファーを出しますか?」

これは単なるパズル解法ツールから、**店長と共に考え、提案してくれる「優秀な副店長」**への進化を意味します。

起動方法 (How to Run Locally)

本番同等の環境をDockerコンテナで即座に立ち上げることができます。

  1. 本リポジトリをクローンします。
  2. Google AI Studioにて、GeminiのAPIキー(gemini-flash-latest等を利用可能なもの)を取得します。
  3. ルートディレクトリに .env ファイルを作成し、APIキーを配置します。
    GEMINI_API_KEY=AIzaSyYourAPIKeyHere...
  4. Docker Compose でコンテナを起動します。
    docker-compose up -d --build
  5. ブラウザで http://localhost:8081 にアクセスしてください。
  6. (カスタム条件を試す場合)frontend/js/app.js 内の sampleConstraints 配列を書き換えることで、任意の極悪な制約条件をエンジンにぶつけることができます。

Architected by Gen & Cecilia (Microforce Semantic Paradigm)

About

Shift creation tool using multidimensional geometric processing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors