def createPlan(database = DEFAULT_DB_ALIAS): # Auxiliary functions for debugging def debugResource(res,mode): # if res.name != 'my favorite resource': return print("=> Situation on resource", res.name) for j in res.loadplans: print("=> ", j.quantity, j.onhand, j.startdate, j.enddate, j.operation.name, j.operationplan.quantity, j.setup) def debugDemand(dem,mode): if dem.name == 'my favorite demand': print("=> Starting to plan demand ", dem.name) solver.loglevel = 2 else: solver.loglevel = 0 # Create a solver where the plan type are defined by an environment variable try: plantype = int(os.environ['FREPPLE_PLANTYPE']) except: plantype = 1 # Default is a constrained plan try: constraint = int(os.environ['FREPPLE_CONSTRAINT']) except: constraint = 15 # Default is with all constraints enabled solver = frepple.solver_mrp(name = "MRP", constraints = constraint, plantype = plantype, loglevel=int(Parameter.getValue('plan.loglevel', database, 0)) #userexit_resource=debugResource, #userexit_demand=debugDemand ) print("Plan type: ", plantype) print("Constraints: ", constraint) solver.solve()
def run(cls, database=DEFAULT_DB_ALIAS, **kwargs): import frepple # Create a solver where the plan type are defined by an environment variable try: plantype = int(os.environ['FREPPLE_PLANTYPE']) except: plantype = 1 # Default is a constrained plan try: constraint = int(os.environ['FREPPLE_CONSTRAINT']) except: constraint = 15 # Default is with all constraints enabled cls.solver = frepple.solver_mrp( constraints=constraint, plantype=plantype, loglevel=int(Parameter.getValue('plan.loglevel', database, 0)), lazydelay=int(Parameter.getValue('lazydelay', database, '86400')), allowsplits=(Parameter.getValue('allowsplits', database, 'true').lower() == "true"), rotateresources=(Parameter.getValue('plan.rotateResources', database, 'true').lower() == "true"), plansafetystockfirst=(Parameter.getValue('plan.planSafetyStockFirst', database, 'false').lower() != "false"), iterationmax=int(Parameter.getValue('plan.iterationmax', database, '0')) ) if hasattr(cls, 'debugResource'): cls.solver.userexit_resource = cls.debugResource if hasattr(cls, 'debugDemand'): cls.solver.userexit_demand = cls.debugDemand if hasattr(cls, 'debugOperation'): cls.solver.userexit_operation = cls.debugOperation print("Plan type: ", plantype) print("Constraints: ", constraint) cls.solver.solve() frepple.printsize()
def run(cls, database=DEFAULT_DB_ALIAS, **kwargs): import frepple # Determine log level loglevel = int(Parameter.getValue("plan.loglevel", database, 0)) if cls.task and cls.task.user: maxloglevel = cls.task.user.getMaxLoglevel(database) if loglevel > maxloglevel: loglevel = maxloglevel # Create a solver where the plan type are defined by an environment variable try: plantype = int(os.environ["FREPPLE_PLANTYPE"]) except: plantype = 1 # Default is a constrained plan try: constraint = int(os.environ["FREPPLE_CONSTRAINT"]) except: constraint = 15 # Default is with all constraints enabled cls.solver = frepple.solver_mrp( constraints=constraint, plantype=plantype, loglevel=loglevel, lazydelay=int(Parameter.getValue("lazydelay", database, "86400")), allowsplits=(Parameter.getValue("allowsplits", database, "true").lower() == "true"), minimumdelay=int( Parameter.getValue("plan.minimumdelay", database, "3600")), rotateresources=(Parameter.getValue("plan.rotateResources", database, "true").lower() == "true"), plansafetystockfirst=(Parameter.getValue( "plan.planSafetyStockFirst", database, "false").lower() != "false"), iterationmax=int( Parameter.getValue("plan.iterationmax", database, "0")), resourceiterationmax=int( Parameter.getValue("plan.resourceiterationmax", database, "500")), administrativeleadtime=86400 * float( Parameter.getValue("plan.administrativeLeadtime", database, "0")), autofence=86400 * float( Parameter.getValue("plan.autoFenceOperations", database, "0")), ) if hasattr(cls, "debugResource"): cls.solver.userexit_resource = cls.debugResource if hasattr(cls, "debugDemand"): cls.solver.userexit_demand = cls.debugDemand if hasattr(cls, "debugOperation"): cls.solver.userexit_operation = cls.debugOperation logger.info("Plan type: %s" % plantype) logger.info("Constraints: %s" % constraint) cls.solver.solve() frepple.printsize()
def run(database=DEFAULT_DB_ALIAS, **kwargs): import frepple # Auxiliary functions for debugging def debugResource(res, mode): # if res.name != 'my favorite resource': return print("=> Situation on resource", res.name) for j in res.loadplans: print("=> ", j.quantity, j.onhand, j.startdate, j.enddate, j.operation.name, j.operationplan.quantity, j.setup) def debugDemand(dem, mode): if dem.name == 'my favorite demand': print("=> Starting to plan demand ", dem.name) solver.loglevel = 2 else: solver.loglevel = 0 # Create a solver where the plan type are defined by an environment variable try: plantype = int(os.environ['FREPPLE_PLANTYPE']) except: plantype = 1 # Default is a constrained plan try: constraint = int(os.environ['FREPPLE_CONSTRAINT']) except: constraint = 15 # Default is with all constraints enabled solver = frepple.solver_mrp( constraints=constraint, plantype=plantype, loglevel=int(Parameter.getValue('plan.loglevel', database, 0)), lazydelay=int(Parameter.getValue('lazydelay', database, '86400')), allowsplits=(Parameter.getValue('allowsplits', database, 'true').lower() == "true"), rotateresources=(Parameter.getValue('plan.rotateResources', database, 'true').lower() == "true"), plansafetystockfirst=(Parameter.getValue( 'plan.planSafetyStockFirst', database, 'false').lower() != "false"), iterationmax=int( Parameter.getValue('plan.iterationmax', database, '0')) #userexit_resource=debugResource, #userexit_demand=debugDemand ) print("Plan type: ", plantype) print("Constraints: ", constraint) solver.solve() frepple.printsize()
def run(cls, database=DEFAULT_DB_ALIAS, **kwargs): import frepple # Determine log level loglevel = int(Parameter.getValue('plan.loglevel', database, 0)) if cls.task and cls.task.user: maxloglevel = cls.task.user.getMaxLoglevel(database) if loglevel > maxloglevel: loglevel = maxloglevel # Create a solver where the plan type are defined by an environment variable try: plantype = int(os.environ['FREPPLE_PLANTYPE']) except: plantype = 1 # Default is a constrained plan try: constraint = int(os.environ['FREPPLE_CONSTRAINT']) except: constraint = 15 # Default is with all constraints enabled cls.solver = frepple.solver_mrp( constraints=constraint, plantype=plantype, loglevel=loglevel, lazydelay=int(Parameter.getValue('lazydelay', database, '86400')), allowsplits=(Parameter.getValue('allowsplits', database, 'true').lower() == "true"), minimumdelay=int(Parameter.getValue('plan.minimumdelay', database, '0')), rotateresources=(Parameter.getValue('plan.rotateResources', database, 'true').lower() == "true"), plansafetystockfirst=(Parameter.getValue('plan.planSafetyStockFirst', database, 'false').lower() != "false"), iterationmax=int(Parameter.getValue('plan.iterationmax', database, '0')), resourceiterationmax=int(Parameter.getValue('plan.resourceiterationmax', database, '500')), administrativeleadtime=86400 * float(Parameter.getValue('plan.administrativeLeadtime', database, '0')), autofence=86400 * float(Parameter.getValue("plan.autoFenceOperations", database, '0')) ) if hasattr(cls, 'debugResource'): cls.solver.userexit_resource = cls.debugResource if hasattr(cls, 'debugDemand'): cls.solver.userexit_demand = cls.debugDemand if hasattr(cls, 'debugOperation'): cls.solver.userexit_operation = cls.debugOperation logger.info("Plan type: %s" % plantype) logger.info("Constraints: %s" % constraint) cls.solver.solve() frepple.printsize()
def run(database=DEFAULT_DB_ALIAS, **kwargs): import frepple # Auxiliary functions for debugging def debugResource(res, mode): # if res.name != 'my favorite resource': return print("=> Situation on resource", res.name) for j in res.loadplans: print("=> ", j.quantity, j.onhand, j.startdate, j.enddate, j.operation.name, j.operationplan.quantity, j.setup) def debugDemand(dem, mode): if dem.name == 'my favorite demand': print("=> Starting to plan demand ", dem.name) solver.loglevel = 2 else: solver.loglevel = 0 # Create a solver where the plan type are defined by an environment variable try: plantype = int(os.environ['FREPPLE_PLANTYPE']) except: plantype = 1 # Default is a constrained plan try: constraint = int(os.environ['FREPPLE_CONSTRAINT']) except: constraint = 15 # Default is with all constraints enabled solver = frepple.solver_mrp( constraints=constraint, plantype=plantype, loglevel=int(Parameter.getValue('plan.loglevel', database, 0)), lazydelay=int(Parameter.getValue('lazydelay', database, '86400')), allowsplits=(Parameter.getValue('allowsplits', database, 'true').lower() == "true"), rotateresources=(Parameter.getValue('plan.rotateResources', database, 'true').lower() == "true"), plansafetystockfirst=(Parameter.getValue('plan.planSafetyStockFirst', database, 'false').lower() != "false"), iterationmax=int(Parameter.getValue('plan.iterationmax', database, '0')) #userexit_resource=debugResource, #userexit_demand=debugDemand ) print("Plan type: ", plantype) print("Constraints: ", constraint) solver.solve() frepple.printsize()
buf1.owner = buf2 except Exception as e: print("Catching exception %s: %s" % (e.__class__.__name__, e)) ### print("\nCreating demands") order1 = frepple.demand(name="order 1", item=item, quantity=10, priority=1, \ due=datetime.datetime(2009,3,2,9), customer=mycustomer, maxlateness=0) order2 = frepple.demand(name="order 2", item=item, quantity=10, priority=2, \ due=datetime.datetime(2009,3,2,8,30,0), customer=mycustomer, maxlateness=0) order3 = frepple.demand(name="order 3", item=item, quantity=10, priority=3, \ due=datetime.datetime(2009,3,2,20,0,0), customer=mycustomer, maxlateness=0) ### print("\nCreating a solver and running it") frepple.solver_mrp(name="MRP", constraints=7, loglevel=0).solve() ### print("\nEchoing the model to a file") printModel("output.1.xml") ### print("\nSaving the model to an XML-file") frepple.saveXMLfile("output.2.xml") ### print("\nPrinting some models in XML format") print(mycustomer.toXML()) print(locA.toXML()) print(opplan.toXML()) print(item.toXML())
buf1.owner = buf2 except Exception as e: print("Catching exception %s: %s" % (e.__class__.__name__, e)) ### print("\nCreating demands") order1 = frepple.demand(name="order 1", item=item, quantity=10, priority=1, \ due=datetime.datetime(2009,3,2,9), customer=mycustomer, maxlateness=0, operation=shipoper) order2 = frepple.demand(name="order 2", item=item, quantity=10, priority=2, \ due=datetime.datetime(2009,3,2,8,30,0), customer=mycustomer, maxlateness=0, operation=shipoper) order3 = frepple.demand(name="order 3", item=item, quantity=10, priority=3, \ due=datetime.datetime(2009,3,2,20,0,0), customer=mycustomer, maxlateness=0, operation=shipoper) ### print("\nCreating a solver and running it") frepple.solver_mrp(constraints=7, loglevel=0).solve() ### print("\nEchoing the model to a file") printModel("output.1.xml") ### print("\nSaving the model to an XML-file") frepple.saveXMLfile("output.2.xml") ### print("\nPrinting some models in XML format") print(mycustomer.toXML()) print(locA.toXML()) print(opplan.toXML()) print(item.toXML())
except Exception as e: print("Catching exception %s: %s" % (e.__class__.__name__, e)) ### print("\nCreating demands") order1 = frepple.demand(name="order 1", item=item, quantity=10, priority=1, \ due=datetime.datetime(2009,3,2,9), customer=mycustomer, maxlateness=0, operation=shipoper) order2 = frepple.demand(name="order 2", item=item, quantity=10, priority=2, \ due=datetime.datetime(2009,3,2,8,30,0), customer=mycustomer, maxlateness=0, operation=shipoper) order3 = frepple.demand(name="order 3", item=item, quantity=10, priority=3, \ due=datetime.datetime(2009,3,2,20,0,0), customer=mycustomer, maxlateness=0, operation=shipoper) ### print("\nCreating a solver and running it") printModel("output.10.xml") frepple.solver_mrp(constraints=7, loglevel=0).solve() ### print("\nEchoing the model to a file") printModel("output.1.xml") ### print("\nSaving the model to an XML-file") frepple.saveXMLfile("output.2.xml") ### print("\nPrinting some models in XML format") print(mycustomer.toXML()) print(locA.toXML()) print(opplan.toXML()) print(item.toXML())