2027학년도 1학기 교양 시간표 편성 시뮬레이션

2시간 연강과 75분 분할 수업을 같은 시간표에 배정했을 때, 교원 한 사람의 주당 시수와 전체 강좌의 동시 수요를 살펴봅니다.

같은 날 캠퍼스를 옮기지 않고 몇 시간을 맡을 수 있나?

‘비판적 사고와 토론’과 ‘창조적 사고와 글쓰기’ 각 분반은 주 1회 2시수 연강입니다. 일반 3시수 강좌는 같은 교시에 이틀간 75분씩 배정하며, 금요일에는 연강도 허용한 모형입니다.

담당 강좌와 시간대
세부 배정 가정

수정에 지정한 분반을 제외한 나머지는 운정에 배정합니다. 아래 두 결과는 같은 분반 구성과 캠퍼스 배분을 사용합니다.

12~18시수의 모든 분반 조합

각 칸은 수정과 운정에 각각 한 분반 이상 배정할 방법이 하나라도 있는지를 나타냅니다. 원하는 캠퍼스별 분반 수가 정해져 있다면 위의 교원별 시간표에서 확인하세요.

비교표는 금요일 두 배정안 각각을 계산합니다. 목요일 협의 범위와 EF 연강 허용 여부 등은 위에서 선택한 조건을 따릅니다.

교양과 전공을 함께 배정할 때의 최대 동시 강좌 수

2025학년도 2학기 자료에서 기존 분석 대상인 전공 982개와 교양 262개에 두 교양 과목의 2시수 연강 80개 분반(수정 61, 운정 19)을 더했습니다. 분석 대상은 총 1,324개 분반입니다. 이들 분반의 실제 시간표에서 최고 동시 강좌 수는 125개였습니다.

전체 시간표의 편성 조건
선택한 배정안의 교시 쌍별 분반 수

최대 동시 강좌 수를 먼저 최소화한 뒤, 같은 최댓값 안에서 교양 우선 시간대에 들어가는 교양 수업 횟수를 최대화했습니다. 승인된 시간을 열어 두기만 하면 미사용도 가능합니다. ‘실제 배정할 분반’은 그 수만큼 목요일에 반드시 배정하는 비교 조건입니다.

시간대와 계산 기준

요일A·BC·DE·F
월·수교양 우선전공전공
화전공전공전공
목전공전공 우선 · 교양 사전 협의전공 우선 · 교양 사전 협의
금교양 우선교양 우선전공·교양 공통

자료 · 「2027학년도 1학기 교양 개설강좌표 편성 안내」 2쪽 및 2025학년도 2학기 전공·교양 2,060개 분반 자료(2025. 10. 10. 기준). 새 시간표에서 사용할 교시 이름은 편성 안내를 따랐습니다.

전체 강좌 재계산 코드 (Python · SciPy)

아래 코드를 저장하고 원본 28번 엑셀 파일 경로를 첫 번째 인수로 실행하면 시나리오별 정수 최적해와 배정 내역을 JSON으로 얻습니다.

"""Usage: python3 bulk.py <2025-2 timetable.xlsx>. Requires SciPy >= 1.9 and NumPy."""
from itertools import combinations, product
from pathlib import Path
from xml.etree import ElementTree as ET
from zipfile import ZipFile
import json, re, sys
import numpy as np
from scipy.optimize import Bounds, LinearConstraint, milp
DAYS = '월화수목금토'
NAMES = ('비판적사고와토론','창조적사고와글쓰기')
AREAS = {'none':'','cd':'CD','ef':'EF','all':'CDEF'}

def read_base(p):
    with ZipFile(p) as z:
        ss=[''.join(t.text or '' for t in n.findall('.//{*}t')) for n in ET.fromstring(z.read('xl/sharedStrings.xml'))]
        sheet, = [n for n in z.namelist() if re.fullmatch(r'xl/worksheets/sheet\d+\.xml',n)]
        rows=ET.fromstring(z.read(sheet)).findall('.//{*}sheetData/{*}row')
    base=np.zeros((3,6,12),dtype=int)
    counts=np.zeros(3,dtype=int);campuses={}
    for row in rows[1:]:
        d={}
        for c in row.findall('{*}c'):
            k=c.get('r').rstrip('0123456789'); v=c.findtext('{*}v')
            if v is not None and k in ('H','K','AH','D'):
                d[k]=ss[int(v)] if c.get('t')=='s' else v
        if d.get('H') not in ('전공','교양'):continue
        periods=set()
        for token in d.get('AH','').split(','):
            m=re.fullmatch(r'([월화수목금토])/(\d+)(?:-(\d+))?',token.strip())
            if not m:
                periods.clear()
                break
            day,a,b=m.groups()
            periods.update((day,n) for n in range(int(a),int(b or a)+1))
        if not periods: continue
        day, first=min(periods); n=len(periods)
        if periods!={(day,first+i) for i in range(n)}:continue
        if n==3 and first in (1,4,7,10):g=int(d['H']=='교양')
        elif n==2 and d['H']=='교양' and ''.join(d['K'].split()) in NAMES:
            g=2
            campuses[d['D']]=campuses.get(d['D'],0)+1
        else:continue
        counts[g]+=1
        base[g,DAYS.index(day),first-1:first-1+n]+=1
    assert counts.tolist()==[982,262,80]
    return counts, base, campuses

def zone(d,h):
    if d in (0,2) and h<2 or d==4 and h<4:return 'priority'
    if d==4 and h in (4,5):return 'common'
    if d==3 and h in (2,3,4,5):return 'consult'
    return 'major'

def solve(totals, area, q, fri, extra, protect):
    edges=[]
    def add(g,d,h,e,k):edges.append((g,d*6+h,e*6+k))
    for a,b in ((0,2),(1,3)):
        for h in range(6):
            if protect and a==0 and h<2:continue
            add(0,a,h,b,h)
    add(0,4,4,4,5)
    for h,c in enumerate('ABCDEF'):
        ds=[d for d in range(5) if zone(d,h) in ('priority','common') or (d==3 and c in AREAS[area])]
        for a,b in combinations(ds,2):add(1,a,h,b,h)
    for day in (0,2):add(2,day,0,day,1)
    for h in (2,4):
        if 'ABCDEF'[h:h+2] in AREAS[area]:add(2,3,h,3,h+1)
    for pair in ['AB',fri]+(['EF'] if extra else []):
        a,b=['ABCDEF'.index(c) for c in pair]
        for g in (1,2):add(g,4,a,4,b)
    cols=len(edges)+1;subject=np.zeros((3,cols),int);load=np.zeros((30,cols),int)
    thu=np.zeros(cols,int);priority=np.zeros(cols,int);peak=np.zeros(cols,int);peak[-1]=1
    for i,(g,a,b) in enumerate(edges):
        subject[g,i]=1;load[[a,b],i]=1
        if g:
            zs=[zone(*divmod(cell,6)) for cell in (a,b)]
            thu[i]=int('consult' in zs);priority[i]=zs.count('priority')
    load[:,-1]=-1
    rules=[LinearConstraint(subject,totals,totals),LinearConstraint(load,-np.inf,0),LinearConstraint(thu,q,q)]
    def run(obj):
        r=milp(obj,integrality=np.ones(cols),bounds=Bounds(0,np.inf),constraints=rules,options={'mip_rel_gap':0.0})
        assert r.success,r.message
        x=np.rint(r.x).astype(int)
        assert np.allclose(x,r.x,atol=1e-5,rtol=0)
        return x
    cap=run(peak)[-1];rules.append(LinearConstraint(peak,cap,cap))
    x=run(-priority)
    assert (subject*x).sum(axis=1).tolist()==totals.tolist() and (thu*x).sum()==q and max((load*x).sum(axis=1))==0
    return {'peak':int(cap),'rows':[[g,a,b,int(v)] for (g,a,b),v in zip(edges,x) if v]}

if __name__=='__main__':
    totals,base,campuses=read_base(Path(sys.argv[1]))
    runs={}
    for area,fri,extra,protect in product(AREAS,('CD','DE'),(0,1),(0,1)):
        for q in ((0,) if area=='none' else (0,10,20,40)):
            runs[f'{area}-{q}-{fri}-{extra}-{protect}']=solve(totals,area,q,fri,extra,protect)
    print(json.dumps({'totals':totals.tolist(),'campuses':campuses,'base':base.tolist(),'runs':runs},ensure_ascii=False,separators=(',',':')))