packages feed

ipopt-hs-0.2.0.0: examples/Test3.hs

module Main where
import Ipopt
import qualified Data.Vector as V
import Control.Lens
import Control.Monad
import Control.Monad.State

-- | the same problem as solved in Test1 and Test2, except
-- showing how bits from Ipopt.NLP help
test22 = do
   [x0, x1, x2, x3] <- replicateM 4 (varFresh (Just (1,5)) "x")
   addF (Just "test22")      $ x0*x3*(x0 + x1 + x2) + x2
   addG Nothing (25,2.0e19)  $ x0*x1*x2*x3
   addG Nothing (40,40)      $ x0*x0 + x1*x1 + x2*x2 + x3*x3
   initX .= V.fromList [1,5,5,1]
   solveNLP' (const (return ()))
 `runStateT` nlpstate0

main = test22