<jupyter_start><jupyter_text>--- 선형계획법 문제와 이차계획법 문제 1) 선형계획법  - 목적함수         $argmin_x c^Tx$              - 제한조건         1) $Ax = b$        2) $x\geq 0$              - CVXPY : 속도가 느림 ..   - !conda install cvxpy     2) 이차계획법   - 목적함수         $\frac{1}{2}x^T Q_x + c^Tx$              - 제한조건         1) $Ax = b$        2) $x\geq 0$              - CvxOpt       - numpy 사용불가, matrix 를 이용해야함    - 부동 소수점으로 풀어야한다.   - !conda install cvxopt --- 집합과 원소 - $x\in A$ - $x\notin A$ --- - mutable (변경 가능) : list - immutable (변경 불가능): 숫자, 문자, tuple --- - set (mutable) - frozenset (immutable)  $\rightarrow$ dict의 key , set자료형의 원소 ---<jupyter_code>a = set([1,2,3,3,2])
a
b = frozenset(['H','T'])
b<jupyter_output><empty_output><jupyter_text>집합의 크기(cardinality) |A| = card(A) = 3   - len 명령을 사용해 원소의 갯수를 구한다    ----  - 실수로 이루어진 집합은 갯수가 무한 .     : set, frozenset 으로 표현 불가능<jupyter_code>len(a), len(b)<jupyter_output><empty_output><jupyter_text>합집합과 교집합  - $A\cup B$ : union , |  - $A\cap B$ : intersection , &<jupyter_code>A1 = set([1,2,3,4])
A2 = set([2,4,6])
A3 = set([1,2,3])
A4 = set([2,3,4,5,6])
A1.union(A2)
A2 | A4
A3.intersection(A4)
A4 & A2<jupyter_output><empty_output><jupyter_text>전체집합 , 부분집합, 여집합 - $A \subset \Omega$ - $A \subset A $ for all $A$    - issubset<jupyter_code>A3.issubset(A1)
A3 <= A1
A3.issubset(A1)
A3 <= A3
A3 < A3<jupyter_output><empty_output><jupyter_text>차집합, 여집합 - $A-B$ - $A^C$ - $A^C = \Omega - A$   - difference<jupyter_code>A1.difference(A3)
A1 - A2<jupyter_output><empty_output><jupyter_text>공집합  - $\emptyset \subset A$, for all $A$ - $A\cap\emptyset = \emptyset$ - $A\cup\emptyset  = A$ - $A\cap A^C = \emptyset$   - empty_set = set([])  - empty_set<jupyter_code>empty_set = set([])
empty_set
empty_set.union(A1)
empty_set.intersection(A1)
empty_set < A1<jupyter_output><empty_output><jupyter_text>부분집합의 수 - $A_1 = B$ - $A_2 = ${1} - $A_3 = ${2} - $A_4 = ${1,2}<jupyter_code>omega = {"HH","HT","TH","TT"}
A1 = frozenset([])
A2 = frozenset(["HH"])
A3 = frozenset(["HT"])
A4 = frozenset(["TH"])
A5 = frozenset(["TT"])
A6 = frozenset(["HH","HT"])
A7 = frozenset(["HH","TH"])
A8 = frozenset(["HH","TT"])
A9 = frozenset(["HT","TH"])
A10 = frozenset(["HT","TT"])
A11 = frozenset(["TH","TT"])
A12 = frozenset(["HH","HT","TH"])
A13 = frozenset(["HH","HT","TT"])
A14 = frozenset(["HH","TH","TT"])
A15 = frozenset(["HT","TH","TT"])
A16 = frozenset(["HH","TH","HT","TT"])

set([A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16])
from itertools import chain, combinations

def get_set_of_subsets(omega):
    return set([frozenset(s) 
                for s in chain.from_iterable(combinations(omega,r)
                                             for r in range(len(omega)+1))])


SS1 = get_set_of_subsets(omega)
SS1<jupyter_output><empty_output><jupyter_text>합집합과 교집합의 분배법칙 - $a \times (b + c) = a \times b + a \times c$<jupyter_code>A = set([1,3,5])
B = set([1,2,3])
C = set([2,4,6])
A|(B&C) == (A|B)&(A|C)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2131979695431472, 'fraction_numerical': 0.04263959390862944, 'mean_word_length': 3.4185351270553066, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '434288', 'license': 'MIT', 'n_tokens_mistral': 1516, 'n_tokens_neox': 1634, 'n_words': 253, 'path': 'MATH/14_linear_programming_Set.ipynb', 'repo_name': 'CATERINA-SEUL/Data-Science-School', 'size': '2955'}