Perform various data analysis on SEC 13-F and obtain some insights of fund activities such as number of holdings, AUM, and change of holdings between two quarters.
日本語の概要は準備中です。原文の説明を表示しています。
Build OR-Tools RoutingModel vehicle-routing models with transit matrices, dimensions, capacity constraints, time windows, optional visits, invalid-arc handling, search parameters, and route extraction.
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Use this skill for vehicle-routing models built with ortools.constraint_solver.pywrapcp.RoutingModel.
NaN; OR-Tools can silently treat bad values as usable arcs.manager.NodeToIndex(node) and manager.IndexToNode(index).RegisterTransitMatrix and RegisterUnaryTransitVector calls over Python callbacks. Routing callbacks are called very often during local search and can consume solve time on large instances.When an input matrix has one shared start depot and one shared end depot, but the routing model needs one start and end node per vehicle, build an internal matrix with cloned depots:
def clone_depots_matrix(external, job_nodes, num_vehicles, start_depot, end_depot, invalid_cost):
num_jobs = len(job_nodes)
start_nodes = list(range(num_jobs, num_jobs + num_vehicles))
end_nodes = list(range(num_jobs + num_vehicles, num_jobs + 2 * num_vehicles))
matrix = [[invalid_cost] * (num_jobs + 2 * num_vehicles) for _ in range(num_jobs + 2 * num_vehicles)]
for i, ext_i in enumerate(job_nodes):
for j, ext_j in enumerate(job_nodes):
matrix[i][j] = external[ext_i][ext_j]
for end in end_nodes:
matrix[i][end] = external[ext_i][end_depot]
for start in start_nodes:
for j, ext_j in enumerate(job_nodes):
matrix[start][j] = external[start_depot][ext_j]
for vehicle in range(num_vehicles):
matrix[start_nodes[vehicle]][end_nodes[vehicle]] = 0
return matrix, start_nodes, end_nodes
Time.CumulVar(index) is the arrival or service-start time, and departure is arrival + service_time.fix_start_cumul_to_zero deliberately. Use False when vehicle start times or shifts may vary; use start time windows or allowed start values instead.routing.Start(vehicle) and routing.End(vehicle), especially when depots are cloned or shared.Apply ordinary visit time windows directly to the node's time cumul:
for node, (window_low, window_high) in time_windows.items():
index = manager.NodeToIndex(node)
time_dim.CumulVar(index).SetRange(int(window_low), int(window_high))
For top-of-hour shift starts inside an operating window, generate the allowed start values and apply them to each vehicle start cumul:
def possible_shift_start_times(operating_window, shift_duration, step_minutes=60):
start, end = operating_window
return [
minute
for minute in range(0, 24 * 60 + 1, step_minutes)
if start <= minute <= end - shift_duration
]
shift_starts = possible_shift_start_times(operating_window, shift_duration)
for vehicle in range(num_vehicles):
time_dim.CumulVar(routing.Start(vehicle)).SetRange(*operating_window)
time_dim.CumulVar(routing.End(vehicle)).SetRange(*operating_window)
time_dim.CumulVar(routing.Start(vehicle)).SetValues(shift_starts)
time_dim.SetSpanUpperBoundForVehicle(shift_duration, vehicle)
routing.AddVariableMinimizedByFinalizer(time_dim.CumulVar(routing.Start(vehicle)))
routing.AddVariableMaximizedByFinalizer(time_dim.CumulVar(routing.End(vehicle)))
AddDisjunction for optional nodes and choose penalties so the primary objective dominates secondary route costs.Use this shape for large matrix-based routing models with cloned depots, time propagation, capacity, a secondary travel-cost objective, and a bounded local search. Add problem-specific visits, disjunctions, and time windows after creating the dimensions.
from ortools.constraint_solver import pywrapcp, routing_enums_pb2
start_nodes = list(range(job_node_count, job_node_count + num_vehicles))
end_nodes = list(range(job_node_count + num_vehicles, job_node_count + 2 * num_vehicles))
manager = pywrapcp.RoutingIndexManager(num_solver_nodes, num_vehicles, start_nodes, end_nodes)
routing = pywrapcp.RoutingModel(manager)
nodes_from_indices = [manager.IndexToNode(index) for index in range(manager.GetNumberOfIndices())]
time_matrix = [
[int(travel_times[i][j] + service_times[i]) for j in nodes_from_indices]
for i in nodes_from_indices
]
cost_matrix = [
[int(arc_costs[i][j]) for j in nodes_from_indices]
for i in nodes_from_indices
]
time_cb = routing.RegisterTransitMatrix(time_matrix)
cost_cb = routing.RegisterTransitMatrix(cost_matrix)
routing.SetArcCostEvaluatorOfAllVehicles(cost_cb)
routing.AddDimension(time_cb, waiting_slack, time_horizon, False, "Time")
time_dim = routing.GetDimensionOrDie("Time")
demand_cb = routing.RegisterUnaryTransitVector([int(demands[node]) for node in nodes_from_indices])
routing.AddDimensionWithVehicleCapacity(demand_cb, 0, vehicle_capacities, True, "Capacity")
params = pywrapcp.DefaultRoutingSearchParameters()
params.first_solution_strategy = routing_enums_pb2.FirstSolutionStrategy.AUTOMATIC
params.local_search_metaheuristic = routing_enums_pb2.LocalSearchMetaheuristic.GENERIC_TABU_SEARCH
params.time_limit.seconds = int(search_limit_seconds)
params.log_search = True
solution = routing.SolveWithParameters(params)
AUTOMATIC is a strong first-solution default, and GENERIC_TABU_SEARCH is often a good local-search metaheuristic for escaping local minima. Avoid assuming that simple arc-based constructors such as PATH_CHEAPEST_ARC will work well on heavily constrained optional-service instances.search_parameters.log_search = True, run Python unbuffered, or print flushed progress before and after the solve.NextVar, route start/end cumul vars, and CostVar; keep the best collected solution by cost if the final return value is unavailable or inconvenient to extract.NextVar from each vehicle start to end, then pass the ordered stops to an independent audit/reporting step.まだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Perform various data analysis on SEC 13-F and obtain some insights of fund activities such as number of holdings, AUM, and change of holdings between two quarters.
日本語の概要は準備中です。原文の説明を表示しています。
AC branch pi-model power flow equations (P/Q and |S|) with transformer tap ratio and phase shift, matching `acopf-math-model.md` and MATPOWER branch fields. Use when computing branch flows in either direction, aggregating bus injections for nodal balance, checking MVA (rateA) limits, computing branch loading %, or debugging sign/units issues in AC power flow.
日本語の概要は準備中です。原文の説明を表示しています。
Redact text from PDF documents for blind review anonymization
日本語の概要は準備中です。原文の説明を表示しています。
Use when checking simplified ADA-derived plan-view bathroom accessibility constraints such as turning space, door clear width, toilet centerline, grab bars, and lavatory knee/toe clearance.
日本語の概要は準備中です。原文の説明を表示しています。
Analyze failed GitHub Action jobs for a pull request.
日本語の概要は準備中です。原文の説明を表示しています。
Use when extracting plan-view architectural geometry from DXF files with semantic CAD layers, especially when outputs must normalize rooms, doors, fixtures, clearances, and grab bars into machine-checkable JSON.
日本語の概要は準備中です。原文の説明を表示しています。