Exemplo n.º 1
0
    def __init__(self, charID):
        """Constructor"""
        self.charID = charID
        blueprints = Blueprints(self.charID)
        typeIDs = blueprints.blueprints.keys(
        )  #sort the itemIDs by corresponding names
        self.datacoresDict = {}

        for typeID in typeIDs:
            bpContainer = blueprints.blueprints[typeID]
            if bpContainer.T2.inventable == 1:
                for index in range(len(bpContainer.T2.inventedIDs)):
                    if bpContainer.t2Priority[index][
                            0] == 'invention' and bpContainer.BPO.component == 0:
                        tempDict = StaticData.datacoreRequirements(typeID)
                        for datacore in tempDict:
                            if datacore in self.datacoresDict:
                                self.datacoresDict[datacore] += tempDict[
                                    datacore] * bpContainer.t2Priority[index][1]
                            else:
                                self.datacoresDict[datacore] = tempDict[
                                    datacore] * bpContainer.t2Priority[index][1]
Exemplo n.º 2
0
    def T2Inventables(self):
        """determine inventable T2 items"""
        #vars
        items = []  #list of all blueprints
        objectiveFunction = {
        }  #names of items, this is the objective function "name": required invention runs
        datacoresDict = {
        }  #a dict containing another dict for every resource. the latter contains the amount of that resource required for every object

        #determine total resources
        for blueprintID in self.blueprints.blueprints:
            bpContainer = self.blueprints.blueprints[blueprintID]
            if not bpContainer.T2.inventable:
                continue
            for idx in range(len(bpContainer.T2.inventedIDs)):
                if not bpContainer.t2Priority[idx][0] == 'invention':
                    continue

                reqDatacores = StaticData.datacoreRequirements(
                    StaticData.originatorBp(bpContainer.T2.inventedIDs[idx]))
                items.append(bpContainer.T2.inventedIDs[idx])
                objectiveFunction[bpContainer.T2.inventedIDs[idx]] = 1
                for datacore in reqDatacores:
                    if datacore not in datacoresDict:
                        datacoresDict[datacore] = {}

        for blueprintID in self.blueprints.blueprints:
            bpContainer = self.blueprints.blueprints[blueprintID]
            if not bpContainer.T2.inventable:
                continue
            for idx in range(len(bpContainer.T2.inventedIDs)):
                bpTypeID = bpContainer.T2.inventedIDs[idx]
                if not bpContainer.t2Priority[idx][0] == 'invention':
                    continue
                reqDatacores = StaticData.datacoreRequirements(
                    StaticData.originatorBp(bpTypeID))

                for datacore in datacoresDict:
                    if datacore in reqDatacores:
                        datacoresDict[datacore][bpTypeID] = reqDatacores[
                            datacore] * bpContainer.t2Priority[idx][1]
                    else:
                        datacoresDict[datacore][bpTypeID] = 0

        prob = LpProblem("t2 inventable items", LpMaximize)
        itemVars = LpVariable.dicts("items", items, 0, 1, LpInteger)

        prob += lpSum([objectiveFunction[i] * itemVars[i] for i in items
                       ]), "all items, this represents the objective function"

        for datacore in datacoresDict:
            if datacore in self.materials:
                ownedMat = self.materials[datacore]
            else:
                ownedMat = 0
            prob += lpSum(
                [datacoresDict[datacore][x] * itemVars[x]
                 for x in items]) <= ownedMat, StaticData.idName(datacore)

        prob.solve()

        #for v in prob.variables():
        #  print(v.name, "=", v.varValue)

        return DatacoreOptimizedAggregator(prob.variables(), self.blueprints,
                                           self.materials)