Problem-Based - MATLAB & Simulink - MathWorks Deutschland (2024)

Open Live Script

This example shows how to solve a mixed-integer linear problem. Although not complex, the example shows the typical steps in formulating a problem using the problem-based approach. For a video showing this example, see Solve a Mixed-Integer Linear Programming Problem using Optimization Modeling.

For the solver-based approach to this problem, see Mixed-Integer Linear Programming Basics: Solver-Based.

Problem Description

You want to blend steels with various chemical compositions to obtain 25 tons of steel with a specific chemical composition. The result should have 5% carbon and 5% molybdenum by weight, meaning 25 tons*5% = 1.25 tons of carbon and 1.25 tons of molybdenum. The objective is to minimize the cost for blending the steel.

This problem is taken from Carl-Henrik Westerberg, Bengt Bjorklund, and Eskil Hultman, “An Application of Mixed Integer Programming in a Swedish Steel Mill.” Interfaces February 1977 Vol. 7, No. 2 pp. 39–43, whose abstract is at https://doi.org/10.1287/inte.7.2.39.

Four ingots of steel are available for purchase. Only one of each ingot is available.

IngotWeightinTons%Carbon%MolybdenumCostTon1553$3502343$3303454$3104634$280

Three grades of alloy steel and one grade of scrap steel are available for purchase. Alloy and scrap steels can be purchased in fractional amounts.

Alloy%Carbon%MolybdenumCostTon186$500277$450368$400Scrap39$100

Formulate Problem

To formulate the problem, first decide on the control variables. Take variable ingots(1)=1 to mean that you purchase ingot 1, and ingots(1)=0 to mean that you do not purchase the ingot. Similarly, variables ingots(2) through ingots(4) are binary variables indicating whether you purchase ingots 2 through 4.

Variables alloys(1) through alloys(3) are the quantities in tons of alloys 1, 2, and 3 that you purchase. scrap is the quantity of scrap steel that you purchase.

steelprob = optimproblem;ingots = optimvar('ingots',4,'Type','integer','LowerBound',0,'UpperBound',1);alloys = optimvar('alloys',3,'LowerBound',0);scrap = optimvar('scrap','LowerBound',0);

Create expressions for the costs associated with the variables.

weightIngots = [5,3,4,6];costIngots = weightIngots.*[350,330,310,280];costAlloys = [500,450,400];costScrap = 100;cost = costIngots*ingots + costAlloys*alloys + costScrap*scrap;

Include the cost as the objective function in the problem.

The problem has three equality constraints. The first constraint is that the total weight is 25 tons. Calculate the weight of the steel.

totalWeight = weightIngots*ingots + sum(alloys) + scrap;

The second constraint is that the weight of carbon is 5% of 25 tons, or 1.25 tons. Calculate the weight of the carbon in the steel.

carbonIngots = [5,4,5,3]/100;carbonAlloys = [8,7,6]/100;carbonScrap = 3/100;totalCarbon = (weightIngots.*carbonIngots)*ingots + carbonAlloys*alloys + carbonScrap*scrap;

The third constraint is that the weight of molybdenum is 1.25 tons. Calculate the weight of the molybdenum in the steel.

molybIngots = [3,3,4,4]/100;molybAlloys = [6,7,8]/100;molybScrap = 9/100;totalMolyb = (weightIngots.*molybIngots)*ingots + molybAlloys*alloys + molybScrap*scrap;

Include the constraints in the problem.

steelprob.Constraints.conswt = totalWeight == 25;steelprob.Constraints.conscarb = totalCarbon == 1.25;steelprob.Constraints.consmolyb = totalMolyb == 1.25;

Solve Problem

Now that you have all the inputs, call the solver.

[sol,fval] = solve(steelprob);
Solving problem using intlinprog.Running HiGHS 1.6.0: Copyright (c) 2023 HiGHS under MIT licence termsPresolving model3 rows, 8 cols, 24 nonzeros3 rows, 8 cols, 18 nonzerosSolving MIP model with: 3 rows 8 cols (4 binary, 0 integer, 0 implied int., 4 continuous) 18 nonzeros Nodes | B&B Tree | Objective Bounds | Dynamic Constraints | Work Proc. InQueue | Leaves Expl. | BestBound BestSol Gap | Cuts InLp Confl. | LpIters Time 0 0 0 0.00% 0 inf inf 0 0 0 0 0.0s 0 0 0 0.00% 8125.6 inf inf 0 0 0 4 0.0s R 0 0 0 0.00% 8495 8495 0.00% 5 0 0 5 0.0sSolving report Status Optimal Primal bound 8495 Dual bound 8495 Gap 0% (tolerance: 0.01%) Solution status feasible 8495 (objective) 0 (bound viol.) 0 (int. viol.) 0 (row viol.) Timing 0.01 (total) 0.00 (presolve) 0.00 (postsolve) Nodes 1 LP iterations 5 (total) 0 (strong br.) 1 (separation) 0 (heuristics)Optimal solution found.Intlinprog stopped at the root node because the objective value is within a gap tolerance of the optimal value, options.AbsoluteGapTolerance = 1e-06. The intcon variables are integer within tolerance, options.ConstraintTolerance = 1e-06.

View the solution.

sol.ingots
ans = 4×1 1 1 0 1
sol.alloys
ans = 3×1 7.2500 0 0.2500
sol.scrap
ans = 3.5000
fval
fval = 8495

The optimal purchase costs $8,495. Buy ingots 1, 2, and 4, but not 3, and buy 7.25 tons of alloy 1, 0.25 ton of alloy 3, and 3.5 tons of scrap steel.

Related Topics

  • Mixed-Integer Linear Programming Basics: Solver-Based
  • Problem-Based Optimization Workflow
  • Integer and Logical Modeling
  • Solve a Mixed-Integer Linear Programming Problem using Optimization Modeling

MATLAB-Befehl

Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:

 

Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.

Problem-Based- MATLAB & Simulink- MathWorks Deutschland (1)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

Problem-Based
- MATLAB & Simulink
- MathWorks Deutschland (2024)
Top Articles
Triple Crown Towson Reviews
Why Is Oculus Air Link So Laggy
Best Pizza Novato
Joliet Patch Arrests Today
Best Team In 2K23 Myteam
Mopaga Game
Senior Tax Analyst Vs Master Tax Advisor
Think Of As Similar Crossword
How do you mix essential oils with carrier oils?
Find The Eagle Hunter High To The East
Koop hier ‘verloren pakketten’, een nieuwe Italiaanse zaak en dit wil je ook even weten - indebuurt Utrecht
Local Collector Buying Old Motorcycles Z1 KZ900 KZ 900 KZ1000 Kawasaki - wanted - by dealer - sale - craigslist
Bfg Straap Dead Photo Graphic
Moviesda3.Com
Katherine Croan Ewald
Rams vs. Lions highlights: Detroit defeats Los Angeles 26-20 in overtime thriller
DBZ Dokkan Battle Full-Power Tier List [All Cards Ranked]
Who called you from +19192464227 (9192464227): 5 reviews
Palm Springs Ca Craigslist
Craigslist Prescott Az Free Stuff
Walmart Car Department Phone Number
Espn Horse Racing Results
Dwc Qme Database
Euro Style Scrub Caps
Ezel Detailing
Air Traffic Control Coolmathgames
Parc Soleil Drowning
Panola County Busted Newspaper
Directions To Nearest T Mobile Store
Telegram Voyeur
TJ Maxx‘s Top 12 Competitors: An Expert Analysis - Marketing Scoop
Uncovering the Enigmatic Trish Stratus: From Net Worth to Personal Life
Neteller Kasiinod
Calvin Coolidge: Life in Brief | Miller Center
The Monitor Recent Obituaries: All Of The Monitor's Recent Obituaries
Elanco Rebates.com 2022
Workboy Kennel
Kaiju Paradise Crafting Recipes
Amici Pizza Los Alamitos
The Best Carry-On Suitcases 2024, Tested and Reviewed by Travel Editors | SmarterTravel
KM to M (Kilometer to Meter) Converter, 1 km is 1000 m
Stanley Steemer Johnson City Tn
Scarlet Maiden F95Zone
No Boundaries Pants For Men
Alpha Labs Male Enhancement – Complete Reviews And Guide
Craigslist Rooms For Rent In San Fernando Valley
Craigslist/Nashville
Top 1,000 Girl Names for Your Baby Girl in 2024 | Pampers
Tacos Diego Hugoton Ks
Graduation Requirements
M Life Insider
Cataz.net Android Movies Apk
Latest Posts
Article information

Author: Wyatt Volkman LLD

Last Updated:

Views: 5317

Rating: 4.6 / 5 (46 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Wyatt Volkman LLD

Birthday: 1992-02-16

Address: Suite 851 78549 Lubowitz Well, Wardside, TX 98080-8615

Phone: +67618977178100

Job: Manufacturing Director

Hobby: Running, Mountaineering, Inline skating, Writing, Baton twirling, Computer programming, Stone skipping

Introduction: My name is Wyatt Volkman LLD, I am a handsome, rich, comfortable, lively, zealous, graceful, gifted person who loves writing and wants to share my knowledge and understanding with you.