qns.utils package

Submodules

qns.utils.log module

qns.utils.log.critical(msg, *args)[source]
qns.utils.log.debug(msg, *args)[source]
qns.utils.log.error(msg, *args)[source]
qns.utils.log.info(msg, *args)[source]
qns.utils.log.install(s)[source]

Install the logger to the simulator

Parameters

s (Simulator) – the simulator

qns.utils.log.logger = <Logger qns (INFO)>

The default logger used by SimQN

qns.utils.log.monitor(*args, sep: str = ',', with_time: bool = False)[source]
qns.utils.log.warn(msg, *args)[source]

qns.utils.multiprocess module

class qns.utils.multiprocess.MPSimulations(settings: Dict = {}, iter_count: int = 1, aggregate: bool = True, cores: int = - 1, name: Optional[str] = None)[source]

Bases: object

MultiProcessSimulations will help users to perfrom multiple simulations with different experiment settings and leverage multiple processes.

get_data()[source]

Get the simulation results

Returns

a result data in pd.DataFrame

get_raw_data()[source]

Get the original raw results, no matter aggregate is True or not.

Returns

a result data in pd.DataFrame

prepare_setting()[source]

Generate the experiment setting for each experiments.

run(setting: Dict = {}) Dict[source]

This function should be overwited by users to provide codes that run a single simulation.

Parameters

setting (Dict) – the simulation setting, e.g. {‘node_num’: 10, ‘req_num’: 10, ‘memory_size’: 50}

Returns

100, ‘fidelity’: 0.88}

Return type

a dictionary that contains all results, e.g. {‘throughput’

start()[source]

Start the multiple process simulation

qns.utils.rnd module

qns.utils.rnd.get_choice(a)[source]

return an random element from a list

Parameters

a – a iterable object

qns.utils.rnd.get_normal(mean: float = 0, std: float = 1)[source]
qns.utils.rnd.get_rand(low: float = 0, high: float = 1) float[source]

Get a random number from [low, high)

Parameters
  • low (int) – the low bound

  • high (int) – the high bound

qns.utils.rnd.get_randint(low: int, high: int) float[source]

Get a random integer from [low, high]

Parameters
  • low (int) – the low bound

  • high (int) – the high bound

qns.utils.rnd.set_seed(seed: Optional[int] = None)[source]

Set a seed for random generator

Parameters

seed (int) – the seed

Module contents

qns.utils.critical(msg, *args)[source]
qns.utils.debug(msg, *args)[source]
qns.utils.error(msg, *args)[source]
qns.utils.get_choice(a)[source]

return an random element from a list

Parameters

a – a iterable object

qns.utils.get_rand(low: float = 0, high: float = 1) float[source]

Get a random number from [low, high)

Parameters
  • low (int) – the low bound

  • high (int) – the high bound

qns.utils.get_randint(low: int, high: int) float[source]

Get a random integer from [low, high]

Parameters
  • low (int) – the low bound

  • high (int) – the high bound

qns.utils.info(msg, *args)[source]
qns.utils.install(s)[source]

Install the logger to the simulator

Parameters

s (Simulator) – the simulator

qns.utils.monitor(*args, sep: str = ',', with_time: bool = False)[source]
qns.utils.set_seed(seed: Optional[int] = None)[source]

Set a seed for random generator

Parameters

seed (int) – the seed

qns.utils.warn(msg, *args)[source]