Building a LLM‑Powered Theme‑Park Queue Planner with Baidu Qianfan AppBuilder

This article walks through using large language model agents to create a theme‑park queue planning assistant for Baidu's Qianfan competition, covering the problem definition, dynamic‑programming‑style solution, prompt engineering, Python code generation, and step‑by‑step deployment in AppBuilder.

Baobao Algorithm Notes
Baobao Algorithm Notes
Baobao Algorithm Notes
Building a LLM‑Powered Theme‑Park Queue Planner with Baidu Qianfan AppBuilder

Background

Advances in large language models (LLMs) have turned them into the "brain" of AI agents, enabling flexible natural‑language interaction for tasks such as travel planning, ticket booking, and venue information retrieval.

Competition Overview

Baidu Cloud Qianfan Cup Phase 1 poses the challenge "Theme‑Park Queue Planning Assistant". Participants must use Baidu's AppBuilder and ModelBuilder to build an AI‑native application that helps visitors optimize ride selections within a limited time and provides operators with operational insights.

Problem Definition

The competition supplies maps for four parks (Universal Studios, Shanghai Disney, Hong Kong Disney, Guangzhou Chimelong) with each ride annotated by duration, visual‑experience score, and thrill score. The task is to select a subset of rides (each at most once, travel time ignored) that maximizes a chosen metric (e.g., total thrill) while staying under a total time budget.

Solution Approach

The underlying problem is a classic 0‑1 knapsack dynamic‑programming problem. Instead of writing the algorithm directly, the guide shows how to prompt an LLM‑based agent to generate the required Python code using Chain‑of‑Thought (CoT) and few‑shot examples.

Prompt Design

Three prompt components are assembled:

Planning : describe the goal, constraints, and required output format.

Memory : provide the ride data as a JSON‑like list (name, time, view, thrill).

Tool : instruct the agent to produce executable Python code that performs backtracking enumeration, respects the time limit, and returns the optimal combination.

Example few‑shot prompt:

Problem: Play for 5 hours, which rides give the highest total thrill?
Answer: ... (list of rides, total time, total thrill)

Implementation in AppBuilder

Steps to create the agent in AppBuilder:

Register for the competition.

Open the AppBuilder console.

Create a new Agent application, naming it after the chosen park (e.g., "Shanghai Disney Queue Planner").

Paste the crafted prompt into the prompt editor.

Publish and test the application.

Testing and Results

Three test cases are provided (5 hours, 2 hours, 4 h 20 min). The generated code correctly enumerates ride combinations, respects the time budget, and outputs the maximum thrill or visual score. Sample output shows the optimal ride list, individual times, and scores, followed by total thrill and total time.

Sample Python code (generated by the agent) demonstrates loading the data, sorting by thrill, backtracking to explore combinations, and printing the best result.

# Load data
data = [{"name": "喷气背包飞行器", "time": 60, "view": 3, "thrill": 9}, ...]
# Sort by thrill descending
data.sort(key=lambda x: x['thrill'], reverse=True)
# Backtrack to find best combination under 300 minutes
max_thrill = 0
max_combination = []

def backtrack(comb, total_time, total_thrill, idx):
    global max_thrill, max_combination
    if total_time > 300 or idx == len(data):
        if total_thrill > max_thrill:
            max_thrill = total_thrill
            max_combination = comb[:]
        return
    if total_time + data[idx]['time'] <= 300:
        comb.append(data[idx])
        backtrack(comb, total_time + data[idx]['time'], total_thrill + data[idx]['thrill'], idx + 1)
        comb.pop()
    backtrack(comb, total_time, total_thrill, idx + 1)

backtrack([], 0, 0, 0)
print("Best combination:")
for item in max_combination:
    print(f"{item['name']}【耗时{item['time']}分钟】【刺激指数:{item['thrill']}】")
print(f"总刺激指数:{max_thrill},总耗时:{sum(i['time'] for i in max_combination)}分钟")

Key Takeaways

The case demonstrates that with proper prompt engineering, an LLM can generate zero‑code solutions for classic optimization problems, lowering the barrier for AI application development. It also highlights the importance of concise prompts (≤ 1400 characters) and the use of CoT, few‑shot, and self‑reflection techniques to improve agent reliability and generalization.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

optimizationPythonLLMdynamic programmingAI AgentAppBuilder
Baobao Algorithm Notes
Written by

Baobao Algorithm Notes

Author of the BaiMian large model, offering technology and industry insights.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.