コード例 #1
0
ファイル: Replanner.py プロジェクト: gcyr/FMT
                 help="Nombre de periode de re-plannification")
 ap.add_argument("-thr",
                 "--threads",
                 required=True,
                 help="Nombre de threads")
 ap.add_argument("-swe",
                 "--Strategicweight",
                 required=True,
                 help="Poids de la cedule strategique")
 args = vars(ap.parse_args())
 if Version.FMTversion().hasfeature("OSI"):
     modelparser = Parser.FMTmodelparser()
     path = args["primary"]
     scenarios = [args["strategic"], args["stochastic"], args["tactic"]]
     models = modelparser.readproject(path, scenarios)
     globalmodel = Models.FMTlpmodel(models[0],
                                     Models.FMTsolverinterface.MOSEK)
     globalmodel.setparameter(Models.FMTintmodelparameters.LENGTH,
                              int(args["strategiclength"]))
     globalmodel.setparameter(
         Models.FMTintmodelparameters.NUMBER_OF_THREADS, 1)
     stochastic = Models.FMTnssmodel(models[1], 0)
     stochastic.setparameter(Models.FMTintmodelparameters.LENGTH, 1)
     localmodel = Models.FMTlpmodel(models[2],
                                    Models.FMTsolverinterface.MOSEK)
     localmodel.setparameter(Models.FMTintmodelparameters.LENGTH, 1)
     localmodel.setparameter(Models.FMTintmodelparameters.NUMBER_OF_THREADS,
                             1)
     selectedoutputs = []
     for output in globalmodel.getoutputs():
         if output.getname() in args["outputs"].split(","):
             selectedoutputs.append(output)
コード例 #2
0
from FMT import Models
from FMT import Parser
from FMT import Core
from FMT import Heuristics
from FMT import Version

if __name__ == "__main__":
    if Version.FMTversion().hasfeature("OSI"):
        primarylocation = "../Models/TWD_land/TWD_land.pri"
        modelparser = Parser.FMTmodelparser()
        models = modelparser.readproject(primarylocation, ["LP"])
        models[0].setquietlogger()
        optimizationmodel = Models.FMTlpmodel(models[0],
                                              Models.FMTsolverinterface.CLP)
        themes = optimizationmodel.getthemes()
        opareas = []
        for attribute in themes[2].getattributes("?"):
            mask = ["?" for theme in themes]
            mask[2] = attribute
            opareas.append(
                Heuristics.FMToperatingareascheme(
                    Heuristics.FMToperatingarea(Core.FMTmask(mask, themes), 0),
                    2, 1, 4, 0, 1))
        for period in range(0, 10):
            print(optimizationmodel.buildperiod())
        allconstraints = optimizationmodel.getconstraints()
        objective = allconstraints.pop(0)
        for constraint in allconstraints:
            optimizationmodel.setconstraint(constraint)
        optimizationmodel.setobjective(objective)
        optimizationmodel.initialsolve()
コード例 #3
0
import os
from FMT import Models
from FMT import Parser
from FMT import Spatial
from FMT import Core
from FMT import Version

if __name__ == "__main__":
    if Version.FMTversion().hasfeature("GDAL"):
        modelparser = Parser.FMTmodelparser()
        path = "../Models/TWD_land/TWD_land.pri"
        scenarios = ["Spatial"]
        models = modelparser.readproject(path, scenarios)
        samodel = Models.FMTsamodel(models[0])
        singletransitions = []
        for transition in samodel.gettransitions():
            singletransitions.append(transition.single())
        samodel.settransitions(singletransitions)
        #for action in samodel.getactions():
        #    print(action.getname())
        areaparser = Parser.FMTareaparser()
        rasterslocation = "../Models/TWD_land/rasters/"
        ageraster = os.path.join(rasterslocation, "AGE.tif")
        themesrasters = []
        themeid = 1
        for theme in samodel.getthemes():
            themesrasters.append(
                os.path.join(rasterslocation, "THEME" + str(themeid) + ".tif"))
            themeid += 1
        initialforestmap = areaparser.readrasters(samodel.getthemes(),
                                                  themesrasters, ageraster, 1,
コード例 #4
0
import os
from FMT import Models
from FMT import Parser
from FMT import Spatial
from FMT import Core
from FMT import Version


if __name__ == "__main__":
    if Version.FMTversion().hasfeature("OSI") and Version.FMTversion().hasfeature("GDAL"):
        modelparser = Parser.FMTmodelparser()
        path = "../Models/TWD_land/TWD_land.pri"
        scenarios = ["Spatial"]
        models = modelparser.readproject(path, scenarios)
        lpmodel = Models.FMTlpmodel(models[0], Models.FMTsolverinterface.CLP)
        for period in range(0,10):
            lpmodel.buildperiod()
        constraints = lpmodel.getconstraints()
        objective = constraints.pop(0)
        for constraint in constraints:
            lpmodel.setconstraint(constraint)
        lpmodel.setobjective(objective)
        if lpmodel.initialsolve():
            simulationmodel = Models.FMTsesmodel(lpmodel)
            singletransitions = []
            for transition in simulationmodel.gettransitions():
                singletransitions.append(transition.single())
            simulationmodel.settransitions(singletransitions)
            areaparser = Parser.FMTareaparser()
            rasterslocation = "../Models/TWD_land/rasters/"
            ageraster = os.path.join(rasterslocation,"AGE.tif")
コード例 #5
0
ファイル: Simpleplanning.py プロジェクト: gcyr/FMT
from FMT import Models
from FMT import Parser
from FMT import Core
from FMT import Version

if __name__ == "__main__":
    if Version.FMTversion().hasfeature("OSI"):
        modelparser = Parser.FMTmodelparser()
        path = "../Models/TWD_land/TWD_land.pri"
        scenarios = ["LP"]
        models = modelparser.readproject(path, scenarios)
        lpmodel = Models.FMTlpmodel(models[0], Models.FMTsolverinterface.CLP)
        for period in range(0, 10):
            lpmodel.buildperiod()
        constraints = lpmodel.getconstraints()
        objective = constraints.pop(0)
        for constraint in constraints:
            lpmodel.setconstraint(constraint)
        lpmodel.setobjective(objective)
        print("Global optimality? " + str(lpmodel.initialsolve()))
    else:
        print("FMT needs to be compiled with OSI")
コード例 #6
0
ファイル: maptoFMTforest.py プロジェクト: gcyr/FMT
from FMT import Models
from FMT import Parser

if __name__ == "__main__":
    modelparser = Parser.FMTmodelparser()
    primarylocation = "../Models/TWD_land/TWD_land.pri"
    models = modelparser.readproject(primarylocation, ["Spatial"])
    sesmodel = Models.FMTsesmodel(models[0])
    themes = sesmodel.getthemes()
    areaparser = Parser.FMTareaparser()
    areaparser.setdefaultexceptionhandler()
    forest = areaparser.vectormaptoFMTforest(
        "../Models/TWD_land/Carte/TWD_land.shp", 380, themes, "AGE",
        "SUPERFICIE", 1, 0.0001, "", 0.0, "../Models/TWD_land/rasters/", False)