
import sys
import traceback

logLabHome = 'c:\\Users\\MikeSteglich\\Documents\\Projekte\\LogisticsLab\\DSS-Logistics\\'
#logLabHome = "C:\\Users\\MikeSteglich\\Documents\\Projekte\\LogisticsLab\\DSS-Logistics\\src\\Applications\\TSP\\Win64\\Debug\\..\\..\\..\\..\\..\\"
sys.path.append(logLabHome)

'''nrOfSources = 4
nrOfDests = 6
varCosts = [[19,75,42,11,52,63],
            [46,109,41,8,34,38],
            [47,65,29,14,17,18],
            [71,64,14,24,22,33]  ]
fixedCosts = [30,40,70,40]  
radius = 65'''

nrOfSources = 3
nrOfDests = 7
varCosts = [[ 102.55, 205.81,216.74, 222.25, 203.35,258.88,234.88],
          [  95.32, 220.83,249.34,230.33,247.07,232.53, 236.88],
          [102.08, 203.89, 224.68,220.18, 215.40,256.53, 232.68]]

fixedCosts = [1000000,500000,2000000]  
radius = 233

from CmplApps import Scp as scp

try:  
    m =scp.Scp(nrOfSources, nrOfDests, varCosts, radius, logLabHome)
    #m.setFixedCosts(fixedCosts)
    m.solve()
    if m.isSolution():
        objVal = m.getObjValue()
        activeSources = m.getActiveSources()
        destSourceMapping = m.getDestSourceMapping()
        destSourceMappingSingleSource = m.getDestSourceMappingSingleSource()
    else:
        scpOk=False
        scpMsg= 'No solution has beeen found'

except scp.ScpException as e: 
    scpOK = False
    scpMsg = e
    traceback.print_exc()
except:
    scpOK = False
    scpMsg = str(sys.exc_info())
    traceback.print_exc()
else:
    scpOK = True
    scpMsg = "OK" 

    print (scpMsg)
 
    print('obj ',objVal)
    print('activeSources ',activeSources)
    print('destSourceMapping ',destSourceMapping)
    print('destSourceMappingSingleSource ',destSourceMappingSingleSource)
    
