how to build mathematic formulation for time violation?

46 Views Asked by At

I build a mathematical model to find a multi-objective model for the vehicle platooning problem. I am using the Gurobi optimization tool to build a mathematical model.

The problem I am facing: Create an objective function for a time violation. When trucks travel on their shortest path that means there is no time violation. If the truck travels the longest path that means there will be a time violation. The formula is: time violation = latest arrival time – shortest path arrival time If time violation = 0 that means, there is no time violation for all trucks travelling the shortest path.

The first part of objective function is :

objective_function_second_Ipart = gp.LinExpr()
    for h,_ in group.items():
         for e in road_network.edges():
            objective_function_second_Ipart+=x[e][h]*(road_network.get_edge_data(*e)["weight"]/speed)

h = trucks, e=edges, x= decision variable truck travels on edges

this 1st part of the objective function for truck time takes on each edge.

earliest_arrival_time_each_truck={}
for h, locations in group.items():
   earliest_arrival_time_each_truck[h] = nx.dijkstra_path_length(road_network, source=locations[0], target=locations[1])/speed

next part objective function compares our first part truck time to shortest path time(earliest_arrival_time_each_truck). If the result is 0 that means time violation = 0

if time violation>0 = I need to add waiting time to the latest arrival time.

waiting time means one truck wait for another truck at a merging point. in the example, truck 0 travel from 1 to 3 time take 1 min truck 1 travel from 2 to 3 take 2 min that means the truck 0 will wait for truck 1 for platoon at node 3 so waiting time {0:1,1:0}

image example

$min z = \sum x_e^h (d_e^h / s)$ what is next part?

the problem I have now is building the next part of the objective function. or make a mathematic formula for time violation based on my model first part objective function(latest arrival time) the second part will be something like: result = objective_function_second_Ipart - earliest_arrival_time_each_truck The next part will be :if result>0 = I need to add waiting time to the latest arrival time last part will be calculated time violation : time_violation[i] = max(latest arrival time[i] / earliest_arrival_time_each_truck[i] - 1 , 0)

please someone is helping me complete this objective function for minimizing time violation

mathematical model gurobi code