Skip to content

This repository implements a novel approach to the NP-hard crop rotation problem. Developed using the D-Wave Ocean SDK, it maps agricultural variables into a Quantum-Native format (DQM) to find optimal low-energy configurations. The framework balances productivity with ecological sustainability, ensuring nutrient preservation, etc.

License

Notifications You must be signed in to change notification settings

MohanKrishnaGR/Farm-Optimization---QC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crop Schedule Management using Quantum Optimization Techniques

Python Version License Status


📄 Abstract

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 ($\approx 82.8%$) while strictly enforcing biological planting windows, growth continuity, and spatial pest-control constraints (crop family separation). This work demonstrates the practical viability of Noisy Intermediate-Scale Quantum (NISQ) technologies in solving complex agro-ecological optimization problems.

📐 Mathematical Formulation

The crop rotation problem is modeled as a constraint satisfaction and optimization problem. We define a discrete time horizon $T$ and a set of farm plots $P$. The goal is to assign a crop $c \in C$ (or no crop) to each plot $p \in P$ at each time step $t \in T$.

Objective Function

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:

$$ \min \left( \sum_{p=1}^{|P|} \sum_{t=1}^{|T|} \sum_{c=1}^{|C|} -G_c \cdot x_{p,t,c} \right) $$

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$.

Constraints

The solution space is restricted by the following constraints, enforced via quadratic penalties (Lagrange multipliers $\gamma$):

  1. Exclusivity: At most one crop can occupy a specific plot at any given time.

$$\sum_{c} x_{p,t,c} \le 1, \quad \forall p, t$$

  1. Growth Continuity: If a crop starts at time $t$, it must occupy the plot for its full duration $G_c$.

  2. Planting Windows: A crop $c$ can only be planted if $t \in [Start_c, End_c]$.

  3. 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)$$

🧩 Methodology

Discrete Quadratic Model (DQM)

Unlike Binary Quadratic Models (BQM) which use qubits as binary variables ($0$ or $1$), this approach utilizes Discrete Quadratic Models (DQM). In a DQM, a variable can take one of several discrete values (representing different crop choices), which maps more naturally to the multi-class nature of crop selection.

Hybrid Solver Architecture

The problem is solved using D-Wave's LeapHybridDQMSampler. This hybrid workflow decomposes the large optimization problem:

  1. Decomposition: Breaking the problem into smaller sub-problems.
  2. Quantum Annealing: Submitting sub-problems to the Quantum Processing Unit (QPU) to find low-energy states.
  3. Classical Tabu Search: Refining the results classically to ensure constraint satisfaction.

📂 Repository Structure

├── 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)

🛠️ Installation & Reproduction

Prerequisites

Setup

  1. Environment Preparation:

    git clone https://github.com/your-username/Farm-Optimization-QC.git
    cd Farm-Optimization-QC
    pip install -r requirements.txt
  2. D-Wave Configuration: Configure your environment with your Leap API token to enable cloud dispatch.

    dwave setup
  3. Execution: Run the solver on the provided dataset.

    python crop.py --path problem1.yaml --verbose

📊 Experimental Results

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.

📚 References

This work builds upon foundational research in agricultural optimization and quantum computing applications:

  1. L. M. R. dos Santos et al., "Crop rotation scheduling with adjacency constraints," Annals of Operations Research, vol. 190, pp. 165–180, 2021.
  2. K. Barati et al., "Cropping Pattern Optimization Using System Dynamics Approach," J. Agr. Sci. Tech., vol. 22, 2020.
  3. C. Maraveas et al., "Harnessing Quantum Computing for Smart Agriculture," Computers and Electronics in Agriculture, vol. 218, 2024.
  4. D-Wave Systems, "Discrete Quadratic Model (DQM) Solver Documentation," Ocean SDK Docs, 2023.

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

This repository implements a novel approach to the NP-hard crop rotation problem. Developed using the D-Wave Ocean SDK, it maps agricultural variables into a Quantum-Native format (DQM) to find optimal low-energy configurations. The framework balances productivity with ecological sustainability, ensuring nutrient preservation, etc.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages