Skip to content

Commit

Permalink
Implement Hotelling Law example (projectmesa#120)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored Apr 20, 2024
1 parent 1933cbc commit 1e0d6b8
Show file tree
Hide file tree
Showing 9 changed files with 962 additions and 0 deletions.
70 changes: 70 additions & 0 deletions examples/hotelling_law/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Hotelling's Law Mesa Simulation

## Overview

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.

## Hotelling's Law

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.

## Installation

To run this simulation, you will need Python 3.x and the following Python libraries:

- mesa
- scipy

You can install all required libraries by running:

```bash
pip install -r requirements.txt
```

## Project Structure

```plaintext
mesa-examples/
└── examples/
└── hotelling_law/
├── hotelling_law/
│ ├── __init__.py
│ ├── model.py
│ └── agents.py
├── __init__.py
├── app.py
├── Readme.md
├── requirements.txt
└── tests.py
```

## Running the Simulation

To start the simulation, navigate to the project directory and execute the following command:

```bash
solara run app.py
```

# Project Details

### Professor: [Vipin P. Veetil](https://www.vipinveetil.com/)
### Indian Institute of Management, Kozhikode

### Project by

| Group 8 | | |
|-|---------------------------|---------------|
| Name | Email Id | Roll No |
| Amrita Tripathy | amrita15d@iimk.edu.in | EPGP-15D-010 |
| Anirban Mondal | anirban15e@iimk.edu.in | EPGP-15E-006 |
| Namita Das | namita15d@iimk.edu.in | EPGP-15D-046 |
| Sandeep Shenoy | sandeep15c@iimk.edu.in | EPGP-15C-076 |
| Sanjeeb Kumar Dhinda | sanjeeb15d@iimk.edu.in | EPGP-15D-074 |
| Umashankar Ankuri | umashankar15d@iimk.edu.in | EPGP-15D-096 |
| Vinayak Nair | vinayak15d@iimk.edu.in | EPGP-15D-102 |
| Wayne Joseph Unger | wayne15d@iimk.edu.in | EPGP-15D-104 |


### Hotelling Law Simulation - Visualization
![plot](hotelling_law_sim.png)
Empty file.
Loading

0 comments on commit 1e0d6b8

Please sign in to comment.