Project Overview
In this project, we developed a Streamlit dashboard that optimizes activity schedules based on live weather data and user-defined constraints. The application leverages Constraint Satisfaction Problems (CSP), Weighted CSP (WCSP), and Conditional Preference Networks (CP-Nets) to generate efficient and personalized schedules. Our goal was to assist users in planning activities by considering weather conditions and personal preferences, enhancing decision-making in daily scheduling.
Introduction to Key Algorithms
Constraint Satisfaction Problems (CSP)
CSP involves variables with specific domains and constraints that define acceptable combinations of values. It’s ideal for problems where the goal is to find a solution that satisfies all given constraints.
- Pros: Simple, direct, and efficient when constraints are clear.
- Cons: Inflexible and may not handle complex scenarios with nuanced preferences.
Weighted CSP (WCSP)
WCSP extends CSP by associating weights with constraints, allowing for preference levels and optimization in solutions.
- Pros: Flexible decision-making with nuanced preference handling.
- Cons: Increased computational complexity and requires careful weight definition.
Conditional Preference Networks (CP-Nets)
CP-Nets model qualitative preference ordering with conditional dependencies, capturing more complex preference structures.
- Pros: Handles complex preferences and manages conditional dependencies effectively.
- Cons: Computationally intensive and needs detailed preference mapping.
Weather Data Integration
We integrated real-time weather data using the WeatherAPI, focusing on key metrics like temperature and chance of rain. This data is critical in tailoring schedules that align with both weather conditions and user preferences.
Sample Weather Dataset
Application Features
- Activity Input: Users can input multiple activities with unique names, durations (in 15-minute intervals), and weather preferences.
- Weather Preferences:
- WCSP: Supports multiple weather preferences in order of priority.
- CSP and CP-Nets: Allow a single weather preference per activity.
- Planning Parameters: Users can select the planning date (limited to the next 3 days) and specify start and end times.
- Validation: The app provides error messages for invalid inputs, such as overlapping activity names or improper time ranges.
- Visualization: Generates activity timelines to visualize the optimized schedule.
Methodology
CSP Implementation
- Variables: Each activity’s start time.
- Domains: Possible start times within the user-defined time frame.
- Constraints:
- No overlapping activities.
- Weather conditions must match the user’s preference.
- Execution Time: Efficient for straightforward constraints (e.g., 0.00 seconds).
WCSP Implementation
- Variables and Domains: Similar to CSP but with added weights to preferences.
- Constraints with Weights:
- Allows for preference levels (e.g., ‘Sunny’ preferred over ‘Cloudy’).
- Optimization: Finds schedules that not only satisfy constraints but also optimize based on weighted preferences.
- Execution Time: Slightly higher due to complexity (e.g., 0.03 seconds).
CP-Net Implementation
- Preference Modeling: Captures conditional dependencies between preferences.
- Algorithm:
- Generates all possible permutations of activities.
- Evaluates each permutation based on user preferences and weather data.
- Selects the schedule with the highest overall preference score.
- Execution Time: More computationally intensive (e.g., 0.72 seconds).
Comparative Analysis
CSP vs. WCSP
- Execution Time:
- CSP: Faster execution due to simpler constraints.
- WCSP: Slightly slower but offers better preference handling.
- Complexity:
- CSP: Polynomial to NP-hard.
- WCSP: NP-hard due to weighted constraints.
WCSP vs. CP-Nets
- Execution Time:
- WCSP: More efficient with acceptable execution times for practical use.
- CP-Nets: Slower due to the exponential number of permutations evaluated.
- Suitability:
- WCSP: Better for scenarios where weighted preferences are sufficient.
- CP-Nets: Ideal when conditional dependencies between preferences are critical.
Findings and Conclusions
- CSP: Best suited for straightforward scheduling problems with clear constraints.
- WCSP and CP-Nets: More effective for complex scenarios where user preferences and weather conditions significantly influence scheduling.
- Practical Applications: The algorithms can be applied to event planning, personal scheduling, and any domain requiring optimization based on preferences and external factors like weather.
- Future Enhancements:
- Incorporate advanced data analytics to predict weather patterns more accurately.
- Apply machine learning techniques to learn user preferences over time for even more personalized scheduling.
Demonstration
Execution Time Comparison
Algorithm | Execution Time | Complexity |
---|---|---|
CSP | 0.00 seconds | Polynomial to NP-hard |
WCSP | 0.03 seconds | NP-hard |
CP-Net | 0.72 seconds | NP-hard to exponential |
References
- WeatherAPI: https://www.weatherapi.com/