--------------------------------------------------------------------------------
Alloy mixture optimization (Minimize Expenses)
There are four metals A, B, C and D that have the following properties:

Metal Density (den) Carbon (crb), % Phosphor (psh), % Price, $ / kg
A 6500 0.2 0.05 2.0
B 5800 0.35 0.015 2.5
C 6200 0.15 0.065 1.5
D 5900 0.11 0.1 2.0
--------------------------------------------------------------------------------

The problem has the following solution
A -
B 0.285
C 0.595
D 0.12

The Total cost of the alloy is $1.84
--------------------------------------------------------------------------------

Solve in R with:
Alloy.lim <- Setup("alloymixture.input")
Linp(Alloy.lim)
--------------------------------------------------------------------------------


## PARAMETERS
A_dens =6500
A_carb=0.2
A_phos=0.05
A_Price=2.0

B_dens =5800
B_carb=0.35
B_phos=0.015
B_Price=2.5

C_dens =6200
C_carb=0.15
C_phos=0.065
C_Price=1.5

D_dens =5900
D_carb=0.11
D_phos=0.1
D_Price=2.0
## END PARAMETERS

The decision variables are the part of each metals in the alloy: X_A, X_B, X_C and X_D.
### DECISION
X_A
X_B
X_C
X_D
### END DECISION

The objective function that to be minimized is the price:

## COST
cost: X_A * A_Price + X_B * B_Price + X_C * C_Price + X_D * D_Price
## END COST

There is a requirement to produce an alloy at minimal cost that has the following property ranges:
Range Density (dens) Carbon (carb), % Phosphor (phos), %
Min   5950           0.1            0.045
Max   6050           0.3            0.055
These constraints are written as:

## CONSTRAINTS
dens:   X_A * A_dens + X_B * B_dens + X_C * C_dens + X_D * D_dens = [5950,6050]
carbon: X_A * A_carb + X_B * B_carb + X_C * C_carb + X_D * D_carb = [0.1,0.3]
phosph: X_A * A_phos + X_B * B_phos + X_C * C_phos + X_D * D_phos = [0.045,0.055]
## END CONSTRAINTS


The part of each metal in the alloy has to sum to 1:

## EQUALITY
X_A + X_B + X_C + X_D = 1
## END EQUALITY

