Reputation: 11
I have the following problem: I am trying to write an optimisation routine in Julia that calculates the potentially unknown coefficients of a transition probability matrix that guarantees me I get from state vector a to new state vector b. As A is a transition probability matrix, the coefficients x1 and x2 have to non-negative and x1 and 1-x1 (or x2 and 1-x2) have to be equal to 1.
using JuMP, GLPK
# Preparing an optimization model
m = Model(GLPK.Optimizer)
# Declaring variables
@variable(m, 0<= x1 <=1)
@variable(m, 0<= x2 <=1)
a = [0.25; 0.5];
b = [0.375; 0.375];
f(x1,x2) = (a'*[x1 1-x1; 1-x2 x2]) - b'
# Setting the objective
@objective(m, Min, f(0.75,0.25))
# Printing the prepared optimization model
print(m)
# Solving the optimization problem
JuMP.optimize!(m)
Upvotes: 1
Views: 63
Reputation: 42244
While it is not clear what you need and there is no question stated here are some comments:
f(x1,x2,a,b) = ((a'*[x1 1-x1; 1-x2 x2]) - b')[1]
@constraint(m, x1+x2==1)
@objective(m, Min, f(x1,x2,a,b))
Upvotes: 0