Ejemplo n.º 1
0
 def MOIP(
     variables : List[int], \
     objectives : List[Dict[int, int]], \
     inequations : List[Dict[int, int]], \
     inequations_operators : List[str], \
     equations : List[Dict[int, int]]
 ) -> MOIPProblem:
     # use objectives make attribute matrix
     attribute_matrix = []
     for objective in objectives:
         line = [0] * (len(variables))
         for key, value in objective.items():
             line[key] = value
         # there was a constant_id = max_id + 1, then api do not work
         # so I assume there's no constant in objective 
         attribute_matrix.append(line)
     # load into the MOIP
     # construct MOIP
     MOIP = MOIPProblem(len(objectives), len(variables), 0)
     # call load
     MOIP.load(objectives, inequations, equations, False, None)
     # ...load manually
     MOIP.sparseInequationSensesList = inequations_operators
     MOIP.attributeMatrix = attribute_matrix
     # return
     return MOIP
Ejemplo n.º 2
0
    paretoOutputFile = '../result/{goalNum}-obj/Pareto_{goalNum}_{name}_{mode}.txt'.format(
        goalNum=problemGoalNum, name=projectName, mode=modelingMode)
    fullResultOutputFile = '../result/{goalNum}-obj/FullResult_{goalNum}_{name}_{mode}.txt'.format(
        goalNum=problemGoalNum, name=projectName, mode=modelingMode)

    reader = BiCriteriaProbReaderOR(inputPath)
    reader.load()
    reader.save(moipInputFile)
    reader.displayFeatureNum()
    reader.displayTestCaseNum()
    reader.displayStmtNum()
    reader.displayFaultNum()
    reader.displayConstraintInequationNum()
    reader.displayConstraintEquationNum()

    prob = MOIPProblem(len(reader.objectNames), len(reader.featureNames),
                       len(reader.objectNames) - 1)
    prob.displayObjectiveCount()
    prob.displayFeatureCount()
    prob.exetractFromFile(moipInputFile)
    prob.displayObjectives()
    #prob.displayVariableNames()
    #prob.displayObjectiveSparseMapList()
    prob.displaySparseInequationsMapListCount()
    prob.displaySparseEquationsMapListCount()
    #prob.displayAttributeMatrix()

    time_start = time.time()
    sol = CwmoipSol(prob)
    sol.prepare()
    sol.execute()
    time_end = time.time()
Ejemplo n.º 3
0
            #bug fixed here, rsltSol should not be returned as the constraints will be modified at the end of the method
            #rsltSol = self.solver.solution
            rsltXvar = cplex.solution.get_values()
            rsltObj = cplex.solution.get_objective_value()

        if origiCplex == None:
            cplex.end()
        else:
            #remove the temp constraints
            cplex.linear_constraints.delete(tempConstNames1)
            cplex.linear_constraints.delete(tempConstNames2)
        return (rsltObj, rsltXvar, rsltSolString)


if __name__ == "__main__":
    prob = MOIPProblem(4, 1244, 3)
    prob.displayObjectiveCount()
    prob.displayFeatureCount()
    prob.exetractFromFile("../test/parameter_ecos1.txt")
    prob.displayObjectives()
    prob.displayVariableNames()
    #prob.displayObjectiveSparseMapList()
    #prob.displaySparseInequationsMapList()
    #prob.displaySparseEquationsMapList()
    #prob.displayAttributeMatrix()

    sol = NcgopSol(prob)
    sol.prepare()
    sol.execute()
    sol.outputCplexParetoMap("../result/parameter_ecos1.txt")
    sol.displaySolvingAttempts()
Ejemplo n.º 4
0
        rsltXvar = []
        rsltObj = float("+inf")
        rsltSolString = self.solver.solution.get_status_string()
        if (rsltSolString.find("optimal") >= 0):
            #bug fixed here, rsltSol should not be returned as the constraints will be modified at the end of the method
            #rsltSol = self.solver.solution
            rsltXvar = self.solver.solution.get_values()
            rsltObj = self.solver.solution.get_objective_value()
        #remove the temp constraints
        self.solver.linear_constraints.delete(tempConstrList)
        return (rsltObj, rsltXvar, rsltSolString)


if __name__ == "__main__":
    prob = MOIPProblem(4, 12, 3)
    prob.displayObjectiveCount()
    prob.displayFeatureCount()
    prob.exetractFromFile("../test/parameter_js1.txt")
    prob.displayObjectives()
    prob.displayVariableNames()
    prob.displayObjectiveSparseMapList()
    prob.displaySparseInequationsMapList()
    prob.displaySparseEquationsMapList()
    prob.displayAttributeMatrix()

    sol = CwmoipSol(prob)
    sol.prepare()
    sol.execute()
    sol.outputCplexParetoMap("../result/Pareto_js1.txt")
    sol.displaySolvingAttempts()
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 14 10:03:21 2018

@author: Yinxing Xue
"""
from moipProb import MOIPProblem
from naiveSol import NaiveSol

if __name__ == "__main__":
    prob = MOIPProblem(2, 7, 1)
    prob.displayObjectiveCount()
    prob.displayFeatureCount()
    prob.exetractFromFile("../test/test_case/parameter_example.txt")
    prob.displayObjectives()
    prob.displayVariableNames()
    prob.displayObjectiveSparseMapList()
    prob.displaySparseInequationsMapList()
    prob.displaySparseEquationsMapList()
    prob.displayAttributeMatrix()

    sol = NaiveSol(prob)
    sol.prepare()
    sol.execute()
    sol.outputCplexParetoMap("../result/test_case/parameter_example.txt")
    sol.displaySolvingAttempts()
    sol.displayObjsBoundsDictionary()
    sol.displayCplexSolutionSetSize()
    sol.displayCplexResultMap()
    sol.displayFullCplexResultMap()
    sol.displayCplexParetoSet()