Skip to content

Incorporate Circular Implementation#33

Open
obaidkhwaja wants to merge 24 commits into
ANL-CEEESA:circularfrom
obaidkhwaja:add-circular-interface
Open

Incorporate Circular Implementation#33
obaidkhwaja wants to merge 24 commits into
ANL-CEEESA:circularfrom
obaidkhwaja:add-circular-interface

Conversation

@obaidkhwaja
Copy link
Copy Markdown

Created an interface in the CircularData.ts file to add some sort of organization for building out the circular model, if you have another idea I'd be happy to go with that!

@obaidkhwaja obaidkhwaja reopened this Jun 11, 2025
@obaidkhwaja obaidkhwaja changed the base branch from master to circular June 11, 2025 16:43
@obaidkhwaja obaidkhwaja changed the title Add circular interface Incorporate Circular Implementation Jul 1, 2025
centers: {},


});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reformat all source code files using prettier

import "../Common/Forms/Tables.css";
import Footer from "./Footer";
import React, { useState,useRef } from "react";
import {CircularData} from "./CircularData";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to refer to everything as CircularSomething. This could be InstanceData instead.

Comment on lines +1 to +36
export interface CircularPlant {
uid: string;
name: string;
x: number;
y: number;
inputs: string[];
outputs: string[];


}

export interface CircularProduct {
uid: string;
name: string;
x: number;
y: number;
}

export interface CircularData {
plants: Record<string, CircularPlant>;
products: Record<string, CircularProduct>;
centers: Record<string, CircularCenter>;


}

export interface CircularCenter {
uid: string;
name: string;
x: number;
y: number;

//single input, multiple outputs
input?: string;
output: string[];
} No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having these isolated data structures in a custom format, could you modify this code so that we have a single structure containing the entire data for the test case, in the JSON format we describe in our documentation? See UnitCommitmentScenario in the UCJL case builder for an example. Each operation in the web interface (such as adding a plant) should modify this data structure while ensuring that the JSON format remains in a valid format. This is also important because we should be able to load/save the test case.

Feel free to add any necessary fields to the JSON format required to persist the pipeline visualization (e.g., x/y location of each copy of that component).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added RELOGScenario interface that uses the current interfaces as shapes and combines them into one

Comment on lines +41 to +53
const randomPosition = (): [number,number] => {
if (window.nextX === undefined) window.nextX = 15;
if (window.nextY === undefined) window.nextY = 15;

window.nextY +=60;
if (window.nextY >=500) {
window.nextY = 15;
window.nextX += 150;

}
return [window.nextX, window.nextY];

};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename this method? It's not really generating a random position.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken from current casebuilder, changed to nextNodePosition

Comment on lines +62 to +131
const onAddPlant = () => {
setCircularData((prevData) => {
const name = promptName(prevData);
if (name ===undefined) return prevData;

const uid = `${name}-${nextUid.current++}`;
const [x,y] = randomPosition();
const newData: CircularData = {
...prevData,
plants: {
...prevData.plants,
[uid]: {
...defaultPlant,
x,
y,
name,
uid
}
}
};
return newData;
});
};

const onAddProduct = () => {
setCircularData((prevData) => {
const name = promptName(prevData);
if (name ===undefined) return prevData;
const uid = `${name}-${nextUid.current++}`;
const [x,y] = randomPosition();
const newData: CircularData = {
...prevData,
products: {
...prevData.products,
[uid]: {
...defaultProduct,
x,
y,
name,
uid
}
}
};
return newData;
});

};

const onAddCenter = () => {
setCircularData((prevData) => {
const name = promptName(prevData);
if (name ===undefined) return prevData;
const uid = `${name}-${nextUid.current++}`;
const [x,y] = randomPosition();
const newData: CircularData = {
...prevData,
centers: {
...prevData.centers,
[uid]: {
...defaultCenter,
x,
y,
name,
uid
}
}
};
return newData;
});
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks quite repetitive.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic was taken from the current casebuilder but you are right and there shouldn't be a reason why these can be connected to 'onAdd' function

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consolidated to onAddNode function

Comment on lines +252 to +255
<button style={{ margin: '0 8px' }} onClick={props.onAddProduct}>Add product</button>
<button style={{ margin: '0 8px' }} onClick={props.onAddPlant}>Add plant</button>
<button style={{ margin: '0 8px' }} onClick={props.onAddCenter}>Add center</button>
<button style={{ margin: '0 8px' }} onClick={onLayout}>Auto Layout</button>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a common style for these buttons. I think we already have some CSS for buttons that you could use here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorporated Buttons.module.css file from current casebuilder

<button style={{ margin: '0 8px' }} onClick={props.onAddCenter}>Add center</button>
<button style={{ margin: '0 8px' }} onClick={onLayout}>Auto Layout</button>
<DownloadButton />
<button style={{ margin: '0 8px' }} title="Drag & connect. Double-click to rename. Delete to remove.">?</button>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tooltip is not working properly. Compared to the one in relog.axavier.org, it takes too long to show.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

Comment on lines +3 to +16
export interface DefaultProduct extends CircularProduct{
x: number;
y: number;
}

export interface DefaultPlant extends CircularPlant{
x: number;
y: number;
}

export interface DefaultCenter extends CircularPlant{
x: number;
y: number;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the need to declare these interfaces. They are also duplicated.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These interfaces are the "objects" for the state while the interfaces in CircularData (now InitialData) are purely types.

Comment thread web/tsconfig.json
"noUnusedParameters": false,
"checkJs": true
"checkJs": false,
"allowImportingTsExtensions": true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify why is this required?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything updated in the tsconfig file was updated on the download of any libraries used, if you want I can take a deeper dive but I never went in and messed with it.

Comment thread web/tsconfig.json Outdated
"noUnusedLocals": false,
"noUnusedParameters": false,
"checkJs": true
"checkJs": false,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't have any .js files in this project, so I'm not sure why is this change required.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes definetely, I'll take this out. I know that having it set as false raised a type warning earlier in the code that I wasn't able to get rid of and it was fully typed but if any issues arise now I'll make note of them and let you know.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkJs works simultaneously with allowJs, if checkJs is set to true then allowJs has to true as well otherwise it raises errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants