Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions docs/api/simulator/occupancy.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
# Occupancy
# Occupancy Models

::: smart_control.simulator.randomized_arrival_departure_occupancy
This page documents all occupancy models available in the `smart_control.simulator.occupancy` module.

::: smart_control.simulator.step_function_occupancy
## Model Comparison

::: smart_control.simulator.stochastic_occupancy
The following chart compares the behavior of all occupancy models over a 24-hour period with 5-minute intervals:

![Occupancy Model Comparison](../../assets/images/occupancy_comparison.png)

For an interactive version of this chart, see the [interactive occupancy comparison plot](../../assets/plots/occupancy_comparison.html).

The comparison script can be run with:
```bash
python -m smart_control.simulator.occupancy.compare
```

## Enhanced Occupancy

::: smart_control.simulator.occupancy.enhanced_occupancy

## Stochastic Occupancy (LIGHTSWITCH)

::: smart_control.simulator.occupancy.stochastic_occupancy

## Randomized Arrival/Departure Occupancy

::: smart_control.simulator.occupancy.randomized_arrival_departure_occupancy

## Step Function Occupancy

::: smart_control.simulator.occupancy.step_function_occupancy
Binary file added docs/assets/images/occupancy_comparison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,888 changes: 3,888 additions & 0 deletions docs/assets/plots/occupancy_comparison.html

Large diffs are not rendered by default.

54 changes: 3 additions & 51 deletions smart_control/simulator/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,6 @@ py_strict_test(
],
)

py_strict_test(
name = "randomized_arrival_departure_occupancy_test",
srcs = ["randomized_arrival_departure_occupancy_test.py"],
deps = [
":randomized_arrival_departure_occupancy",
"//third_party/py/absl/testing:absltest",
"//third_party/py/absl/testing:parameterized",
"//third_party/py/google/protobuf:use_fast_cpp_protos", # Automatically added go/proto_python_upb_flip
"//third_party/py/numpy",
"//third_party/py/pandas",
],
)

py_strict_test(
name = "rejection_simulator_building_test",
srcs = ["rejection_simulator_building_test.py"],
Expand Down Expand Up @@ -167,7 +154,7 @@ py_strict_test(
":hvac_floorplan_based",
":setpoint_schedule",
":simulator_flexible_floor_plan",
":step_function_occupancy",
"//third_party/py/smart_buildings/smart_control/simulator/occupancy:step_function_occupancy",
":weather_controller",
"//third_party/py/absl/testing:absltest",
"//third_party/py/absl/testing:parameterized",
Expand All @@ -189,7 +176,7 @@ py_strict_test(
":hvac",
":setpoint_schedule",
":simulator",
":step_function_occupancy",
"//third_party/py/smart_buildings/smart_control/simulator/occupancy:step_function_occupancy",
":weather_controller",
"//third_party/py/absl/testing:absltest",
"//third_party/py/absl/testing:parameterized",
Expand All @@ -212,18 +199,6 @@ py_strict_test(
],
)

py_strict_test(
name = "step_function_occupancy_test",
srcs = ["step_function_occupancy_test.py"],
deps = [
":step_function_occupancy",
"//third_party/py/absl/testing:absltest",
"//third_party/py/absl/testing:parameterized",
"//third_party/py/google/protobuf:use_fast_cpp_protos", # Automatically added go/proto_python_upb_flip
"//third_party/py/pandas",
],
)

py_strict_test(
name = "thermal_diffuser_utils_test",
srcs = ["thermal_diffuser_utils_test.py"],
Expand Down Expand Up @@ -336,18 +311,6 @@ pytype_strict_library(
],
)

pytype_strict_library(
name = "randomized_arrival_departure_occupancy",
srcs = ["randomized_arrival_departure_occupancy.py"],
deps = [
"//third_party/py/gin",
"//third_party/py/numpy",
"//third_party/py/pandas",
"//third_party/py/smart_buildings/smart_control/models:base_occupancy",
"//third_party/py/smart_buildings/smart_control/utils:conversion_utils",
],
)

pytype_strict_library(
name = "rejection_simulator_building",
srcs = ["rejection_simulator_building.py"],
Expand Down Expand Up @@ -452,7 +415,7 @@ pytype_strict_library(
":setpoint_schedule",
":simulator",
":simulator_building",
":step_function_occupancy",
"//third_party/py/smart_buildings/smart_control/simulator/occupancy:step_function_occupancy",
":weather_controller",
"//third_party/py/absl/testing:parameterized",
"//third_party/py/pandas",
Expand Down Expand Up @@ -490,17 +453,6 @@ pytype_strict_library(
],
)

pytype_strict_library(
name = "step_function_occupancy",
srcs = ["step_function_occupancy.py"],
deps = [
"//third_party/py/gin",
"//third_party/py/pandas",
"//third_party/py/smart_buildings/smart_control/models:base_occupancy",
"//third_party/py/smart_buildings/smart_control/utils:conversion_utils",
],
)

pytype_strict_library(
name = "thermal_diffuser_utils",
srcs = ["thermal_diffuser_utils.py"],
Expand Down
124 changes: 124 additions & 0 deletions smart_control/simulator/occupancy/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# BUILD file for simulator/occupancy package.
load("//devtools/python/blaze:pytype.bzl", "pytype_strict_library")
load("//devtools/python/blaze:strict.bzl", "py_strict_test")

package(
default_applicable_licenses = ["//third_party/py/smart_buildings:license"],
default_visibility = ["//visibility:public"],
)

# Occupancy Model Libraries

pytype_strict_library(
name = "enhanced_occupancy",
srcs = ["enhanced_occupancy.py"],
deps = [
"//third_party/py/gin",
"//third_party/py/numpy",
"//third_party/py/pandas",
"//third_party/py/smart_buildings/smart_control/models:base_occupancy",
"//third_party/py/smart_buildings/smart_control/utils:conversion_utils",
],
)

pytype_strict_library(
name = "stochastic_occupancy",
srcs = ["stochastic_occupancy.py"],
deps = [
"//third_party/py/gin",
"//third_party/py/numpy",
"//third_party/py/pandas",
"//third_party/py/smart_buildings/smart_control/models:base_occupancy",
"//third_party/py/smart_buildings/smart_control/utils:conversion_utils",
],
)

pytype_strict_library(
name = "randomized_arrival_departure_occupancy",
srcs = ["randomized_arrival_departure_occupancy.py"],
deps = [
"//third_party/py/gin",
"//third_party/py/numpy",
"//third_party/py/pandas",
"//third_party/py/smart_buildings/smart_control/models:base_occupancy",
"//third_party/py/smart_buildings/smart_control/utils:conversion_utils",
],
)

pytype_strict_library(
name = "step_function_occupancy",
srcs = ["step_function_occupancy.py"],
deps = [
"//third_party/py/gin",
"//third_party/py/pandas",
"//third_party/py/smart_buildings/smart_control/models:base_occupancy",
"//third_party/py/smart_buildings/smart_control/utils:conversion_utils",
],
)

# Occupancy Model Tests

py_strict_test(
name = "enhanced_occupancy_test",
srcs = ["enhanced_occupancy_test.py"],
deps = [
":enhanced_occupancy",
"//third_party/py/absl/testing:absltest",
"//third_party/py/absl/testing:parameterized",
"//third_party/py/google/protobuf:use_fast_cpp_protos",
"//third_party/py/numpy",
"//third_party/py/pandas",
],
)

py_strict_test(
name = "stochastic_occupancy_test",
srcs = ["stochastic_occupancy_test.py"],
deps = [
":stochastic_occupancy",
"//third_party/py/absl/testing:absltest",
"//third_party/py/absl/testing:parameterized",
"//third_party/py/google/protobuf:use_fast_cpp_protos",
"//third_party/py/numpy",
"//third_party/py/pandas",
],
)

py_strict_test(
name = "randomized_arrival_departure_occupancy_test",
srcs = ["randomized_arrival_departure_occupancy_test.py"],
deps = [
":randomized_arrival_departure_occupancy",
"//third_party/py/absl/testing:absltest",
"//third_party/py/absl/testing:parameterized",
"//third_party/py/google/protobuf:use_fast_cpp_protos",
"//third_party/py/numpy",
"//third_party/py/pandas",
],
)

py_strict_test(
name = "step_function_occupancy_test",
srcs = ["step_function_occupancy_test.py"],
deps = [
":step_function_occupancy",
"//third_party/py/absl/testing:absltest",
"//third_party/py/absl/testing:parameterized",
"//third_party/py/google/protobuf:use_fast_cpp_protos",
"//third_party/py/pandas",
],
)
37 changes: 37 additions & 0 deletions smart_control/simulator/occupancy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""Occupancy models for building simulation.

This module contains various occupancy models that simulate the presence and
behavior of people in building zones. These models are used to calculate
average occupancy for different time intervals, which is an important input
for building simulation and control.

Available Models:
- EnhancedOccupancy: Enhanced stochastic model with minute-level control
and different worker types (weekday-only, weekend-regular, etc.)
- LIGHTSWITCHOccupancy: Stochastic model based on the LIGHTSWITCH algorithm
with arrival, departure, and lunch break patterns
- RandomizedArrivalDepartureOccupancy: Model with randomized arrival and
departure times within specified windows
- StepFunctionOccupancy: Simple model with constant occupancy levels for
work and non-work periods
"""

from smart_control.simulator.occupancy.enhanced_occupancy import EnhancedOccupancy
from smart_control.simulator.occupancy.enhanced_occupancy import MinuteLevelZoneOccupant
from smart_control.simulator.occupancy.enhanced_occupancy import WorkerType
from smart_control.simulator.occupancy.randomized_arrival_departure_occupancy import RandomizedArrivalDepartureOccupancy
from smart_control.simulator.occupancy.step_function_occupancy import StepFunctionOccupancy
from smart_control.simulator.occupancy.stochastic_occupancy import LIGHTSWITCHOccupancy
from smart_control.simulator.occupancy.stochastic_occupancy import OccupancyStateEnum
from smart_control.simulator.occupancy.stochastic_occupancy import ZoneOccupant

__all__ = [
"EnhancedOccupancy",
"MinuteLevelZoneOccupant",
"WorkerType",
"LIGHTSWITCHOccupancy",
"ZoneOccupant",
"RandomizedArrivalDepartureOccupancy",
"StepFunctionOccupancy",
"OccupancyStateEnum",
]
Loading
Loading