The recommendation engine uses a deterministic multi-criteria scoring algorithm that evaluates efficiency, traction, soil compatibility, economics, and availability to rank tractors from 0-100 points.
Overview
The MaqAgr recommendation system acts as an “agricultural matchmaker” that analyzes your terrain, implement requirements, and available tractors to suggest the optimal equipment for your operation. Key Features:- ✅ Multi-factor scoring (efficiency, traction, soil, economics, availability)
- ✅ Mandatory 4WD detection for steep slopes (>15%)
- ✅ Penalizes over-powered tractors (fuel waste)
- ✅ Considers soil-traction compatibility
- ✅ Ownership validation (users only access their terrains)
The Recommendation Algorithm
Scoring Weights
Each tractor receives a score from 0-100 points based on five weighted criteria:| Criterion | Weight | Description |
|---|---|---|
| Efficiency | 30% | Penalizes over-dimensioning (fuel waste) |
| Traction | 25% | Bonus for 4WD on slopes, penalizes 2WD |
| Soil | 20% | Tire/track compatibility with soil type |
| Economic | 15% | Prefers lower power (when adequate) |
| Availability | 10% | Tractor status (available, in-use, maintenance) |
Weights are configured in
SCORING_CONFIG and sum to exactly 100%.Scoring Components
1. Efficiency Score (30 points)
Penalizes tractors with excessive power for the task. Formula:| Power Ratio | Utilization | Score | Interpretation |
|---|---|---|---|
| 1.0 (100%) | 100% | 30 pts | ⭐ Perfect efficiency |
| 1.15 (115%) | 87% | 22.5 pts | ✅ Good match |
| 1.3 (130%) | 77% | 15 pts | ⚠️ Threshold |
| 1.5 (150%) | 67% | 9 pts | ❌ Wasteful |
| 2.0 (200%) | 50% | -6 pts | 🚫 Excessive |
2. Traction Score (25 points)
Rewards appropriate traction systems for terrain conditions. Traction Bonus Matrix:| Traction Type | Flat Terrain | Rolling (5-15%) | Steep (>15%) |
|---|---|---|---|
| 4x4 / 4WD | +5 pts | +15 pts | +25 pts |
| Track (Oruga) | 0 pts | +20 pts | +30 pts |
| 4x2 / 2WD | +10 pts | 0 pts | -50 pts |
Tractors without 4WD are automatically filtered out for slopes >15% (they don’t even reach the scoring phase).Normalization: The bonus range (-50 to +30) is normalized to 0-25 score points:
3. Soil Compatibility Score (20 points)
Evaluates tire/track suitability for soil conditions. Soil Difficulty Index:| Soil Type | Difficulty | Preferred Tire | Description |
|---|---|---|---|
| Sandy (Arena) | 20/100 | Standard | Easy, low resistance |
| Loam (Franco) | 40/100 | Standard | Moderate |
| Clay (Arcilla) | 70/100 | Track | Difficult, sticky |
| Rocky (Rocoso) | 85/100 | Reinforced | Very difficult |
| Wet Clay | 95/100 | Track | Extreme conditions |
Tire Match Bonus
- Track on clay/wet_clay: 20 pts (maximum)
- Reinforced tires on rocky: 18 pts
- Standard on loam/sandy: 16 pts
4. Economic Score (15 points)
Prefers tractors with adequate but not excessive power (lower operating costs). Logic:- Tractor A: 110 HP → ratio = 100/110 = 0.909 → 13.6 pts
- Tractor B: 150 HP → ratio = 100/150 = 0.667 → 10.0 pts
5. Availability Score (10 points)
Simple status-based scoring:| Status | Score | Description |
|---|---|---|
available / active | 10 pts | Ready to use |
in_use / maintenance | 5 pts | Limited availability |
unavailable / inactive | 0 pts | Cannot use |
Filtering Process
Before scoring, tractors pass through cascading filters:Classification Labels
Tractors are classified based on power utilization percentage:| Utilization | Label | Description | Emoji |
|---|---|---|---|
| ≥85% | OPTIMAL | Perfect power match | ✅ |
| 70-84% | GOOD | Good balance | 👍 |
| 50-69% | OVERPOWERED | Over-dimensioned | ⚠️ |
| <50% | EXCESSIVE | Wastefully over-sized | ❌ |
API Endpoint
Generate Recommendations
Generates top 5 ranked tractor recommendations.Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
terrain_id | integer | Yes | ID of the terrain (must belong to user) |
implement_id | integer | Yes | ID of the implement |
working_depth_m | number | No | Working depth override (m) |
work_type | string | No | Type: tillage, planting, harvesting, transport, general |
Response
The API persists the top 3 recommendations to the database for historical tracking. All 5 are returned in the response.
Error Responses
401 Unauthorized - User not authenticated:Real-World Example
Scenario:- Terrain: Highland farm, 18% slope, clay soil
- Implement: Heavy-duty chisel plow, 95 HP base requirement
- Required Power: 156.7 HP (after soil/slope/depth/safety factors)
| ID | Model | Power | Traction | Status |
|---|---|---|---|---|
| 3 | Case IH Puma 185 | 185 HP | 4x4 | available |
| 7 | New Holland T6.175 | 175 HP | 4x4 | available |
| 11 | Massey Ferguson 7718 | 180 HP | 4x4 | in_use |
| 15 | John Deere 6145M | 145 HP | 4x2 | available |
| 22 | Valtra N174 | 174 HP | 4x4 | available |
Power Filter
- John Deere 6145M (145 HP): REJECTED - Insufficient power (145 < 156.7)
- All others: PASS
Traction Filter (Critical)
Slope = 18% (STEEP) → 4WD MANDATORY
- John Deere 6145M: Would be rejected here too (4x2)
- All others: PASS (all are 4x4)
- 🥇 New Holland T6.175 - 78.0 pts (OPTIMAL, 89.5% utilization)
- 🥈 Valtra N174 - 77.8 pts (OPTIMAL, 90.1% utilization)
- 🥉 Case IH Puma 185 - 74.8 pts (GOOD, 84.7% utilization)
- Massey Ferguson 7718 - 69.2 pts (availability penalty)
“Alta eficiencia energética (89.5% utilización). Tracción óptima para pendiente pronunciada. Buen balance potencia/necesidad.”
Recommendation History
Get History
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number |
limit | integer | 10 | Records per page (max: 50) |
work_type | string | - | Filter: tillage, planting, harvesting, transport, general |
Response
Get Recommendation by ID
Response
Code Reference
The recommendation engine is implemented across multiple files:- Controller:
src/controllers/recommendationController.js:141(generateRecommendation) - Service:
src/services/recommendationService.js:542(generateRecommendation) - Scoring:
src/services/recommendationService.js:480(calculateScore) - Terrain Analysis:
src/services/recommendationService.js:157(analyzeTerrain) - Model:
src/models/Recommendation.js - Routes:
src/routes/recommendation.routes.js:139
src/services/recommendationService.js:91):
Best Practices
Always validate terrain ownership
Always validate terrain ownership
The API automatically checks that
terrain_id belongs to the authenticated user. This prevents unauthorized access to other users’ data.Trust the 4WD rule
Trust the 4WD rule
The algorithm automatically rejects 2WD tractors for slopes >15%. This is a safety rule based on agricultural engineering standards.
Consider the top 3, not just #1
Consider the top 3, not just #1
The top 3 recommendations are often very close in score. Consider operational factors (availability, location, cost) when making the final decision.
Update tractor availability
Update tractor availability
Keep tractor
status fields updated for accurate availability scoring.Use work_type for better tracking
Use work_type for better tracking
Specify
work_type (tillage, planting, etc.) to enable better historical analysis and filtering.Related Topics
Power Loss Calculations
Physics-based power loss analysis
Terrains API
Manage terrain profiles
Tractors API
Tractor catalog operations
Implements API
Agricultural implement management
