Chapter 1: LINGO Quick Start Case: Production Planning Problem

Chapter 1: LINGO Quick Start Case: Production Planning Problem

Problem Description

Suppose there is a manufacturing company that needs to decide the number of products to be produced each month in order to maximize the total profit. The business has two products (A and B) with the following constraints:

  1. Product A has a monthly demand of at least 1000 units.
  2. Product B has a monthly demand of at least 800 units.
  3. Due to limited material supply, the total production of Products A and B cannot exceed 2000 units.
  4. Product A costs $10 per unit to produce and Product B costs $15 per unit to produce.

Our goal is to determine the production quantity of each product so as to maximize the total profit.

LINGO Code Solutions

Here is the code to set up and solve the above production planning problem using LINGO:

SETS:
    PROD   / A, B /;  ! 声明一个集合 PROD,用于表示产品 A 和 B

DATA:
    PARAMS:
        Demand(PROD)  ProductionCost(PROD);  ! 声明参数 Demand 和 ProductionCost

    Demand(A)   1000  ! 产品 A 的需求量为 1000
    Demand(B)   800   ! 产品 B 的需求量为 800

    ProductionCost(A)   10   ! 产品 A 的生产成本为 10
    ProductionCost(B)   15;  ! 产品 B 的生产成本为 15

VARIABLES:
    Production(PROD)  integer;  ! 定义变量 Production,表示每个产品的生产数量 

OBJECTIVE:
    MAX = SUM(PROD, (Production(PROD) * (Demand(PROD) * ProductionCost(PROD))));  ! 最大化目标函数 MAX

CONSTRAINTS:
    TotalDemand(PROD)  <= Demand(PROD)  ! 约束条件:每个产品的总产量不超过其需求量
    TotalProduction   <= 2000;  ! 约束条件:总产量不超过 2000

END.  ! 代码结束标识

code explanation

SETS statement:

The first section (SETS) is where the sets are declared. In this case, we define a PROD collection to represent products A and B.

DATA statement:

The next section (DATA) is where the parameters are declared. We define two parameters Demand and ProductionCost to represent demand and production cost.

VARIABLES statement:

Then, we define a variable Production, which is used to represent the production quantity of each product, and set its integer property.

OBJECTIVE statement:

In the OBJECTIVE section, we set the total profit MAX as the objective function. The SUM function is used here to multiply the demand and production cost of each product to obtain the total profit.

The CONSTRAINTS statement:

Finally, in the CONSTRAINTS section, we define two constraints. The TotalDemand constraint ensures that the total production of each product does not exceed the demand, and the TotalProduction constraint limits the total production to no more than 2000.

results and analysis

After running the above LINGO code, LINGO will output the optimal solution and the corresponding objective function value.

Based on the above questions, LINGO may produce the following results:

---- EQU Profit                          =        18000.000  total overall profit
---- VAR Production.L1                    =         1000.000  quantity of product A produced
---- VAR Production.L2                    =          800.000  quantity of product B produced
---- CONSTR TotalDemand.L1                =         1000.000  total demand for product A
---- CONSTR TotalDemand.L2                =          800.000  total demand for product B
---- CONSTR TotalProduction               =         2000.000  total production limit

According to the above results, the optimal solution is to set the production quantity of product A to 1000 and the production quantity of product B to 800. The total profit is $18,000.

This example shows how to use LINGO to solve a simple production planning problem. You can modify the code to suit your own needs and constraints, and use LINGO to solve it.

Guess you like

Origin blog.csdn.net/qq_51447496/article/details/132222721
Recommended