Yes, dimensions are not related to each other in the code. That is
not what I am suggesting. What I am saying is that you, the modeler,
have to decide what it means to optimize both dimensions at once.
There are always tradeoffs, and you have to make that choice.
In the CP-SAT side of the fence, you have to make your own objective
function, so that is more obvious. In routing model land, the
objective is hidden behind API calls.
What I would do is to use maybe SetSpanCostCoefficientForVehicle
https://developers.google.com/optimization/reference/python/constraint_solver/pywrapcp#setspancostcoefficientforvehicle
To quote the docs,
"The cost for a vehicle is
span_cost = coefficient * (dimension end value - dimension start value)."
That gets lumped into the objective and minimized, so it is not useful
for maximizing (the coefficient can't be negative).
Since I think you want to maximize customer value, maybe you can do a
tricky hack with SetCumulVarSoft[Lower|Upper]Bound on
the end nodes for each vehicle
https://developers.google.com/optimization/reference/python/constraint_solver/pywrapcp#setcumulvarsoftlowerbound
(Set upper bound to zero to mimic minimizing, set lower bound to a
large number to mimic maximizing)
something like:
```python
impossible_customer_value = 1000
customer_value_factor = 2
for vehicle_id in range(manager.GetNumberOfVehicles()):
end_index = routing.End(vehicle_id)
customervaluedim.SetCumulVarSoftLowerBound(end_index,
impossible_customer_value,
customer_value_factor)
```
That is a little bit convoluted, and you can probably do better if you
think longer about it that I just did, but the idea is that the solver
will never be able to assign a high enough total customer value to hit
"impossible_customer_value", so the difference will be multiplied by the
factor and minimized.
What I was talking about in my earlier messages was the factors in
both of those API calls. Those factors are the rule to convert one
dimension into equivalent units of another dimension. If one unit of
customer value really is equal to one second, then the factor can be
1 (assuming your time is in seconds).
But an economist would recommend converting total_travel dimensions
into dollars (or equiv), and the same for customer value, then the
statement
minimize(total_travel +
Sum_all(i){factor_i*(impossible_customer_value - customer_value_i)})
(for all vehicles i)
will make sense, rather than being mostly useless.
> --
> You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
or-tools-discu...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/or-tools-discuss/ad796d1e-cd0d-4706-a055-3870a42ef0d9n%40googlegroups.com.
--
James E. Marca
Activimetrics LLC