Skip to content
Snippets Groups Projects
Commit e7968267 authored by ThibautDemare's avatar ThibautDemare
Browse files

add transportation costs to measure of efficiency + improve stuff relatives to this

parent 8140f34a
Branches
Tags
No related merge requests found
......@@ -18,9 +18,11 @@ species Building {
float handling_time_to_road <- 1;
float handling_time_from_road <- 1;
float colorValue <- -1;
float cost;
reflex manageRoadComingCommodities {
int i <- 0;
loop while:i<length(comingCommodities) {
......@@ -35,7 +37,7 @@ species Building {
}
}
}
action receiveCommodity(Commodity c){
if(c.finalDestination = self){
create AwaitingStock number: 1 returns: ast {
......@@ -45,6 +47,9 @@ species Building {
self.building <- myself;
}
entering_stocks <- entering_stocks + ast[0];
ask c {
do die;
}
}
else {
comingCommodities <+ c;
......@@ -97,7 +102,6 @@ species RestockingBuilding parent: Building {
list<Order> currentOrders <- [];
list<Vehicle> leavingVehicles <- [];
int maxProcessOrdersCapacity;
float cost;
action addOrder(Order order){
currentOrders <- currentOrders + order;
......@@ -188,6 +192,7 @@ species RestockingBuilding parent: Building {
ask forwardingAgent {
commodity.paths <- compute_shortest_path(myself, order.building, order.strategy, commodity);//'financial_costs'//travel_time
}
order.fdm.localTransportationCosts <- order.fdm.localTransportationCosts + commodity.costs;
leavingCommodities <- leavingCommodities + commodity;
}
}
\ No newline at end of file
......@@ -10,4 +10,5 @@ species Commodity {
string currentNetwork;
Stock stock;
int stepOrderMade;
float costs;
}
\ No newline at end of file
......@@ -194,6 +194,12 @@ experiment 'Every output' type: gui {
}
}/**/
display 'Average transportation and warehousing costs' refresh:every(1) {
chart "Average transportation and warehousing costs" type: series {
data "Average transportation and warehousing costs" value: averageCosts color: rgb('green') ;
}
}/**/
display 'Share of the different strategies adopted' refresh:every(1) {
chart "Share of the different strategies adopted" type: series {
data "Strategy 1 (closest/largest warehouse according to a probability)" value: nbLPStrat1 color: rgb('green') ;
......
......@@ -24,7 +24,9 @@ species FinalDestinationManager {
list<int> localTimeToBeDeliveredLastDeliveries <- []; // This variable is used to have an idea of the efficicency of the LP to deliver quickly the goods
float localTimeToBeDelivered <- 0.0;
// based on costs of deliveries and warehousing
float localCosts <- 0.0;
list<float> localTransportationCosts <- [];
float localWarehousingCosts <- 0.0;
float localAverageCosts <- 0.0;
init {
......@@ -110,7 +112,7 @@ species FinalDestinationManager {
reflex manageContractWithLP when: allowLSPSwitch {
numberOfHoursOfContract <- numberOfHoursOfContract + 1;
if(numberOfHoursOfContract > minimalNumberOfHoursOfContract){
if(shouldISwitchMyLSP){
if(shouldISwitchMyLSP()){
// the logsitic provider is not efficient enough. He must be replaced by another one.
// Inform the current logistic provider that he losts a customer
TransferredStocks stocksRemoved;
......@@ -143,7 +145,9 @@ species FinalDestinationManager {
localAverageNbStockShortagesLastSteps <- 0.0;
localTimeToBeDeliveredLastDeliveries <- [];
localTimeToBeDelivered <- 0.0;
localCosts <- 0.0;
localTransportationCosts <- [];
localWarehousingCosts <- 0.0;
localAverageCosts <- 0.0;
}
}
}
......@@ -160,7 +164,7 @@ species FinalDestinationManager {
}
}
else if(stratMeasureLSPEfficiency = 3){
if(logisticsServiceProvider.averageCosts < averageCosts){
if(localAverageCosts > averageCosts){
return true;
}
}
......
......@@ -18,10 +18,23 @@ species LogisticsServiceProvider {
float averageCosts <- 0;
float threshold;
float probaAnt <- 0.5;
string costsPathStrategy <- one_of(['financial_costs']);//'financial_costs';//'travel_time'//'financial_costs','travel_time'
string costsPathStrategy;
init {
adoptedSelectingWarehouseStrategy <- one_of(possibleSelectingWarehouseStrategies);
if(isLocalSelectingWarehouseStrategies){
adoptedSelectingWarehouseStrategy <- one_of(possibleSelectingWarehouseStrategies);
}
else {
adoptedSelectingWarehouseStrategy <- globalSelectingWarehouseStrategies;
}
if(isLocalCostPathStrategy){
costsPathStrategy <- one_of(possibleCostPathStrategies);
}
else {
costsPathStrategy <- globalCostPathStrategy;
}
provider <- one_of(Provider);
ask provider {
do addCustomer(myself);
......@@ -489,6 +502,8 @@ species LogisticsServiceProvider {
gs_add_edge_attribute gs_sender_id:"supply_chain" gs_edge_id:(sceCloseWarehouse.building.name + sceLarge.building.name) gs_attribute_name:"length" gs_attribute_value:p;
}
}
return sceLarge;
}
/**
......@@ -512,11 +527,12 @@ species LogisticsServiceProvider {
* connect this leaf to a close warehouse
*/
SupplyChainElement sceCloseWarehouse <- connectLvl1Warehouse(fdm, fdmLeaf, stocksLvl1);
fdm.localWarehousingCosts <- fdm.localWarehousingCosts + sceCloseWarehouse.building.cost;
/*
* Connect the close warehouse to the large warehouse
*/
do connectLvl2Warehouse(fdm, sceCloseWarehouse, stocksLvl2);
SupplyChainElement sceLarge <- connectLvl2Warehouse(fdm, sceCloseWarehouse, stocksLvl2);
fdm.localWarehousingCosts <- fdm.localWarehousingCosts + sceLarge.building.cost;
customers <- customers + fdm;
}
......
......@@ -274,6 +274,33 @@ global {
}
}
reflex update_average_costs {
// Update the average costs
int i <- 0;
float sum <- 0;
ask FinalDestinationManager {
if(length(localTransportationCosts) > 0){
int j <- 0;
float localSum <- 0;
loop while: 50 < length(localTransportationCosts) {
remove index: 0 from: localTransportationCosts;
}
loop while: j<length(localTransportationCosts) {
localSum <- localSum + localTransportationCosts[j];
j <- j + 1;
}
localAverageCosts <- localWarehousingCosts + localSum / length(localTransportationCosts);
sum <- sum + localAverageCosts;
i <- i + 1;
}
}
if(i > 0){
averageCosts <- (sum/i);
}
}
// Average number of LSP for each strategy
list<int> listNbLPStrat1 <- [];
list<int> listNbLPStrat2 <- [];
......@@ -427,33 +454,6 @@ global {
averageStrat4 <- averageStrat4/length(listNbLPStrat4);
}
reflex computeLPCost{
averageCosts <- 0;
int nbLP <- 0;
ask LogisticsServiceProvider {
if(length(customers) > 0){
nbLP <- nbLP + 1;
cumulateCosts <- 0;
int i <- 0;
loop while: i<length(lvl1Warehouses) {
cumulateCosts <- cumulateCosts + lvl1Warehouses[i].cost;
i <- i + 1;
}
i <- 0;
loop while: i<length(lvl2Warehouses) {
cumulateCosts <- cumulateCosts + lvl2Warehouses[i].cost;
i <- i + 1;
}
cumulateCosts <- cumulateCosts + provider.cost;
self.averageCosts <- cumulateCosts/length(customers);
myself.averageCosts <- myself.averageCosts + self.averageCosts;
}
}
if(nbLP > 0){
averageCosts <- averageCosts / nbLP;
}
}
reflex portsShare {
nbAntwerp <- 0;
nbHavre <- 0;
......
......@@ -8,9 +8,17 @@ global {
float step <- 60 #mn;//60 minutes per step
date starting_date <- date([2018,6,5,11,0,0]);// 5 Juin 2018 11h00
// Selecting Warehouse Strategies
bool isLocalSelectingWarehouseStrategies <- true;
int globalSelectingWarehouseStrategies <- 1;
list<int> possibleSelectingWarehouseStrategies <- [1, 2, 3, 4]; //[1];//[1, 4];// [1, 2, 3, 4] // 1 : biased random selection - 2 : accessibility - 3 : closest/largest - 4 : pure random selection
int numberWarehouseSelected <- 50;
// Cost path strategies
bool isLocalCostPathStrategy <- true;
list<string> possibleCostPathStrategies <- ['financial_costs','travel_time'];
string globalCostPathStrategy <- 'financial_costs';
// Parameters relative to the threshold used by LSPs to decide when to restock
bool localThreshold <- true;
float minlocalThreshold <- 0.05;
......@@ -20,7 +28,7 @@ global {
// Parameters relative to the ability of the final consignee to switch of LSP
bool isLocalLSPSwitcStrat <- false;
list<int> possibleLSPSwitcStrats <- [1, 2, 3]; // 1 : NbStockShortages - 2 : TimeToBeDelivered - 3 : Costs
int globalLSPSwitchStrat <- 1;
int globalLSPSwitchStrat <- 3;
bool allowLSPSwitch <- true;
// Attractiveness parameters
......@@ -32,7 +40,7 @@ global {
*/
bool allowScenarioAttractiveness <- false;
bool allowScenarioBlockRoads <- false;
bool allowScenarionCanalSeineNord <- true;
bool allowScenarionCanalSeineNord <- false;
/*
* Some variables and functions to call some reflex
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment