This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

showproblem

Display optimization problem

Syntax

showproblem(prob)

Description

example

showproblem(prob) displays the objective function, constraints, and bounds of prob.

Examples

collapse all

Create an optimization problem, including an objective function and constraints, and display the problem.

Create the problem in Mixed-Integer Linear Programming Basics: Problem-Based.

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) + 990*ingots(2) + 1240*ingots(3) + 1680*ingots(4)
     + 500*alloys(1) + 450*alloys(2) + 400*alloys(3) + 100*alloys(4)

	subject to conswt:
       5*ingots(1) + 3*ingots(2) + 4*ingots(3) + 6*ingots(4) + alloys(1)
     + alloys(2) + alloys(3) + alloys(4) == 25

	subject to conscarb:
       0.25*ingots(1) + 0.12*ingots(2) + 0.2*ingots(3) + 0.18*ingots(4)
     + 0.08*alloys(1) + 0.07*alloys(2) + 0.06*alloys(3) + 0.03*alloys(4) == 1.25

	subject to consmolyb:
       0.15*ingots(1) + 0.09*ingots(2) + 0.16*ingots(3) + 0.24*ingots(4)
     + 0.06*alloys(1) + 0.07*alloys(2) + 0.08*alloys(3) + 0.09*alloys(4) == 1.25

	variable bounds:
       0 <= alloys(1)
       0 <= alloys(2)
       0 <= alloys(3)
       0 <= alloys(4)

       0 <= ingots(1) <= 1
       0 <= ingots(2) <= 1
       0 <= ingots(3) <= 1
       0 <= ingots(4) <= 1

Input Arguments

collapse all

Optimization problem, specified as an OptimizationProblem object. Create a problem by using optimproblem.

Example: prob = optimproblem; prob.Objective = obj; prob.Constraints.cons1 = cons1;

Tips

  • showproblem is equivalent to calling all of the following:

  • For a problem that has many bounds or constraints, use writeproblem to generate a text file containing the objective, constraint, and bound information.

Introduced in R2017b