Iteration 0 - OR_EXPERT
Sequence: 1
Timestamp: 2025-07-27 22:18:48

Prompt:
You are an Operations Research (OR) expert focused ONLY on optimization modeling. Your role is to analyze the business domain and design LINEAR optimization problems without involving database design decisions.

CRITICAL MATHEMATICAL CONSTRAINTS FOR LINEAR/MIXED-INTEGER PROGRAMMING:
- The optimization problem MUST be either Linear Programming (LP) or Mixed-Integer Programming (MIP)
- Objective function MUST be linear: minimize/maximize ∑(coefficient × variable)
- All constraints MUST be linear: ∑(coefficient × variable) ≤/≥/= constant
- Decision variables can be continuous (LP) or mixed continuous/integer (MIP)
- NO variable products, divisions, or other nonlinear relationships
- Design business scenarios that naturally lead to linear mathematical formulations
- Generate between 2 and 20 constraints for optimization feasibility

YOUR SCOPE: Focus exclusively on optimization modeling and understanding current schema-to-optimization mapping. Do NOT propose database changes.
ROW COUNT AWARENESS: Be aware that data engineer will apply 3-row minimum rule - tables unable to generate sufficient meaningful rows will be moved to business_configuration_logic.json.

CRITICAL: Respond with ONLY a valid JSON object. No explanations, no markdown, no extra text.

Database: farm

```sql
CREATE TABLE city (
  City_ID NUMBER,
  Official_Name TEXT,
  Status TEXT,
  Area_km_2 NUMBER,
  Population NUMBER,
  Census_Ranking TEXT
);
```

```sql
CREATE TABLE farm (
  Farm_ID NUMBER,
  Year NUMBER,
  Total_Horses NUMBER,
  Working_Horses NUMBER,
  Total_Cattle NUMBER,
  Oxen NUMBER,
  Bulls NUMBER,
  Cows NUMBER,
  Pigs NUMBER,
  Sheep_and_Goats NUMBER
);
```

```sql
CREATE TABLE farm_competition (
  Competition_ID NUMBER,
  Year NUMBER,
  Theme TEXT,
  Host_city_ID NUMBER,
  Hosts TEXT
);
```

```sql
CREATE TABLE competition_record (
  Competition_ID NUMBER,
  Farm_ID NUMBER,
  Rank NUMBER
);
```



Current Business Configuration Logic: {} (initially empty)

TASK: Design a realistic LINEAR optimization problem and analyze how it maps to the current schema.

JSON STRUCTURE REQUIRED:

{
  "database_id": "farm",
  "iteration": 0,
  "business_context": "Describe the realistic business scenario that leads to linear optimization (avoid scenarios requiring nonlinear relationships)",
  "optimization_problem_description": "Detailed description of what needs to be optimized using linear objective functions and constraints",
  "optimization_formulation": {
    "objective": "minimize/maximize specific_linear_metric with clear definition (sum of weighted variables only)",
    "decision_variables": "What linear variables can be controlled/decided (continuous or integer)",
    "constraints": "What linear limitations must be respected (no variable products or divisions) - design 2 to 20 constraints"
  },
  
  "current_optimization_to_schema_mapping": {
    "objective_coefficients": {
      "coefficient_name[indices]": {
        "currently_mapped_to": "table.column OR business_configuration_logic.key OR missing",
        "mapping_adequacy": "good/missing/redundant/partial/inaccurate",
        "description": "what this coefficient represents in the optimization model"
      }
    },
    "constraint_bounds": {
      "constraint_name[indices]": {
        "currently_mapped_to": "table.column OR business_configuration_logic.key OR missing", 
        "mapping_adequacy": "good/missing/redundant/partial/inaccurate",
        "description": "what this constraint bound represents"
      }
    },
    "decision_variables": {
      "variable_name[indices]": {
        "currently_mapped_to": "table.column OR business_configuration_logic.key OR missing",
        "mapping_adequacy": "good/missing/redundant/partial/inaccurate", 
        "description": "what this decision variable represents",
        "variable_type": "continuous/integer/binary"
      }
    }
  },
  
  "missing_optimization_requirements": [
    "List what data/parameters are needed for complete linear optimization model"
  ],
  
  "iteration_status": {
    "complete": false,
    "confidence": "low/medium/high",
    "next_focus": "What optimization aspects need refinement"
  }
}

Response:
{
  "database_id": "farm",
  "iteration": 0,
  "business_context": "A farm wants to optimize the allocation of its livestock resources to maximize the total number of competitions won across different years.",
  "optimization_problem_description": "The farm aims to determine the optimal number of each type of livestock (horses, cattle, pigs, sheep, and goats) to allocate to competitions each year to maximize the total number of competitions won, subject to the availability of livestock and competition participation constraints.",
  "optimization_formulation": {
    "objective": "maximize total_competitions_won = \u2211(win_coefficient[Competition_ID, Farm_ID] \u00d7 participation[Competition_ID, Farm_ID])",
    "decision_variables": "participation[Competition_ID, Farm_ID] (binary) indicating whether the farm participates in a competition",
    "constraints": [
      "\u2211(Working_Horses[Year] \u00d7 participation[Competition_ID, Farm_ID]) \u2264 Total_Horses[Year] for each Year",
      "\u2211(Oxen[Year] \u00d7 participation[Competition_ID, Farm_ID]) \u2264 Total_Cattle[Year] for each Year",
      "\u2211(Pigs[Year] \u00d7 participation[Competition_ID, Farm_ID]) \u2264 Pigs[Year] for each Year",
      "\u2211(Sheep_and_Goats[Year] \u00d7 participation[Competition_ID, Farm_ID]) \u2264 Sheep_and_Goats[Year] for each Year",
      "participation[Competition_ID, Farm_ID] \u2208 {0, 1} for each Competition_ID, Farm_ID"
    ]
  },
  "current_optimization_to_schema_mapping": {
    "objective_coefficients": {
      "win_coefficient[Competition_ID, Farm_ID]": {
        "currently_mapped_to": "competition_record.Rank",
        "mapping_adequacy": "partial",
        "description": "represents the potential win impact of participating in a competition"
      }
    },
    "constraint_bounds": {
      "Total_Horses[Year]": {
        "currently_mapped_to": "farm.Total_Horses",
        "mapping_adequacy": "good",
        "description": "total number of horses available in a given year"
      },
      "Total_Cattle[Year]": {
        "currently_mapped_to": "farm.Total_Cattle",
        "mapping_adequacy": "good",
        "description": "total number of cattle available in a given year"
      },
      "Pigs[Year]": {
        "currently_mapped_to": "farm.Pigs",
        "mapping_adequacy": "good",
        "description": "total number of pigs available in a given year"
      },
      "Sheep_and_Goats[Year]": {
        "currently_mapped_to": "farm.Sheep_and_Goats",
        "mapping_adequacy": "good",
        "description": "total number of sheep and goats available in a given year"
      }
    },
    "decision_variables": {
      "participation[Competition_ID, Farm_ID]": {
        "currently_mapped_to": "missing",
        "mapping_adequacy": "missing",
        "description": "binary variable indicating if a farm participates in a competition",
        "variable_type": "binary"
      }
    }
  },
  "missing_optimization_requirements": [
    "Data on the win coefficient for each competition and farm combination",
    "Historical data on livestock allocation to competitions"
  ],
  "iteration_status": {
    "complete": false,
    "confidence": "medium",
    "next_focus": "Refine the mapping of decision variables and obtain missing data for win coefficients"
  }
}
