Fix coverage with several contract classes; table annotation and file path checks; clean task dir on write
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
164
tasks_gen/eval/G0115/faulty/m0_refill_planner.clas.abap
Normal file
164
tasks_gen/eval/G0115/faulty/m0_refill_planner.clas.abap
Normal file
@@ -0,0 +1,164 @@
|
||||
CLASS {{p}}refill_planner DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
ty_machine_id TYPE c LENGTH 8,
|
||||
ty_district TYPE c LENGTH 4,
|
||||
ty_quantity TYPE i,
|
||||
ty_fill_level TYPE i,
|
||||
BEGIN OF ty_machine,
|
||||
machine_id TYPE ty_machine_id,
|
||||
district TYPE ty_district,
|
||||
fill_level TYPE ty_fill_level,
|
||||
END OF ty_machine,
|
||||
tt_machines TYPE STANDARD TABLE OF ty_machine WITH EMPTY KEY,
|
||||
BEGIN OF ty_refill,
|
||||
machine_id TYPE ty_machine_id,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_refill,
|
||||
tt_refills TYPE STANDARD TABLE OF ty_refill WITH EMPTY KEY,
|
||||
BEGIN OF ty_district_summary,
|
||||
district TYPE ty_district,
|
||||
machines TYPE i,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_district_summary,
|
||||
tt_district_summary TYPE STANDARD TABLE OF ty_district_summary WITH EMPTY KEY.
|
||||
|
||||
METHODS add_machine
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
iv_district TYPE ty_district
|
||||
iv_fill_level TYPE ty_fill_level.
|
||||
METHODS add_refill
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
iv_quantity TYPE ty_quantity
|
||||
RETURNING VALUE(rv_accepted) TYPE abap_bool.
|
||||
METHODS get_refill
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
RETURNING VALUE(rv_quantity) TYPE ty_quantity.
|
||||
METHODS machines_below
|
||||
IMPORTING iv_fill_level TYPE ty_fill_level
|
||||
RETURNING VALUE(rt_machines) TYPE tt_machines.
|
||||
METHODS top_refills
|
||||
IMPORTING iv_count TYPE i
|
||||
RETURNING VALUE(rt_refills) TYPE tt_refills.
|
||||
METHODS district_summary
|
||||
RETURNING VALUE(rt_summary) TYPE tt_district_summary.
|
||||
METHODS total_quantity
|
||||
RETURNING VALUE(rv_total) TYPE ty_quantity.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_machine_state,
|
||||
machine_id TYPE ty_machine_id,
|
||||
district TYPE ty_district,
|
||||
fill_level TYPE ty_fill_level,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_machine_state,
|
||||
tt_machine_state TYPE HASHED TABLE OF ty_machine_state WITH UNIQUE KEY machine_id.
|
||||
|
||||
DATA mt_machines TYPE tt_machine_state.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}refill_planner IMPLEMENTATION.
|
||||
METHOD add_machine.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc = 0.
|
||||
<ls_machine>-district = to_upper( iv_district ).
|
||||
<ls_machine>-fill_level = iv_fill_level.
|
||||
ELSE.
|
||||
INSERT VALUE #( machine_id = lv_machine_id
|
||||
district = to_upper( iv_district )
|
||||
fill_level = iv_fill_level
|
||||
quantity = 0 ) INTO TABLE mt_machines.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD add_refill.
|
||||
IF iv_quantity <= 0.
|
||||
rv_accepted = abap_true.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc <> 0.
|
||||
rv_accepted = abap_false.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
<ls_machine>-quantity = <ls_machine>-quantity + iv_quantity.
|
||||
rv_accepted = abap_true.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_refill.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc = 0.
|
||||
rv_quantity = <ls_machine>-quantity.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD machines_below.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
IF ls_machine-fill_level < iv_fill_level.
|
||||
INSERT VALUE #( machine_id = ls_machine-machine_id
|
||||
district = ls_machine-district
|
||||
fill_level = ls_machine-fill_level ) INTO TABLE rt_machines.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
SORT rt_machines BY fill_level machine_id.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD top_refills.
|
||||
DATA lv_index TYPE i.
|
||||
DATA lt_refills TYPE tt_refills.
|
||||
IF iv_count <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
IF ls_machine-quantity > 0.
|
||||
INSERT VALUE #( machine_id = ls_machine-machine_id
|
||||
quantity = ls_machine-quantity ) INTO TABLE lt_refills.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
SORT lt_refills BY quantity DESCENDING machine_id ASCENDING.
|
||||
LOOP AT lt_refills INTO DATA(ls_refill).
|
||||
lv_index = lv_index + 1.
|
||||
IF lv_index > iv_count.
|
||||
EXIT.
|
||||
ENDIF.
|
||||
INSERT ls_refill INTO TABLE rt_refills.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD district_summary.
|
||||
TYPES:
|
||||
BEGIN OF ty_district_state,
|
||||
district TYPE ty_district,
|
||||
machines TYPE i,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_district_state,
|
||||
tt_district_state TYPE HASHED TABLE OF ty_district_state WITH UNIQUE KEY district.
|
||||
DATA lt_districts TYPE tt_district_state.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
ASSIGN lt_districts[ district = ls_machine-district ] TO FIELD-SYMBOL(<ls_district>).
|
||||
IF sy-subrc <> 0.
|
||||
INSERT VALUE #( district = ls_machine-district )
|
||||
INTO TABLE lt_districts ASSIGNING <ls_district>.
|
||||
ENDIF.
|
||||
<ls_district>-machines = <ls_district>-machines + 1.
|
||||
<ls_district>-quantity = <ls_district>-quantity + ls_machine-quantity.
|
||||
ENDLOOP.
|
||||
LOOP AT lt_districts INTO DATA(ls_district).
|
||||
INSERT VALUE #( district = ls_district-district
|
||||
machines = ls_district-machines
|
||||
quantity = ls_district-quantity ) INTO TABLE rt_summary.
|
||||
ENDLOOP.
|
||||
SORT rt_summary BY district.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD total_quantity.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
rv_total = rv_total + ls_machine-quantity.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
164
tasks_gen/eval/G0115/faulty/m1_refill_planner.clas.abap
Normal file
164
tasks_gen/eval/G0115/faulty/m1_refill_planner.clas.abap
Normal file
@@ -0,0 +1,164 @@
|
||||
CLASS {{p}}refill_planner DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
ty_machine_id TYPE c LENGTH 8,
|
||||
ty_district TYPE c LENGTH 4,
|
||||
ty_quantity TYPE i,
|
||||
ty_fill_level TYPE i,
|
||||
BEGIN OF ty_machine,
|
||||
machine_id TYPE ty_machine_id,
|
||||
district TYPE ty_district,
|
||||
fill_level TYPE ty_fill_level,
|
||||
END OF ty_machine,
|
||||
tt_machines TYPE STANDARD TABLE OF ty_machine WITH EMPTY KEY,
|
||||
BEGIN OF ty_refill,
|
||||
machine_id TYPE ty_machine_id,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_refill,
|
||||
tt_refills TYPE STANDARD TABLE OF ty_refill WITH EMPTY KEY,
|
||||
BEGIN OF ty_district_summary,
|
||||
district TYPE ty_district,
|
||||
machines TYPE i,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_district_summary,
|
||||
tt_district_summary TYPE STANDARD TABLE OF ty_district_summary WITH EMPTY KEY.
|
||||
|
||||
METHODS add_machine
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
iv_district TYPE ty_district
|
||||
iv_fill_level TYPE ty_fill_level.
|
||||
METHODS add_refill
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
iv_quantity TYPE ty_quantity
|
||||
RETURNING VALUE(rv_accepted) TYPE abap_bool.
|
||||
METHODS get_refill
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
RETURNING VALUE(rv_quantity) TYPE ty_quantity.
|
||||
METHODS machines_below
|
||||
IMPORTING iv_fill_level TYPE ty_fill_level
|
||||
RETURNING VALUE(rt_machines) TYPE tt_machines.
|
||||
METHODS top_refills
|
||||
IMPORTING iv_count TYPE i
|
||||
RETURNING VALUE(rt_refills) TYPE tt_refills.
|
||||
METHODS district_summary
|
||||
RETURNING VALUE(rt_summary) TYPE tt_district_summary.
|
||||
METHODS total_quantity
|
||||
RETURNING VALUE(rv_total) TYPE ty_quantity.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_machine_state,
|
||||
machine_id TYPE ty_machine_id,
|
||||
district TYPE ty_district,
|
||||
fill_level TYPE ty_fill_level,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_machine_state,
|
||||
tt_machine_state TYPE HASHED TABLE OF ty_machine_state WITH UNIQUE KEY machine_id.
|
||||
|
||||
DATA mt_machines TYPE tt_machine_state.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}refill_planner IMPLEMENTATION.
|
||||
METHOD add_machine.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc = 0.
|
||||
<ls_machine>-district = to_upper( iv_district ).
|
||||
<ls_machine>-fill_level = iv_fill_level.
|
||||
ELSE.
|
||||
INSERT VALUE #( machine_id = lv_machine_id
|
||||
district = to_upper( iv_district )
|
||||
fill_level = iv_fill_level
|
||||
quantity = 0 ) INTO TABLE mt_machines.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD add_refill.
|
||||
IF iv_quantity <= 0.
|
||||
rv_accepted = abap_false.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc <> 0.
|
||||
rv_accepted = abap_false.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
<ls_machine>-quantity = <ls_machine>-quantity + iv_quantity.
|
||||
rv_accepted = abap_true.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_refill.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc = 0.
|
||||
rv_quantity = <ls_machine>-quantity.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD machines_below.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
IF ls_machine-fill_level < iv_fill_level.
|
||||
INSERT VALUE #( machine_id = ls_machine-machine_id
|
||||
district = ls_machine-district
|
||||
fill_level = ls_machine-fill_level ) INTO TABLE rt_machines.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
SORT rt_machines BY fill_level machine_id.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD top_refills.
|
||||
DATA lv_index TYPE i.
|
||||
DATA lt_refills TYPE tt_refills.
|
||||
IF iv_count > 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
IF ls_machine-quantity > 0.
|
||||
INSERT VALUE #( machine_id = ls_machine-machine_id
|
||||
quantity = ls_machine-quantity ) INTO TABLE lt_refills.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
SORT lt_refills BY quantity DESCENDING machine_id ASCENDING.
|
||||
LOOP AT lt_refills INTO DATA(ls_refill).
|
||||
lv_index = lv_index + 1.
|
||||
IF lv_index > iv_count.
|
||||
EXIT.
|
||||
ENDIF.
|
||||
INSERT ls_refill INTO TABLE rt_refills.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD district_summary.
|
||||
TYPES:
|
||||
BEGIN OF ty_district_state,
|
||||
district TYPE ty_district,
|
||||
machines TYPE i,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_district_state,
|
||||
tt_district_state TYPE HASHED TABLE OF ty_district_state WITH UNIQUE KEY district.
|
||||
DATA lt_districts TYPE tt_district_state.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
ASSIGN lt_districts[ district = ls_machine-district ] TO FIELD-SYMBOL(<ls_district>).
|
||||
IF sy-subrc <> 0.
|
||||
INSERT VALUE #( district = ls_machine-district )
|
||||
INTO TABLE lt_districts ASSIGNING <ls_district>.
|
||||
ENDIF.
|
||||
<ls_district>-machines = <ls_district>-machines + 1.
|
||||
<ls_district>-quantity = <ls_district>-quantity + ls_machine-quantity.
|
||||
ENDLOOP.
|
||||
LOOP AT lt_districts INTO DATA(ls_district).
|
||||
INSERT VALUE #( district = ls_district-district
|
||||
machines = ls_district-machines
|
||||
quantity = ls_district-quantity ) INTO TABLE rt_summary.
|
||||
ENDLOOP.
|
||||
SORT rt_summary BY district.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD total_quantity.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
rv_total = rv_total + ls_machine-quantity.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
164
tasks_gen/eval/G0115/faulty/m2_refill_planner.clas.abap
Normal file
164
tasks_gen/eval/G0115/faulty/m2_refill_planner.clas.abap
Normal file
@@ -0,0 +1,164 @@
|
||||
CLASS {{p}}refill_planner DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
ty_machine_id TYPE c LENGTH 8,
|
||||
ty_district TYPE c LENGTH 4,
|
||||
ty_quantity TYPE i,
|
||||
ty_fill_level TYPE i,
|
||||
BEGIN OF ty_machine,
|
||||
machine_id TYPE ty_machine_id,
|
||||
district TYPE ty_district,
|
||||
fill_level TYPE ty_fill_level,
|
||||
END OF ty_machine,
|
||||
tt_machines TYPE STANDARD TABLE OF ty_machine WITH EMPTY KEY,
|
||||
BEGIN OF ty_refill,
|
||||
machine_id TYPE ty_machine_id,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_refill,
|
||||
tt_refills TYPE STANDARD TABLE OF ty_refill WITH EMPTY KEY,
|
||||
BEGIN OF ty_district_summary,
|
||||
district TYPE ty_district,
|
||||
machines TYPE i,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_district_summary,
|
||||
tt_district_summary TYPE STANDARD TABLE OF ty_district_summary WITH EMPTY KEY.
|
||||
|
||||
METHODS add_machine
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
iv_district TYPE ty_district
|
||||
iv_fill_level TYPE ty_fill_level.
|
||||
METHODS add_refill
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
iv_quantity TYPE ty_quantity
|
||||
RETURNING VALUE(rv_accepted) TYPE abap_bool.
|
||||
METHODS get_refill
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
RETURNING VALUE(rv_quantity) TYPE ty_quantity.
|
||||
METHODS machines_below
|
||||
IMPORTING iv_fill_level TYPE ty_fill_level
|
||||
RETURNING VALUE(rt_machines) TYPE tt_machines.
|
||||
METHODS top_refills
|
||||
IMPORTING iv_count TYPE i
|
||||
RETURNING VALUE(rt_refills) TYPE tt_refills.
|
||||
METHODS district_summary
|
||||
RETURNING VALUE(rt_summary) TYPE tt_district_summary.
|
||||
METHODS total_quantity
|
||||
RETURNING VALUE(rv_total) TYPE ty_quantity.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_machine_state,
|
||||
machine_id TYPE ty_machine_id,
|
||||
district TYPE ty_district,
|
||||
fill_level TYPE ty_fill_level,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_machine_state,
|
||||
tt_machine_state TYPE HASHED TABLE OF ty_machine_state WITH UNIQUE KEY machine_id.
|
||||
|
||||
DATA mt_machines TYPE tt_machine_state.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}refill_planner IMPLEMENTATION.
|
||||
METHOD add_machine.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc = 0.
|
||||
<ls_machine>-district = to_upper( iv_district ).
|
||||
<ls_machine>-fill_level = iv_fill_level.
|
||||
ELSE.
|
||||
INSERT VALUE #( machine_id = lv_machine_id
|
||||
district = to_upper( iv_district )
|
||||
fill_level = iv_fill_level
|
||||
quantity = 0 ) INTO TABLE mt_machines.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD add_refill.
|
||||
IF iv_quantity <= 0.
|
||||
rv_accepted = abap_false.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc <> 0.
|
||||
rv_accepted = abap_false.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
<ls_machine>-quantity = <ls_machine>-quantity + iv_quantity.
|
||||
rv_accepted = abap_true.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_refill.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc = 0.
|
||||
rv_quantity = <ls_machine>-quantity.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD machines_below.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
IF ls_machine-fill_level < iv_fill_level.
|
||||
INSERT VALUE #( machine_id = ls_machine-machine_id
|
||||
district = ls_machine-district
|
||||
fill_level = ls_machine-fill_level ) INTO TABLE rt_machines.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
SORT rt_machines BY fill_level machine_id.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD top_refills.
|
||||
DATA lv_index TYPE i.
|
||||
DATA lt_refills TYPE tt_refills.
|
||||
IF iv_count <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
IF ls_machine-quantity <= 0.
|
||||
INSERT VALUE #( machine_id = ls_machine-machine_id
|
||||
quantity = ls_machine-quantity ) INTO TABLE lt_refills.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
SORT lt_refills BY quantity DESCENDING machine_id ASCENDING.
|
||||
LOOP AT lt_refills INTO DATA(ls_refill).
|
||||
lv_index = lv_index + 1.
|
||||
IF lv_index > iv_count.
|
||||
EXIT.
|
||||
ENDIF.
|
||||
INSERT ls_refill INTO TABLE rt_refills.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD district_summary.
|
||||
TYPES:
|
||||
BEGIN OF ty_district_state,
|
||||
district TYPE ty_district,
|
||||
machines TYPE i,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_district_state,
|
||||
tt_district_state TYPE HASHED TABLE OF ty_district_state WITH UNIQUE KEY district.
|
||||
DATA lt_districts TYPE tt_district_state.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
ASSIGN lt_districts[ district = ls_machine-district ] TO FIELD-SYMBOL(<ls_district>).
|
||||
IF sy-subrc <> 0.
|
||||
INSERT VALUE #( district = ls_machine-district )
|
||||
INTO TABLE lt_districts ASSIGNING <ls_district>.
|
||||
ENDIF.
|
||||
<ls_district>-machines = <ls_district>-machines + 1.
|
||||
<ls_district>-quantity = <ls_district>-quantity + ls_machine-quantity.
|
||||
ENDLOOP.
|
||||
LOOP AT lt_districts INTO DATA(ls_district).
|
||||
INSERT VALUE #( district = ls_district-district
|
||||
machines = ls_district-machines
|
||||
quantity = ls_district-quantity ) INTO TABLE rt_summary.
|
||||
ENDLOOP.
|
||||
SORT rt_summary BY district.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD total_quantity.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
rv_total = rv_total + ls_machine-quantity.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
164
tasks_gen/eval/G0115/faulty/m3_refill_planner.clas.abap
Normal file
164
tasks_gen/eval/G0115/faulty/m3_refill_planner.clas.abap
Normal file
@@ -0,0 +1,164 @@
|
||||
CLASS {{p}}refill_planner DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
ty_machine_id TYPE c LENGTH 8,
|
||||
ty_district TYPE c LENGTH 4,
|
||||
ty_quantity TYPE i,
|
||||
ty_fill_level TYPE i,
|
||||
BEGIN OF ty_machine,
|
||||
machine_id TYPE ty_machine_id,
|
||||
district TYPE ty_district,
|
||||
fill_level TYPE ty_fill_level,
|
||||
END OF ty_machine,
|
||||
tt_machines TYPE STANDARD TABLE OF ty_machine WITH EMPTY KEY,
|
||||
BEGIN OF ty_refill,
|
||||
machine_id TYPE ty_machine_id,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_refill,
|
||||
tt_refills TYPE STANDARD TABLE OF ty_refill WITH EMPTY KEY,
|
||||
BEGIN OF ty_district_summary,
|
||||
district TYPE ty_district,
|
||||
machines TYPE i,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_district_summary,
|
||||
tt_district_summary TYPE STANDARD TABLE OF ty_district_summary WITH EMPTY KEY.
|
||||
|
||||
METHODS add_machine
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
iv_district TYPE ty_district
|
||||
iv_fill_level TYPE ty_fill_level.
|
||||
METHODS add_refill
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
iv_quantity TYPE ty_quantity
|
||||
RETURNING VALUE(rv_accepted) TYPE abap_bool.
|
||||
METHODS get_refill
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
RETURNING VALUE(rv_quantity) TYPE ty_quantity.
|
||||
METHODS machines_below
|
||||
IMPORTING iv_fill_level TYPE ty_fill_level
|
||||
RETURNING VALUE(rt_machines) TYPE tt_machines.
|
||||
METHODS top_refills
|
||||
IMPORTING iv_count TYPE i
|
||||
RETURNING VALUE(rt_refills) TYPE tt_refills.
|
||||
METHODS district_summary
|
||||
RETURNING VALUE(rt_summary) TYPE tt_district_summary.
|
||||
METHODS total_quantity
|
||||
RETURNING VALUE(rv_total) TYPE ty_quantity.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_machine_state,
|
||||
machine_id TYPE ty_machine_id,
|
||||
district TYPE ty_district,
|
||||
fill_level TYPE ty_fill_level,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_machine_state,
|
||||
tt_machine_state TYPE HASHED TABLE OF ty_machine_state WITH UNIQUE KEY machine_id.
|
||||
|
||||
DATA mt_machines TYPE tt_machine_state.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}refill_planner IMPLEMENTATION.
|
||||
METHOD add_machine.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc = 0.
|
||||
<ls_machine>-district = to_upper( iv_district ).
|
||||
<ls_machine>-fill_level = iv_fill_level.
|
||||
ELSE.
|
||||
INSERT VALUE #( machine_id = lv_machine_id
|
||||
district = to_upper( iv_district )
|
||||
fill_level = iv_fill_level
|
||||
quantity = 0 ) INTO TABLE mt_machines.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD add_refill.
|
||||
IF iv_quantity <= 0.
|
||||
rv_accepted = abap_false.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc <> 0.
|
||||
rv_accepted = abap_false.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
<ls_machine>-quantity = <ls_machine>-quantity + iv_quantity.
|
||||
rv_accepted = abap_true.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_refill.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc = 0.
|
||||
rv_quantity = <ls_machine>-quantity.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD machines_below.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
IF ls_machine-fill_level < iv_fill_level.
|
||||
INSERT VALUE #( machine_id = ls_machine-machine_id
|
||||
district = ls_machine-district
|
||||
fill_level = ls_machine-fill_level ) INTO TABLE rt_machines.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
SORT rt_machines BY fill_level machine_id.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD top_refills.
|
||||
DATA lv_index TYPE i.
|
||||
DATA lt_refills TYPE tt_refills.
|
||||
IF iv_count <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
IF ls_machine-quantity > 0.
|
||||
INSERT VALUE #( machine_id = ls_machine-machine_id
|
||||
quantity = ls_machine-quantity ) INTO TABLE lt_refills.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
SORT lt_refills BY quantity DESCENDING machine_id ASCENDING.
|
||||
LOOP AT lt_refills INTO DATA(ls_refill).
|
||||
lv_index = lv_index - 1.
|
||||
IF lv_index > iv_count.
|
||||
EXIT.
|
||||
ENDIF.
|
||||
INSERT ls_refill INTO TABLE rt_refills.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD district_summary.
|
||||
TYPES:
|
||||
BEGIN OF ty_district_state,
|
||||
district TYPE ty_district,
|
||||
machines TYPE i,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_district_state,
|
||||
tt_district_state TYPE HASHED TABLE OF ty_district_state WITH UNIQUE KEY district.
|
||||
DATA lt_districts TYPE tt_district_state.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
ASSIGN lt_districts[ district = ls_machine-district ] TO FIELD-SYMBOL(<ls_district>).
|
||||
IF sy-subrc <> 0.
|
||||
INSERT VALUE #( district = ls_machine-district )
|
||||
INTO TABLE lt_districts ASSIGNING <ls_district>.
|
||||
ENDIF.
|
||||
<ls_district>-machines = <ls_district>-machines + 1.
|
||||
<ls_district>-quantity = <ls_district>-quantity + ls_machine-quantity.
|
||||
ENDLOOP.
|
||||
LOOP AT lt_districts INTO DATA(ls_district).
|
||||
INSERT VALUE #( district = ls_district-district
|
||||
machines = ls_district-machines
|
||||
quantity = ls_district-quantity ) INTO TABLE rt_summary.
|
||||
ENDLOOP.
|
||||
SORT rt_summary BY district.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD total_quantity.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
rv_total = rv_total + ls_machine-quantity.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
164
tasks_gen/eval/G0115/faulty/m4_refill_planner.clas.abap
Normal file
164
tasks_gen/eval/G0115/faulty/m4_refill_planner.clas.abap
Normal file
@@ -0,0 +1,164 @@
|
||||
CLASS {{p}}refill_planner DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
ty_machine_id TYPE c LENGTH 8,
|
||||
ty_district TYPE c LENGTH 4,
|
||||
ty_quantity TYPE i,
|
||||
ty_fill_level TYPE i,
|
||||
BEGIN OF ty_machine,
|
||||
machine_id TYPE ty_machine_id,
|
||||
district TYPE ty_district,
|
||||
fill_level TYPE ty_fill_level,
|
||||
END OF ty_machine,
|
||||
tt_machines TYPE STANDARD TABLE OF ty_machine WITH EMPTY KEY,
|
||||
BEGIN OF ty_refill,
|
||||
machine_id TYPE ty_machine_id,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_refill,
|
||||
tt_refills TYPE STANDARD TABLE OF ty_refill WITH EMPTY KEY,
|
||||
BEGIN OF ty_district_summary,
|
||||
district TYPE ty_district,
|
||||
machines TYPE i,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_district_summary,
|
||||
tt_district_summary TYPE STANDARD TABLE OF ty_district_summary WITH EMPTY KEY.
|
||||
|
||||
METHODS add_machine
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
iv_district TYPE ty_district
|
||||
iv_fill_level TYPE ty_fill_level.
|
||||
METHODS add_refill
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
iv_quantity TYPE ty_quantity
|
||||
RETURNING VALUE(rv_accepted) TYPE abap_bool.
|
||||
METHODS get_refill
|
||||
IMPORTING iv_machine_id TYPE ty_machine_id
|
||||
RETURNING VALUE(rv_quantity) TYPE ty_quantity.
|
||||
METHODS machines_below
|
||||
IMPORTING iv_fill_level TYPE ty_fill_level
|
||||
RETURNING VALUE(rt_machines) TYPE tt_machines.
|
||||
METHODS top_refills
|
||||
IMPORTING iv_count TYPE i
|
||||
RETURNING VALUE(rt_refills) TYPE tt_refills.
|
||||
METHODS district_summary
|
||||
RETURNING VALUE(rt_summary) TYPE tt_district_summary.
|
||||
METHODS total_quantity
|
||||
RETURNING VALUE(rv_total) TYPE ty_quantity.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_machine_state,
|
||||
machine_id TYPE ty_machine_id,
|
||||
district TYPE ty_district,
|
||||
fill_level TYPE ty_fill_level,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_machine_state,
|
||||
tt_machine_state TYPE HASHED TABLE OF ty_machine_state WITH UNIQUE KEY machine_id.
|
||||
|
||||
DATA mt_machines TYPE tt_machine_state.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}refill_planner IMPLEMENTATION.
|
||||
METHOD add_machine.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc = 0.
|
||||
<ls_machine>-district = to_upper( iv_district ).
|
||||
<ls_machine>-fill_level = iv_fill_level.
|
||||
ELSE.
|
||||
INSERT VALUE #( machine_id = lv_machine_id
|
||||
district = to_upper( iv_district )
|
||||
fill_level = iv_fill_level
|
||||
quantity = 0 ) INTO TABLE mt_machines.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD add_refill.
|
||||
IF iv_quantity <= 0.
|
||||
rv_accepted = abap_false.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc <> 0.
|
||||
rv_accepted = abap_false.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
<ls_machine>-quantity = <ls_machine>-quantity + iv_quantity.
|
||||
rv_accepted = abap_true.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_refill.
|
||||
DATA(lv_machine_id) = to_upper( iv_machine_id ).
|
||||
ASSIGN mt_machines[ machine_id = lv_machine_id ] TO FIELD-SYMBOL(<ls_machine>).
|
||||
IF sy-subrc = 0.
|
||||
rv_quantity = <ls_machine>-quantity.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD machines_below.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
IF ls_machine-fill_level < iv_fill_level.
|
||||
INSERT VALUE #( machine_id = ls_machine-machine_id
|
||||
district = ls_machine-district
|
||||
fill_level = ls_machine-fill_level ) INTO TABLE rt_machines.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
SORT rt_machines BY fill_level machine_id.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD top_refills.
|
||||
DATA lv_index TYPE i.
|
||||
DATA lt_refills TYPE tt_refills.
|
||||
IF iv_count <= 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
IF ls_machine-quantity > 0.
|
||||
INSERT VALUE #( machine_id = ls_machine-machine_id
|
||||
quantity = ls_machine-quantity ) INTO TABLE lt_refills.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
SORT lt_refills BY quantity DESCENDING machine_id ASCENDING.
|
||||
LOOP AT lt_refills INTO DATA(ls_refill).
|
||||
lv_index = lv_index + 1.
|
||||
IF lv_index > iv_count.
|
||||
EXIT.
|
||||
ENDIF.
|
||||
INSERT ls_refill INTO TABLE rt_refills.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD district_summary.
|
||||
TYPES:
|
||||
BEGIN OF ty_district_state,
|
||||
district TYPE ty_district,
|
||||
machines TYPE i,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_district_state,
|
||||
tt_district_state TYPE HASHED TABLE OF ty_district_state WITH UNIQUE KEY district.
|
||||
DATA lt_districts TYPE tt_district_state.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
ASSIGN lt_districts[ district = ls_machine-district ] TO FIELD-SYMBOL(<ls_district>).
|
||||
IF sy-subrc <> 0.
|
||||
INSERT VALUE #( district = ls_machine-district )
|
||||
INTO TABLE lt_districts ASSIGNING <ls_district>.
|
||||
ENDIF.
|
||||
<ls_district>-machines = <ls_district>-machines - 1.
|
||||
<ls_district>-quantity = <ls_district>-quantity + ls_machine-quantity.
|
||||
ENDLOOP.
|
||||
LOOP AT lt_districts INTO DATA(ls_district).
|
||||
INSERT VALUE #( district = ls_district-district
|
||||
machines = ls_district-machines
|
||||
quantity = ls_district-quantity ) INTO TABLE rt_summary.
|
||||
ENDLOOP.
|
||||
SORT rt_summary BY district.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD total_quantity.
|
||||
LOOP AT mt_machines INTO DATA(ls_machine).
|
||||
rv_total = rv_total + ls_machine-quantity.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user