Skip to content

Supply Curve Generation

Scott Kirkland edited this page Aug 18, 2021 · 4 revisions

Supply Curve

Running Supply Curve locally

Running the supply curve requires running node supplyCurve.js in the home directory.

The supplyCurve.ts file contains some code assumptions for your supply curve parameters, including fuel prices, moisture content, and other details that could change the final cost calculations. Change them as desired before compiling into JS and running.

Running Supply Curve on Farm Cluster

If you want to run for multiple counties or treatments, we'll want to create a runner which can take multiple values. This runner will read from a CSV file which will contain name, location, and treatment info.

supply-curve-runner.sh

#!/bin/bash -l

INPUT=/home/postit/facilities-to-run-supply-curve.csv

OLDIFS=$IFS
IFS=','
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }

while IFS=, read -r name latitude longitude
do
    echo "$name and $latitude and $longitude"
 
    export FACILITY_NAME=$name
    export FACILITY_LAT=$latitude
    export FACILITY_LNG=$longitude

    export CSV_OUT=/home/postit/$name-supplyCurve.csv

    sbatch supply-curve-processor.sh
done < $INPUT

IFS=$OLDIFS

supply-curve-processor.sh

#!/bin/bash -l

# Name of the job - You'll probably want to customize this.
#SBATCH -J jsupplycurve

# Standard out and Standard Error output files with the job number in the name.
#SBATCH -o slurm-supply-curve-%j.output
#SBATCH -e slurm-supply-curve-%j.output

# Ask for enough memory to hold our osrm route details
#SBATCH --mem=32000
#SBATCH --time=8:01:00
#SBATCH --partition=med

# Print the hostname for debugging purposes
hostname

# Set your variables
export DB_HOST=
export DB_USER=
export DB_PASS=
export DB_NAME=
export DB_PORT=
export OSRM=/home/postit/cecdss-backend/data/california-latest.osrm

# Facility and CSV info should be set by caller

srun node ./cecdss-backend/runSupplyCurve.js

Example CSV containing two facilities, with Burney running through 3 treatments

facilities-to-run-supply-curve.csv

Burney,40.879,-121.727,1
Burney,40.879,-121.727,2
Burney,40.879,-121.727,3
Anderson,40.4282,-122.275,1
Clone this wiki locally