Esempio n. 1
0
def update_current_sums(curr_sums: dict, pub: Pub, auth: Author) -> dict:
    """
    Updates temporary values needed to run greedy algorithm. Instead of recount
    values in every loop iteration, we simply update them.

    Args:
        curr_sums: dictionary with values to update
            contrib_sum: sum of contributions from all accepted publicatons (float)
            monograph_sum: sum of contributions from all accepted monographs (float)
            phd_and_outsiders: sum of contributions from all accepted phds' and
                outsiders' publicatons (float)
        pub: newly accepted publication
        auth: publication's author

    Returns:
        dictionary with updated values

    """
    monograph_sum = curr_sums["monograph_sum"]
    phd_and_outsiders = curr_sums["phd_and_outsiders"]

    if pub.is_monograph():
        monograph_sum += pub.get_contribution()
    if auth.is_phd_student() or not auth.is_in_n():
        phd_and_outsiders += pub.get_contribution()

    result = {
        "contrib_sum": curr_sums["contrib_sum"] + pub.get_contribution(),
        "monograph_sum": monograph_sum,
        "phd_and_outsiders": phd_and_outsiders,
    }
    return result
Esempio n. 2
0
def consider_single_publication(pub: Pub, curr_sums: dict, data: dict) -> bool:
    """
    Checks if publication will be accepted and checks limits.

    Args:
        pub: publication
        curr_sums: dictionary with sums needed to decide if publication meets the
            limits. Keys:
            contrib_sum: sum of contributions from all accepted publicatons (float)
            monograph_sum: sum of contributions from all accepted monographs (float)
            phd_and_outsiders: sum of contributions from all accepted phds' and
                outsiders' publicatons (float)
        data: dictionary with data from file

    Returns:
        True if publication meets the limits. Otherwise returns False

    """
    mono_modif = 0
    phd_out_modif = 0
    if pub.is_monograph():
        mono_modif = pub.get_contribution()
    if pub.get_author().is_phd_student() or not pub.get_author().is_employee():
        phd_out_modif = pub.get_contribution()

    tmp_sums = {
        "contrib_sum": curr_sums["contrib_sum"] + pub.get_contribution(),
        "monograph_sum": curr_sums["monograph_sum"] + mono_modif,
        "phd_and_outsiders": curr_sums["phd_and_outsiders"] + phd_out_modif,
    }
    return check_limits(data, tmp_sums)
Esempio n. 3
0
    def accept_publication(self, pub: Publication) -> bool:
        self.__check_if_publication_is_on_publications_list(pub)

        if pub not in self.accepted_publications and self.__check_limits(pub):
            self.accepted_publications.append(pub)
            pub.set_is_accepted(True)
            self.__accepted_pubs_contrib_sum += pub.get_contribution()
            if pub.is_monograph():
                self.__accepted_mons_contrib_sum += pub.get_contribution()
            return True
        return False
Esempio n. 4
0
 def __check_limits_for_phd_students(self, pub: Publication) -> bool:
     tmp_contrib = self.__accepted_pubs_contrib_sum + pub.get_contribution()
     if not self.is_phd:
         return True
     elif tmp_contrib <= PUBLICATIONS_COEFFICIENT_FOR_PHD:
         return True
     return False
Esempio n. 5
0
 def __check_moographs_limit(self, pub: Publication) -> bool:
     tmp_mons_contrib = self.__accepted_mons_contrib_sum + pub.get_contribution(
     )
     if self.is_phd:
         return True
     elif not pub.is_monograph():
         return True
     elif tmp_mons_contrib <= MONOGRAPH_COEFFICIENT * self.contribution:
         return True
     elif pub.get_points() > MONOGRAPH_LIMIT_MAX_POINTS:
         return True
     return False
Esempio n. 6
0
 def __check_limits(self, pub: Publication) -> bool:
     return (self.__accepted_pubs_contrib_sum + pub.get_contribution() <=
             BASIC_CONTRIB_COEFFICIENT)
Esempio n. 7
0
 def __check_publications_limit(self, pub: Publication) -> bool:
     tmp_contrib = self.__accepted_pubs_contrib_sum + pub.get_contribution()
     return tmp_contrib <= PUBLICATIONS_COEFFICIENT * self.contribution
Esempio n. 8
0
def get_temporary_pub_rate(pub: Publication):
    return pub.get_points() / pub.get_contribution()