Пример #1
0
    def addAssignment(self, name, ptsWorth, ptsReceived, category, date):
        infoArray = []
        infoArray.append(ptsWorth)
        infoArray.append(ptsReceived)
        infoArray.append(category)
        infoArray.append(date)
        newAssignment = assignment.Assignment(name, infoArray)
        self.assignments.append(newAssignment)

        total = 0
        for i in range(0, self.assignments.__len__()):
            total += self.assignments[i].gradePercent
        self.currentMPGrade = total / self.assignments.__len__()
Пример #2
0
    def addAssignment(self, name, ptsWorth, ptsReceived, category, date):
        infoArray = []
        infoArray.append(ptsWorth)
        infoArray.append(ptsReceived)
        for i in range(1, len(self.Category) + 1):
            if (category.__contains__(str(self.Category(i).name))
                    or str(self.Category(i).name).__contains__("TotalPoints")):
                infoArray.append(self.Category(i))

        infoArray.append(date)
        infoArray.append(self)

        newAssignment = assignment.Assignment(name, infoArray)
        self.assignments.append(newAssignment)

        self.calculateCurrentMPGrade()
    def revise(self, csp, var1, var2, constraint):
        revised = False
        dv2Values = []
        assig = assignment.Assignment()
        assig.addVariableToAssignment(self.var, self.val)
        if assig.hasAssignmentFor(var2):
            dv2Values.append(self.assignment.getAssignmentOfVariable(var2))
        else:
            dv2Values = csp.getDomainValues(var2)

        for dv1 in csp.getDomainValues(var1):
            for dv2 in dv2Values:
                if not assig.hasAssignmentFor(var1):
                    assig.addVariableToAssignment(var1, dv1)
                assig.addVariableToAssignment(var1, dv1)
                if not assig.isConsistent([constraint]):
                    csp.removeValueFromDomain(var1, dv1)
                    revised = True
        return revised
    def doInference(self, inferenceInfo, csp, variable, value):

        self.assignment = assignment.Assignment()
        self.assignment.addVariableToAssignment(variable, value)
        self.var = variable
        self.val = value
        queue = csp.getConstraints(variable)
        #print('queue',queue)
        pairs = []

        for con in queue:
            #con in working
            if len(con.getScope()) == 2:
                obj = [con.getScope()[1], con.getScope()[0], con]
                #print(con.getScope()[1],con.getScope()[0],con)
                pairs.append(obj)

        while len(pairs) > 0:

            constraint = pairs[0][2]
            #p
            if self.revise(csp, pairs[0][0], pairs[0][1], constraint):

                if len(csp.getDomainValues(pairs[0][0])) == 0:
                    return None
                #print('getneighbour',csp.getNeighboursOfVariableExcept(pairs[0][0],pairs[0][1]))
                for con in csp.getneighbourexcept(pairs[0][0], pairs[0][1]):

                    if con.getScope()[0] == variable or con.getScope(
                    )[1] == variable:
                        continue
                    if con.getScope()[0] == pairs[0][0]:
                        pairs.append(
                            [con.getScope()[1],
                             con.getScope()[0], con])
                    else:
                        pairs.append(
                            [con.getScope()[0],
                             con.getScope()[1], con])
            del pairs[0]
        return []
    def doInference(self, inferenceInfo, csp, variable, value):
        assignment = assignment.Assignment()
        assignment.addVariableToAssignment(variable, value)
        for con in csp.getConstraints(variable):
            otherVariables = csp.getNeighbour(variable, con)
            for ov in otherVariables:
                someValues = []
                changed = False
                domVals = inferenceInfo.getDomainsOfAffectedVariables(ov)
                if domVals is None:
                    domVals = csp.getDomainValues(ov)

                for domVal in domVals:
                    assignment.addVariableToAssignment(ov, domVal)
                    if not con.isConsistentWith(assignment):
                        changed = True
                    else:
                        someValues.append(domVal)

                if changed:
                    inferenceInfo.addToAffectedVariables(ov, someValues)

                assignment.removeVariableFromAssignment(ov)
        return []
Пример #6
0
source = teapot_points
destination = bunny_points * 10

source_points, destination_points = [], []
src_pts_path = Path("source_pts.pkl")
dst_pts_path = Path("dst_pts.pkl")

if src_pts_path.exists():
    with open(src_pts_path, "rb") as fp:
        source_points = pickle.load(fp)
    with open(dst_pts_path, "rb") as fp:
        destination_points = pickle.load(fp)

else:
    start = time.time()
    Morphing = AS.Assignment(source, destination)
    Morphing.calculate()
    source_points, destination_points = Morphing.get_result()
    print("time : ", time.time() - start)

if not src_pts_path.exists():
    with open(src_pts_path, "wb") as fp:
        pickle.dump(source_points, fp)

    with open("dst_pts.pkl", "wb") as fp:
        pickle.dump(destination_points, fp)

# Test

FRAME = 240
filename = "test.mp4"
Пример #7
0
 def open1(self, widget):
     d = widget.get_date()
     d1 = list(d)
     date = str(d1[2]) + "/" + str(d1[1]) + "/" + str(d1[0])
     a = assignment.Assignment(str(date))
     a.display()
Пример #8
0
 def intiliazeRandomly(self, csp):
     self._assignment = assignment.Assignment()
     domainLength = len(csp._domain)
     for va in csp.getVariables():
         self._assignment.addVariableToAssignment(
             va, csp._domain[random.randint(0, domainLength - 1)])
Пример #9
0
f2 = flight.Flight()

f2.dep = "Vigo"
f2.arr = "New York"
f2.time_dep = 15 * 60
f2.time_arr = 20 * 60
f2.passengers = 74

f3 = flight.Flight()

f3.dep = "Palma"
f3.arr = "Paris"
f3.time_dep = 14 * 60
f3.time_arr = 15 * 60
f3.passengers = 67

ass1 = assignment.Assignment()

ass1.aircraft = ac1
ass1.flights = [f1, f2]

ass2 = assignment.Assignment()

ass2.aircraft = ac2
ass2.flights = [f1, f3]

assignment.plot_assignment(ass1)

assignment.plot_assignments([ass1, ass2])
 def addAssignment(self, assignmentName, grade):
     newAssignment = assignment.Assignment(assignmentName, grade)
     self.assignments.append(newAssignment)