CO2 emission assessment and optimization

JOpt.TourOptimizer calculates the CO2 emission of each route and of the whole plan, and it can include the emission in the optimization goal. This guide covers the default emission factor, how to set a factor per vehicle, and the weight that makes CO2 part of the cost. It is written for developers who model fleets; if you are new to JOpt.TourOptimizer, start with the first optimization.
What it does
JOpt.TourOptimizer has a built-in emission assessment and an optional CO2 optimization goal for fleet operators. It calculates the emission of a route as the driven distance times the emission factor of the vehicle, one factor per vehicle; the load on board does not change it. With the CO2 goal, the emission becomes part of the route cost, so the optimizer prefers shorter distances and vehicles with a lower factor.
Default emission factor
By default, a vehicle in JOpt.TourOptimizer has a CO2 emission factor of 0.377 [kg*CO2/km]. With 2.629 kg of CO2 per litre of diesel, the diesel factor of the code below and of the CO2 emission optimization example, this is about 14.3 litres of diesel per 100 km (0.377 / 2.629 = 0.143 litres per km). A vehicle that drives 500 kilometres therefore emits 188.5 kilograms of CO2. The CO2 emission value is part of the individual route result header.
Reporting and optimization goal
By default, the CO2 feature is a reporting feature: the emission factors of the vehicles do not affect the optimization result. With the weight JOptWeight.CO2Emission set above zero, the optimizer prefers schedules with a lower overall CO2 emission (see How to use it). Time windows, load capacities, working times and the other planning goals still count in the cost.
When to use it
Use the assessment to report emissions per route and in total, and the weight when the plan should prefer vehicles with a lower emission.
Heavy-duty vehicles (lorries, buses and coaches) are responsible for more than a quarter of the greenhouse gas emissions from road transport in the EU and for over 6% of the total EU greenhouse gas emissions (European Commission: Lorries, buses and coaches). On 20 June 2019, the European Parliament and the Council adopted Regulation (EU) 2019/1242 setting CO2 emission standards for heavy-duty vehicles, with targets for reducing the average emissions from new lorries for 2025 and 2030.
How to use it
Set a custom emission factor
The emission factor is a function of the vehicle type, the fuel type, the amount of goods it carries, and more. Set it for each vehicle.
The following code defines two vehicles: one has a fuel consumption of 25 litres of diesel per 100 km, the other 8 litres of petrol per 100 km.
double fuelConsumptionVehicleOne = 25.0 / 100; // Litre Diesel per 1 km
double fuelConsumptionVehicleTwo = 8.0 / 100; // Litre petrol per 1 km
double co2FactorDiesel = 2.629; // kg/l
double co2FactorPetrol = 2.362; // kg/l
// Define the Resource
IResource vehicleOne =
new CapacityResource(...);
vehicleOne.setAverageCO2EmissionFactor(fuelConsumptionVehicleOne * co2FactorDiesel);
// Define the Resource
IResource vehicleTwo =
new CapacityResource(...);
vehicleTwo.setAverageCO2EmissionFactor(fuelConsumptionVehicleTwo * co2FactorPetrol);
Use the CO2 emission as an optimization goal
Set the weight JOptWeight.CO2Emission to a value above zero, for example 10:
props.setProperty("JOptWeight.CO2Emission", "10.0");
The optimizer then tries to reduce the overall CO2 emission during the optimization run, which usually leads to more use of vehicles with a lower CO2 emission factor.
CO2 in the JSON input of the REST service
In the JSON input of the REST service, the resource field co2emissionFactor holds the emission factor, and the key JOptWeight.CO2Emission goes into optimizationOptions.properties. The API reference shows the schema.
Properties
| Property key | Description |
|---|---|
JOptWeight.CO2Emission | The weight of the CO2 emission in the optimization. A higher value gives a higher cost penalty for using resources with a high CO2 emission. |
Optimization properties lists its default.
Limits
- Without a positive
JOptWeight.CO2Emission, the emission factors change the report only, not the plan. - With the weight, there is a break-even for vehicles with a lower emission factor: for example, when such a vehicle is very expensive, when its starting location does not match the nodes that need to be visited, or because of other restrictions.
Related examples
- CO2 emission optimization: the example explained, with two vehicles of different emission factors and a fixed cost
- CO2EmissionOptimizationExample.java: the source of the example
Related pages
- First optimization: a complete optimization step by step, with the result header
- Optimization properties: the property keys by category, with their defaults
- Contact: questions about your use case
Authors
DNA Evolutions GmbH
Added: 2026-01-03 (JOpt core 7.5.2-j17) | Last updated: 2026-10-23
Clustering during construction
How SmartConstructionAlgo, the default construction algorithm of JOpt, builds the starting solution from clusters, and result maps of three examples.
Comparison tool
The comparison tool of JOpt modifies an optimization result and compares the original and the modified result by cost and by constraint violations.