From 371daafe1a7fc2c6dfc7142c245917801204bc0b Mon Sep 17 00:00:00 2001 From: Tom Szendrey Date: Fri, 23 Aug 2024 11:50:06 -0400 Subject: [PATCH 1/4] qoi pyciemss mapping on client as it has the info --- .../tera-optimize-ciemss-drilldown.vue | 36 +++++++++++++------ .../tera-optimize-criterion-group-form.vue | 4 ++- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/tera-optimize-ciemss-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/tera-optimize-ciemss-drilldown.vue index 7d99369bf3..8efdffe624 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/tera-optimize-ciemss-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/tera-optimize-ciemss-drilldown.vue @@ -547,9 +547,12 @@ const model = ref(null); const modelParameterOptions = computed(() => (model.value?.semantics?.ode?.parameters ?? []).map((p) => p.id) ); -const modelStateAndObsOptions = ref([]); +const modelStateAndObsOptions = ref<{ label: string; value: string }[]>([]); -const simulationChartOptions = computed(() => [...modelParameterOptions.value, ...modelStateAndObsOptions.value]); +const simulationChartOptions = computed(() => [ + ...modelParameterOptions.value, + ...modelStateAndObsOptions.value.map((ele) => ele.label) +]); const modelConfiguration = ref(); const showAdditionalOptions = ref(true); @@ -656,13 +659,20 @@ const initialize = async () => { optimizedInterventionPolicy.value = await getInterventionPolicyById(optimizedPolicyId); } - modelStateAndObsOptions.value = model.value?.model.states.map((state: any) => state.id); - - /** Until supported by pyciemss-service, do not show observables. - if (model?.semantics?.ode.observables) { - modelStateAndObsOptions.value.push(...model.semantics.ode.observables.map((observable: any) => observable.id)); + modelStateAndObsOptions.value = model.value?.model.states.map((state: any) => ({ + label: state.id, + value: `${state.id}_state` + })); + + // Add obs: + if (model.value?.semantics?.ode.observables) { + modelStateAndObsOptions.value.push( + ...model.value.semantics.ode.observables.map((observable: any) => ({ + label: observable.id, + value: `${observable.id}_observable` + })) + ); } - */ }; const setInterventionPolicyGroups = (interventionPolicy: InterventionPolicy) => { @@ -778,7 +788,7 @@ const runOptimize = async () => { // InferredParameters is to link a calibration run to this optimize call. optimizePayload.extra.inferredParameters = modelConfiguration.value.simulationId; - + console.log(optimizePayload); const optResult = await makeOptimizeJobCiemss(optimizePayload, nodeMetadata(props.node)); const state = _.cloneDeep(props.node.state); state.inProgressOptimizeId = optResult.simulationId; @@ -801,7 +811,13 @@ const setOutputSettingDefaults = () => { if (!knobs.value.selectedSimulationVariables.length) { props.node.state.constraintGroups.forEach((constraint) => { if (constraint.targetVariable) { - selectedSimulationVariables.push(constraint.targetVariable); + // Use modelStateAndObsOptions to map from value -> label as simulation selection uses S not S_State + const userSelection = modelStateAndObsOptions.value.find( + (ele) => ele.value === constraint.targetVariable + )?.label; + if (userSelection) { + selectedSimulationVariables.push(userSelection); + } } }); if (selectedSimulationVariables.length) { diff --git a/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/tera-optimize-criterion-group-form.vue b/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/tera-optimize-criterion-group-form.vue index f7da3c39a4..252e8aeeb7 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/tera-optimize-criterion-group-form.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/tera-optimize-criterion-group-form.vue @@ -24,6 +24,8 @@ (); const emit = defineEmits(['update-self', 'delete-self']); From cf7e74b4deb07c0a066e41697e8f7a1907ec10eb Mon Sep 17 00:00:00 2001 From: Tom Szendrey Date: Fri, 23 Aug 2024 11:59:17 -0400 Subject: [PATCH 2/4] minor comment. --- .../workflow/ops/optimize-ciemss/optimize-ciemss-operation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/optimize-ciemss-operation.ts b/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/optimize-ciemss-operation.ts index 45694bd4aa..31d6e94210 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/optimize-ciemss-operation.ts +++ b/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/optimize-ciemss-operation.ts @@ -41,7 +41,7 @@ export interface InterventionPolicyGroupForm { export interface Criterion { name: string; // Title of the group - targetVariable: string; + targetVariable: string; // qoi context which will contain _state or _observable accordingly qoiMethod: ContextMethods; riskTolerance: number; threshold: number; From 8ce463cb443f5d963a2bb62e1a62b9ec12187648 Mon Sep 17 00:00:00 2001 From: Tom Szendrey Date: Fri, 23 Aug 2024 14:03:47 -0400 Subject: [PATCH 3/4] minor update createSuccessCriteriaChart --- packages/client/hmi-client/src/services/charts.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/client/hmi-client/src/services/charts.ts b/packages/client/hmi-client/src/services/charts.ts index 028eb3456f..3d94885c67 100644 --- a/packages/client/hmi-client/src/services/charts.ts +++ b/packages/client/hmi-client/src/services/charts.ts @@ -745,9 +745,8 @@ export function createSuccessCriteriaChart( alpha: number, options: BaseChartOptions ): any { - const targetState = `${targetVariable}_state`; - const data = riskResults[targetState]?.qoi || []; - const risk = riskResults[targetState]?.risk?.[0] || 0; + const data = riskResults[targetVariable]?.qoi || []; + const risk = riskResults[targetVariable]?.risk?.[0] || 0; const binCount = Math.floor(Math.sqrt(data.length)) ?? 1; const alphaPercentile = percentile(data, alpha); From a784aff43a4e3849cb7bfc53920a9f843b018562 Mon Sep 17 00:00:00 2001 From: Tom Szendrey Date: Tue, 3 Sep 2024 15:57:34 -0400 Subject: [PATCH 4/4] extract out for easier reading. --- .../optimize-ciemss/tera-optimize-ciemss-drilldown.vue | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/tera-optimize-ciemss-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/tera-optimize-ciemss-drilldown.vue index 5aea4afa09..52d4efeb71 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/tera-optimize-ciemss-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/optimize-ciemss/tera-optimize-ciemss-drilldown.vue @@ -658,16 +658,17 @@ const initialize = async () => { if (optimizedPolicyId) { optimizedInterventionPolicy.value = await getInterventionPolicyById(optimizedPolicyId); } - - modelStateAndObsOptions.value = model.value?.model.states.map((state: any) => ({ + const modelStates = model.value?.model.states; + modelStateAndObsOptions.value = modelStates.map((state: any) => ({ label: state.id, value: `${state.id}_state` })); // Add obs: - if (model.value?.semantics?.ode.observables) { + const modelObs = model.value?.semantics?.ode.observables; + if (modelObs) { modelStateAndObsOptions.value.push( - ...model.value.semantics.ode.observables.map((observable: any) => ({ + ...modelObs.map((observable: any) => ({ label: observable.id, value: `${observable.id}_observable` }))