Solving Integer programming example with LPSOLVE: How to add restritions?

coder

New member
Joined
Jan 20, 2022
Messages
1
Problem:

A company is attempting to decide the mix of products which it should produce
next week. It has seven products, each with a profit (£) per unit and a production
time (man-hours) per unit as shown below:

ProductProfit (£ per unit)Production time (man-hours per unit)
1
10
1.0
222
2.0
335
3.7
4192.4
5554.5
610
0.7
7115 9.5


The company has 720 man-hours available next week.
Incorporate the following additional restrictions into your integer program
(retaining linear constraints and a linear objective):

  • If any of product 7 are produced an additional fixed cost of £2000 is incurred.
  • Each unit of product 2 that is produced over 100 units requires a production time of 3.0 man-hours instead of 2.0 man-hours (e.g. producing 101 units of product 2 requires 100(2.0) + 1(3.0) man-hours).
  • If both product 3 and product 4 are produced 75 man-hours are needed for production line setup and hence the (effective) number of man-hours available falls to 720 - 75 = 645.

Formulate the problem of how many units (if any) of each product to produce next
week as an integer program in which all the constraints are linear

Variables

  • - xi (integer >=0) be the number of units of product i produced then the integer program is
  • - z7 = 1 if produce product 7 (x7 >= 1), 0 otherwise
  • - y2 = number of units of product 2 produced in excess of 100 units, y2 >= 0
  • - z3 = 1 if produce product 3, 0 otherwise
  • - z4 = 1 if produce product 4, 0 otherwise
  • - Z = 1 if produce both product 3 and product 4, otherwise

Restrictions

  • 1.0x1 + 2.0x2 + 3.7x3 + 2.4x4 + 4.5x5 + 0.7x6 + 9.5x7 <= 720
  • x7 <= Mz7
  • x2 <= 100 (This will work because x2 and y2 have the same objective function coefficient but y2 requires longer to produce so will always get more flexibility by producing x2 first (up to the 100 limit) before producing y2.)
  • 1.0x1 + (2.0x2 + 3.0y2) + 3.7x3 + 2.4x4 + 4.5x5 + 0.7x6 + 9.5x7 <= 720 - 75Z
  • x3 <= Mz3 and x4 <= Mz4
  • Z = z3z4

which we linearise by replacing the non-linear constraint by the two linear
constraints
  • Z >= z3 + z4 - 1
  • Z <= (z3 + z4)/2

Objective
maximise W = 10x1 + 22(x2 + y2) + 35x3 + 19x4 + 55x5 + 10x6 + 115x7

Question : How to add the restrictions to lpsolve to solve the problem?
I'm using lpsolve LpSolve software to help me solve the problem, but i'm having some difficulties writing the restrictions.

Code:
* Objective function */
max:10x1+22x2+35x3+19x5+10x6+115x7 ;

/* Variable bounds */
x1 >=0;
x2 >=0;
x3 >=0;
x4 >=0;
x5 >=0;
x6 >=0;
x7 >=0;

1.0x1 + 2.0x2 + 3.7x3 + 2.4x4 + 4.5x5 + 0.7x6 + 9.5x7 <= 720;
 
Top