Displaying results

Describes how to display results by writing an execute IBM® ILOG® Script block.

The statements presented so far did not specify what elements of the solution should be displayed. OPL offers a way to display the results of an application. An interesting feature of OPL is the ability to display tuples of expressions.

To display results using an execute block:

  1. Add the following IBM ILOG Script execute block to the product.mod file (see The production-planning problem revisited (product.mod))
    
    tuple R { float x; float y; };
    {R} Result = { <Inside[p],Outside[p]> | p in Products };
    execute { writeln("Result=",Result); } 
    

    You see the following output:

    
    Optimal solution found with objective: 372
    result= {<40.0000 60.0000> <0.0000 200.0000> <0.0000 300.0000>} 
    
  2. Run the product model with the productn.dat data file shown in Named data for the revised production-planning problem (productn.dat).

    You can visualize the inside and outside productions of a product simultaneously.

    
    Final Solution with objective 372.0000:
      inside = [40.0000 0.0000 0.0000];
      outside = [60.0000 200.0000 300.0000];
    

    Named data for the revised production-planning problem (productn.dat)

    Products =  { "kluski", "capellini", "fettuccine" };
    Resources = { "flour", "eggs" };
    
    Product = #[
          kluski : 
       #< demand:100
               insideCost:0.6
               outsideCost:0.8
               consumption:[0.5 0.2]
            >#,
          capellini :
       #< demand:200
               insideCost:0.8
               outsideCost:0.9
               consumption:[0.4 0.4]
            >#,
          fettuccine :
       #< demand:300
               insideCost:0.3
               outsideCost:0.4
               consumption:[0.3 0.6]
            >#
              ]#;
    
    Capacity = [ 20, 40 ];
    
  3. Add the following IBM ILOG Script postprocessing lines to the product.mod file
    
    execute {
       for(p in Products)
         writeln("inside[",p,"].reducedCost = ", inside[p].reducedCost); 
    }
    

    You can see both the inside production of a product and its reduced cost.

    
    Optimal solution found with objective: 372 
     inside[kluski].reducedCost = 0 
     inside[capellini].reducedCost = 0.06000000000000005
     inside[fettuccine].reducedCost = 0.02000000000000002