Friday, December 24, 2021

Optimization Solutions Using Microsoft Excel – Solver

 

There is a useful optimization tool available with Microsoft Excel. Many users are not aware of the existence or of the utility of this Excel Add-in feature, Solver (tips for setting up Solver are given at the end of this post).

Here is an example of a typical optimization problem. A financial advisor uses a questionnaire to determine the appropriate risk level for a client. Based on the client’s answers, age, and other factors, a risk level of 1 to 10 is assigned to the client. Each investment offered by the advisor has a potential rate of return and is assigned a risk score based on its volatility. The advisor’s firm may also have various rules such as: no more than 10% of the portfolio may be in one investment; no more than 30% of the portfolio may be in one sector, etc.

Now the question becomes what is the best mix of investments to maximize the potential return while meeting not exceeding the risk tolerance of the client and meeting the other investment guidelines of the advisor’s firm?

Maximizing the potential return is called the objective function of the problem. The total investment amount, the risk tolerance, and the investment guidelines are called the constraints of the problem. The amounts to place in each investment are called the decision variables. It is these decision variables that we are trying to determine to reach the optimal solution to the problem.

Without good analytical tools, a solution could be found by trial-and-error (not very efficient) or by setting up a matrix of linear equations and solving for an optimal solution (tedious and difficult). However, using Excel, one just needs to be able to express objective function and constraints as functions of the decision variables.

Here is a specific example:

Total amount to invest: $1,000,000
Client’s Risk Tolerance: 5

Available Investment Choices (with potential return and risk scores)

Investment   Symbol Potential Return             Risk Score

Cash                   C               1%                                    1
MuniBond        M              3%                                    2
TechStock1       TS1           10%                                  9
TechStock2       TS2           7%                                   8
Utility1               U1             5%                                   4
Utility2              U2             5%                                   6

(Realistically, there would be many more investment choices. However, the same method works for any number of choices.)

The objective function becomes:
Maximize Return = .01C + .03M + .10TS1 + .07TS2 + .05U1 + .05U2

The Total Investment Constraint is:

1C + 1M + 1TS1 + 1TS2 + 1U1 + 1U2 = 1,000,000

The Risk Constraint is:
1C + 2M + 9TS1 + 8TS2 + 4U1 + 6U1 <= 5,000,000 (the limit is the client’s risk tolerance x total inv)

The constraints for the maximum allowed in each investment are (we only have a choice of 6 investments, so use a max of 30% for any one investment – this is higher than normal investment advice, but that is when you have a much larger selection of possible investments).

C <= 300,000 (30% of 1,000,000)
M<= 300,000
TS1 <= 300,000
TS2 <= 300,000
U1 <= 300,000
U2 <= 300,000

The constraints for the maximum invested in each sector are (this example uses 50%. Again, this is higher than normal conventions, but we only have four sectors in our example – cash, bonds, tech, utilities).

C <= 500,000 (50% of 1,000,000)
M <= 500,000
TS1+TS2 < 500,000
U1 + U2 < 500,000

The complete formulation of the problem now has one objective function, six decision variables, and twelve constraints.

In Excel, the problem is set up as shown below:


To complete the solution of the problem, pull up the Solver dialogue box. The Total Potential Return in cell H13 is the objective function. The functions for the constraints are given in column G and the limits of the constraints are given in column H. Each constraint uses the sumproduct(array1,array2) function, where array 1 is the group of cells A10:F10 (the decision variables) and array 2 is group of constraint coefficients in the rows 18 through 32. The completed dialogue box for Solver is:



Clicking the Solve box and the spreadsheet is updated with the optimal solution:


The Solver solution says to invest $42,587 in Cash, $300,000 in Muni Bond, $300,00 in Tech Stock 1, $57,143 in Tech Stock 2, $300,000 in Utility 1 and $0 in Utility 2. The potential annual return is projected to be $58,429.

Viewing column G, we see all the constraints are met.

Once a user has completed a modest size problem as the above, it is just a matter of adding additional decision variables (columns) and constraints (rows) to solve much larger problems.  

Solver Set-up:
In Excel, from the top ribbon click on Data then look for Solver. If it is not there, go to File and click on Options. Select Add-ins then click on Go. In the dialogue box, click Solver then OK. Now, when you return to Data on the ribbon, Solver should be there. For your version of Excel, the steps may be different, so review this link from Frontline for your version of Excel: Search | solver.

For another example of using Solver see: A Geometry Puzzle Solved with Solver.

Saturday, December 11, 2021

An Abbreviated Timeline of Artificial Intelligence

 


Chronology of Artificial Intelligence Milestones
This chronologically is abbreviated as it is limited by topics discussed elsewhere in this blog. For a more complete history, see History of artificial intelligence - Wikipedia

1949: Arthur Lee Samuel of IBM conceives a computer that was considered the first self-learning program. Limited by available memory, it could not play at a championship level but improved as increased memory became available. Computer Pioneers - Arthur Lee Samuel

1950: Alan Turing publishes a paper in which he proposes the Turing Test to determine if a computer program is intelligent. Computing Machinery and Intelligence - Wikipedia

1952: Cambridge University develops computer that plays tic-tac-toe. In 1952, OXO (or Noughts and Crosses), developed by British computer scientist Sandy Douglas for the EDSAC computer at the University of Cambridge, became one of the first known video games. The computer player could play perfect games of tic-tac-toe against a human opponent.

1990: The program Chinook, developed by the University of Alberta, becomes the first computer program to beat a world checkers champion. Chinook (computer program) - Wikipedia

1997: University of Illinois mathematicians Ken Appel and Wolfgang Haken use a computer to complete a proof of the Four-Color Map Theorem. Math Vacation: Four Color Map (jamesmacmath.blogspot.com)

1997: IBM’s Deep Blue chess program defeats world champion Garry Kasparov Deep Blue versus Garry Kasparov - Wikipedia

2017: DeepMind’s AlphaGo defeats the world’s highest rank Go player The latest AI can work things out without being taught | The Economist

2021: The Ramanujan Machine - Technion - Israel Institute of Technology

2021: DeepMind says it can predict the shape of every protein in the human body | Live Science

2021: Advancing mathematics by guiding human intuition with AI | Nature


 

DeepMind Artificial Intelligence

 

With the recent advances in artificial intelligence, we will see more assistance from computers helping prove theorems and suggesting new conjectures to explore. In the very near future, we will see many headlines about artificial intelligence helping us solve very complex problems. Recently, an article in Nature described the advances of DeepMind Technologies.

DeepMind Technologies is a British artificial intelligence subsidiary of Alphabet Inc. and research laboratory founded in September 2010. DeepMind was acquired by Google in 2014.

A link to the Nature article is given here: https://rdcu.be/cC1lb

The Nature article prompted response by the press:

DeepMind was able to make progress on proving a decades-old conjecture about multidimensional graphs and suggested an additional conjecture in the subject area of topology. Both of these conjectures are reminiscent of my prior blog posts - the University of Illinois mathematicians who used a computer to complete a proof of the four-color map conjecture and the team from Technion-Israeli Institute of Technology who used A.I. to automatically generate mathematical conjectures that appear in the form of formulas for mathematical constants - The Ramanujan Machine. 

For those readers more curious about practical mathematical applications, DeepMind says it can predict the shape of every protein in the human body. Understanding how proteins fold is a very complex task and is critical to further advancing biology and medicine.

DeepMind says it can predict the shape of every protein in the human body | Live Science

12/11/2021 Update - just after I posted this original blog, I came across another use of DeepMind - a machine-learning model that suggests a molecule’s characteristics by predicting the distribution of electrons within it. 

12/12/2021 Update - Further DeepMind Articles
DeepMind can play poker chess and more
DeepMind has the reading comprehension of a high-schooler

12/18/2021 Update - 
MIT Researchers Just Discovered an AI Mimicking the Brain on Its Own

12/20/2021 Update - What Does It Mean for AI to Understand? Quantamagazine

1679 - One important message sent from Earth 31 years ago

In 1974 an interstellar radio transmission was broadcast to the  globular cluster   Messier 13   from the Arecibo radio telescope in Puerto ...

Popular in last 30 days