Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ INPUT_DATA_DIRECTORY_PATH=data
OUTPUT_DATA_DIRECTORY_PATH=output
NUMBER_OF_UPDATES_BETWEEN_STATES=1000
NUMBER_OF_STATES_TO_SEND_AT_ONCE=1
MAX_STATES_EXTRACTION_CONCURRENT_TASKS=10
DEBUG_TASKS=false
34 changes: 34 additions & 0 deletions .github/workflows/angular-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Angular Tests

on:
push:
branches:
- main
paths:
- 'python/**'
pull_request:
branches:
- main
paths:
- 'python/**'

jobs:
angular-tests:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '22'

- name: Install dependencies
run: npm install
working-directory: ./multimodal-ui

- name: Run tests
run: npm run test:ci
working-directory: ./multimodal-ui
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ venv
# Python cache
__pycache__

# Input data
data/

# Data files (saved_logs, saved_simulations)
output/saved_logs
output/saved_simulations
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ The most useful environment variables are `CLIENT_PORT`, `SERVER_PORT`, `INPUT_D
- `OUTPUT_DATA_DIRECTORY_PATH` (default `output`): The path to the output data directory.
- `NUMBER_OF_UPDATES_BETWEEN_STATES` (default `1000`): The number of updates between simulation states. The lower the number, the larger the save file will be. However, increasing this number may cause the animation to freeze when receiving new states from the server.
- `NUMBER_OF_STATES_TO_SEND_AT_ONCE` (default `1`): The number of states to send at once. Increasing this number may cause the animation to freeze when receiving new states from the server.
- `MAX_STATES_EXTRACTION_CONCURRENT_TASKS` (default `10`): The maximum number of states being extracted at the same time. Increasing this number might impact the memory usage during the loading only for a slight increase in performance.
- `DEBUG_TASKS` (default `false`): If set to `true`, debug logs regarding the tasks will be printed in the client console.

## Frontend

Expand Down
9 changes: 6 additions & 3 deletions multimodal-ui/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
},
"@schematics/angular:resolver": {
"skipTests": true
},
"@schematics/angular:service": {
"skipTests": true
}
},
"root": "",
Expand Down Expand Up @@ -114,6 +111,12 @@
"@angular/material/prebuilt-themes/azure-blue.css",
"src/styles.scss"
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test.ts"
}
],
"scripts": []
}
},
Expand Down
3 changes: 2 additions & 1 deletion multimodal-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"build": "npm run set-env && ng build",
"set-env": "ts-node scripts/set-environment.ts && prettier --write ./angular.json ./public/environment.json",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"test": "ng test --poll 1000",
"test:ci": "ng test --no-watch --no-progress --browsers=ChromeHeadless",
"lint": "ng lint",
"format": "prettier --write .",
"format:check": "prettier --check ."
Expand Down
2 changes: 2 additions & 0 deletions multimodal-ui/public/environment.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"OUTPUT_DATA_DIRECTORY_PATH": "output",
"NUMBER_OF_UPDATES_BETWEEN_STATES": "1000",
"NUMBER_OF_STATES_TO_SEND_AT_ONCE": "1",
"MAX_STATES_EXTRACTION_CONCURRENT_TASKS": "10",
"DEBUG_TASKS": "false",
"HOST": "127.0.0.1"
}
41 changes: 4 additions & 37 deletions multimodal-ui/src/app/interfaces/continuous.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import { SimulationState } from './state.model';
import { Statistics } from './statistics.model';
import { Stop } from './stop.model';
import { Tagged } from './tags.model';
import {
AtomicTask,
BUILD_CONTINUOUS_ENVIRONMENT_TASK_PRIORITY as BUILD_CONTINUOUS_ENVIRONMENTS_TASK_PRIORITY,
CompositeTask,
Task,
} from './task.model';
import { AtomicTask, CompositeTask, Task } from './task.model';
import {
PassengerUpdate,
StatisticsUpdate,
Expand Down Expand Up @@ -112,42 +107,14 @@ export function createContinuousEnvironmentReferences(): ContinuousEnvironmentRe
}

// MARK: Tasks
export class BuildContinuousEnvironmentsTask extends CompositeTask {
private readonly continuousEnvironments: ContinuousEnvironment[] = [];

constructor(
queue: SortedList<Task>,
private readonly states: SimulationState[],
private readonly references: ContinuousEnvironmentReferences,
private readonly callback: (environments: ContinuousEnvironment[]) => void,
) {
super(BUILD_CONTINUOUS_ENVIRONMENTS_TASK_PRIORITY, queue);
}

protected override beforeAll(): void {
for (const state of this.states) {
new BuildContinuousEnvironmentTask(
this.subtasks,
state,
this.references,
this.continuousEnvironments,
).addToQueue();
}
}

protected override afterAll(): void {
this.callback(this.continuousEnvironments);
}
}

class BuildContinuousEnvironmentTask extends CompositeTask {
export class BuildContinuousEnvironmentTask extends CompositeTask {
private readonly continuousEnvironment: ContinuousEnvironment;

constructor(
queue: SortedList<Task>,
private readonly state: SimulationState,
private readonly references: ContinuousEnvironmentReferences,
private readonly continuousEnvironments: ContinuousEnvironment[],
private readonly callback: (environment: ContinuousEnvironment) => void,
) {
super(0, queue);

Expand Down Expand Up @@ -207,7 +174,7 @@ class BuildContinuousEnvironmentTask extends CompositeTask {
}

protected override afterAll(): void {
this.continuousEnvironments.push(this.continuousEnvironment);
this.callback(this.continuousEnvironment);
}

private buildEmptyContinuousEnvironment(): ContinuousEnvironment {
Expand Down
47 changes: 47 additions & 0 deletions multimodal-ui/src/app/interfaces/performances.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ export class SortedList<T> {
return this._items.shift();
}

public remove(item: T): void {
const startIndex = this.findFirstEqualIndex(item);

if (startIndex === null) {
// Item not in list
return;
}

const index = this._items.indexOf(item, startIndex);

if (index !== -1) {
this._items.splice(index, 1);
}
}

public get length(): number {
return this._items.length;
}
Expand Down Expand Up @@ -44,4 +59,36 @@ export class SortedList<T> {

return low; // Insertion point
}

private findFirstEqualIndex(item: T): number | null {
let low = 0;
let high = this._items.length - 1;

while (low < high) {
const mid = Math.floor((low + high) / 2);
const comparison = this.compare(this._items[mid], item);

if (comparison < 0) {
low = mid + 1;
} else if (comparison > 0) {
high = mid - 1;
} else {
high = mid;
}
}

const lowComparison = this.compare(this._items[low], item);

if (lowComparison === 0) {
return low;
}

const highComparison = this.compare(this._items[high], item);

if (highComparison === 0) {
return high;
}

return null;
}
}
Loading
Loading