- Machine: 193.144.12.89
- user: userX where X{0...10}
- password userX is userX where X{0...10}

sshssh userX@193.144.12.89scpscp route_to_a_file(user machine) userX@193.144.12.89:route(server machine)scpscp -r route_to_a_directory(user machine) userX@193.144.12.89:route(server machine)

- Linear Programing: The Happiness Problem
- Model
- Using CPLEX solver (terminal)
- Using CPLEX solver (API JAVA)
- Game-Theory and Linear Programming: Two-Person Zero-Sum Games
- Paper-Rock-Scissors Game
- The Ultra Conservative Investor
- Using AMPL + NEOS

There are 7 days in a week, so there are **168** hours in a week. We want to allocate our time between:

- Classes and Studing
**(C)** - Fun activities and going to parties
**(P)** - Vital activities such as slepping, eating, ...
**(O)**

Suppose that our notion of happines it can be mesured and follow the following function: **happines( P,O,S) = 2*P + O **.

Suppose that to survive we need at least **56 hours** on **O**, which is 8 hours per day. Besides, to mantain sanity we need ** P + O >= 70 **. To pass our courses, we need

Maximize;//This is the optimitzation sense.obj: 2*P + O;//This is the objective function.Subject to://This are the constraints.To survive: O >= 56;To sanity: P + O >= 70;To pass the course: S >= 60;For compensation: 2*S + O -3*P >= 150;Total Amount of (H) in a week: S + P + O = 168;It can be possible not to have fun: P >=0;end;

$./cplexCPLEX>help

$./cplexCPLEX>enterCPLEX>Enter name of the problem: happiness.lpCPLEX>Enter new problem ['end' on a separate line terminates]:CPLEX>//here copy and paste the previous modelCPLEX>optimizeCPLEX>display solution objectiveCPLEX>display solution variables -

import ilog.concert.*; import ilog.cplex.*; public class Happiness { public static void main(String[] args){ try { IloCplex cplex = new IloCplex(); IloObjective obj = cplex.addMaximize(); IloRange c1 = cplex.addRange(-infinity, 70.0, "c1"); IloNumVar P = cplex.numVar(cplex.column(obj, 1.0).and( cplex.column(c1, -1.0).and(cplex.column(c2, 1.0).and( cplex.column(c3, 1.0)))),0, infinity, "P"); cplex.solve(); System.out.println("f.o: "+cplex.getObjValue()); System.out.println("P: "+cplex.getValue(P)); } catch (IloException e) {System.err.println("Concert exception caught: " + e);}}}

PayOff Matrix |
||||
---|---|---|---|---|

Rock | Paper | Scissors | ||

Rock | 0 | -1 | 1 | |

Paper | 1 | -0 | -1 | |

Scissors | -1 | 1 | 0 |

`x`

== probability that Sheldom chooses rock`y`

== probability that Sheldom chooses paper`z`

== probability that Sheldom chooses scissors`v`

== total value (smallest of column totals)

PayOff Matrix | Rock | Paper | Scissors |
---|---|---|---|

Rock (x) | 0 | -1 | 1 |

Paper (y) | 1 | 0 | -1 |

Scissors (z) | -1 | 1 | 0 |

Average (v) | y-z | z-x | x-y |

Maximize;//This is the optimitzation sense.obj:v//This is the objective functionSubject to//This are the constraints.c1: y - z >= v(Rock)c2: z - x >= v(Paper)c3: x - y >= v(Scissors)c4: x + y + z = 1Boundsx >= 0 y >= 0 z >= 0end

setROWS;setCOLS;param{ROWS,COLS}default0;varx{COLS} >= 0;varv;maximizezot: v;subject toineqs {i in ROWS}:sum{j in COLS} -A[i,j] * x[j] + v < = 0;subject toequal:sum{j in COLS} x[j] = 1;

data;setROWS := Paper Scissors Rock;setCOLS := Paper Scissors Rock;paramA: Paper Scissors Rock:= Paper 0 1 -2 Scissors -3 0 4 Rock 5 -6 0 ;

solve;printf{j in COLS}: "%3s %10.7f \n", j, 100*x[j];printf{i in ROWS}: "%3s %10.7f \n", i, 100*ineqs[i];printf"Value = %10.7f \n", 100*v;

Year | Ibex 35 | NASDAQ | Dow Jones | DAX | Gold |
---|---|---|---|---|---|

2010 | 1,235 | 1,217 | 1,092 | 1,080 | 0,872 |

2011 | 1,030 | 0,903 | 1,103 | 1,150 | 0,825 |

2012 | 1,326 | 1,333 | 1,080 | 1,213 | 1,006 |

2013 | 1,161 | 1,086 | 1,092 | 1,156 | 1,216 |

2014 | 1,023 | 0,959 | 1,063 | 1,023 | 1,244 |

- Lets consider now the historical return on investment data:
**ROI**. - We can view this as a
**payoff matrix**in a game between**Fate**and**the investor**. - The columns represents pure strategies for our conservative investor.
- The rows represents how history might repeat itself.
- So in
**2015**,**Fate**won't just repeat a previous year but, rather will present some mix of these previous years. - The
**inverstor**won't put all of his money into one asset. Instead he will put a certain fraction into each one.'

Jordi Mateo Fornés