Hybrid LLM-Optimization System for Trip Planning with Real-World Constraints

google · Tech · 2025 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: consumer trip planning with real-world logistical constraints

Google needed AI-generated day-by-day travel itineraries that preserve a user's qualitative preferences while satisfying hard logistical constraints such as opening hours, travel time, budgets, and multi-day scheduling feasibility.

Constraints:

Architecture

Google's AI trip ideas feature uses a hybrid LLM-plus-optimization architecture. An incoming trip-planning query is first sent to a Gemini model, which creates an initial itinerary with activities, suggested durations, and importance levels reflecting the user's qualitative preferences. The system then grounds that itinerary with current opening hours and travel times, retrieves additional relevant substitute activities from search backends, and feeds the initial plan, substitutes, and grounding data into a two-stage optimizer. Stage one optimizes each day with dynamic programming over feasible activity subsets. Stage two treats the whole itinerary as a weighted set-packing variant and uses local search from the initial LLM itinerary to exchange activities between days until the total score no longer improves.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  Trip_planning_query["Trip-planning query"] --> Gemini_itinerary_generator["Gemini itinerary generator"]
  Gemini_itinerary_generator --> Grounding_data_fetcher["Grounding data fetcher"]
  Search_backend_retrieval["Search backend retrieval"] --> Optimization_algorithm["Optimization algorithm"]
  Grounding_data_fetcher --> Optimization_algorithm
  Gemini_itinerary_generator --> Optimization_algorithm
  Optimization_algorithm --> Single_day_dynamic_programming_stage["Single-day dynamic programming stage"]
  Single_day_dynamic_programming_stage --> Multi_day_local_search_stage["Multi-day local search stage"]
  Optimization_algorithm --> Multi_day_local_search_stage
  Multi_day_local_search_stage --> Final_itinerary["Final itinerary"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Trip-planning query Natural-language request containing destination, duration, constraints, and qualitative preferences. Gemini itinerary generator
Gemini itinerary generator LLM that produces an initial day-by-day trip plan with activities, durations, and importance levels. Grounding data fetcher, Optimization algorithm
Grounding data fetcher Retrieves up-to-date opening hours, travel times, and logistical constraints for suggested activities. Optimization algorithm
Search backend retrieval Retrieves additional relevant activities that can substitute for LLM-suggested items if the plan needs modification. Optimization algorithm
Optimization algorithm Combines the initial plan, substitutes, and grounding data to produce a feasible itinerary close to the LLM plan. Single-day dynamic programming stage, Multi-day local search stage, Final itinerary
Single-day dynamic programming stage Computes feasible schedules and quality scores for subsets of activities within each day. Multi-day local search stage
Multi-day local search stage Improves the overall itinerary by exchanging activities between days until score convergence. Final itinerary
Final itinerary User-facing trip plan that preserves the LLM's intent while satisfying opening-hour and travel-time constraints. —

Data flow

A user submits a natural-language trip-planning query. Gemini generates an initial itinerary with activity details, duration, and importance. The system fetches opening hours and travel times, retrieves substitute activities from search backends, and sends the initial plan, substitutes, and grounding data to an optimizer. The optimizer scores feasible single-day schedules with dynamic programming, then improves the multi-day itinerary with local activity exchanges, returning a final plan that stays close to the LLM suggestion while satisfying real-world constraints.

3 supporting quotes
“Given an incoming user query, we first pass the query to an LLM, which for our system is a version of our latest Gemini models.”article, stated
“We start by grounding the initial itinerary with up-to-date opening hours and travel times.”article, stated
“The initial plan, substitute activities, and grounding data are then fed into an optimization algorithm to find a trip plan similar to the initial plan that also ensures feasibility.”article, stated

Why this architecture

The system is hybrid because neither an LLM nor a traditional retrieval/optimization system is sufficient on its own. The LLM understands qualitative travel preferences such as lesser-known museums or kid-friendly restaurants, but it may hallucinate feasibility. Search and grounding provide current facts, while the optimizer enforces travel-time and opening-hour constraints without discarding the LLM's user-tailored intent.

3 supporting quotes
“This approach integrates the LLM’s ability to handle soft requirements with the algorithmic precision needed to meet hard logistical constraints.”article, stated
“The initial plan is well-tailored to the user’s interests but may have feasibility issues, like suggesting an establishment that has recently closed.”article, stated
“If we remove the LLM suggestion and rely only on the search-retrieved activities, the resulting itinerary includes some lesser known museums but also the Metropolitan Museum of Art and the Guggenheim Museum”article, stated

Models used: Gemini models · large language models · dynamic programming optimizer · local search heuristic

Scale

Alternatives considered (roads not taken)

Use the LLM-generated itinerary directly

Rejected because: The initial LLM plan can be user-tailored but logistically infeasible due to stale or complex real-world constraints.

“The initial plan is well-tailored to the user’s interests but may have feasibility issues, like suggesting an establishment that has recently closed.”article, stated

Use search-retrieved activities without LLM preference modeling

Rejected because: The NYC example shows retrieval-only results contradicting the user's stated preference to avoid famous crowded museums.

“If we remove the LLM suggestion and rely only on the search-retrieved activities, the resulting itinerary includes some lesser known museums but also the Metropolitan Museum of Art and the Guggenheim Museum”article, stated

Solve the multi-day itinerary exactly

Rejected because: The itinerary-level problem is NP-complete, so the team uses local search heuristics that work because the objective starts near the initial LLM plan.

“This is a weighted variant of the set packing problem, which is well-known to be NP-complete and thus computationally intractable.”article, stated
“we found that local search heuristics were effective. Starting from the initial itinerary, we make local adjustments by exchanging activities between pairs of days”article, stated

Patterns

tool-use-orchestration (system-design)

The production pipeline orchestrates Gemini, search backends, real-world grounding data, dynamic programming, and local search instead of relying on a single model call.

“Our solution employs a hybrid system that uses an LLM to suggest an initial plan combined with an algorithm that jointly optimizes for similarity to the LLM plan and real-world factors”article, stated
“The initial plan, substitute activities, and grounding data are then fed into an optimization algorithm”article, stated

rag-retrieval (retrieval)

Search backends retrieve substitute activities and grounding data so the itinerary is not limited to stale LLM knowledge.

“we also use search backends to retrieve additional relevant activities that serve as potential substitutes in case the LLM-suggested plan needs to be modified.”article, stated

safety-policy-enforcement (reliability)

The optimizer enforces hard logistical feasibility constraints that the LLM alone may violate.

“quality score determined primarily based on similarity to the original plan and feasibility of the scheduling subject to opening hour and travel time constraints”article, stated

eval-driven-development (quality)

The team uses examples and testing to compare LLM-only, search-only, and hybrid behavior against preference and feasibility failures.

“During our testing, the LLM suggested a number of good attractions, such as the de Young museum (which also includes an observation tower) and the iconic Coit Tower.”article, stated
“We were able to correct this in the optimization step, resulting in a logistically feasible plan that preserves the original intent.”article, stated

latency-optimization (operations)

The optimizer uses exhaustive dynamic programming only where day-level activity sets are small, then switches to local search for the intractable itinerary-level problem.

“Since the number of activities within a day is small, we found that the scores can be computed by exhaustive search with a sufficiently optimized dynamic programming-based implementation.”article, stated
“given that our optimization objective tries to stay close to the initial itinerary by design, we found that local search heuristics were effective.”article, stated

Tradeoffs

Hybrid LLM plus optimizer

Chose LLM initial plan corrected by algorithmic optimization over pure LLM trip planning.

Rationale: The LLM captures soft preferences, while the optimizer enforces hard constraints such as opening hours and travel time.

“integrates the LLM’s ability to handle soft requirements with the algorithmic precision needed to meet hard logistical constraints.”article, stated

Retrieve substitutes in parallel with grounding

Chose search-backed substitute activities over only modifying or deleting LLM-suggested activities.

Rationale: Substitutes give the optimizer alternatives when the original plan needs to change for feasibility.

“In parallel, we also use search backends to retrieve additional relevant activities that serve as potential substitutes in case the LLM-suggested plan needs to be modified.”article, stated

Dynamic programming for single-day planning

Chose exhaustive search with optimized dynamic programming within a day over a heuristic for every part of the problem.

Rationale: The number of activities within a day is small enough to compute high-quality day scores exactly or near-exactly.

“Since the number of activities within a day is small, we found that the scores can be computed by exhaustive search with a sufficiently optimized dynamic programming-based implementation.”article, stated

Local search for the multi-day itinerary

Chose incremental activity exchanges until convergence over exact global set-packing optimization.

Rationale: The global problem is NP-complete, but starting near the LLM itinerary makes local improvements effective.

“given that our optimization objective tries to stay close to the initial itinerary by design, we found that local search heuristics were effective.”article, stated

Gotchas (what bit them)

LLMs can satisfy preferences while violating real-world feasibility.

Root cause: Quantitative logistics depend on current opening hours, travel times, and interacting constraints that may not be in the model's knowledge.

Resolution: Ground the LLM itinerary with current data and optimize the schedule against opening-hour and travel-time constraints.

“they are less reliable at handling quantitative logistical constraints, which may require detailed and up-to-date real-world information”article, stated
“LLM-generated plans can at times include impractical elements, such as visiting a museum that would be closed by the time you can travel there.”article, stated

Search-only retrieval misses nuanced user intent.

Root cause: Traditional retrieval can return relevant attractions that conflict with qualitative constraints such as avoiding large crowds.

Resolution: Use the LLM's preference understanding to form the initial plan, then use search as a source of grounding and substitutes rather than as the sole planner.

“the resulting itinerary includes some lesser known museums but also the Metropolitan Museum of Art and the Guggenheim Museum, famous museums directly contradicting the user’s request.”article, stated

Exact itinerary optimization does not scale cleanly across multiple days.

Root cause: The overall itinerary problem is a weighted set-packing variant and is NP-complete.

Resolution: Use local search from the LLM's initial itinerary, exchanging activities between pairs of days until convergence.

“well-known to be NP-complete and thus computationally intractable.”article, stated
“Starting from the initial itinerary, we make local adjustments by exchanging activities between pairs of days so long as this would increase the total score.”article, stated

Optimizing feasibility can accidentally erase the LLM's qualitative intent.

Root cause: A plan could become logistically valid but no longer match the user's original preferences.

Resolution: Score schedules primarily on both similarity to the original LLM plan and practical feasibility.

“We then assign it a quality score determined primarily based on similarity to the original plan and feasibility of the scheduling”article, stated
“resulting in a logistically feasible plan that preserves the original intent.”article, stated

Evaluation

The article demonstrates evaluation qualitatively through examples: an NYC query showing that LLM suggestions preserve user preference better than search-only retrieval, and a San Francisco query showing the optimizer correcting an LLM itinerary's impractical cross-city travel.

Metrics: qualitative match to user preference · opening-hour feasibility · travel-time feasibility · similarity to original LLM plan · optimization score convergence

3 supporting quotes
“The following query illustrates how the detailed understanding LLMs provide can better serve the user’s needs than a traditional retrieval system.”article, stated
“the next query demonstrates a case where the hybrid system corrects an issue with the original LLM-suggested itinerary”article, stated
“This procedure is repeated until convergence, resulting in the final itinerary.”article, stated

Outcomes

The article is a product/research writeup rather than a benchmark report; it does not disclose latency, traffic, or aggregate success-rate metrics. Its strongest evidence is the explicit system architecture and qualitative examples.

3 supporting quotes
“We recently introduced AI trip ideas in Search, a feature that suggests day-by-day itineraries”article, stated
“Our system produces an itinerary matching the user’s request, suggesting museums such as the Museum of the Moving Image and the New York Transit Museum.”article, stated
“We were able to correct this in the optimization step, resulting in a logistically feasible plan that preserves the original intent.”article, stated