Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize user guardrails #5304

Merged
merged 8 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
:disabled="_.isEmpty(node.outputs[0].value)"
/>
<tera-pyciemss-cancel-button class="mr-auto" :simulation-run-id="cancelRunId" />
<Button :disabled="isRunDisabled" label="Run" icon="pi pi-play" @click="runOptimize" />
<div v-tooltip="runButtonMessage">
<Button :disabled="isRunDisabled" label="Run" icon="pi pi-play" @click="runOptimize" />
</div>
</span>
</div>

Expand All @@ -48,7 +50,10 @@
/>
</section>
<section class="form-section">
<h5>Intervention policy</h5>
<h5>
Intervention policy
<i v-if="!isInterventionReady" v-tooltip="interventionReadyTooltip" class="pi pi-exclamation-circle" />
</h5>
<template v-for="(cfg, idx) in knobs.interventionPolicyGroups">
<tera-static-intervention-policy-group
v-if="
Expand Down Expand Up @@ -94,6 +99,12 @@
:calendar-settings="getCalendarSettingsFromModel(model)"
v-model="knobs.endTime"
/>
<i
class="pi pi-exclamation-circle"
style="max-width: fit-content"
v-if="!isEndTimeValid"
v-tooltip="endTimeTooltip"
/>
</div>
<div class="input-row">
<div class="label-and-input">
Expand Down Expand Up @@ -405,7 +416,6 @@ import { logger } from '@/utils/logger';
import { nodeMetadata } from '@/components/workflow/util';
import { WorkflowNode } from '@/types/workflow';
import TeraSliderPanel from '@/components/widgets/tera-slider-panel.vue';

import TeraNotebookError from '@/components/drilldown/tera-notebook-error.vue';
import { flattenInterventionData, getInterventionPolicyById } from '@/services/intervention-policy';
import TeraCheckbox from '@/components/widgets/tera-checkbox.vue';
Expand Down Expand Up @@ -512,16 +522,41 @@ const datasetId = computed(() => {

const displayOptimizationResultMessage = ref(true);

const isRunDisabled = computed(() => {
// Checks for disabling run button:
const isCriteriaReady = computed(() => {
const activeConstraintGroups = knobs.value.constraintGroups.filter((ele) => ele.isActive);
return (
activeConstraintGroups.length === 0 ||
!activeConstraintGroups.every((ele) => ele.targetVariable) ||
knobs.value.interventionPolicyGroups.length === 0 ||
activePolicyGroups.value.length <= 0
);
return activeConstraintGroups.length !== 0 && activeConstraintGroups.every((ele) => ele.targetVariable);
});

const isInterventionReady = computed(() => activePolicyGroups.value.length > 0);

const isEndTimeValid = computed(() =>
activePolicyGroups.value.every((ele) => {
if (
[OptimizationInterventionObjective.startTime, OptimizationInterventionObjective.paramValueAndStartTime].includes(
ele.optimizationType
)
) {
return ele.endTime <= knobs.value.endTime;
}
return true;
})
);

const isRunDisabled = computed(() => !isCriteriaReady.value || !isInterventionReady.value || !isEndTimeValid.value);

const criteriaReadyTooltip = computed(() => (!isCriteriaReady.value ? 'Success criteria must be filled in. \n' : ''));
const interventionReadyTooltip = computed(() =>
!isInterventionReady.value ? 'Must contain at least one active intervention policy.\n' : ''
);
const endTimeTooltip = computed(() =>
!isEndTimeValid.value ? 'End time must be greater than or equal to all intervention policy end times. \n' : ''
);

const runButtonMessage = computed(() =>
isRunDisabled.value ? `${criteriaReadyTooltip.value} ${interventionReadyTooltip.value} ${endTimeTooltip.value}` : ''
);

const presetType = computed(() => {
if (
knobs.value.numSamples === speedValues.numSamplesToSimModel &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
placeholder="Select"
@update:model-value="emit('update-self', config)"
/>
<i v-if="_.isEmpty(config.targetVariable)" class="pi pi-exclamation-circle" v-tooltip="requiredTooltip" />
is
<Dropdown
class="toolbar-button"
Expand All @@ -44,6 +45,7 @@
/>
a threshold of
<tera-input-number v-model="config.threshold" @update:model-value="emit('update-self', config)" />
<i v-if="!config.threshold" class="pi pi-exclamation-circle" v-tooltip="requiredTooltip" />
at
<Dropdown
:options="[
Expand All @@ -56,8 +58,11 @@
@update:model-value="emit('update-self', config)"
/>
in
<tera-input-number v-model="config.riskTolerance" @update:model-value="emit('update-self', config)" />% of
simulated outcomes
<tera-input-number v-model="config.riskTolerance" @update:model-value="emit('update-self', config)" /><i
v-if="!config.riskTolerance"
class="pi pi-exclamation-circle"
v-tooltip="requiredTooltip"
/>% of simulated outcomes
</div>
<div v-else class="section-row">
Ensure <b>{{ config.targetVariable }}</b> is <b>{{ config.isMinimized ? 'below' : 'above' }}</b> a threshold of
Expand All @@ -84,7 +89,7 @@ const props = defineProps<{
const emit = defineEmits(['update-self', 'delete-self']);

const config = ref<Criterion>(_.cloneDeep(props.criterion));

const requiredTooltip = 'Required';
const isEditing = ref<boolean>(false);

const onEdit = () => {
Expand Down