补充10 供应链中定价和收入的的算法——基于java的实现

第六部分 供应链跨职能驱动因素地管理(二)供应链的定价和收入管理icon-default.png?t=N7T8https://blog.csdn.net/weixin_56917624/article/details/132939199


目录

1.多个细分市场的定价

(1)没有产能约束

(2)有产能约束

2.动态定价

3.估计动态定价下得产品初始量


1.多个细分市场的定价

         某合同制造商为其产能确定了两个细分市场:一个市场愿意提前至少一周下订单;另一个市场原以为在一周内下订单而支付更高的价格。那些不愿意提前下订单的顾客对价格不敏感,其需求曲线为d_{1}=500-20p_{1}。那些愿意提前下订单的顾客对价格更敏感,其需求曲线为d_{2}=5000-40p_{2}。单位生产成本为c=10美元。如果制造商的目标是使利润最大化,他应如何指定每个细分市场的价格?如果该制造商对两个细分市场指定相同的价格,该价格为多少?差异定价带来了多少利润增长?如果总产能最高只有4000单位,该合同制造商应如何指定每个细分市场的价格?

(1)没有产能约束

public class SegmentedMarketsPriceData {
    //多个市场的截距
    double[] intercept = {5000,5000};
    //多个市场的斜率
    double[] slope = {20,40};
    //单位生产成本
    double unitProductionCost = 10;
    //最高产能约束
    double maxProductionCapacity = 4000;
    //市场数量
    int markets = 2;
}
import java.util.Arrays;
import java.util.LinkedList;

public class SegmentedMarketsPriceModel {
    private SegmentedMarketsPriceData data;

    public SegmentedMarketsPriceModel(SegmentedMarketsPriceData data) {
        this.data = data;
    }
    //1.没有产能约束
    public void calculate(){
        //(1)细分市场不同价格
        LinkedList<Double> prices = new LinkedList<>();
        LinkedList<Double> demands = new LinkedList<>();
        double totalProfit = 0;
        for (int i = 0; i < data.markets; i++) {
            double price = data.intercept[i]/(2*data.slope[i]) + data.unitProductionCost/2;
            double demand = data.intercept[i] - data.slope[i]*price;
            prices.add(price);
            demands.add(demand);
            totalProfit += price * demand;
        }
        double totalDemands = demands.stream().reduce(Double::sum).orElse(0.0);
        totalProfit -= totalDemands*data.unitProductionCost;
        System.out.println("细分市场的定价(不同):" + prices.toString());
        System.out.println("细分市场的需求(不同):" + demands.toString());
        System.out.println("总利润(不同):" + totalProfit);
        //(2)细分市场相同价格
        double totalIntercept = Arrays.stream(data.intercept).reduce(Double::sum).orElse(0.0);
        double totalSlope = Arrays.stream(data.slope).reduce(Double::sum).orElse(0.0);
        double priceSame = totalIntercept / (2*totalSlope) + data.unitProductionCost/2;
        System.out.println("细分市场的价格(相同):" + priceSame);
        LinkedList<Double> demandsInSame = new LinkedList<>();
        for (int i = 0; i < data.markets; i++) {
            double demand = data.intercept[i] - data.slope[i] * priceSame;
            demandsInSame.add(demand);
        }
        System.out.println("细分市场的需求(相同):" + demands.toString());
        double totalDemandsInSame = demandsInSame.stream().reduce(Double::sum).orElse(0.0);
        double totalProfitSame = (priceSame - data.unitProductionCost) * totalDemandsInSame;
        System.out.println("总利润(相同):" + totalProfitSame);
    }
}
public class Test {
    public static void main(String[] args) {
        SegmentedMarketsPriceData segmentedMarketsPriceData = new SegmentedMarketsPriceData();
        SegmentedMarketsPriceModel segmentedMarketsPriceModel = new SegmentedMarketsPriceModel(segmentedMarketsPriceData);
        segmentedMarketsPriceModel.calculate();
    }
}

结果如下:

(2)有产能约束

import ilog.concert.IloException;
import ilog.concert.IloNumExpr;
import ilog.concert.IloNumVar;
import ilog.concert.IloNumVarType;
import ilog.cplex.IloCplex;

public class SegmentedMarketsPriceInCapacityModel {
    private SegmentedMarketsPriceData data;

    public SegmentedMarketsPriceInCapacityModel(SegmentedMarketsPriceData data) {
        this.data = data;
    }
    //定义cplex内部对象
    IloCplex model;
    //定义变量
    public IloNumVar[] prices;

    //求解函数
    public void solve() throws IloException {
        if(model.solve()==false){
            System.out.println("模型不可解");
        } else {
            //System.out.println(model);
            for(int i=0;i<data.markets;i++){
                if(model.getValue(prices[i])!=0){
                    System.out.println("市场"+(i+1)+"定价price:"+model.getValue(prices[i]));
                    System.out.println("市场"+(i+1)+"需求demand:"+ (data.intercept[i] - data.slope[i]*model.getValue(prices[i])));
                }
            }
            System.out.println("总利润:"+model.getObjValue());
        }
    }

    //根据数学模型建立求解模型
    public void BuildModel() throws IloException{
        //初始化model
        model = new IloCplex();
        model.setOut(null);
        //定义决策变量prices及取值范围
        prices = new IloNumVar[data.markets];
        for (int i = 0; i < data.markets; i++) {
            prices[i] = model.numVar(0,Double.MAX_VALUE, IloNumVarType.Int, "prices[" + i + "]");
        }
        //设置目标函数
        IloNumExpr obj = model.numExpr();
        for (int i = 0; i < data.markets; i++) {
            IloNumExpr expr1 = model.diff(prices[i],data.unitProductionCost);
            IloNumExpr expr2 = model.diff(data.intercept[i],model.prod(data.slope[i],prices[i]));
            obj = model.sum(obj,model.prod(expr1,expr2));
        }
        model.addMaximize(obj);
        //约束条件
        IloNumExpr constraints = model.numExpr();
        for (int i = 0; i < data.markets; i++) {
            IloNumExpr constraint = model.diff(data.intercept[i],model.prod(data.slope[i],prices[i]));
            constraints = model.sum(constraints,constraint);
            model.addGe(constraint,0);
        }
        model.addLe(constraints,data.maxProductionCapacity);
    }
}
import ilog.concert.IloException;

public class Test {
    public static void main(String[] args) throws IloException {
        SegmentedMarketsPriceData segmentedMarketsPriceData = new SegmentedMarketsPriceData();
        SegmentedMarketsPriceInCapacityModel segmentedMarketsPriceInCapacityModel = new SegmentedMarketsPriceInCapacityModel(segmentedMarketsPriceData);
        segmentedMarketsPriceInCapacityModel.BuildModel();
        segmentedMarketsPriceInCapacityModel.solve();
    }
}

结果如下:

2.动态定价

        MoonLight在冬季来临之前以100美元购买了400个收集(总成本为40000美元)。销售季持续三个月,预计这三个月得需求分别使d_{1}=300-p_{1}d_{2}=300-1.3p_{2}d_{3}=300-1.8p_{3}。公司应该在这三个月如何进行价格调整使收入最大化?

public class DynamicPriceData {
    //多个月份的截距
    double[] intercept = {300,300,300};
    //多个月份的斜率
    double[] slope = {1,1.3,1.8};
    //月份数量
    int months = 3;
    //最高产能约束
    double maxProductionCapacity = 400;
}
import ilog.concert.IloException;
import ilog.concert.IloNumExpr;
import ilog.concert.IloNumVar;
import ilog.concert.IloNumVarType;
import ilog.cplex.IloCplex;

public class DynamicPriceModel {
    private DynamicPriceData data;

    public DynamicPriceModel(DynamicPriceData data) {
        this.data = data;
    }
    //定义cplex内部对象
    IloCplex model;
    //定义变量
    public IloNumVar[] prices;

    //求解函数
    public void solve() throws IloException {
        if(model.solve()==false){
            System.out.println("模型不可解");
        } else {
            System.out.println(model);
            for(int i=0;i<data.months;i++){
                if(model.getValue(prices[i])!=0){
                    System.out.println("市场"+(i+1)+"定价price:"+model.getValue(prices[i]));
                    System.out.println("市场"+(i+1)+"需求demand:"+ (data.intercept[i] - data.slope[i]*model.getValue(prices[i])));
                }
            }
            System.out.println("总利润:"+model.getObjValue());
        }
    }

    //根据数学模型建立求解模型
    public void BuildModel() throws IloException {
        //初始化model
        model = new IloCplex();
        model.setOut(null);
        //定义决策变量prices及取值范围
        prices = new IloNumVar[data.months];
        for (int i = 0; i < data.months; i++) {
            prices[i] = model.numVar(0,Double.MAX_VALUE, IloNumVarType.Int, "prices[" + i + "]");
        }
        //设置目标函数
        IloNumExpr obj = model.numExpr();
        for (int i = 0; i < data.months; i++) {
            IloNumExpr expr = model.diff(data.intercept[i],model.prod(data.slope[i],prices[i]));
            obj = model.sum(obj,model.prod(prices[i],expr));
        }
        model.addMaximize(obj);
        //约束条件
        IloNumExpr constraints = model.numExpr();
        for (int i = 0; i < data.months; i++) {
            IloNumExpr constraint = model.diff(data.intercept[i],model.prod(data.slope[i],prices[i]));
            constraints = model.sum(constraints,constraint);
            model.addGe(constraint,0);
        }
        model.addLe(constraints,data.maxProductionCapacity);
    }
}
import ilog.concert.IloException;

public class Test {
    public static void main(String[] args) throws IloException {
        DynamicPriceData dynamicPriceData = new DynamicPriceData();
        DynamicPriceModel dynamicPriceModel = new DynamicPriceModel(dynamicPriceData);
        dynamicPriceModel.BuildModel();
        dynamicPriceModel.solve();
    }
}

结果如下:

3.估计动态定价下得产品初始量

       假设需求曲线如例2所示,MoonLight在季初应购买多少收集,使这三个月定价从而使利润最大化?

import ilog.concert.IloException;
import ilog.concert.IloNumExpr;
import ilog.concert.IloNumVar;
import ilog.concert.IloNumVarType;
import ilog.cplex.IloCplex;

public class InitialQuantityModel {
    private DynamicPriceData data;

    public InitialQuantityModel(DynamicPriceData data) {
        this.data = data;
    }
    //定义cplex内部对象
    IloCplex model;
    //定义变量
    public IloNumVar[] prices;
    public IloNumVar initCount;

    //求解函数
    public void solve() throws IloException {
        if(model.solve()==false){
            System.out.println("模型不可解");
        } else {
            System.out.println(model);
            for(int i=0;i<data.months;i++){
                if(model.getValue(prices[i])!=0){
                    System.out.println("时期"+(i+1)+"定价price:"+model.getValue(prices[i]));
                    System.out.println("时期"+(i+1)+"需求demand:"+ (data.intercept[i] - data.slope[i]*model.getValue(prices[i])));
                }
            }
            System.out.println("季初数量:"+model.getValue(initCount));
            System.out.println("总利润:"+model.getObjValue());
        }
    }

    //根据数学模型建立求解模型
    public void BuildModel() throws IloException {
        //初始化model
        model = new IloCplex();
        model.setOut(null);
        //定义决策变量prices及取值范围
        prices = new IloNumVar[data.months];
        for (int i = 0; i < data.months; i++) {
            prices[i] = model.numVar(0,Double.MAX_VALUE, IloNumVarType.Int, "prices[" + i + "]");
        }
        initCount  = model.numVar(0,Double.MAX_VALUE, IloNumVarType.Int, "initCount");
        //设置目标函数
        IloNumExpr obj = model.numExpr();
        for (int i = 0; i < data.months; i++) {
            IloNumExpr expr = model.diff(data.intercept[i],model.prod(data.slope[i],prices[i]));
            obj = model.sum(obj,model.prod(prices[i],expr));
        }
        obj = model.diff(obj,model.prod(initCount,data.unitProductionCost));
        model.addMaximize(obj);
        //约束条件
        IloNumExpr constraints = model.numExpr();
        for (int i = 0; i < data.months; i++) {
            IloNumExpr constraint = model.diff(data.intercept[i],model.prod(data.slope[i],prices[i]));
            constraints = model.sum(constraints,constraint);
            model.addGe(constraint,0);
        }
        model.addLe(constraints,initCount);
    }
}
import ilog.concert.IloException;

public class Test {
    public static void main(String[] args) throws IloException {
        DynamicPriceData dynamicPriceData = new DynamicPriceData();
        InitialQuantityModel initialQuantityModel = new InitialQuantityModel(dynamicPriceData);
        initialQuantityModel.BuildModel();
        initialQuantityModel.solve();
    }
}

结果如下:

        这比例2中的400件利润要高。

  • 24
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值