Skip to content

Commit

Permalink
feat(ui-config): add 'MILP' value option in 'Unit Commitment Mode' field
Browse files Browse the repository at this point in the history
 in 'Advanced Parameters' for studies v8.8 or above'
  • Loading branch information
skamril committed Jun 17, 2024
1 parent 3c56c0b commit 2e64e56
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ import {
UNIT_COMMITMENT_MODE_OPTIONS,
SIMULATION_CORES_OPTIONS,
RENEWABLE_GENERATION_OPTIONS,
UnitCommitmentMode,
} from "./utils";
import { useOutletContext } from "react-router";
import { StudyMetadata } from "../../../../../../common/types";

interface Props {
version: number;
}

function Fields(props: Props) {
function Fields() {
const [t] = useTranslation();
const { control } = useFormContextPlus<AdvancedParamsFormFields>();
const { version } = props;
const { study } = useOutletContext<{ study: StudyMetadata }>();
const studyVersion = Number(study.version);

////////////////////////////////////////////////////////////////
// JSX
Expand Down Expand Up @@ -178,7 +178,11 @@ function Fields(props: Props) {
/>
<SelectFE
label={t("study.configuration.advancedParameters.unitCommitmentMode")}
options={UNIT_COMMITMENT_MODE_OPTIONS}
options={UNIT_COMMITMENT_MODE_OPTIONS.filter(
(v) => v !== UnitCommitmentMode.MILP || studyVersion >= 880,
).map((v) =>
v === UnitCommitmentMode.MILP ? { label: "MILP", value: v } : v,
)}
name="unitCommitmentMode"
control={control}
/>
Expand All @@ -188,7 +192,7 @@ function Fields(props: Props) {
name="numberOfCoresMode"
control={control}
/>
{version >= 810 && (
{studyVersion >= 810 && (
<SelectFE
label={t(
"study.configuration.advancedParameters.renewableGenerationModeling",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function AdvancedParameters() {
onSubmitSuccessful={handleSubmitSuccessful}
enableUndoRedo
>
<Fields version={Number(study.version)} />
<Fields />
</Form>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ enum ReserveManagement {
Global = "global",
}

enum UnitCommitmentMode {
export enum UnitCommitmentMode {
Fast = "fast",
Accurate = "accurate",
// Since v8.8
MILP = "milp",
}

enum SimulationCore {
Expand Down

0 comments on commit 2e64e56

Please sign in to comment.