Code Monkey home page Code Monkey logo

smartcity-simulator's Introduction

SmartCity-simulator

Smart City Simulator designed for hackathons !

Package installation

pip3 install --user smartcity On Google Colab !pip3 install smartcity

Python > 3.6

Env Instantiation

In the package, 3 envs are available :

  • SmartCity-v0 : small env
  • SmartCity-v1 : medium env
  • SmartCity-v2 : big env
import smartcity
import gym

env = gym.make("SmartCity-v0")

obs, info = env.reset()

Actions

To send action, you have to send a dictionnary instead of the usual vectors. There's 3 keys to send : energies, heaters and lights. Energies defines how much of each type of energy you buy. Lights define whether each light is on or off (a threshold at 0.5 is set). Heaters define the temperature of each heater. To have the size and the type of each parameter, they are available in the obs variable. obs is a dictionnary you can use to predict your actions. Keys lights, heaters and energies_amount have the exact format requested for actions, you can just copy them.

Energies

Energies are ordered the same way for all the arrays

Observations and informations

There's 5 keys in the obs dictionnary :

  • lights : numpy array of size #light. Each light is either 0 (off) or 1 (on)
  • heaters : numpy array of size #heater. Each heater is defined by its temperature
  • energies_cost : cost of each quantity. This cost is defined for each point of each energy
  • energies_amount : available amount for energy
  • needed_energy : the total amount of energy needed. If you don't send enough energy, an exception is raised. During Hackathon submission, it will be an elimination criteria. If you buy more energy that needed, it is stored indefinitely so you can use it.

There's 2 keys in info dictionnary :

  • light_interraction : a matrix of shape (#people, #lights). If there's a 1 at [i, j], the citizen i is connected to light light
  • heaters_interraction : same as lights but for heaters
  • energy_pollution : pollution factor for each type of enegy (carbon, nuclear, renewable)

Example

import smartcity
import gym
import random

env = gym.make("SmartCity-v0")

obs, info = env.reset()

energies = [0.8*obs["needed_energy"], 0.15*obs["needed_energy"], 0.1*obs["needed_energy"]]

lights = np.array([random.random() for _ in range(obs["lights"].shape[0])])
heaters = obs["heaters"] + 2

actions = {"energies": energies, "heaters": heaters, "lights": lights}

obs, score, done, info = env.step(actions)

Evaluation

We'll give you a seed and a json file dubbed setting.json and a seed.

import smartcity
import gym

seed = # given seed
env = gym.make("SmartCity-v1337")
env.seed(seed)

obs, info = env.reset()
# Learning
# your code here

# Evaluation
env.seed(seed)
obs, info = env.reset()

with open("groupe_name.sub", "w") as f:
    for i in range(100):
        actions = # prediction de votre modèle
        obs, score, done, info = env.step(actions)
        f.write(f"{actions}\n")

Pour ceux qui sont dans colab, copiez collez le contenu du fichier json dans une variable dans une cellule puis sauvegarder là comme suit :

SEED = 1337

smartcity-simulator's People

Contributors

nicolasbizzozzero avatar ricocotam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

smartcity-simulator's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.