This repository contains the implementation of a Quantum-Inspired Optimization framework for agricultural crop rotation scheduling. Addressing the NP-hard nature of multi-variable resource allocation in farming, this research proposes a formulation based on Discrete Quadratic Models (DQM). By leveraging Quantum Annealing via D-Wave's hybrid solver architecture, the system generates optimal planting schedules that maximize land utilization (
The crop rotation problem is modeled as a constraint satisfaction and optimization problem. We define a discrete time horizon
The primary objective is to maximize the total utilization of the farm plots, defined mathematically as minimizing the negative sum of growth times for active crops:
Where:
-
$x_{p,t,c}$ is a discrete variable equal to 1 if crop$c$ is planted in plot$p$ at time$t$ , and 0 otherwise. -
$G_c$ is the growth duration of crop$c$ .
The solution space is restricted by the following constraints, enforced via quadratic penalties (Lagrange multipliers
- Exclusivity: At most one crop can occupy a specific plot at any given time.
-
Growth Continuity: If a crop starts at time
$t$ , it must occupy the plot for its full duration$G_c$ . -
Planting Windows: A crop
$c$ can only be planted if$t \in [Start_c, End_c]$ . -
Spatial Adjacency (Pest Control): Two adjacent plots (
$p_i, p_j$ ) must not cultivate crops from the same biological family$F$ simultaneously to prevent nutrient depletion and disease spread.$$x_{p_i, t, c_a} \cdot x_{p_j, t, c_b} = 0 \quad \text{if } Family(c_a) = Family(c_b) \text{ and } \text{Adjacent}(p_i, p_j)$$
Unlike Binary Quadratic Models (BQM) which use qubits as binary variables (
The problem is solved using D-Wave's LeapHybridDQMSampler. This hybrid workflow decomposes the large optimization problem:
- Decomposition: Breaking the problem into smaller sub-problems.
- Quantum Annealing: Submitting sub-problems to the Quantum Processing Unit (QPU) to find low-energy states.
- Classical Tabu Search: Refining the results classically to ensure constraint satisfaction.
├── crop.py # Main entry point: Problem loading, DQM construction, and Solving
├── caselabeldqm.py # Wrapper for dimod.DiscreteQuadraticModel handling string labels
├── problem1.yaml # Experimental Dataset: Farm topology, crop definitions, and time windows
├── requirements.txt # Python dependencies (Ocean SDK, Matplotlib, PyYAML)
└── output.png # Visualization of the computed schedule (Generated)
- Python 3.8+
- D-Wave Leap Account (for API Token)
-
Environment Preparation:
git clone https://github.com/your-username/Farm-Optimization-QC.git cd Farm-Optimization-QC pip install -r requirements.txt -
D-Wave Configuration: Configure your environment with your Leap API token to enable cloud dispatch.
dwave setup
-
Execution: Run the solver on the provided dataset.
python crop.py --path problem1.yaml --verbose
Experiments were conducted on a dataset simulating a 9-plot farm over a 20-unit time horizon with 11 distinct crop varieties.
- Solution Quality: The solver consistently converged to valid states with energy levels minimizing the objective function (High Utilization).
- Plot Utilization: Achieved 82.8% efficient land use.
- Constraint Satisfaction: 100% adherence to adjacency and planting window constraints in validated runs.
This work builds upon foundational research in agricultural optimization and quantum computing applications:
- L. M. R. dos Santos et al., "Crop rotation scheduling with adjacency constraints," Annals of Operations Research, vol. 190, pp. 165–180, 2021.
- K. Barati et al., "Cropping Pattern Optimization Using System Dynamics Approach," J. Agr. Sci. Tech., vol. 22, 2020.
- C. Maraveas et al., "Harnessing Quantum Computing for Smart Agriculture," Computers and Electronics in Agriculture, vol. 218, 2024.
- D-Wave Systems, "Discrete Quadratic Model (DQM) Solver Documentation," Ocean SDK Docs, 2023.
This project is licensed under the MIT License - see the LICENSE file for details.