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

add support for deactivating slacks through UI #73

Merged
merged 11 commits into from
Jul 29, 2024
14 changes: 5 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: App build
on:
push:
branches:
- "fix-compare-page"
- "add-slack-option"

defaults:
run:
Expand Down Expand Up @@ -46,13 +46,9 @@ jobs:
- name: Get idaes extensions
run: idaes get-extensions

- name: Install correct tag of pareto
- name: Install correct branch of pareto
working-directory: ../
run: git clone https://github.com/tarnold17/project-pareto.git && cd project-pareto && git fetch --all && git checkout generate_report_fix && pip install --progress-bar off .

# - name: Install correct branch of pareto
# working-directory: ../
# run: git clone https://github.com/project-pareto/project-pareto.git && cd project-pareto && pip install --progress-bar off .
run: git clone https://github.com/project-pareto/project-pareto.git && cd project-pareto && pip install --progress-bar off .

- name: Install build requirements
working-directory: ./backend
Expand All @@ -70,12 +66,12 @@ jobs:

- name: Sign Windows Distribution
run: |
AzureSignTool sign -kvu "${{ secrets.AZURE_KEY_VAULT_URI }}" -kvi "${{ secrets.AZURE_CLIENT_ID }}" -kvt "${{ secrets.AZURE_TENANT_ID }}" -kvs "${{ secrets.AZURE_CLIENT_SECRET }}" -kvc ${{ secrets.AZURE_CERT_NAME }} -tr http://timestamp.digicert.com -v electron/dist/ParetoUI-24.07.15-win64.exe
AzureSignTool sign -kvu "${{ secrets.AZURE_KEY_VAULT_URI }}" -kvi "${{ secrets.AZURE_CLIENT_ID }}" -kvt "${{ secrets.AZURE_TENANT_ID }}" -kvs "${{ secrets.AZURE_CLIENT_SECRET }}" -kvc ${{ secrets.AZURE_CERT_NAME }} -tr http://timestamp.digicert.com -v electron/dist/ParetoUI-24.07.24-win64.exe

- name: Upload artifact for windows build
uses: actions/upload-artifact@v4
if: always()
with:
name: windows-pareto-dist
path: |
electron/dist/ParetoUI-24.07.15-win64.exe
electron/dist/ParetoUI-24.07.24-win64.exe
3 changes: 3 additions & 0 deletions backend/app/extra-hooks/hook-pareto.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,7 @@
datas.append(('internal/assets/pareto_input_template.xlsx', 'app/internal/assets'))
datas.append(('internal/assets/workshop_baseline_all_data_0.9.0.xlsx', 'app/internal/assets'))

# add lorem ipsum.txt for jaraco
datas.append(('internal/assets/Lorem ipsum.txt', 'jaraco/text'))

print(datas)
Empty file.
4 changes: 2 additions & 2 deletions backend/app/internal/pareto_stategic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def run_strategic_model(input_file, output_file, id, modelParameters, overrideVa
optimality_gap = int(modelParameters["optimalityGap"])/100
except:
optimality_gap = 0
# _log.info(f'optimality gap is {optimality_gap}')
# _log.info(f'deactivating slacks: {modelParameters["deactivate_slacks"]}')
options = {
"deactivate_slacks": True,
"deactivate_slacks": modelParameters["deactivate_slacks"],
"scale_model": modelParameters["scale_model"],
"scaling_factor": 1000,
"running_time": modelParameters["runtime"],
Expand Down
1 change: 1 addition & 0 deletions backend/app/routers/scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ async def run_model(request: Request, background_tasks: BackgroundTasks):
"desalination_model": optimizationSettings.get("desalination_model", "false"),
"infrastructure_timing": optimizationSettings.get("infrastructure_timing", "false"),
"subsurface_risk": optimizationSettings.get("subsurface_risk", "false"),
"deactivate_slacks": optimizationSettings.get("deactivate_slacks", True),
}

_log.info(f"modelParameters: {modelParameters}")
Expand Down
4 changes: 2 additions & 2 deletions electron/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pareto-ui",
"version": "24.07.15",
"version": "24.07.24",
"author": "Michael Pesce",
"private": true,
"main": "build/main.js",
Expand Down Expand Up @@ -74,10 +74,10 @@
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"artifactName": "ParetoUI-24.07.15-win64.exe"
"artifactName": "ParetoUI-24.07.24-win64.exe"
},
"dmg": {
"artifactName": "ParetoUI-24.07.15-arm64.dmg"
"artifactName": "ParetoUI-24.07.24-arm64.dmg"
},
"deb": {
"depends": [
Expand All @@ -86,7 +86,7 @@
"liblapack3",
"libblas3"
],
"artifactName": "ParetoUI-24.07.15-amd64.deb"
"artifactName": "ParetoUI-24.07.24-amd64.deb"
},
"directories": {
"buildResources": "assets"
Expand All @@ -106,7 +106,7 @@
"win": {
"target": "nsis",
"icon": "build/pareto-logo.ico",
"artifactName": "ParetoUI-24.07.15-win64.exe"
"artifactName": "ParetoUI-24.07.24-win64.exe"
},
"linux": {
"target": "Deb",
Expand Down
2 changes: 1 addition & 1 deletion electron/ui/src/views/LandingPage/LandingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function LandingPage(props) {
<Grid item xs={3}> </Grid>
<Grid item xs={6}>
<Box>
<p style={{paddingTop:0, marginTop: 0, color:"#9c9c9c"}}>v24.07.15 (PARETO v{process.env.REACT_APP_PARETO_VERSION})</p>
<p style={{paddingTop:0, marginTop: 0, color:"#9c9c9c"}}>v24.07.24 (PARETO v{process.env.REACT_APP_PARETO_VERSION})</p>
</Box>
</Grid>
<Grid item xs={3}> </Grid>
Expand Down
11 changes: 9 additions & 2 deletions electron/ui/src/views/Optimization/AdvancedOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const advancedOptions = {
}
},
pipeline_cost: {
displayName: "Pipeline Capacity",
displayName: "Pipeline Cost",
defaultValue: "distance_based",
options: {
"Distance-based": "distance_based",
Expand Down Expand Up @@ -46,7 +46,6 @@ export const advancedOptions = {
"False": "false",
"Exclude Over/Under PW": "exclude_over_and_under_pressured_wells",
"Calculate Risk Metrics": "calculate_risk_metrics"

}
},
removal_efficiency_method: {
Expand All @@ -66,4 +65,12 @@ export const advancedOptions = {
"MD": "md"
},
},
deactivate_slacks: {
displayName: "Deactivate Slacks",
defaultValue: true,
options: {
"True": true,
"False": false
},
},
}
26 changes: 14 additions & 12 deletions electron/ui/src/views/Optimization/Descriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ export const descriptions = {
This setting limits the runtime for the solver to find a solution.
Note that this time does not include time to build the model and process output.
</div>,
pipelineCost: <div>
There are two ways pipeline capacity expansion costs can be calculated:<br/>
-Distance-based: Uses pipeline distance, diameter and $/inch-mile rate<br/>
-Capacity-based: Uses pipeline capacity and $/bbl rate
</div>,
optimalityGap: <div>
Measure of optimality guaranteed
(example: 0% gap is the mathematically proven best possible solution, 3% optimality
Expand All @@ -32,40 +27,47 @@ export const descriptions = {
Select the solver you would like to use. Note: Gurobi requires a license.
If you do not have a Gurobi licence, select "CBC", an open source solver.
</div>,
scaleModel: <div>
scale_model: <div>
Choose whether you would like to scale the model or not.
</div>,

pipelineCapacity: <div>
pipeline_capacity: <div>
Alternate pipeline capacity selection:<br/>
-Input: use input for pipeline capacity<br/>
-Calculated: calculate pipeline capacity from pipeline diameters</div>,
nodeCapacity: <div>
pipeline_cost: <div>
Alternate pipeline CAPEX cost structures (distance or capacity based):<br/>
-Capacity-based: use pipeline capacities and rate in [currency/volume] to calculate pipeline CAPEX costs<br/>
-Distance-based: use pipeline distances and rate in [currency/(diameter-distance)] to calculate pipeline CAPEX costs</div>,
node_capacity: <div>
Selection to include Node Capacity:<br/>
-True: Include network node capacity constraints<br/>
-False: Exclude network node capacity constraints
</div>,
infrastructureTiming: <div>
infrastructure_timing: <div>
Selection to include infrastructure timing:<br/>
-True: Include infrastructure timing in model<br/>
-False: Exclude infrastructure timing from model<br/>
Note that infrastructure timing calculations are performed post-optimization.
</div>,
subsurfaceRisk: <div>
subsurface_risk: <div>
Selection to include subsurface risk<br/>
-False: Exclude subsurface risk from model unless the subsurface risk objective function is selected<br/>
-Exclude Over/Under PW: Calculate subsurface risk metrics and disallow disposal to overpressured and underpressured wells<br/>
-Calculate Risk Metrics: Calculate subsurface risk metrics for the user to view, but don't change the optimization model
</div>,
removalEfficiencyMethod: <div>
removal_efficiency_method: <div>
Method for calculating removal efficiency<br/>
-Load based: use contaminant load (flow times concentration) to calculate removal efficiency<br/>
-Concentration based: use contaminant concentration to calculate removal efficiency
</div>,
desalinationModel: <div>
desalination_model: <div>
Selection to include surrogate model for desalination:<br/>
-False: Do not use surrogate model for desalination<br/>
-MVC: Use MVC (Mechanical Vapor Compressor) surrogate model<br/>
-MD: Use MD (Membrane Distillation) surrogate model
</div>,
deactivate_slacks: <div>
True to deactivate slack variables, False to use slack variables. Default is True<br/>
</div>,
}
45 changes: 8 additions & 37 deletions electron/ui/src/views/Optimization/Optimization.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,49 +264,20 @@ export default function Optimization(props) {
</Grid>
<Grid item xs={columnWidths[1]} style={styles.gridItems}>
</Grid>

<Grid item xs={columnWidths[0]} style={styles.gridItems}>
<Collapse in={showAdvancedOptions} timeout="auto" unmountOnExit>
<Box sx={styles.settingName}>
<p>Scale Model</p>
<Tooltip title={descriptions.scaleModel} placement="right-start"><IconButton><InfoIcon fontSize='small'/></IconButton></Tooltip>
</Box>
<Box sx={styles.settingName}>
<p>Pipeline Capacity</p>
<Tooltip title={descriptions.pipelineCapacity} placement="right-start"><IconButton><InfoIcon fontSize='small'/></IconButton></Tooltip>
</Box>
<Box sx={styles.settingName}>
<p>Pipeline Cost</p>
<Tooltip title={descriptions.pipelineCost} placement="right-start"><IconButton><InfoIcon fontSize='small'/></IconButton></Tooltip>
</Box>
<Box sx={styles.settingName}>
<p>Node Capacity</p>
<Tooltip title={descriptions.nodeCapacity} placement="right-start"><IconButton><InfoIcon fontSize='small'/></IconButton></Tooltip>
</Box>
<Box sx={styles.settingName}>
<p>Infrastructure Timing</p>
<Tooltip title={descriptions.infrastructureTiming} placement="right-start"><IconButton><InfoIcon fontSize='small'/></IconButton></Tooltip>
</Box>
<Box sx={styles.settingName}>
<p>Subsurface Risk</p>
<Tooltip title={descriptions.subsurfaceRisk} placement="right-start"><IconButton><InfoIcon fontSize='small'/></IconButton></Tooltip>
</Box>
<Box sx={styles.settingName}>
<p>Removal Efficiency Method</p>
<Tooltip title={descriptions.removalEfficiencyMethod} placement="right-start"><IconButton><InfoIcon fontSize='small'/></IconButton></Tooltip>
</Box>
<Box sx={styles.settingName}>
<p>Desalination Model</p>
<Tooltip title={descriptions.desalinationModel} placement="right-start"><IconButton><InfoIcon fontSize='small'/></IconButton></Tooltip>
</Box>
MichaelPesce marked this conversation as resolved.
Show resolved Hide resolved
{
Object.entries(advancedOptions).map(([ key, data ]) => (
<Box key={key} sx={styles.settingName}>
<p>{data.displayName}</p>
<Tooltip title={descriptions[key]} placement="right-start"><IconButton><InfoIcon fontSize='small'/></IconButton></Tooltip>
</Box>
))
}
</Collapse>
</Grid>
<Grid item xs={columnWidths[1]} style={styles.gridItems}>
<Collapse in={showAdvancedOptions} timeout="auto" unmountOnExit>

{/*
advanced options:
*/}
{
Object.entries(advancedOptions).map(([ key, data ]) => (
<Box key={key}>
Expand Down