1

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)
HeroldEcon
  • 11
  • 1

1 Answers1

0

While it is not clear what you need and there is no question stated here are some comments:

  1. The goal function needs to state a single value not a vector, eg. it could be:
    f(x1,x2,a,b) = ((a'*[x1 1-x1; 1-x2 x2]) - b')[1]
    
  2. If you need x1+x2==1 you could add a constraint:
    @constraint(m, x1+x2==1)
    
  3. The goal function should reference decision variables so perhaps you want:
    @objective(m, Min, f(x1,x2,a,b))
    
Przemyslaw Szufel
  • 40,002
  • 3
  • 32
  • 62
  • Thanks for your suggestions, I get a running program from that. However, I wonder what I could do to both address the first and the second entry (jointly) in the objective function. Basically, the answer is a root-finding problem with roots x1 = x2 = 0.5 given the constraints on x1 and x2. I am sorry that the first entry was a bit out of context - parts of my questions were cut due to length. – HeroldEcon Aug 14 '23 at 13:34
  • If you have more than one criteria you need to look into mutli-criteria optimization methods (eg. goal programming). You could also look at https://github.com/anriseth/MultiJuMP.jl – Przemyslaw Szufel Aug 14 '23 at 21:14