Skip to content

Commit

Permalink
fix quality command
Browse files Browse the repository at this point in the history
  • Loading branch information
milesstoetzner committed Sep 17, 2024
1 parent 527b544 commit aaa5e73
Show file tree
Hide file tree
Showing 25 changed files with 78,601 additions and 17,518 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ set -e
source configuration.sh

# Quality
$VINTNER template quality --template ${TEMPLATE_DIR}/variable-service-template.yaml --presets ${DEPLOYMENT_VARIANT}
for dir in ../tests/*/;
#for dir in "../tests/gcp";
do
dir=$(basename $dir)
echo "${dir}: $($VINTNER template quality --template ${TEMPLATE_DIR}/variable-service-template.yaml --inputs ${TEMPLATE_DIR}/tests/${dir}/inputs.yaml)"
done
26 changes: 20 additions & 6 deletions src/controller/study/technology.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as files from '#files'
import Graph from '#graph/graph'
import Loader from '#graph/loader'
import * as utils from '#utils'
import * as console from 'node:console'
import path from 'path'

export type StudyTechnologyOptions = {
Expand Down Expand Up @@ -240,12 +241,21 @@ export default async function (options: StudyTechnologyOptions) {

qualityData.push({
scenario: original,
expert: quality.max_weight.weight,
non_expert: [quality.min_weight, quality.max_weight],
random: [quality.min_weight.weight, quality.max_weight.weight],
counting: [quality.min_count.min.weight, quality.min_count.max.weight],
quality: quality.max_weight.weight,
quality_counting: quality.max_weight_min_count.weight,
expert: utils.roundNumber(quality.max_weight.technologies.weight_average),
non_expert: [
utils.roundNumber(quality.min_weight.technologies.weight_average),
utils.roundNumber(quality.max_weight.technologies.weight_average),
],
random: [
utils.roundNumber(quality.min_weight.technologies.weight_average),
utils.roundNumber(quality.max_weight.technologies.weight_average),
],
counting: [
utils.roundNumber(quality.min_count.min.technologies.weight_average),
utils.roundNumber(quality.min_count.max.technologies.weight_average),
],
quality: utils.roundNumber(quality.max_weight.technologies.weight_average),
quality_counting: utils.roundNumber(quality.max_weight_min_count.technologies.weight_average),
})
}

Expand Down Expand Up @@ -341,6 +351,10 @@ export default async function (options: StudyTechnologyOptions) {
*/
relativeMaintenanceDiff(vdmm_plus_automated_diff, vdmm_baseline_diff),
])

console.log()
console.log('CAUTION: Is this case study running with the latest implementation?')
console.log()
}

type StudyConfig = {
Expand Down
31 changes: 18 additions & 13 deletions src/controller/template/quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ async function weight(options: TemplateQualityOptions, direction: 'min' | 'max')
const result = utils.first(optimized)

return {
weight: utils.roundNumber(result.quality.average),
direction,
count: result.technologies,
topology: result.topology,
technologies: result.technologies,
}
}

Expand All @@ -60,10 +60,10 @@ async function count(options: TemplateQualityOptions, direction: 'min' | 'max')
},
})
const all = new Resolver(loaded.graph, loaded.inputs).optimize({all: true})
const min = Math.min(...all.map(it => it.technologies.count))
const minCountGroups = Math.min(...all.map(it => it.technologies.count_groups))
const candidates = all
.filter(it => it.technologies.count === min)
.sort((a, b) => a.quality.average - b.quality.average)
.filter(it => it.technologies.count_groups === minCountGroups)
.sort((a, b) => a.technologies.weight_average - b.technologies.weight_average)

// TODO: remove this
/*
Expand All @@ -74,20 +74,25 @@ async function count(options: TemplateQualityOptions, direction: 'min' | 'max')
console.log(
candidates.map(it => ({
technologies: it.technologies.count_each,
quality: it.quality.average,
quality: it.technologies.weight_average,
presences: it.getPresences('technology'),
}))
)
*/

const minResult = utils.first(candidates)
const maxResult = utils.last(candidates)
const min = utils.first(candidates)
const max = utils.last(candidates)

return {
count: min,
direction,
min: minResult.technologies,
max: maxResult.technologies,
min: {
topology: min.topology,
technologies: min.technologies,
},
max: {
topology: max.topology,
technologies: max.technologies,
},
}
}

Expand All @@ -107,7 +112,7 @@ async function weightCount(options: TemplateQualityOptions) {
const result = utils.first(optimized)

return {
weight: utils.roundNumber(result.quality.average),
count: result.technologies,
topology: result.topology,
technologies: result.technologies,
}
}
48 changes: 20 additions & 28 deletions src/resolver/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class Result {
.map(([name, _]) => name)
}

get topology(): {count: number; weight: number} {
get topology(): {count: number; weight: number; components: string[]} {
/**
* Present nodes
*/
Expand All @@ -60,15 +60,24 @@ export class Result {
*/
const weight = present.reduce((sum, it) => sum + it.weight, 0)

return {count, weight}
/**
* Components (names of present components)
*/
const components = present.map(it => it.name)

/**
* Result
*/
return {count, weight, components}
}

get technologies(): {
count: number
count_groups: number
count_total: number
count_each: {[technology: string]: number}
weight: number
weight_each: {[technology: string]: number}
weight_average: number
assignments: string[]
} {
/**
Expand All @@ -80,12 +89,14 @@ export class Result {
/**
* Count (total number of different technologies, i.e., number of groups by name)
*/
const count = Object.values(groups).length
const count_groups = Object.values(groups).length

/**
* Count Total (total number of all present technologies)
*/
const count_total = present.length
assert.isNumber(count_total)
if (count_total === 0) throw new Error(`Technology count is 0`)

/**
* Count Each (number of technologies per group)
Expand All @@ -109,37 +120,18 @@ export class Result {
}, {})

/**
* Presences
*/
const assignments = this.getPresences('technology')

/**
* Result
*/
return {count, count_total, count_each, weight, weight_each, assignments}
}

get quality(): {count: number; weight: number; average: number} {
/**
* Count (total number of present technologies)
* Weight Average (average weight per technology
*/
const count = this.graph.technologies.filter(it => this.isPresent(it)).length
assert.isNumber(count)
if (count === 0) throw new Error(`Technology count is 0`)
const weight_average = weight / count_total

/**
* Weight (sum of all weights of all present technologies)
*/
const weight = this.technologies.weight

/**
* Average (average weight per technology)
* Presences
*/
const average = this.technologies.weight / count
const assignments = this.getPresences('technology')

/**
* Result
*/
return {count, weight, average}
return {count_groups, count_total, count_each, weight, weight_each, weight_average, assignments}
}
}

0 comments on commit aaa5e73

Please sign in to comment.