混合整数非线性规划
最小化目标函数:
\[1.5(x_{1}-\sin(x_{1}-x_{2}))^2+0.5x_{2}^{2}+x_{3}^{2}-x_{1}x_{2}-2x_{1}+x_{2}x_{3} \]
约束条件:\(\forall i\),\(-20 \le x_{i} \le 20\),并且\(x_{3} \in \mathbb{Z}\)。
其解\(x = [4.9996328200986,9.7341480178787,-5]^{T}\),最小值是\(-10.961821657691\)。
local print = require('package.print').print
local mol = libminoptlab
function test(xx)
local x1 = xx[1]
local x2 = xx[2]
local x3 = xx[3]
return 1.5*(x1-math.sin(x1-x2))^2+0.5*x2^2+x3^2-x1*x2-2*x1+x2*x3
end
local eqcon = mol.nullconfun()
local ineqcon = mol.nullconfun()
local eps = 1e-5
local algo = mol.listoptalgo()[1]
local n = 2000
local intindex = {3}
local lb = {-20,-20,-20}
local ub = {20,20,20}
local best ,fbest = mol.fmincon(test ,lb ,ub ,eqcon ,ineqcon ,algo ,eps ,n,intindex)
print({
best = best,fbest=fbest
})