@@ -127,83 +127,83 @@ function prize_collecting_vsp(
127127 return retrieve_routes (value .(y), graph)
128128end
129129
130- # ?
131- function prize_collecting_vsp_Q (
132- θ:: AbstractVector ,
133- vals:: AbstractVector ;
134- instance:: DVSPState ,
135- model_builder= highs_model,
136- kwargs... ,
137- )
138- (; duration) = instance. instance
139- graph = create_graph (instance)
140- model = model_builder ()
141- set_silent (model)
142- nb_nodes = nv (graph)
143- job_indices = 2 : (nb_nodes)
144- @variable (model, y[i= 1 : nb_nodes, j= 1 : nb_nodes; has_edge (graph, i, j)] >= 0 )
145- θ_ext = fill (0.0 , location_count (instance. instance)) # no prize for must dispatch requests, only hard constraints
146- θ_ext[instance. is_postponable] .= θ
147- # v_ext = fill(0.0, nb_locations(instance.instance)) # no prize for must dispatch requests, only hard constraints
148- # v_ext[instance.is_postponable] .= vals
149- @objective (
150- model,
151- Max,
152- sum (
153- (θ_ext[dst (edge)] + vals[dst (edge)] - duration[src (edge), dst (edge)]) *
154- y[src (edge), dst (edge)] for edge in edges (graph)
155- )
156- )
157- @constraint (
158- model,
159- flow[i in 2 : nb_nodes],
160- sum (y[j, i] for j in inneighbors (graph, i)) ==
161- sum (y[i, j] for j in outneighbors (graph, i))
162- )
163- @constraint (
164- model, demand[i in job_indices], sum (y[j, i] for j in inneighbors (graph, i)) <= 1
165- )
166- # must dispatch constraints
167- @constraint (
168- model,
169- demand_must_dispatch[i in job_indices; instance. is_must_dispatch[i]],
170- sum (y[j, i] for j in inneighbors (graph, i)) == 1
171- )
172- optimize! (model)
173- return retrieve_routes (value .(y), graph)
174- end
130+ # # ?
131+ # function prize_collecting_vsp_Q(
132+ # θ::AbstractVector,
133+ # vals::AbstractVector;
134+ # instance::DVSPState,
135+ # model_builder=highs_model,
136+ # kwargs...,
137+ # )
138+ # (; duration) = instance.instance
139+ # graph = create_graph(instance)
140+ # model = model_builder()
141+ # set_silent(model)
142+ # nb_nodes = nv(graph)
143+ # job_indices = 2:(nb_nodes)
144+ # @variable(model, y[i=1:nb_nodes, j=1:nb_nodes; has_edge(graph, i, j)] >= 0)
145+ # θ_ext = fill(0.0, location_count(instance.instance)) # no prize for must dispatch requests, only hard constraints
146+ # θ_ext[instance.is_postponable] .= θ
147+ # # v_ext = fill(0.0, nb_locations(instance.instance)) # no prize for must dispatch requests, only hard constraints
148+ # # v_ext[instance.is_postponable] .= vals
149+ # @objective(
150+ # model,
151+ # Max,
152+ # sum(
153+ # (θ_ext[dst(edge)] + vals[dst(edge)] - duration[src(edge), dst(edge)]) *
154+ # y[src(edge), dst(edge)] for edge in edges(graph)
155+ # )
156+ # )
157+ # @constraint(
158+ # model,
159+ # flow[i in 2:nb_nodes],
160+ # sum(y[j, i] for j in inneighbors(graph, i)) ==
161+ # sum(y[i, j] for j in outneighbors(graph, i))
162+ # )
163+ # @constraint(
164+ # model, demand[i in job_indices], sum(y[j, i] for j in inneighbors(graph, i)) <= 1
165+ # )
166+ # # must dispatch constraints
167+ # @constraint(
168+ # model,
169+ # demand_must_dispatch[i in job_indices; instance.is_must_dispatch[i]],
170+ # sum(y[j, i] for j in inneighbors(graph, i)) == 1
171+ # )
172+ # optimize!(model)
173+ # return retrieve_routes(value.(y), graph)
174+ # end
175175
176- function my_objective_value (θ, routes; instance)
177- (; duration) = instance. instance
178- total = 0.0
179- θ_ext = fill (0.0 , location_count (instance))
180- θ_ext[instance. is_postponable] .= θ
181- for route in routes
182- for (u, v) in partition (vcat (1 , route), 2 , 1 )
183- total += θ_ext[v] - duration[u, v]
184- end
185- end
186- return - total
187- end
176+ # function my_objective_value(θ, routes; instance)
177+ # (; duration) = instance.instance
178+ # total = 0.0
179+ # θ_ext = fill(0.0, location_count(instance))
180+ # θ_ext[instance.is_postponable] .= θ
181+ # for route in routes
182+ # for (u, v) in partition(vcat(1, route), 2, 1)
183+ # total += θ_ext[v] - duration[u, v]
184+ # end
185+ # end
186+ # return -total
187+ # end
188188
189- function _objective_value (θ, routes; instance)
190- (; duration) = instance. instance
191- total = 0.0
192- θ_ext = fill (0.0 , location_count (instance))
193- θ_ext[instance. is_postponable] .= θ
194- mapping = cumsum (instance. is_postponable)
195- g = falses (length (θ))
196- for route in routes
197- for (u, v) in partition (vcat (1 , route), 2 , 1 )
198- total -= duration[u, v]
199- if instance. is_postponable[v]
200- total += θ_ext[v]
201- g[mapping[v]] = 1
202- end
203- end
204- end
205- return - total, g
206- end
189+ # function _objective_value(θ, routes; instance)
190+ # (; duration) = instance.instance
191+ # total = 0.0
192+ # θ_ext = fill(0.0, location_count(instance))
193+ # θ_ext[instance.is_postponable] .= θ
194+ # mapping = cumsum(instance.is_postponable)
195+ # g = falses(length(θ))
196+ # for route in routes
197+ # for (u, v) in partition(vcat(1, route), 2, 1)
198+ # total -= duration[u, v]
199+ # if instance.is_postponable[v]
200+ # total += θ_ext[v]
201+ # g[mapping[v]] = 1
202+ # end
203+ # end
204+ # end
205+ # return -total, g
206+ # end
207207
208208# function ChainRulesCore.rrule(::typeof(my_objective_value), θ, routes; instance)
209209# total, g = _objective_value(θ, routes; instance)
0 commit comments