-
Notifications
You must be signed in to change notification settings - Fork 391
Document adversarial temporal graph problem statement #801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shubuexe
wants to merge
5
commits into
codemistic:main
Choose a base branch
from
shubuexe:Adversarial-Temporal-Graph-with-Stateful-Encodin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| <!-- Suggested filename: adversarial-temporal-graph.md --> | ||
| # Adversarial Temporal Graph with Stateful Encoding | ||
|
|
||
| Problem Statement | ||
| You are given: | ||
| A directed graph with n nodes (0 → n-1) | ||
| Each edge has: | ||
| cost (energy consumption) | ||
| time (time taken) | ||
| label (a lowercase character 'a'–'z') | ||
| An integer K (max energy) | ||
| An integer T (max time) | ||
| An integer M (modulo) | ||
| A forbidden pattern string P | ||
|
|
||
| Rules | ||
|
|
||
| You start at node 0 and want to reach node n-1. | ||
|
|
||
| You maintain: | ||
|
|
||
| 1. ⏱ Time | ||
| Total time ≤ T | ||
|
|
||
| 3. ⚡ Energy | ||
| Total energy ≤ K | ||
|
|
||
| 4. 🔐 Stateful Encoding | ||
| Each path generates a value as follows. | ||
| Let χ(c) be the integer value of a label character c, defined by χ('a') = 1, χ('b') = 2, …, χ('z') = 26. | ||
| For a path whose edge labels form the string c₁c₂…c_L (each cᵢ ∈ {'a', …, 'z'}), define: | ||
| value₀ = 0 | ||
| valueᵢ = (valueᵢ₋₁ · 131 + χ(cᵢ)) mod M for i = 1…L | ||
| The encoded value of the path is value_L. | ||
|
|
||
| 5. 🚫 Forbidden Pattern Constraint | ||
| The concatenated labels along your path must NOT contain P as a substring. | ||
|
|
||
| 5. 🔁 Temporal Edge Activation | ||
| Each edge (u → v) is only usable at certain times: | ||
| You are given for each edge: | ||
| A list of active intervals [l, r] | ||
|
|
||
| Waiting at nodes: | ||
| - You may wait at any node for any non-negative amount of time. | ||
| - Waiting increases the current time but does not consume energy and does not traverse any edge. | ||
|
|
||
| Edge usage condition: | ||
| - Suppose an edge e has traversal time te and active intervals [l, r]. | ||
| - You may start traversing e from time τ only if the entire interval [τ, τ + te] is contained in at least one active interval [l, r] for e. | ||
| - Equivalently, τ and τ + te must satisfy l ≤ τ and τ + te ≤ r for some [l, r] of that edge. | ||
| 7. 🎭 Adversarial Twist (well-defined minimax model) | ||
| The game proceeds in discrete moves. A move happens whenever you are at some node u at current time t, with remaining energy and current encoded value. | ||
| On each such move, the order of actions is: | ||
| 1. The adversary may choose at most one outgoing edge e = (u → v) whose label has never been flipped before and permanently change its label to any lowercase character 'a'–'z'. | ||
| 2. You observe all current labels on outgoing edges of u (including any just flipped by the adversary) and then choose one outgoing edge to traverse, subject to the time, energy, temporal activation, and forbidden-pattern constraints. You may also choose to stop. | ||
| 3. You traverse the chosen edge, advance time by its time cost, decrease energy by its energy cost, and update the encoded value using the (possibly flipped) label on that edge. | ||
| Label flips are persistent: once an edge’s label is changed, all future traversals of that edge see the new label. The adversary cannot change labels of edges that are not outgoing from your current node on that move, and cannot flip the same edge more than once in the entire run. | ||
| You must assume the adversary acts to minimize your final value. | ||
| You still try to maximize the final value. | ||
|
|
||
shubuexe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Objective | ||
| Return the maximum possible encoded value you can guarantee under worst-case adversarial behavior. | ||
| If no valid path exists, return -1 | ||
|
|
||
| Constraints | ||
| 1 ≤ n ≤ 100 | ||
| 1 ≤ edges ≤ 500 | ||
| 1 ≤ K ≤ 5000 | ||
| 1 ≤ T ≤ 5000 | ||
| |P| ≤ 50 | ||
| Active intervals per edge ≤ 10 | ||
|
|
||
| Example 1: | ||
| n = 3 | ||
| edges: | ||
| 0 → 1 (cost=2, time=2, label='a', active=[0,10]) | ||
| 1 → 2 (cost=2, time=2, label='b', active=[0,10]) | ||
|
|
||
| K = 5 | ||
| T = 5 | ||
| M = 1000 | ||
| P = "ab" | ||
|
|
||
| Example 2: | ||
| n = 3 | ||
| edges: | ||
| 0 → 1 (cost=1, time=1, label='a', active=[0,10]) | ||
| 1 → 2 (cost=1, time=1, label='c', active=[0,10]) | ||
|
|
||
| K = 5 | ||
| T = 5 | ||
| M = 1000 | ||
| P = "ab" | ||
shubuexe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.