Skip to content

Commit

Permalink
update cucumber test
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Feb 21, 2025
1 parent d78c8c2 commit 1f6b5cc
Show file tree
Hide file tree
Showing 26 changed files with 371 additions and 50 deletions.
53 changes: 31 additions & 22 deletions src/tests/cucumber/features/modeler-features/epic2/us2.8.feature
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
Feature: 2.8
Feature: 1 - Simple end-to-end tests to test temporal expression management

Scenario: 2.8.1: One model with one load and two generators, one timestep
Scenario: 1.1: One model with one load and two generators, two timesteps
Given the study path is "modeler/1_1"
When I run antares modeler
Then the modeler simulation succeeds
And the objective value is 160
And the optimal value of variable node1.gen1_p_0 is 80
And the optimal value of variable node1.gen2_p_0 is 20
Then the simulation succeeds
And the objective value is 320
And the optimal values of the variables are
| component | variable | timestep | value |
| node1 | gen1_p | 0-1 | 80 |
| node1 | gen2_p | 0-1 | 20 |

Scenario: 2.8.1: One model with one load and two generators, mix of constant and time dependent parameter, one timestep.
Scenario: 1.2: One model with one load and two generators, two timesteps ; mix of constant parameters and timeseries
Given the study path is "modeler/1_2"
When I run antares modeler
Then the modeler simulation succeeds
And the objective value is 160
And the optimal value of variable node1.gen1_p_0 is 80
And the optimal value of variable node1.gen2_p_0 is 20
Then the simulation succeeds
And the objective value is 320
And the optimal values of the variables are
| component | variable | timestep | value |
| node1 | gen1_p | 0-1 | 80 |
| node1 | gen2_p | 0-1 | 20 |

Scenario: 2.8.1: Exception handling: time series of different lengths.
Scenario: 1.3: One model with one load and two generators, one timestep ; fails because of timeseries of different lengths
Given the study path is "modeler/1_3"
When I run antares modeler
Then the simulation fails

Scenario: 2.8.1: Mixture of constant parameters and time series (2 time steps), With booleans type.

Scenario: 1.4: test system with one load (100 MW) and two generators in the same node (with Pmax_1 = 80 MW & Pmax_2 = 200 MW) ; gen1 has a fixed switch on cost. Two timesteps.
Given the study path is "modeler/1_4"
When I run antares modeler
Then the modeler simulation succeeds
Then the simulation succeeds
And the objective value is 765
And the optimal values of the variables are
| component | variable | timestep | value |
| node1 | gen1_p | 0-1 | 80-0 |
| node1 | gen2_p | 0-1 | 20-100 |
| component | variable | timestep | value |
| node1 | gen1_p | 0 | 80 |
| node1 | gen2_p | 0 | 20 |
| node1 | gen1_p | 1 | 0 |
| node1 | gen2_p | 1 | 100 |
| node1 | on_off_gen1_p | 0 | 1 |
| node1 | on_off_gen1_p | 1 | 0 |


Scenario: 2.8.1: Exception handling: given time serie for a constant in time parameter.
Scenario: 1.5: One model with one load and two generators, one timestep ; fails because of timeseries given for parameter with time_dependant = false
Given the study path is "modeler/1_5"
When I run antares modeler
Then the simulation fails


Scenario: 2.8.1: Mixture of constant parameters and time series (10 time steps)
Given the study path is "modeler/1_7"
Scenario: 1.6: One model with one load and two generators, 100 timesteps
Given the study path is "modeler/1_6"
When I run antares modeler
Then the modeler simulation succeeds
Then the simulation succeeds
And the objective value is 16000
And the optimal values of the variables are
| component | variable | timestep | value |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def __read_csv(self, file_name) -> pd.DataFrame:
return pd.read_csv(absolute_path, header=None, sep=' ', low_memory=False)

def get_optimal_value(self, var : str) -> float:

for row in self.results.iterrows():
if row[1][0] == var:
return row[1][1]
raise ValueError("Variable not found")
raise ValueError(f"Variable '{var}' not found")
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import subprocess
import os
from common_steps.modeler_output_handler import modeler_output_handler


def run_modeler(context):
Expand All @@ -18,6 +19,10 @@ def run_modeler(context):
print("*********************** Begin stderr ***********************")
print(err.replace(b'\r\n', b'\n').decode('utf-8'))
print("*********************** End stderr ***********************")
else:
context.output_path = os.path.join(context.study_path,
"output") # TODO : fixme parse_output_folder_from_logs(out)
context.moh = modeler_output_handler(context.output_path)

context.return_code = process.returncode

Expand Down
7 changes: 0 additions & 7 deletions src/tests/cucumber/features/steps/common_steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from common_steps.simulator_utils import run_simulation

from features.steps.common_steps.assertions import assert_double_close
from common_steps.modeler_output_handler import modeler_output_handler



Expand All @@ -36,12 +35,6 @@ def simu_success(context):
assert context.return_code == 0


@then('the modeler simulation succeeds')
def simu_success(context):
print(f"context.return_code = {context.return_code} ***********************")
assert context.return_code == 0
context.output_path = os.path.join(context.study_path, "output") # TODO : fixme parse_output_folder_from_logs(out)
context.moh = modeler_output_handler(context.output_path)



Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
80
80
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
0.5
0.5
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
200
200
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
6
6
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
100
100
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ library:

models:
- id: node_2gen_1load
description: A simple node with two generators and one load
description: A simple node with two generators and one load, two timesteps
parameters:
- id: load
time-dependent: true
Expand Down
14 changes: 13 additions & 1 deletion src/tests/resources/modeler/1_1/input/system.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
system:
id: sys_example_1_1
description: test system
description: >
A single component containing 2 generators and a consumption of 100MW, two timesteps
The generators have no Pmin constraint.
Generator 1 costs 0.5 €/MW and has a Pmax of 80 MW.
Generator 2 costs €6/MW and has a maximum output of 200 MW.
Solution :
node1.gen1_p[0] = 80
node1.gen2_p[0] = 20
node1.gen1_p[1] = 80
node1.gen2_p[1] = 20
Objective function value: 320
model-libraries: lib_example_1_1

components:
Expand Down
4 changes: 2 additions & 2 deletions src/tests/resources/modeler/1_1/parameters.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
solver: sirius
solver: xpress
solver-logs: true
solver-parameters: THREADS 1
no-output: false
first-time-step: 0
last-time-step: 0
last-time-step: 1
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
0.5
0.5
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
200
200
12 changes: 11 additions & 1 deletion src/tests/resources/modeler/1_2/input/system.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
system:
id: sys_example_1_2
description: test system
description: >
A single component containing 2 generators and a consumption of 100MW, two timesteps
The generators have no Pmin constraint.
Generator 1 costs 0.5 €/MW and has a Pmax of 80 MW.
Generator 2 costs €6/MW and has a maximum output of 200 MW.
Solution : node1.gen1_p[0] = 80
node1.gen2_p[0] = 20
node1.gen1_p[1] = 80
node1.gen2_p[2] = 20
Objective function value: 320
model-libraries: lib_example_1_2

components:
Expand Down
4 changes: 2 additions & 2 deletions src/tests/resources/modeler/1_2/parameters.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
solver: sirius
solver: xpress
solver-logs: true
solver-parameters: THREADS 1
no-output: false
first-time-step: 0
last-time-step: 0
last-time-step: 1
2 changes: 1 addition & 1 deletion src/tests/resources/modeler/1_3/input/system.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
system:
id: sys_example_1_3
description: test system
description: Bugged system because of timeseries of different sizes
model-libraries: lib_example_1_3

components:
Expand Down
4 changes: 2 additions & 2 deletions src/tests/resources/modeler/1_3/parameters.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
solver: sirius
solver: xpress
solver-logs: true
solver-parameters: THREADS 1
no-output: false
first-time-step: 0
last-time-step: 2
last-time-step: 2
16 changes: 9 additions & 7 deletions src/tests/resources/modeler/1_4/input/system.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
system:
id: sys_example_1_4
description: >
test system with one load (100 MW) and two generators in the same node (with Pmax_1 = 80 MW & Pmax_2 = 200 MW) ; gen1 has a fixed cost. Two time steps.
t=1 : gen1_prop_cost = 0.5 €/MW, gen1_fixed_cost = 5 €, gen1_prop_cost = 6 €/MW
t = 2 : gen1_prop_cost = 0.5 €/MW, gen1_fixed_cost = 1000 €, gen1_prop_cost = 6 €/MW
Solutions
t = 1, gen1_p = 80, gen2_p = 20
t = 2, gen1_p = 0, gen2_p = 100
test system with one load (100 MW) and two generators in the same node (with Pmax_1 = 80 MW & Pmax_2 = 200 MW) ; gen1 has a fixed cost. Two time steps.
t=0 : gen1_prop_cost = 0.5 €/MW, gen1_fixed_cost = 5 €, gen1_prop_cost = 6 €/MW
t = 1 : gen1_prop_cost = 0.5 €/MW, gen1_fixed_cost = 1000 €, gen1_prop_cost = 6 €/MW
Solutions
t = 0, gen1_p = 80, gen2_p = 20, on_off_gen1_p = 1
t = 1, gen1_p = 0, gen2_p = 100, on_off_gen1_p = 0
Objective function : 765
model-libraries: lib_example_1_4

Expand Down
2 changes: 1 addition & 1 deletion src/tests/resources/modeler/1_4/parameters.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
solver: sirius
solver: xpress
solver-logs: true
solver-parameters: THREADS 1
no-output: false
Expand Down
4 changes: 2 additions & 2 deletions src/tests/resources/modeler/1_5/parameters.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
solver: sirius
solver: xpress
solver-logs: true
solver-parameters: THREADS 1
no-output: false
first-time-step: 0
last-time-step: 0
last-time-step: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
0.5
Loading

0 comments on commit 1f6b5cc

Please sign in to comment.