Pipeline controller: plan 2 (hard +, error +50 %), backlog throttle, 2 trajectory workers, stop rules, summaries every 50; budget reserve
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
96
tasks_gen/train/G1311/reference/fish_auction.clas.abap
Normal file
96
tasks_gen/train/G1311/reference/fish_auction.clas.abap
Normal file
@@ -0,0 +1,96 @@
|
||||
CLASS {{p}}fish_auction DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
TYPES ty_species TYPE c LENGTH 10.
|
||||
TYPES ty_boat_id TYPE c LENGTH 10.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_catch,
|
||||
boat_id TYPE ty_boat_id,
|
||||
species TYPE ty_species,
|
||||
weight_kg TYPE i,
|
||||
END OF ty_catch.
|
||||
TYPES tt_catch TYPE STANDARD TABLE OF ty_catch WITH EMPTY KEY.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_summary,
|
||||
species TYPE ty_species,
|
||||
total_weight TYPE i,
|
||||
boat_count TYPE i,
|
||||
END OF ty_summary.
|
||||
TYPES tt_summary TYPE STANDARD TABLE OF ty_summary WITH EMPTY KEY.
|
||||
|
||||
METHODS summarize
|
||||
IMPORTING it_catch TYPE tt_catch
|
||||
RETURNING VALUE(rt_summary) TYPE tt_summary.
|
||||
|
||||
METHODS best_species
|
||||
IMPORTING it_catch TYPE tt_catch
|
||||
RETURNING VALUE(rv_species) TYPE ty_species.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_boat_species,
|
||||
species TYPE ty_species,
|
||||
boat_id TYPE ty_boat_id,
|
||||
END OF ty_boat_species,
|
||||
tt_boat_species TYPE HASHED TABLE OF ty_boat_species
|
||||
WITH UNIQUE KEY species boat_id.
|
||||
|
||||
METHODS species_key
|
||||
IMPORTING iv_species TYPE ty_species
|
||||
RETURNING VALUE(rv_species) TYPE ty_species.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}fish_auction IMPLEMENTATION.
|
||||
|
||||
METHOD summarize.
|
||||
DATA lt_total TYPE SORTED TABLE OF ty_summary WITH UNIQUE KEY species.
|
||||
DATA lt_boat_species TYPE tt_boat_species.
|
||||
DATA lv_species TYPE ty_species.
|
||||
|
||||
LOOP AT it_catch INTO DATA(ls_catch).
|
||||
lv_species = species_key( ls_catch-species ).
|
||||
IF lv_species IS INITIAL OR ls_catch-weight_kg <= 0.
|
||||
CONTINUE.
|
||||
ENDIF.
|
||||
|
||||
READ TABLE lt_total WITH TABLE KEY species = lv_species
|
||||
ASSIGNING FIELD-SYMBOL(<ls_total>).
|
||||
IF sy-subrc <> 0.
|
||||
INSERT VALUE #( species = lv_species ) INTO TABLE lt_total.
|
||||
READ TABLE lt_total WITH TABLE KEY species = lv_species
|
||||
ASSIGNING <ls_total>.
|
||||
ENDIF.
|
||||
<ls_total>-total_weight = <ls_total>-total_weight + ls_catch-weight_kg.
|
||||
|
||||
INSERT VALUE #( species = lv_species boat_id = ls_catch-boat_id )
|
||||
INTO TABLE lt_boat_species.
|
||||
IF sy-subrc = 0.
|
||||
<ls_total>-boat_count = <ls_total>-boat_count + 1.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
rt_summary = lt_total.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD best_species.
|
||||
DATA(lt_summary) = summarize( it_catch ).
|
||||
DATA lv_best_weight TYPE i.
|
||||
|
||||
LOOP AT lt_summary INTO DATA(ls_summary).
|
||||
IF ls_summary-total_weight > lv_best_weight.
|
||||
lv_best_weight = ls_summary-total_weight.
|
||||
rv_species = ls_summary-species.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD species_key.
|
||||
DATA lv_species TYPE ty_species.
|
||||
lv_species = iv_species.
|
||||
SHIFT lv_species LEFT DELETING LEADING space.
|
||||
rv_species = to_upper( lv_species ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user