Repository navigation
Beamforming - #5
krzysztofrusek wants to merge 11 commits into
Conversation
m-wojnar
left a comment
There was a problem hiding this comment.
Looks good 👍 For the further steps, I propose to add some class or function wrapper for a whole process. This will allow the user to call just one function instead of preparation of the wall matrix, antena gain matrix, and finally simulator.
Do you possibly know why unit tests are failing? It looks like a tfp or jax bug?
I agree. My idea is to have simulator as a callable with differentiable parameters. This callable can be either :
I am not sure right now what is better at this point, as we need to modularize the
no, but indeed this looks like tfp issue, maybe we need to bump version. |
Describe obstacles geometrically as (rotated) rectangles with an attenuation coefficient in dB/m and estimate the attenuation of a link by sampling points uniformly along it and counting how many fall inside each wall. The estimator is unbiased, branch-free (jit/vmap/grad friendly), and symmetric, and it handles arbitrarily many overlapping obstacles. Also document that the binomial sampling noise of the estimator can play the role of the shadowing term of the fading model, add plot_walls for visualization, and add tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFmELrvX87L5zFiKPYGwVt
Monte Carlo walls (pushed as
|
Bring in 31 commits from main (greedy MCS selection, channel width, Internals, path_loss_fn hook, dependency and CI updates) and reconcile them with the walls refactor of this branch: - `network_data_rate` takes `loss_gain`, an additive dB matrix of losses (walls) and gains (antennas), instead of the binary `walls` matrix, - `tgax_path_loss` adds `loss_gain` directly and no longer scales it by `wall_loss`; `utils.binary_walls` builds a `loss_gain` matrix from the old binary representation, - matplotlib is now an optional `viz` dependency (`plot_walls`). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFmELrvX87L5zFiKPYGwVt
Antenna gains are absolute (dBi, relative to an isotropic radiator) rather than relative to the maximum of the pattern, so that the link budget stays additive, tx_power keeps meaning conducted power, and antennas with different beamwidths remain comparable. The reasoning is documented in docs/antennas.rst. Add the 3GPP/TGax parabolic sector pattern, the bearing matrix, a planar peak gain estimate, and link_gain, which sums the transmitter and receiver gains into the (symmetric) term subtracted from loss_gain. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFmELrvX87L5zFiKPYGwVt
Branch updated to
|
matplotlib is an optional dependency, so the annotations must not resolve its name at runtime (flake8 F821 in CI). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFmELrvX87L5zFiKPYGwVt
`accepts_walls` adds `walls` and `wall_loss` keyword arguments to any function taking a `loss_gain` matrix and converts them with `binary_walls`, raising a DeprecationWarning. `network_data_rate` is decorated with it, so the previous call style keeps working. The legacy argument is keyword-only: a matrix passed positionally is always `loss_gain`, as the two representations cannot be told apart (under jit the values are tracers, and a binary matrix is a valid `loss_gain` matrix). Passing both raises a TypeError. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFmELrvX87L5zFiKPYGwVt
Compatibility layer for
|
Annotate with jax.Array and declare pytree dataclasses with @jax.tree_util.register_dataclass on top of a standard @DataClass, as in mapc_sim.experimental.graph. This covers the Wall obstacle, the Internals of the simulator, and the type annotations of the walls and antenas modules, so chex is no longer needed at all. Wall is now a plain dataclass, so it is updated with dataclasses.replace instead of the chex .replace method. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFmELrvX87L5zFiKPYGwVt
Dropped
|
Take main's version of every conflicting file and re-apply only what the loss_gain argument and the accepts_walls decorator require: - sim.py: main's Nakagami fading, keeping the loss_gain parameter and the decorator, - utils.py: main's nakagami_fading_db, keeping tgax_path_loss additive in loss_gain plus binary_walls and accepts_walls, - pyproject.toml: main's jax 0.8 and tfp-nightly, plus the viz extra and mapc_sim.experimental in the package list, which main's explicit packages entry would otherwise drop from the distribution. Also document how the sampling noise of the wall estimator relates to the new Nakagami fading, and stop asserting the absence of unrelated DeprecationWarnings in test_compat, since tfp-nightly emits them on jax 0.8. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFmELrvX87L5zFiKPYGwVt
Merged
|
There was a problem hiding this comment.
Pull request overview
Adds beamforming and geometric wall modeling through a generalized additive loss_gain matrix.
Changes:
- Adds antenna gain and Monte Carlo wall models.
- Preserves keyword-based compatibility for legacy wall matrices.
- Adds packaging, documentation, visualization, and tests.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
mapc_sim/sim.py |
Integrates loss_gain into simulation. |
mapc_sim/utils.py |
Adds compatibility and wall conversion helpers. |
mapc_sim/experimental/walls.py |
Implements geometric wall attenuation. |
mapc_sim/experimental/antenas.py |
Implements directional antenna gains. |
test/test_walls.py |
Tests wall geometry and attenuation. |
test/test_compat.py |
Tests legacy API compatibility. |
test/test_antenas.py |
Tests antenna and beamforming behavior. |
README.md |
Updates usage and compatibility guidance. |
pyproject.toml |
Packages experimental modules and visualization extras. |
docs/walls.rst |
Documents the wall model. |
docs/antennas.rst |
Documents antenna gain conventions. |
docs/index.rst |
Adds features and documentation navigation. |
docs/api.rst |
Exposes experimental APIs. |
Suppressed comments (1)
mapc_sim/experimental/walls.py:314
_pair_hitsreuses each sampled point for every wall, so the wall indicators are correlated. Summing only the individual binomial variances omits covariance terms and returns the wrong standard deviation for links crossing multiple walls (for two identical overlapping walls, this underestimates the variance by a factor of two). Compute the variance of the per-sample weighted sum, or include pairwise joint hit probabilities, before using this value to calibratesigma.
var = ((walls.attenuation ** 2) * p * (1. - p) / n_samples).sum(axis=-1)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| idx = jnp.arange(n) | ||
| lo = jnp.minimum(idx[:, None], idx[None, :]) | ||
| hi = jnp.maximum(idx[:, None], idx[None, :]) | ||
| return jax.vmap(jax.vmap(jax.random.fold_in, in_axes=(None, 0)), in_axes=(None, 0))(key, lo * n + hi) |
| It is added to the path loss, so walls contribute a positive value and antenna gains a | ||
| negative one. It can be built from a geometric description of the environment with | ||
| :func:`mapc_sim.experimental.walls.wall_attenuation`, from antenna patterns with | ||
| :func:`mapc_sim.experimental.antenas.gain`, or from a binary adjacency matrix of walls |
| * The sampling noise of the wall estimator is **shadowing (slow) fading** -- driven | ||
| by the uncertainty about the obstacles the link crosses, and correlated for links | ||
| that share geometry. |
| This module is experimental and its API may change. See :doc:`antennas` for | ||
| a discussion of the gain convention. | ||
|
|
||
| .. automodule:: mapc_sim.experimental.antenas |
This pr introduces beam forming and better walls handling in the simulator.
TODO
wallsargumentdocs/antennas.rst)