-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...s-dialog/implementation-nisq-analyzer-qpu-selection-initial-weights-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<div *ngIf="weightLearningForm"> | ||
<h1 mat-dialog-title>Initially learned Weights</h1> | ||
<div mat-dialog-content> | ||
<form [formGroup]="weightLearningForm"> | ||
<p>The learned weights are presented</p> | ||
<div formArrayName="criteriaAndValues"> | ||
<div *ngFor="let criterion of criteriaNamesAndValues; let i = index" [formGroupName]="i"> | ||
<div *ngIf="criterion.name !== 'queue-size'"> | ||
{{ criterion.name }}: | ||
<br> | ||
{{ criterion.weight }} | ||
</div> | ||
<br> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
<div mat-dialog-actions> | ||
<button mat-button [mat-dialog-close]="data">Ok | ||
</button> | ||
</div> | ||
</div> |
Empty file.
97 changes: 97 additions & 0 deletions
97
...hts-dialog/implementation-nisq-analyzer-qpu-selection-initial-weights-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { Component, Inject, OnInit } from '@angular/core'; | ||
import { AbstractControl, FormBuilder, FormGroup } from '@angular/forms'; | ||
import { | ||
MAT_DIALOG_DATA, | ||
MatDialog, | ||
MatDialogRef, | ||
} from '@angular/material/dialog'; | ||
import { XmcdaCriteriaService } from 'api-nisq/services/xmcda-criteria.service'; | ||
// eslint-disable-next-line max-len | ||
import { Criterion } from '../implementation-nisq-analyzer-qpu-selection-prioritization-dialog/implementation-nisq-analyzer-qpu-selection-prioritization-dialog.component'; | ||
|
||
@Component({ | ||
selector: | ||
'app-implementation-nisq-analyzer-qpu-selection-initial-weights-dialog', | ||
templateUrl: | ||
'./implementation-nisq-analyzer-qpu-selection-initial-weights-dialog.component.html', | ||
styleUrls: [ | ||
'./implementation-nisq-analyzer-qpu-selection-initial-weights-dialog.component.scss', | ||
], | ||
}) | ||
export class ImplementationNisqAnalyzerQpuSelectionInitialWeightsDialogComponent | ||
implements OnInit { | ||
weightLearningForm: FormGroup; | ||
criteriaNamesAndValues: Criterion[] = []; | ||
inputChanged = false; | ||
|
||
constructor( | ||
public dialogRef: MatDialogRef< | ||
ImplementationNisqAnalyzerQpuSelectionInitialWeightsDialogComponent | ||
>, | ||
@Inject(MAT_DIALOG_DATA) public data: DialogData, | ||
public dialog: MatDialog, | ||
private formBuilder: FormBuilder, | ||
private mcdaService: XmcdaCriteriaService | ||
) {} | ||
|
||
get criteriaAndValues(): AbstractControl | null { | ||
return this.weightLearningForm.get('criteriaAndValues'); | ||
} | ||
|
||
ngOnInit(): void { | ||
this.onMcdaMethodChanged(); | ||
} | ||
|
||
onNoClick(): void { | ||
this.dialogRef.close(); | ||
} | ||
|
||
onMcdaMethodChanged(): void { | ||
this.criteriaNamesAndValues = []; | ||
this.mcdaService | ||
.getCriterionForMethod({ methodName: this.data.mcdaMethod }) | ||
.subscribe((criteriaList) => { | ||
// then get for each criterion the name and value and store both in the map as value | ||
criteriaList.mcdaCriterionList.forEach((criterion) => { | ||
this.mcdaService | ||
.getCriterionValue({ | ||
methodName: this.data.mcdaMethod, | ||
criterionId: criterion.id, | ||
}) | ||
.subscribe((criterionValueModel) => { | ||
const value = criterionValueModel.valueOrValues.pop(); | ||
if (value) { | ||
const realValue = value['real']; | ||
this.criteriaNamesAndValues.push({ | ||
id: criterion.id, | ||
name: criterion.name, | ||
weight: realValue, | ||
points: Math.round( | ||
Number(criterionValueModel.description.subTitle) | ||
), | ||
}); | ||
} | ||
this.weightLearningForm = this.formBuilder.group({ | ||
criteriaAndValues: this.formBuilder.array( | ||
this.criteriaNamesAndValues.map((c) => | ||
this.formBuilder.group({ | ||
[c.name]: [c.weight], | ||
}) | ||
) | ||
), | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
onChangeEvent(): void { | ||
this.inputChanged = true; | ||
} | ||
} | ||
|
||
export interface DialogData { | ||
title: string; | ||
mcdaMethod: string; | ||
criteriaAndValues: Criterion[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters