A sophisticated mathematical modeling assistant that leverages advanced language models to iteratively solve, evaluate, and improve mathematical modeling problems.
- Iterative Problem Solving: Multi-round approach combining solution generation, evaluation, and improvement
- Rigorous Mathematical Validation: Strict verification of mathematical correctness and completeness
- LaTeX Support: Full support for mathematical expressions using TeX notation
- Structured Output: Well-organized solution format with summaries and detailed derivations
- Continuous Improvement: Progressive refinement through automated review and enhancement cycles
Model-Agent/
├── api_client.py # API client for model interactions
├── prompt.py # Core system prompts and instructions
├── reasoning.py # Main iterative solving logic
├── api.ENV # API configuration (create from template)
├── problem.txt # Input problem statement
└── extra.txt # Additional requirements/constraints
- Python 3.9+
- Access to a compatible language model API
- Clone the repository:
git clone https://github.com/pancacake/Model-Agent.git
cd Model-Agent- Create and configure your API environment file:
cp api.ENV.template api.ENV
# Edit api.ENV with your API credentials- Place your mathematical modeling problem in
problem.txt - (Optional) Add additional requirements in
extra.txt - Run the solver:
python reasoning.py --rounds 3 --max_tokens 15000--problem_txt: Problem statement file (default: problem.txt)--extra_txt: Additional requirements file (default: extra.txt)--env: API configuration file (default: api.ENV)--rounds: Number of improvement iterations (default: 3)--outdir: Output directory (default: outputs)--run_name: Name for this run (default: run)--max_tokens: Maximum tokens per response (default: 15000)--temperature: Response randomness (default: 0.2)
The system generates three main outputs in the specified output directory:
-
trace.md: Detailed record of each iteration, including:
- SOLVE: Initial solution attempt
- JUDGE: Validation and error identification
- IMPROVE: Enhanced solution based on feedback
-
final.md: The final, polished solution
-
memory.json: Complete execution record including:
- Metadata (rounds, parameters)
- Context (problem, requirements)
- Full iteration history
-
SOLVE Phase
- Constructs rigorous mathematical model
- Provides structured solution with clear assumptions
- Ensures LaTeX formatting for mathematical content
-
JUDGE Phase
- Validates mathematical correctness
- Identifies critical errors and gaps
- Provides detailed verification log
-
IMPROVE Phase
- Addresses identified issues
- Refines mathematical arguments
- Maintains solution coherence
The system enforces:
- Rigorous mathematical reasoning
- Complete step-by-step derivations
- Clear documentation of assumptions
- Proper LaTeX formatting
- Systematic error detection
- Progressive solution improvement
Example run with a basic optimization problem:
python reasoning.py --problem_txt examples/optimization.txt --rounds 2The solution will be generated in outputs/run-TIMESTAMP/ with full iteration history and final solution.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
If you encounter any problems or have suggestions, please open an issue on GitHub.