기본 콘텐츠로 건너뛰기

knapsack problem (배낭문제)

Knapsack Problem

Definition in Wikipedia

배낭 문제(Knapsack Problem 냅색 프라블럼[*])는 조합 최적화의 유명한 문제이다.
간단하게 말하면, 한 여행가가 가지고 가는 배낭에 담을 수 있는 무게의 최댓값이 정해져 있고, 일정 가치와 무게가 있는 짐들을 배낭에 넣을 때, 가치의 합이 최대가 되도록 짐을 고르는 방법을 찾는 문제이다.
이 배낭문제는 짐을 쪼갤 수 있는 경우(무게가 소수일 수 있는 경우)와 짐을 쪼갤 수 없는 경우(이 경우 짐의 무게는 0 이상의 정수만 가능) 두 가지로 나눌 수 있는데, 짐을 쪼갤 수 있는 경우의 배낭문제를 분할가능 배낭문제(Fractional Knapsack Problem), 짐을 쪼갤 수 없는 경우의 배낭문제를 0-1 배낭문제(0-1 Knapsack Problem)라 부른다.
이 문제는 쪼갤 수 있는 경우에는 그리디 알고리즘으로 다항 시간에, 쪼갤 수 없는 경우에는 동적계획법(Dynamic Programming)등으로 의사 다항 시간에 풀 수 있다. 단, 쪼갤 수 없는 경우는 NP-완전이기 때문에 알려진 다항 시간 알고리즘은 없고, FPTAS만 존재한다. 배낭 문제에 대한 FPTAS는 오스카 이바라와 김철언이 1975년에 개발하였다.

ZeroDivision Error

https://airbrake.io/blog/python-exception-handling/zerodivisionerror-2

Greedy metrics


댓글

이 블로그의 인기 게시물

[Android] Android Studio Github 설정하기

1. Settings File > Settings 2. Version Control 메뉴 or 검색창에서 git 입력 3. 사용중인 Github 계정 및 비번을 입력하고 'Apply' > 'OK'색에서 'git' 검색 4. VCS > Checkout from Version Control > Github 5. Clone Repository에 Checkout 받을 프로젝트를 선택한 후, 'Clone'을 실행

Udacity - Retrieve Accuracy using Decision Tree

sklearn decision tree split을 2, 50로 설정하고 accuracy를 비교한다. import  sys from  class_vis  import  prettyPicture from  prep_terrain_data  import  makeTerrainData   import  matplotlib.pyplot as plt import  numpy as np import  pylab as pl   features_train, labels_train, features_test, labels_test  =  makeTerrainData()   ########################## DECISION TREE ################################# ### your code goes here--now create 2 decision tree classifiers, ### one with min_samples_split=2 and one with min_samples_split=50 ### compute the accuracies on the testing data and store ### the accuracy numbers to acc_min_samples_split_2 and ### acc_min_samples_split_50,...