server package

server.Launch module

server.Server module

server.Visualization module

Defines the visualisation components for the Mesa server.

This module creates all the necessary elements for the browser-based visualisation of the simulation. It includes several agent portrayal functions that define how agents are coloured and described on the map based on their current state (e.g., heating system type, energy demand, knowledge). It also sets up chart modules for plotting time-series data and configures the main map visualisation.

Authors:
HS_portrayal(agent)[source]

Defines the portrayal for visualising the distribution of heating systems.

This function colours agents on the map based on the type of heating system currently installed in their house. Colours are defined in the global settings file.

Parameters:
agentmesa_geo.GeoAgent

The House agent to be portrayed.

Returns:
dict

A dictionary specifying the agent’s ‘size’ and ‘color’.

energy_demand_portrayal(agent)[source]

Defines the portrayal for visualising the distribution of energy demand.

This function colours agents on a yellow-to-red gradient based on their total energy demand. The colour intensity is scaled relative to the maximum energy demand observed in the model for normalisation.

Parameters:
agentmesa_geo.GeoAgent

The House agent to be portrayed.

Returns:
dict

A dictionary specifying the agent’s ‘size’ and ‘color’.

emissions_portrayal(agent)[source]

Defines the portrayal for visualizing the distribution of CO2 emissions.

This function colours agents on a green-to-red gradient based on their annual CO2 emissions. The colour intensity is scaled relative to the maximum emissions observed in the model for normalisation.

Parameters:
agentmesa_geo.GeoAgent

The House agent to be portrayed.

Returns:
dict

A dictionary specifying the agent’s ‘size’ and ‘color’.

information_overspread_middleware(agent)[source]

Acts as a dispatcher to select the active information-spread portrayal.

Based on a global setting, this function calls the appropriate portrayal method to visualise either the spread of subsidy knowledge, heating system knowledge, or the probability of installing a target system.

Parameters:
agentmesa_geo.GeoAgent

The House agent to be portrayed.

Returns:
dict

The portrayal dictionary from the selected function.

probability_of_installing_portrayal(agent)[source]

Defines the portrayal for visualising the likelihood of installing a target system.

This function colours an agent based on the comparison between the rating of their current heating system and their rating for a scenario-defined target system. The colour indicates how favourably the agent views the target system relative to their own.

Parameters:
agentmesa_geo.GeoAgent

The House agent to be portrayed.

Returns:
dict

A dictionary specifying the agent’s ‘color’ and ‘description’ (tooltip).

best_system_rating(agent)[source]

Defines the portrayal for visualising the rating of the target system vs. the best-known alternative.

This function colours an agent based on the ratio between their rating for a target heating system and the rating of the best alternative system they know. This helps to visualise the competitiveness of the target system from the agent’s perspective.

Parameters:
agentmesa_geo.GeoAgent

The House agent to be portrayed.

Returns:
dict

A dictionary specifying the agent’s ‘color’ and ‘description’ (tooltip).

server.additional_methods module

Helper functions for Mesa server visualisation.

This module provides utility functions used by the main visualisation components. It includes a colour converter and specific agent portrayal methods for visualising the spread of information (subsidies and heating system knowledge) on the simulation map.

Authors:
rgb_to_hex(rgb)[source]

Converts an RGB colour tuple to a hexadecimal string.

This function takes an RGB colour, represented as a list or tuple of three integers, and converts it into the standard hexadecimal colour format used in web and visualisation contexts.

Parameters:
rgblist or tuple of int

An iterable containing three integer values (Red, Green, Blue) ranging from 0 to 255.

Returns:
str

The hexadecimal color representation (e.g., ‘#RRGGBB’).

Examples

>>> rgb_to_hex([255, 0, 0])
'#ff0000'
>>> rgb_to_hex((0, 128, 255))
'#0080ff'
subsidy_overspread_portrayal(agent)[source]

Defines the agent portrayal for visualising subsidy knowledge.

This Mesa portrayal function determines how a House agent is displayed on the map. If the agent’s associated houseowner knows about the specific subsidy being observed in the model (agent.model.subsidy_to_observe), the agent is coloured green. Otherwise, it is white. The portrayal’s description tooltip lists all subsidies known by the agent.

Parameters:
agentmesa_geo.GeoAgent

The House agent to be portrayed. It is expected to have a houseowner attribute with subsidy information.

Returns:
dict

A dictionary specifying the agent’s ‘color’ and ‘description’ for the visualisation.

heating_system_overspread_portrayal(agent)[source]

Defines the agent portrayal for visualising heating system knowledge.

This Mesa portrayal function determines how a House agent is displayed on the map. If the agent’s associated houseowner knows about the specific heating system being observed in the model (agent.model.known_hs_to_observe), the agent is coloured green. Otherwise, it is white. The portrayal’s description tooltip lists all heating systems known by the agent.

Parameters:
agentmesa_geo.GeoAgent

The House agent to be portrayed. It is expected to have a houseowner attribute with heating system information.

Returns:
dict

A dictionary specifying the agent’s ‘color’ and ‘description’ for the visualisation.

Module contents