Commit 614b98a4 authored by Dr.李's avatar Dr.李

added ipopt

parent e5182b39
......@@ -8,5 +8,7 @@ Alpha_Mind.egg-info/*
*.cpp
*.html
*.nbc
*.nbi
/notebooks/.ipynb_checkpoints
\ No newline at end of file
*.nbi
/notebooks/.ipynb_checkpoints
alphamind/examples/*
notebooks/*
\ No newline at end of file
......@@ -29,10 +29,10 @@ cdef class LPOptimizer:
cnp.ndarray[double] ubound,
cnp.ndarray[double] objective):
self.cobj = new LpOptimizer(cons_matrix.flatten().copy(),
lbound.copy(),
ubound.copy(),
objective.copy())
self.cobj = new LpOptimizer(cons_matrix.flatten(),
lbound,
ubound,
objective)
def __del__(self):
del self.cobj
......@@ -43,5 +43,35 @@ cdef class LPOptimizer:
def feval(self):
return self.cobj.feval()
def x_value(self):
return np.array(self.cobj.xValue())
cdef extern from "meanvariance.hpp" namespace "pfopt":
cdef cppclass MeanVariance:
MeanVariance(vector[double], vector[double], double) except +
vector[double] xValue()
double feval()
cdef class MVOptimizer:
cdef MeanVariance* cobj
def __init__(self,
cnp.ndarray[double] expected_return,
cnp.ndarray[double, ndim=2] cov_matrix,
double risk_aversion):
self.cobj = new MeanVariance(expected_return,
cov_matrix.flatten(),
risk_aversion)
def __del__(self):
del self.cobj
def feval(self):
return self.cobj.feval()
def x_value(self):
return np.array(self.cobj.xValue())
\ No newline at end of file
......@@ -8,7 +8,7 @@ Created on 2017-5-5
import numpy as np
from typing import Tuple
from typing import Union
from alphamind.cython.lpoptimizer import LPOptimizer
from alphamind.cython.optimizers import LPOptimizer
def linear_build(er: np.ndarray,
......
......@@ -24,8 +24,8 @@ else:
if platform.system() != "Windows":
extensions = [
Extension('alphamind.cython.lpoptimizer',
['alphamind/cython/lpoptimizer.pyx'],
Extension('alphamind.cython.optimizers',
['alphamind/cython/optimizers.pyx'],
include_dirs=["./libs/include/clp",
"./libs/include/ipopt",
"./libs/include/pfopt",
......@@ -36,8 +36,8 @@ if platform.system() != "Windows":
]
else:
extensions = [
Extension('alphamind.cython.lpoptimizer',
['alphamind/cython/lpoptimizer.pyx'],
Extension('alphamind.cython.optimizers',
['alphamind/cython/optimizers.pyx'],
include_dirs=["./libs/include/clp",
"./libs/include/ipopt",
"./libs/include/pfopt",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment