2007: J F M A M J J A S O N D
2008: J F M A M J J A S O N D
2009: J F M A M J J A S O N D
2010: J F M A M J J A S O N D
2011: J F M A M J J A S O N D
2012: J F M A M J J A S O N D
2013: J F M A M J J A S O N D

# Blog, by date: 2012_feb

from the desk of travis johnson.

## cplex matlab interface (from 2012/02/01)

Just for my own reference, I'm documenting the interface to CPLEX.

CPLEX expects a problem in the form

and is called by

```cplex = Cplex('test');
cplex.Param.feasopt.tolerance.Cur = 1e-8;
if params.printLevel < 8
cplex.DisplayFunc = [];
end
cplex.Model.sense = 'minimize';
cplex.Param.qpmethod.Cur = 1;
cplex.Model.Q = W;
cplex.Model.obj = g;
cplex.Model.lb = d_L;
cplex.Model.ub = d_U;
cplex.Model.lhs= c_L;
cplex.Model.rhs= c_U;
cplex.solve();
```

## a trig problem solved in MATLAB (from 2012/02/01)

 I came across this post. The basic idea is the guy wants to maximize constrained to this box, where is the length of beam . It's constrained to be a 61 cmx61 cm box, but one beam must start from 10cm up from the bottom right corner and the beams must meet at a point along the top of the box. I added the further assumption that the other beam must end in the bottom left corner.

which fall from simple trig. There's one more equation, which constrains the side length to 61 cm:

Next, I squared each pair of equations to get

and similarly .

I'm planning on using MATLAB's FMINCON, which means I need to formulate this as a minimization problem. This is accomplished by observing

Therefore, the final nonlinear program that I want to solve is

which can be solved with the matlab program

```function xsol = solveproblem()
f = @(x) -x(1)-x(2);
x0 = [0;0;0;0]; LB=[0;0;0;0];
settings = optimset('TolFun',1e-8,'Algorithm','interior-point');
xsol = fmincon(f,x0,[],[],[],[],LB,[],@nonlincon,settings);

function [c,ceq]=nonlincon(x)
l1=x(1);l2=x(2);t1=x(3);t2=x(4);
c=[];
ceq = [l1^2-t1^2-51^2;
l2^2-t2^2-61^2;
t1 + t2 - 61];
end
end
```

When run, this produces a length 140.5 pair of beams. Hooray!