Skip to content

Commit

Permalink
Ensemble weights to not be normalized (#5536)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Szendrey authored Nov 18, 2024
1 parent 5bb9d5d commit 9f8445a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,33 @@
</template>
</Dropdown>
<!-- Signal Bars -->
<ul>
<li v-for="n in numberOfBars" :key="n" :class="{ active: n <= modelValue }" :style="getBarStyle(n)" />
<ul v-if="minOption > 0">
<li v-for="n in options.length" :key="n" :class="{ active: n <= modelValue }" :style="getBarStyle(n)" />
</ul>
<ul v-if="minOption <= 0">
<li v-for="n in options.length - 1" :key="n" :class="{ active: n <= modelValue }" :style="getBarStyle(n)" />
</ul>
</div>
</template>

<script setup lang="ts">
import _ from 'lodash';
import Dropdown from 'primevue/dropdown';
import { ref } from 'vue';
const baseDelay = 0.03; // transition delay for each bar
const barWidth = 2; // width for each bar
const maxNumberOfBars = 15; // just setting a max number of bars arbitrarily
const props = defineProps({
modelValue: {
type: Number,
required: true
},
numberOfBars: {
minOption: {
type: Number,
default: 0
},
maxOption: {
type: Number,
default: 10
},
Expand All @@ -39,9 +46,8 @@ const props = defineProps({
const emit = defineEmits(['update:modelValue']);
const previousValue = ref(props.modelValue);
const numberOfBars = Math.min(props.numberOfBars, maxNumberOfBars);
const options: number[] = Array.from({ length: numberOfBars + 1 }, (_, i) => i);
const options: number[] = _.range(props.minOption, props.maxOption + 1, 1);
// fun styling for the bars :)
const getBarStyle = (n: number) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export function formatCalibrateModelConfigurations(
weights: CalibrateEnsembleWeights
): EnsembleModelConfigs[] {
const ensembleModelConfigMap: { [key: string]: EnsembleModelConfigs } = {};
const totalWeight = Object.values(weights).reduce((acc, curr) => acc + curr, 0) ?? 1;
// 1. map the weights to the ensemble model configs
Object.entries(weights).forEach(([key, value]) => {
// return if there is no weight
Expand All @@ -52,7 +51,7 @@ export function formatCalibrateModelConfigurations(
const ensembleModelConfig: EnsembleModelConfigs = {
id: key,
solutionMappings: {},
weight: value / totalWeight
weight: value
};

ensembleModelConfigMap[key] = ensembleModelConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<tera-signal-bars
v-if="modelConfiguration?.id"
class="ml-auto"
:min-option="1"
:model-value="knobs.configurationWeights[modelConfiguration.id] ?? 0"
@update:model-value="knobs.configurationWeights[modelConfiguration.id] = $event"
label="Relative certainty"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export function formatSimulateModelConfigurations(
weights: SimulateEnsembleWeights
): EnsembleModelConfigs[] {
const ensembleModelConfigMap: { [key: string]: EnsembleModelConfigs } = {};
const totalWeight = Object.values(weights).reduce((acc, curr) => acc + curr, 0) ?? 1;
// 1. map the weights to the ensemble model configs
Object.entries(weights).forEach(([key, value]) => {
// return if there is no weight
Expand All @@ -15,7 +14,7 @@ export function formatSimulateModelConfigurations(
const ensembleModelConfig: EnsembleModelConfigs = {
id: key,
solutionMappings: {},
weight: value / totalWeight
weight: value
};

ensembleModelConfigMap[key] = ensembleModelConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
<td>
<tera-signal-bars
label="Relative certainty"
:min-option="1"
v-model="knobs.weights[key]"
@change="updateWeights()"
/>
Expand Down

0 comments on commit 9f8445a

Please sign in to comment.