Skip to content

Conversation

@vanshg1729
Copy link

What's Included

1. New Algorithm Module: Rod Cutting

algorithms/RodCutting.typ

  • Formal DP recurrence definition for $r(n, k)$, the maximum revenue obtainable by cutting a rod of length $n$.
  • Mapcode-style specification $(ρ, F, π)$.
  • Concrete DP computation for a sample instance $(n = 4, P = (1, 5, 8, 9))$.
  • Full DP-table visualization using the project's mapcode-viz framework.

2. New Algorithm Module: Subset Sum

algorithms/SubsetSum.typ

  • Formal recursive definition for $D(i, j)$, determining if sum $j$ can be made using the first $i$ items.
  • Mapcode-style specification $(ρ, F, π)$.
  • Computation for a sample instance $(S = (3, 5, 8), T = 11)$.
  • Visualization of the 2D DP table $X(i, j)$, showing the evolution of valid partial sum solutions.

3. Documentation Integration

Updated main.typ:

  • Added #include "algorithms/SubsetSum.typ" after the previous algorithm section.
  • Added #include "algorithms/RodCutting.typ" directly after the Subset Sum section.
  • Ensures the new algorithm chapters appear in the output in correct sequence.

Why This Matters

  • Brings two more classical computational problems into the mapcode framework, expanding coverage.
  • Demonstrates the framework's versatility in handling both 1D tensor-based DP problems (Rod Cutting) and 2D matrix-based DP problems (Subset Sum).
  • Provides additional templates for future algorithm additions, showcasing incremental computation and proper dependency checking.
  • Enhances the educational value of the repository with well-documented, classic optimization problems.

Files Changed

  • algorithms/RodCutting.typ117 lines added
  • algorithms/SubsetSum.typ139 lines added
  • main.typ4 lines added

No existing code modified; additions are isolated and non-breaking.


Checklist

  • Builds successfully
  • Renders correctly in main.typ
  • Follows repository style and structure
  • No backward-incompatible changes

Additional Notes

Both algorithms have been thoroughly tested:

  • Rod Cutting: Correctly computes maximum revenue of 10 for length 4 (optimal cut: 2+2)
  • Subset Sum: Correctly determines that sum 11 can be achieved from {3, 5, 8} using subset {3, 8}

The implementations follow the mapcode framework's conventions with proper initialization (ρ), iterative function application (F), and projection (π) to extract the final answer.


image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant