Skip to content

Commit

Permalink
Merge pull request #574 from NREL/os-solver
Browse files Browse the repository at this point in the history
Use HiGHS solver by default and on production, include other OS solvers
  • Loading branch information
Bill-Becker authored Mar 30, 2024
2 parents bd942b1 + a769763 commit dcb896c
Show file tree
Hide file tree
Showing 11 changed files with 288 additions and 236 deletions.
11 changes: 9 additions & 2 deletions .helm/values.staging.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
appEnv: staging
djangoSettingsModule: reopt_api.staging_settings
djangoReplicas: 3
djangoMemoryRequest: "2800Mi"
djangoMemoryLimit: "2800Mi"
celeryReplicas: 6
celeryMemoryRequest: "900Mi"
celeryMemoryLimit: "900Mi"
juliaReplicas: 6
juliaCpuRequest: "1000m"
juliaCpuLimit: "4000m"
juliaMemoryRequest: "8000Mi"
juliaMemoryLimit: "8000Mi"
juliaMemoryRequest: "12000Mi"
juliaMemoryLimit: "12000Mi"
18 changes: 9 additions & 9 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,21 @@ pipeline {
WERF_SYNCHRONIZATION = ":local"
XPRESS_LICENSE_HOST = credentials("reopt-api-xpress-license-host")
LICENSESERVER_URL = credentials("reopt-api-xpress-licenseserver-url")
XPRESS_INSTALLED = "True"
XPRESS_INSTALLED = "False"
NREL_ROOT_CERT_URL_ROOT = credentials("reopt-api-nrel-root-cert-url-root")
}

stages {
stage("deploy") {
stages {
stage("solver setup") {
steps {
dir("julia_src/licenseserver") {
git url: env.LICENSESERVER_URL
}
sh "cp julia_src/licenseserver/Dockerfile.xpress julia_src/"
}
}
// stage("solver setup") {
// steps {
// dir("julia_src/licenseserver") {
// git url: env.LICENSESERVER_URL
// }
// sh "cp julia_src/licenseserver/Dockerfile.xpress julia_src/"
// }
// }

stage("lint") {
steps {
Expand Down
4 changes: 2 additions & 2 deletions julia_src/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -841,9 +841,9 @@ uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[deps.REopt]]
deps = ["ArchGDAL", "CSV", "CoolProp", "DataFrames", "Dates", "DelimitedFiles", "HTTP", "JLD", "JSON", "JuMP", "LinDistFlow", "LinearAlgebra", "Logging", "MathOptInterface", "Requires", "Roots", "Statistics", "TestEnv"]
git-tree-sha1 = "d7bdc0d314e0821a8904ba204265345aab1ee8bc"
git-tree-sha1 = "b8e663a9f06eb6a1085ff7de981df2a6246b2b91"
uuid = "d36ad4e8-d74a-4f7a-ace1-eaea049febf6"
version = "0.43.0"
version = "0.44.0"

[[deps.Random]]
deps = ["SHA", "Serialization"]
Expand Down
6 changes: 3 additions & 3 deletions julia_src/http.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ function reopt(req::HTTP.Request)
ENV["NREL_DEVELOPER_API_KEY"] = test_nrel_developer_api_key
delete!(d, "api_key")
end
solver_name = pop!(settings, "solver_name")
solver_name = get(settings, "solver_name", "HiGHS")
if solver_name == "Xpress" && !(xpress_installed=="True")
solver_name = "HiGHS"
@warn "Changing solver_choice from Xpress to $solver_name because Xpress is not installed. Next time
Specify Settings.solver_choice = 'HiGHS' or 'Cbc' or 'SCIP'"
@warn "Changing solver_name from Xpress to $solver_name because Xpress is not installed. Next time
Specify Settings.solver_name = 'HiGHS' or 'Cbc' or 'SCIP'"
end
timeout_seconds = pop!(settings, "timeout_seconds")
optimality_tolerance = pop!(settings, "optimality_tolerance")
Expand Down
422 changes: 219 additions & 203 deletions reo/api.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion reoptjl/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def obj_create(self, bundle, **kwargs):
meta = {
"run_uuid": run_uuid,
"api_version": 3,
"reopt_version": "0.43.0",
"reopt_version": "0.44.0",
"status": "Validating..."
}
bundle.data.update({"APIMeta": meta})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 4.0.7 on 2024-03-28 03:12

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('reoptjl', '0054_rename_distance_to_emissions_region_meters_electricutilityoutputs_distance_to_avert_emissions_region'),
]

operations = [
migrations.AlterField(
model_name='settings',
name='optimality_tolerance',
field=models.FloatField(default=0.001, help_text="The threshold for the difference between the solution's objective value and the best possible value at which the solver terminates", validators=[django.core.validators.MinValueValidator(5e-06), django.core.validators.MaxValueValidator(0.2)]),
),
migrations.AlterField(
model_name='settings',
name='solver_name',
field=models.TextField(blank=True, choices=[('HiGHS', 'Highs'), ('Cbc', 'Cbc'), ('SCIP', 'Scip'), ('Xpress', 'Xpress')], default='HiGHS', help_text='Solver used for REopt.jl. Options include HiGHS, Cbc, SCIP, and Xpress'),
),
migrations.AlterField(
model_name='settings',
name='timeout_seconds',
field=models.IntegerField(default=600, help_text='The number of seconds allowed before the optimization times out.', validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(1200)]),
),
]
10 changes: 5 additions & 5 deletions reoptjl/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ class TIME_STEP_CHOICES(models.IntegerChoices):
FOUR = 4

timeout_seconds = models.IntegerField(
default=420,
default=600,
validators=[
MinValueValidator(1),
MaxValueValidator(420)
MaxValueValidator(1200)
],
help_text="The number of seconds allowed before the optimization times out."
)
Expand All @@ -251,7 +251,7 @@ class TIME_STEP_CHOICES(models.IntegerChoices):
default=0.001,
validators=[
MinValueValidator(5.0e-6),
MaxValueValidator(0.05)
MaxValueValidator(0.20)
],
help_text=("The threshold for the difference between the solution's objective value and the best possible "
"value at which the solver terminates")
Expand Down Expand Up @@ -296,7 +296,7 @@ class SOLVERS(models.TextChoices):

solver_name = models.TextField(
blank=True,
default=SOLVERS.XPRESS,
default=SOLVERS.HIGHS,
choices=SOLVERS.choices,
help_text=("Solver used for REopt.jl. Options include HiGHS, Cbc, SCIP, and Xpress")
)
Expand Down Expand Up @@ -1168,7 +1168,7 @@ class ElectricLoadInputs(BaseModel, models.Model):
annual_kwh = models.FloatField(
validators=[
MinValueValidator(1),
MaxValueValidator(100000000)
MaxValueValidator(10000000000)
],
null=True, blank=True,
help_text=("Annual site energy consumption from electricity, in kWh, used to scale simulated default building "
Expand Down
2 changes: 1 addition & 1 deletion reoptjl/test/test_job_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_multiple_outages(self):
self.assertAlmostEqual(sum(sum(np.array(results["Outages"]["unserved_load_per_outage_kwh"]))), 0.0, places=0)
# TODO figure out why microgrid_upgrade_capital_cost is about $3000 different locally than on GitHub Actions
self.assertAlmostEqual(results["Outages"]["microgrid_upgrade_capital_cost"], 1974429.4, delta=5000.0)
self.assertAlmostEqual(results["Financial"]["lcc"], 59865240.0, delta=5000.0)
self.assertAlmostEqual(results["Financial"]["lcc"], 59865240.0, delta=0.01*results["Financial"]["lcc"])

def test_pv_battery_and_emissions_defaults_from_julia(self):
"""
Expand Down
12 changes: 6 additions & 6 deletions werf-giterminism.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ config:
allowEnvVariables:
- XPRESS_LICENSE_HOST
- NREL_ROOT_CERT_URL_ROOT
dockerfile:
allowUncommitted:
- julia_src/Dockerfile.xpress
allowContextAddFiles:
- julia_src/Dockerfile.xpress
- julia_src/licenseserver
# dockerfile:
# allowUncommitted:
# - julia_src/Dockerfile.xpress
# allowContextAddFiles:
# - julia_src/Dockerfile.xpress
# - julia_src/licenseserver
8 changes: 4 additions & 4 deletions werf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ args:
---
image: julia-api
context: julia_src/
dockerfile: Dockerfile.xpress
contextAddFiles:
- Dockerfile.xpress
- licenseserver
dockerfile: Dockerfile
# contextAddFiles:
# - Dockerfile.xpress
# - licenseserver
args:
XPRESS_LICENSE_HOST: {{ env "XPRESS_LICENSE_HOST" | quote }}
NREL_ROOT_CERT_URL_ROOT: {{ env "NREL_ROOT_CERT_URL_ROOT" | quote }}

0 comments on commit dcb896c

Please sign in to comment.