To do this, I need an activity coeff., which is dependent on the composition xp1. The way this work is, you keep looking for two phase compositions xp1 and xp2, until xp1actcoeff1-xp2actcoeff2 = 0.
The activity coeff. is a function of the composition xp1 or xp2. Instead using Unifac/Uniquac/etc… to calculate the act. coeff., I am using a quantum chemical software, which can be triggered by command line with GAMMAP1().

The Problem is that this software needs a .inp file with the concentrations xp1 and xp2. When I ran my JuMP Model, the .inp file that was created had { xp1[1] xp1[2] } as concentration, instead of the values that the solver is currently using for this iteration step.

My question is: How do I get to the value that is currently being used by the solver on the current iteration step?

using JuMP
using Ipopt
m = Model(solver=IpoptSolver(print_level=0))
@variable(m, xp1[1:n_komp])
@variable(m, xp2[1:n_komp])
@variable(m, x[1:n_komp])
@variable(m, y[1:n_komp])
@variable(m, F)
@variable(m, V)
@variable(m, g1[1:n_komp], start = GAMMAP1(t, n_komp, getvalue(xp1)))
@variable(m, g2[1:n_komp], start = GAMMAP2(t, n_komp, getvalue(xp2)))
@NLobjective(m, Min, V+F-1)
@constraint(m, sum(x) == 1)
@constraint(m, sum(y) == 1)
@constraint(m, sum(xp1) == 1)
@constraint(m, sum(xp2) == 1)
@constraint(m, K.*x.-y .== 0)
@constraint(m, F.*x+V*y.-z .== 0)
@constraint(m, xp1.*g1 .== xp2.*g2 )
solve(m)
global x = getvalue(x)
global y = getvalue(y)
global V = getvalue(V)
global F = getvalue(F)
println("x = ", x)
println("y = ", y)
println("F = ", F)
println("V = ", V)

I need the solver to get the g1 and g2 values from the function. This function gets the value from an outside software (CosmoTherm). It need the concentration vector xp1 and xp2 as input to calculate g1 and g2.

You’re using JuMP 0.18. (Are you on Julia 0.6?) You should upgrade to Julia 1.0 and JuMP 0.19.

Read the JuMP nonlinear documentation, particularly about user-defined functions Nonlinear Modeling · JuMP
You need to call JuMP.register in order to be able to use a user-defined function.

start = only provides a primal start hint for the solver. It does not enforce a constraint. Is that what you want? See Variables · JuMP

Thanks. I just updates to 0.19 earlier. I was using JuliaPro 1.0.3 and it automatically installed v0.18.

I am not sure if I need derivatives. I guess g1 should be given as a constraint and not a variable.
What I need is to use the current value for the variables xp1 and xp2 to calculate g1 and g2 (activity coefficients) with CosmoTherm. The GAMMAP1 and GAMMAP2 are used to run CosmoTherm (quantum chemical software) from the command line.

JuMP isn’t really suited for this problem. You should probably just use NLopt directly. There are a number of derivative-free algorithms: NLopt Algorithms - NLopt Documentation