Skip to content

Commit 1e0d6b8

Browse files
aumashankarpre-commit-ci[bot]umashankar-xebia
authored
Implement Hotelling Law example (#120)
* Add hotelling-law project * Added team details * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * changed import statements * fixing imports with ruff * fixing recognizing hotelling_law module by tests * fixing imports for recognizing hotelling_law module by tests * fixing imports for recognizing hotelling_law module by tests * fixing import sequence with ruff * refactored code inline with other examples -fixing review comments 1. The self.can_move check is redundant here, because it's already done in self.move 2. model.agents is the new API, and is simpler. 3. The whole function can be simplified to return np.mean(model.agents.get("price")). 4. The intermediate variables are not necessary, because the docstring is already sufficiently descriptive. 5. added tests for slope * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * - fixing feedback comment * - fixing import * - processing feedback comment * - processing feedback comment * - processing feedback comments. integrating mesa3.0 experimental UI * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixing lint and import sort issues * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * processing feedback * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update Readme.md * adopted project structure with other examples, removed relative imports and changed test for variance as for hotelling law variance need not decrease depends on factors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added consumer preferences, market share dynamics to have changes in pricing and location. Removed old implementation * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixing lint * updated dependencies as per feedback * chore: fixing dependencies * chore: removing profile tests --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: umashankar-xebia <umashankar.ankuri@xebia.com>
1 parent 1933cbc commit 1e0d6b8

File tree

9 files changed

+962
-0
lines changed

9 files changed

+962
-0
lines changed

examples/hotelling_law/Readme.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Hotelling's Law Mesa Simulation
2+
3+
## Overview
4+
5+
This project is an agent-based model implemented using the Mesa framework in Python. It simulates market dynamics based on Hotelling's Law, exploring the behavior of stores in a competitive market environment. Stores adjust their prices and locations if it's increases market share to maximize revenue, providing insights into the effects of competition and customer behavior on market outcomes.
6+
7+
## Hotelling's Law
8+
9+
Hotelling's Law is an economic theory that predicts competitors in a market will end up in a state of minimum differentiation, often referred to as the "principle of minimum differentiation" or "Hotelling's linear city model". This model explores how businesses choose their location in relation to competitors and how this affects pricing and consumer choice.
10+
11+
## Installation
12+
13+
To run this simulation, you will need Python 3.x and the following Python libraries:
14+
15+
- mesa
16+
- scipy
17+
18+
You can install all required libraries by running:
19+
20+
```bash
21+
pip install -r requirements.txt
22+
```
23+
24+
## Project Structure
25+
26+
```plaintext
27+
mesa-examples/
28+
└── examples/
29+
└── hotelling_law/
30+
├── hotelling_law/
31+
│ ├── __init__.py
32+
│ ├── model.py
33+
│ └── agents.py
34+
├── __init__.py
35+
├── app.py
36+
├── Readme.md
37+
├── requirements.txt
38+
└── tests.py
39+
```
40+
41+
## Running the Simulation
42+
43+
To start the simulation, navigate to the project directory and execute the following command:
44+
45+
```bash
46+
solara run app.py
47+
```
48+
49+
# Project Details
50+
51+
### Professor: [Vipin P. Veetil](https://www.vipinveetil.com/)
52+
### Indian Institute of Management, Kozhikode
53+
54+
### Project by
55+
56+
| Group 8 | | |
57+
|-|---------------------------|---------------|
58+
| Name | Email Id | Roll No |
59+
| Amrita Tripathy | amrita15d@iimk.edu.in | EPGP-15D-010 |
60+
| Anirban Mondal | anirban15e@iimk.edu.in | EPGP-15E-006 |
61+
| Namita Das | namita15d@iimk.edu.in | EPGP-15D-046 |
62+
| Sandeep Shenoy | sandeep15c@iimk.edu.in | EPGP-15C-076 |
63+
| Sanjeeb Kumar Dhinda | sanjeeb15d@iimk.edu.in | EPGP-15D-074 |
64+
| Umashankar Ankuri | umashankar15d@iimk.edu.in | EPGP-15D-096 |
65+
| Vinayak Nair | vinayak15d@iimk.edu.in | EPGP-15D-102 |
66+
| Wayne Joseph Unger | wayne15d@iimk.edu.in | EPGP-15D-104 |
67+
68+
69+
### Hotelling Law Simulation - Visualization
70+
![plot](hotelling_law_sim.png)

examples/hotelling_law/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)