SAS Demo | SAS Optimization Web App Using REST APIs with Embedded Visual Analytics Reports

By | March 13, 2020


Hello, everyone. My name is Nabaruna
Karmakar, and today, I’m going to demonstrate
SAS Optimization web app using REST APIs with
embedded SAS Visual Analytics Reports. So the motivation for
these optimization demos was really to build an
interactive user interface, or a web app, to demonstrate
small scale, mixed integer linear programming optimization
models, also known as MILP. And we want to showcase
these to customers and cater to their
specific business needs. We can demonstrate
the capability of the runOptmodel
action in SAS Viya, hosted on a cloud
Analytic Server, or CAS. And we can use that to solve
optimization problems quickly. Also we want to showcase
some Visual Analytics reports so that interactively, the
user can visualize their data and do some what-if analysis. The integration between all
these different SAS products is done using REST APIs. So the front end framework
is react and material UI. And the back end is SAS Viya. And the connection between
the SAS Viya server and the front end is done using
a JavaScript library called as restAF. Let me talk about
the specific problem that I’m going to
demonstrate today is call the facility
location optimization. So the problem is
to optimally assign products to be manufactured
at some eligible facilities. We want to also decide
which facilities to keep open and closed. We have some cost
associated with that. So a variable cost incurred
per unit of the product that is manufactured at a facility. A fixed cost is
incurred one time for operating a facility to
keep a facility open or closed. Each of these facilities
can manufacture at most one product. The capacity for each facility
and the demand for each product are provided in terms
of units of products. The objective function can
be to minimize a fixed cost, or you want to minimize
the sum of variable costs, or the total costs, which is the
sum of fixed and variable cost. And this is something the user
is able to select themselves. The user is also able to
perform a what-if analysis by fixing the
assignment of a product to a particular facility. And this is optional. So let me take you
to the web page. So the first thing it does is
takes me to the landing page. It’s the log on page. I’m going to enter
my credentials. And hit the Sign In button. It takes me to the landing
page of the web app. So here I’m describing the
problem specific for this demo. We have 5 products– in our case, these are cars– and 25 existing facilities. And we want to decide
which facilities to keep open, which to
close, and which products or which cars should be
built at which facility. So the first thing
I’m doing is I’m pulling in a Visual
Analytics report which is going to help us
visualize the input data. It’s a very interactive report. On the left, each bar is
representing each type of car. We have coupes, sedans,
trucks, convertibles, or SUVs. And when I click on each
of these bars on the right, each of these bubbles
are presenting where this type of
car can be produced. So the SUV can be produced
at some 18 facilities on the right, and
it’s filtered out. And each of these bubbles
represent where the facilities are located, what the variable
costs for producing the SUV at that facility would be. And the variable cost is
represented by the color. So green being less
and red being high. And then the fixed
costs are shown using the size of the bubbles. Ultimately, the idea is
to select the smallest green bubble for each of these
products or each of these cars. Similarly, when I click
on each of these bars, I’m able to filter those out
and just analyze the input data. So next thing I’m going to do
is input optimization parameters page, which enables me to
do the scenario analysis. So this is the default
data that is already there. So each of the car names we
have on the first column, and the required number
of units of those cars in the second column. And we are just at
this point trying to find the optimal solution. So I’m not going to assign
any fixed facilities. So let optimization
decide which product to be built at which facility. I’m going to select
Total Cost so I can minimize the sum of the
fixed and variable costs. When I hit the Optimize
button, what it’s doing is in the back end, it’s
submitting the optimization code– my MILT model. And it’s bringing back
the optimal solution so that we can
compare the solution. Here in the Visual Analytics
report, very interactively, we can see for the
current solution that is in place that our
variable cost is $64,000 and the total cost is $73,000. And when I click on each of
these different types of cars, I can see where they’re
actually being produced. And this big box is
basically showing us which are the facilities
they’re at this point deciding to close. And then when I hit
on the right tab, I can see I can compare
their current solution to the optimal solution. So it seems that
the current decision is incurring a lot of
costs due to the decision to keep site 10 open. And optimization is telling
them to close down site 10. Let’s go back to the input
optimization parameters table and do some scenario analysis. So I want to create a scenario. I’m going to call it scenario 1. I’m going to say that I
have more demand for sedans. So from 200 units to 400 units. And due to some
business rules, It might be necessary
to manufacture a certain type of product
at a certain facility. So I’m going to fix
that facility for sedans to be produced at site 2. And now I’m going to
select Total Costs as my objective function and
click on the Optimize button. So when I click on
the Optimize button, it’s rerunning for scenario 1. So it’s kind of
changing the input data, taking it in from the user form,
and rerunning for that scenario and bringing back the optimal
solution and the Visual Analytics report and appending
it to a master table. So that also contains
our optimal solution. So our optimal solution
said $46,000 total cost for scenario 1. Of course, we see an
increase because we are producing more sedans. So sedans are more expensive. When I click on the
sedan box, I can see that I have assigned
site 2 to sedans, and site 2 is producing
sedans up to its capacity. Then let’s do a side-by-side
comparison of the scenarios. On the top left, we can
see that in scenario 1, we are producing more
number of units of sedans– 400 as opposed to 200 in
the other two scenarios. And we are also incurring
more variable costs for sedans in scenario 1. In the bottom graph, we can
see that we still do not recommend site 10 to be open. And we recommend that site
2 be open for scenario 1. And this was fixed by the user. So similarly, a user is able to
do many more scenario analysis and decide the trade off
between their different business rules and different KPIs
that they’re looking at. In that case, the
KPIs were costs. So that’s pretty
much it for the demo. For more information on this web
app and other cool optimization problems, please visit our blog. And also be on the lookout
for a GitHub repository where this code will be
made public so the users can download and play with it. Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *