Feat/strict hardmask - #33
Open
pkhyrn268 wants to merge 15 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
작업 목적
기존 모델에서는 pairing의 base 출발·복귀 조건이 일부 실행 옵션과 reward penalty에 의존하고 있었음.
그 결과 실행 경로에 따라 다음 문제가 발생할 수 있었음.
step()을 직접 호출하여 CPP 제약 우회본 PR에서는 이러한 경로를 제거하고, 항공사별 home-base 규칙을 CPP 실행 전체에서 항상 적용되는 불변조건으로 통일함.
주요 변경 사항
1. Base 출발 조건 상시 적용
2. Base 복귀 가능성 기반 hard mask 적용
일반 항공사는 현재 pairing이 시작한 base를 대상으로 reachability를 계산함.
Turkish는 HB1과 HB2 각각의 reachability를 계산하고, 둘 중 하나로 복귀 가능하면 candidate를 허용함.
3. EndPairing legality 강제
EndPairing은 다음 조건을 모두 만족할 때만 허용함.일반 항공사:
Turkish:
decoder mask뿐 아니라
step()내부에서도 동일 조건을 다시 확인함.mask를 거치지 않고
EndPairing을 직접 호출하더라도 조건 위반 시ValueError가 발생하도록 변경함.4. Flight 및 EndDuty 직접 호출 우회 차단
기존에는 decoder가 mask를 사용하더라도 외부 코드가
step()을 직접 호출하면 일부 제약을 우회할 수 있었음.다음 검증을
step()내부에 추가함.EndDuty의 현재 mask 재검사EndPairing의 현재 mask 재검사처리 방식:
N+2이상 action:IndexErrorValueErrorEndDuty직접 호출:ValueErrorEndPairing직접 호출:ValueErrorstate와assigned를 변경하기 전에 오류가 발생하도록 처리함.5. All-zero 및 막다른 상태 처리 수정
다음 action이 모두 불가능한 상태를 all-zero 상태로 정의함.
EndDuty불가EndPairing불가기존에는 이 상태에서 다음 동작이 발생할 수 있었음.
현재 처리 방식:
임의 공항 이동과 arbitrary restart는 수행하지 않음.
6. Pairing 저장 경계 검증 추가
mask의 정상 동작에만 의존하지 않고 candidate pool에 pairing을 추가하기 직전에 legality를 다시 검사함.
검사 항목:
검사를 통과하지 못한 pairing은 pool에 추가하지 않거나
ValueError로 처리함.동일 검사를 다음 경로에 적용함.
7. Single 및 batch rollout 계약 통일
기존 vectorized batch rollout은 single rollout과 lifecycle이 달랐으며, 다음 처리가 완전히 동일하지 않았음.
현재는 correctness가 검증된 single rollout을 batch 크기만큼 실행하도록 변경함.
이에 따라 single과 batch에서 같은 CPP legality를 보장함.
현재 구현은 속도보다 correctness를 우선함.
동일 lifecycle을 유지하는 vectorization은 후속 작업으로 분리함.
8. Phase I 학습 경로 정합화
모든 학습 episode에서 항공사별 home-base reachability를 구성함.
변경 사항:
관련 metric:
n_uncoveredcoverage_pctn_zero_maskn_deadheadsn_pairings9. Phase II dual pool 정합화
Phase II의 restricted LP와 dual 학습에 infeasible column이 들어가지 않도록 수정함.
변경 사항:
이를 통해 infeasible pairing이 dual signal을 왜곡하는 경로를 차단함.
10. 최종 평가 correctness 강화
평가 함수와 CLI에서 base-return 검사를 끄는 option을 제거함.
각 평가 chunk에서 local flight ID 기준 reachability를 구성함.
항공사별 pairing 유효성 판정:
최종 set-covering 결과가 다음 중 하나에 해당하면 완성된 CPP 결과로 보고하지 않음.
이 경우
RuntimeError를 발생시키며, 불완전 coverage 상태의 ManDays와 FTC 등을 최종 결과처럼 출력하지 않음.변경된 주요 파일
RL/base_reach.pyRL/environment.pyRL/turkish/environment_turkish.pyRL/turkish/constraints_turkish.pyRL/rollout.pyexperiments/train.pyevaluation/evaluate_ip.pytest/v1_strict_hardmask/result/v1_strict_hardmask/동작 변경 및 주의사항
후속 작업
lambda_dhsweep