Display Optimization Problem
Create an optimization problem, including an objective function and constraints, and display the problem.
Create the problem in docid:optim_ug#mw_31626a35-4add-49be-b3d8-f0bf8037caf2.
steelprob = optimproblem; ingots = optimvar('ingots',4,1,'Type','integer','LowerBound',0,'UpperBound',1); alloys = optimvar('alloys',4,1,'LowerBound',0); weightIngots = [5,3,4,6]; costIngots = weightIngots.*[350,330,310,280]; costAlloys = [500,450,400,100]; cost = costIngots*ingots + costAlloys*alloys; steelprob.Objective = cost; totalweight = weightIngots*ingots + sum(alloys); carbonIngots = [5,4,5,3]/100; carbonAlloys = [8,7,6,3]/100; totalCarbon = (weightIngots.*carbonIngots)*ingots + carbonAlloys*alloys; molybIngots = [3,3,4,4,]/100; molybAlloys = [6,7,8,9]/100; totalMolyb = (weightIngots.*molybIngots)*ingots + molybAlloys*alloys; steelprob.Constraints.conswt = totalweight == 25; steelprob.Constraints.conscarb = totalCarbon == 1.25; steelprob.Constraints.consmolyb = totalMolyb == 1.25;
Display the problem.
showproblem(steelprob)
OptimizationProblem : minimize : 1750*ingots(1, 1) + 990*ingots(2, 1) + 1240*ingots(3, 1) + 1680*ingots(4, 1) + 500*alloys(1, 1) + 450*alloys(2, 1) + 400*alloys(3, 1) + 100*alloys(4, 1) subject to conswt: 5*ingots(1, 1) + 3*ingots(2, 1) + 4*ingots(3, 1) + 6*ingots(4, 1) + alloys(1, 1) + alloys(2, 1) + alloys(3, 1) + alloys(4, 1) == 25 subject to conscarb: 0.25*ingots(1, 1) + 0.12*ingots(2, 1) + 0.2*ingots(3, 1) + 0.18*ingots(4, 1) + 0.08*alloys(1, 1) + 0.07*alloys(2, 1) + 0.06*alloys(3, 1) + 0.03*alloys(4, 1) == 1.25 subject to consmolyb: 0.15*ingots(1, 1) + 0.09*ingots(2, 1) + 0.16*ingots(3, 1) + 0.24*ingots(4, 1) + 0.06*alloys(1, 1) + 0.07*alloys(2, 1) + 0.08*alloys(3, 1) + 0.09*alloys(4, 1) == 1.25 variable bounds: 0 <= alloys(1, 1) 0 <= alloys(2, 1) 0 <= alloys(3, 1) 0 <= alloys(4, 1) 0 <= ingots(1, 1) <= 1 0 <= ingots(2, 1) <= 1 0 <= ingots(3, 1) <= 1 0 <= ingots(4, 1) <= 1