Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a0d7c26
added the investment_constraints input file
Aurashk Dec 1, 2025
2631e5d
Create ProcessAvailabilities struct
tsmbland Nov 25, 2025
e737a0c
New limits for investment appraisal
tsmbland Nov 25, 2025
6989bfb
New constraints for dispatch
tsmbland Nov 25, 2025
8d48eea
Add get_availability_limit function
tsmbland Nov 25, 2025
1553789
Update inputs module
tsmbland Nov 26, 2025
2c03f99
Use range syntax in input files
tsmbland Nov 26, 2025
7972784
Fix/update tests
tsmbland Nov 27, 2025
a074cbb
Tidy-ups to `ActivityLimits`
tsmbland Nov 27, 2025
5fb29ee
Better error handling
tsmbland Nov 27, 2025
ebd5f79
Documentation and coverage checks
tsmbland Nov 27, 2025
e1b6218
Undo delete rows
tsmbland Nov 27, 2025
e66fa1b
Remove empty constraints
tsmbland Nov 27, 2025
653e4e6
Update regenerate data script
tsmbland Nov 27, 2025
1461133
Update results files
tsmbland Nov 27, 2025
9a5473c
Add tests
tsmbland Nov 27, 2025
85b3178
Small imprevements from self-review
tsmbland Nov 28, 2025
ac3c8e6
Address review comments
tsmbland Dec 2, 2025
0c5eedc
simplify investment constraints map
Aurashk Dec 5, 2025
d47da0f
Merge branch 'main' into add-process-investment-constraints-input
Aurashk Dec 5, 2025
e9bb2f2
Merge branch 'main' into add-process-investment-constraints-input
Aurashk Dec 8, 2025
83d5734
simplify process investment constraints
Aurashk Dec 8, 2025
4358102
fix commision years format for process investment constraints
Aurashk Dec 8, 2025
7dd9790
remove constraint name from process investment constraints
Aurashk Dec 8, 2025
5282831
Update src/input/process/investment_constraints.rs
Aurashk Dec 8, 2025
cd8a1fb
restrict investment constraint years to only milestone years within p…
Aurashk Dec 9, 2025
1642d79
Merge branch 'main' into add-process-investment-constraints-input
Aurashk Dec 9, 2025
0714c35
more fine grained error message checking in investment constraints tests
Aurashk Dec 9, 2025
b8b7446
more fine grained error checking in investment constraints tests
Aurashk Dec 9, 2025
2f30d33
remove duplicate test
Aurashk Dec 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions schemas/input/process_investment_constraints.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
$schema: https://specs.frictionlessdata.io/schemas/table-schema.json
description: |
Constraints on the amount agents can invest in processes.

notes: |
Not implemented yet! This file is reserved for future use.

fields:
- name: process_id
type: string
description: The process to which this entry applies
- name: regions
type: string
description: The region(s) to which this entry applies
notes: |
One or more region IDs, separated by semicolons or the string `all`. Must be regions in which
the process operates.
- name: commission years
type: string
description: The milestone year(s) to which this entry applies
notes: One or more milestone years separated by semicolons, `all` to select all years or a year
range in the form 'start..end' to select all valid years within range, inclusive. Either 'start'
'end' or both can be omitted, which will set the corresponding limit to the minimum or maximum
valid year, respectively. Must be within the process's year range.
- name: addition limit
type: number
description: Yearly constraint on the amount agents can invest in the process
notes: The addition limit is allocated evenly between all agents using their proportion
of the processes primary commodity demand.
13 changes: 11 additions & 2 deletions src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::agent::{
use crate::asset::{Asset, AssetPool, AssetRef};
use crate::commodity::{Commodity, CommodityID, CommodityLevyMap, CommodityType, DemandMap};
use crate::process::{
ActivityLimits, Process, ProcessActivityLimitsMap, ProcessFlow, ProcessFlowsMap, ProcessMap,
ProcessParameter, ProcessParameterMap,
ActivityLimits, Process, ProcessActivityLimitsMap, ProcessFlow, ProcessFlowsMap,
ProcessInvestmentConstraintsMap, ProcessMap, ProcessParameter, ProcessParameterMap,
};
use crate::region::RegionID;
use crate::simulation::investment::appraisal::{
Expand Down Expand Up @@ -173,6 +173,13 @@ pub fn process_activity_limits_map(
.collect()
}

#[fixture]
/// Create an empty set of ProcessInvestmentConstraints for a given region/year
/// Returns a HashMap keyed by (RegionID, year) with empty Rc<ProcessInvestmentConstraint>
pub fn process_investment_constraints() -> ProcessInvestmentConstraintsMap {
HashMap::new()
}

#[fixture]
/// Create an empty set of ProcessFlows for a given region/year
pub fn process_flows() -> Rc<IndexMap<CommodityID, ProcessFlow>> {
Expand All @@ -199,6 +206,7 @@ pub fn process(
process_parameter_map: ProcessParameterMap,
process_activity_limits_map: ProcessActivityLimitsMap,
process_flows_map: ProcessFlowsMap,
process_investment_constraints: ProcessInvestmentConstraintsMap,
) -> Process {
Process {
id: "process1".into(),
Expand All @@ -210,6 +218,7 @@ pub fn process(
regions: region_ids,
primary_output: None,
capacity_to_activity: ActivityPerCapacity(1.0),
investment_constraints: process_investment_constraints,
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/input/agent/search_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ mod tests {
use super::*;
use crate::fixture::{agents, assert_error, region_ids};
use crate::process::{
ProcessActivityLimitsMap, ProcessFlowsMap, ProcessID, ProcessParameterMap,
ProcessActivityLimitsMap, ProcessFlowsMap, ProcessID, ProcessInvestmentConstraintsMap,
ProcessParameterMap,
};
use crate::region::RegionID;
use crate::units::ActivityPerCapacity;
Expand All @@ -226,6 +227,7 @@ mod tests {
regions: region_ids.clone(),
primary_output: None,
capacity_to_activity: ActivityPerCapacity(1.0),
investment_constraints: ProcessInvestmentConstraintsMap::new(),
};
(id, process.into())
})
Expand Down
9 changes: 8 additions & 1 deletion src/input/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use super::{input_err_msg, read_csv};
use crate::commodity::CommodityMap;
use crate::id::IDCollection;
use crate::process::{
Process, ProcessActivityLimitsMap, ProcessFlowsMap, ProcessID, ProcessMap, ProcessParameterMap,
Process, ProcessActivityLimitsMap, ProcessFlowsMap, ProcessID, ProcessInvestmentConstraintsMap,
ProcessMap, ProcessParameterMap,
};
use crate::region::{RegionID, parse_region_str};
use crate::time_slice::TimeSliceInfo;
Expand All @@ -22,6 +23,8 @@ use flow::read_process_flows;
mod parameter;
use crate::id::define_id_getter;
use parameter::read_process_parameters;
mod investment_constraints;
use investment_constraints::read_process_investment_constraints;

const PROCESSES_FILE_NAME: &str = "processes.csv";

Expand Down Expand Up @@ -61,6 +64,8 @@ pub fn read_processes(
let mut activity_limits = read_process_availabilities(model_dir, &processes, time_slice_info)?;
let mut flows = read_process_flows(model_dir, &mut processes, commodities, milestone_years)?;
let mut parameters = read_process_parameters(model_dir, &processes, milestone_years)?;
let mut investment_constraints =
read_process_investment_constraints(model_dir, &processes, milestone_years)?;

// Add data to Process objects
for (id, process) in &mut processes {
Expand All @@ -71,6 +76,7 @@ pub fn read_processes(
process.activity_limits = activity_limits.remove(id).unwrap();
process.flows = flows.remove(id).unwrap();
process.parameters = parameters.remove(id).unwrap();
process.investment_constraints = investment_constraints.remove(id).unwrap_or_default();
}

Ok(processes)
Expand Down Expand Up @@ -156,6 +162,7 @@ where
regions,
primary_output,
capacity_to_activity,
investment_constraints: ProcessInvestmentConstraintsMap::new(),
};

ensure!(
Expand Down
Loading