Skip to content

Commit

Permalink
Updating optimize to have presets (#4322)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvince2 authored Jul 30, 2024
1 parent a7c0447 commit 42b3d57
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,19 +266,19 @@ const presetType = computed(() => {
return '';
});
const speedValues = {
const speedValues = Object.freeze({
numSamples: 1,
method: CiemssMethodOptions.euler,
numIterations: 10,
learningRate: 0.1
};
});
const qualityValues = {
const qualityValues = Object.freeze({
numSamples: 100,
method: CiemssMethodOptions.dopri5,
numIterations: 1000,
learningRate: 0.03
};
});
const numSamples = ref<number>(props.node.state.numSamples);
const method = ref<string>(props.node.state.method);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@on-close-clicked="emit('close')"
@update-state="(state: any) => emit('update-state', state)"
>
<section :tabName="OptimizeTabs.Wizard" class="ml-4 mr-2 pt-3">
<section :tabName="DrilldownTabs.Wizard" class="ml-4 mr-2 pt-3">
<tera-drilldown-section>
<template #header-controls-left>
The model configuration will be optimized with the following settings
Expand Down Expand Up @@ -85,6 +85,17 @@
/>
</div>
<div v-if="showAdditionalOptions">
<div class="input-row">
<div class="label-and-input">
<label>Preset (optional)</label>
<Dropdown
v-model="presetType"
placeholder="Select an option"
:options="[CiemssPresetTypes.Fast, CiemssPresetTypes.Normal]"
@update:model-value="setPresetValues"
/>
</div>
</div>
<div class="input-row">
<div class="label-and-input">
<label>Number of samples to simulate model</label>
Expand All @@ -96,8 +107,7 @@
<label>Solver method</label>
<Dropdown
class="p-inputtext-sm"
disabled
:options="['dopri5', 'euler']"
:options="[CiemssMethodOptions.dopri5, CiemssMethodOptions.euler]"
v-model="knobs.solverMethod"
placeholder="Select"
/>
Expand Down Expand Up @@ -196,7 +206,7 @@
</section>
</tera-drilldown-section>
</section>
<section :tabName="OptimizeTabs.Notebook" class="ml-4 mr-2 pt-3">
<section :tabName="DrilldownTabs.Notebook" class="ml-4 mr-2 pt-3">
<p>Under construction. Use the wizard for now.</p>
<div class="result-message-grid">
<div v-for="(value, key) in optimizeRequestPayload" :key="key" class="result-message-row">
Expand Down Expand Up @@ -339,7 +349,8 @@ import {
getRunResultCSV,
makeOptimizeJobCiemss,
parsePyCiemssMap,
getSimulation
getSimulation,
CiemssMethodOptions
} from '@/services/models/simulation-service';
import {
CsvAsset,
Expand Down Expand Up @@ -367,6 +378,7 @@ import { createSuccessCriteriaChart, createForecastChart, createInterventionChar
import VegaChart from '@/components/widgets/VegaChart.vue';
import MultiSelect from 'primevue/multiselect';
import { mergeResults, renameFnGenerator } from '@/components/workflow/ops/calibrate-ciemss/calibrate-utils';
import { CiemssPresetTypes, DrilldownTabs } from '@/types/common';
import teraOptimizeCriterionGroupForm from './tera-optimize-criterion-group-form.vue';
import TeraStaticInterventionPolicyGroup from './tera-static-intervention-policy-group.vue';
import TeraDynamicInterventionPolicyGroup from './tera-dynamic-intervention-policy-group.vue';
Expand All @@ -385,11 +397,6 @@ const props = defineProps<{
const emit = defineEmits(['update-state', 'close', 'select-output']);
enum OptimizeTabs {
Wizard = 'Wizard',
Notebook = 'Notebook'
}
enum OutputView {
Charts = 'Charts',
Data = 'Data'
Expand All @@ -411,7 +418,7 @@ interface BasicKnobs {
const knobs = ref<BasicKnobs>({
endTime: props.node.state.endTime ?? 1,
numSamples: props.node.state.numSamples ?? 0,
solverMethod: props.node.state.solverMethod ?? '', // Currently not used.
solverMethod: props.node.state.solverMethod ?? CiemssMethodOptions.dopri5,
maxiter: props.node.state.maxiter ?? 5,
maxfeval: props.node.state.maxfeval ?? 25,
preForecastRunId: props.node.state.preForecastRunId ?? '',
Expand Down Expand Up @@ -494,6 +501,26 @@ const isRunDisabled = computed(
activePolicyGroups.value.length <= 0
);
const presetType = computed(() => {
if (
knobs.value.numSamples === speedValues.numSamplesToSimModel &&
knobs.value.solverMethod === speedValues.method &&
knobs.value.maxiter === speedValues.maxiter &&
knobs.value.maxfeval === speedValues.maxfeval
) {
return CiemssPresetTypes.Fast;
}
if (
knobs.value.numSamples === qualityValues.numSamplesToSimModel &&
knobs.value.solverMethod === qualityValues.method &&
knobs.value.maxiter === qualityValues.maxiter &&
knobs.value.maxfeval === qualityValues.maxfeval
) {
return CiemssPresetTypes.Normal;
}
return '';
});
const selectedOutputId = ref<string>();
const outputViewSelection = ref(OutputView.Charts);
Expand Down Expand Up @@ -572,6 +599,35 @@ const formatJsonValue = (value) => {
return value;
};
const setPresetValues = (data: CiemssPresetTypes) => {
if (data === CiemssPresetTypes.Normal) {
knobs.value.numSamples = qualityValues.numSamplesToSimModel;
knobs.value.solverMethod = qualityValues.method;
knobs.value.maxiter = qualityValues.maxiter;
knobs.value.maxfeval = qualityValues.maxfeval;
}
if (data === CiemssPresetTypes.Fast) {
knobs.value.numSamples = speedValues.numSamplesToSimModel;
knobs.value.solverMethod = speedValues.method;
knobs.value.maxiter = speedValues.maxiter;
knobs.value.maxfeval = speedValues.maxfeval;
}
};
const speedValues = Object.freeze({
numSamplesToSimModel: 1,
method: CiemssMethodOptions.euler,
maxiter: 0,
maxfeval: 1
});
const qualityValues = Object.freeze({
numSamplesToSimModel: 100,
method: CiemssMethodOptions.dopri5,
maxiter: 5,
maxfeval: 25
});
const initialize = async () => {
const modelConfigurationId = props.node.inputs[0].value?.[0];
if (!modelConfigurationId) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ enum OutputView {
Data = 'Data'
}
const speedValues = {
const speedValues = Object.freeze({
numSamples: 10,
method: CiemssMethodOptions.euler
};
});
const qualityValues = {
const qualityValues = Object.freeze({
numSamples: 100,
method: CiemssMethodOptions.dopri5
};
});
const updateLlmQuery = (query: string) => {
llmThoughts.value = [];
Expand Down

0 comments on commit 42b3d57

Please sign in to comment.