著名IT公司ILog的APS高级排产优化引擎
源代码在线查看: productdemand.java
package com.power.pipeengine.Entity;
import java.util.ResourceBundle;
import java.util.*;
import com.power.pipeengine.Entity.*;
import com.power.pipeengine.InputData.*;
public class ProductDemand
{
private Product _product;
private int _bucket;
private int _priority;
private int _facilityID;
private double _dmdQty;
private double _asp;
public ProductDemand( Product prod,
int bucket,
int priority,
int facility,
double dmdQty,
double asp ) {
_product = prod;
_bucket = bucket;
_priority = priority;
_facilityID = facility;
_dmdQty = dmdQty;
_asp = asp;
}
public Product getProduct() {
return _product;
}
public int getBucketID() {
return _bucket;
}
public int getPriority() {
return _priority;
}
public int getFacilityID() {
return _facilityID;
}
public double getDmdQty() {
return _dmdQty;
}
public double getASP() {
return _asp;
}
private Vector routes = new Vector();
public void genProducingRoutes() {
findProducingRoutes( routes, _product, null );
/*System.out.println( "Product: " + _product.getProductID() );
for( int i=0; i Route rte = (Route) routes.elementAt( i );
System.out.print( ", " + rte.getRouteID() );
}
System.out.println( );*/
}
public Vector getProducingRoutes() {
return routes;
}
public void findProducingRoutes( Vector allRoutes, Product p, Route srcingRte ) {
Vector producingRoutes = p.getProducingRoutes();
if( producingRoutes.size() == 0 ) {
return;
}
//establish prev/next relationship
for( int i=0; i Route aRoute = (Route) producingRoutes.elementAt( i );
if( allRoutes.size() == 0 ) break;
//Route lastRoute = (Route) allRoutes.lastElement();
if( null == srcingRte ) break;
aRoute.setNextRoute( srcingRte );
srcingRte.addPrevRoute( aRoute );
}
//do recursion
for( int i=0; i Route aRoute = (Route) producingRoutes.elementAt( i );
allRoutes.add( aRoute );
Vector rteSrcs = DataModel.getInstance().getRouteSources().getRouteSources( aRoute );
for( int j = 0; j RouteSource rteSrc = (RouteSource) rteSrcs.elementAt( j );
Product srcProd = rteSrc.getSrcingProduct();
findProducingRoutes( allRoutes, srcProd, aRoute );
}
}
}
public void print() {
System.out.println( _product.getProductID() + "," +
_bucket + "," +
_priority + "," +
_dmdQty + "," +
_asp );
}
}