有没有优化算法可以解决这个问题?

时间:2019-07-15 06:06:02

标签: optimization

我正在尝试解决此问题:

关于优惠

- There are 3 offers with 3 costs. C = [10,20,30]

- And 3 quotas (availability of the offers). Q = [5,10,15]

关于人

- There is a matrix of 5 people with profits calculated for each offer.

  P = [[10,20,50],[20,60,10],[30,50,15],[60,40,50],[10,25,50]]

问题

我们最多可以分发5个价值10美元的报价,10个价值20美元的报价和15个价值30美元的报价。 我只需要为一个人分配一个要约。我的总预算为700美元。我需要以一种使人们获得最大利润的方式向人们分配要约。

**我可以使用任何优化算法来解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

是的,您可以使用整数编程解决此问题。

例如,使用CPLEX。有一个供学术使用的免费版本,请参见here。该文档可在线here获得。

使用OPL(CPLEX随附的建模语言)编写的优化问题可能是这样的:范围报价= 1..3;

range people = 1..5;
int C[offers] = [10,20,30];
int Q[offers] = [5,10,15];
int P[people][offers] = [[10,20,50],[20,60,10],[30,50,15],[60,40,50],[10,25,50]];

int budget = 700;

dvar boolean assign[p in people][o in offers];  // 1 if offer o is assigned to person p
dvar int+ quantity[p in people][o in offers];   // how much of offer o is shipped to person p
dexpr int profit = sum(p in people, o in offers) quantity[p][o] * P[p][o];

// Maximize the profit
maximize profit;

subject to {
  // Assign at most one offer to each person
  forall (p in people)
    sum(o in offers) assign[p][o] <= 1;
  // Respect the quota
  forall (o in offers)
    sum(p in people) quantity[p][o] <= Q[o];
  // Respect the budget limit
  sum(o in offers) C[o] * sum(p in people) quantity[p][o] <= budget;
  // The quantity can only be >0 if the "assign" variable is 1.
  forall(o in offers, p in people)
    quantity[p][o] <= C[o] * assign[p][o];
}

// Dump the results. This would not be necessary if you solved the problem
// in the IDE that ships with CPLEX.
execute {
  for (var p in people) {
    for (var o in offers) {
      if (quantity[p][o] > 0) {
        writeln("Ship " + quantity[p][o] + " of offer " + o + " to " + p);
      }
    }
  }
  writeln("Total profit: " + profit);
}