Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
A
alpha-mind
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dr.李
alpha-mind
Commits
0ee8b1cb
Commit
0ee8b1cb
authored
Jul 24, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update interface
parent
e3b8c8f7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
10 deletions
+30
-10
optimizers.pyx
alphamind/cython/optimizers.pyx
+15
-2
meanvariance.hpp
libs/include/pfopt/meanvariance.hpp
+11
-7
mvoptimizer.hpp
libs/include/pfopt/mvoptimizer.hpp
+4
-1
pfopt.lib
libs/lib/windows/pfopt.lib
+0
-0
No files found.
alphamind/cython/optimizers.pyx
View file @
0ee8b1cb
...
@@ -49,7 +49,14 @@ cdef class LPOptimizer:
...
@@ -49,7 +49,14 @@ cdef class LPOptimizer:
cdef extern from "mvoptimizer.hpp" namespace "pfopt":
cdef extern from "mvoptimizer.hpp" namespace "pfopt":
cdef cppclass MVOptimizer:
cdef cppclass MVOptimizer:
MVOptimizer(vector[double], vector[double], vector[double], vector[double], double) except +
MVOptimizer(vector[double],
vector[double],
vector[double],
vector[double],
vector[double],
vector[double],
vector[double],
double) except +
vector[double] xValue()
vector[double] xValue()
double feval()
double feval()
int status()
int status()
...
@@ -64,12 +71,18 @@ cdef class QPOptimizer:
...
@@ -64,12 +71,18 @@ cdef class QPOptimizer:
cnp.ndarray[double, ndim=2] cov_matrix,
cnp.ndarray[double, ndim=2] cov_matrix,
cnp.ndarray[double] lbound,
cnp.ndarray[double] lbound,
cnp.ndarray[double] ubound,
cnp.ndarray[double] ubound,
double risk_aversion):
cnp.ndarray[double, ndim=2] cons_matrix,
cnp.ndarray[double] clbound,
cnp.ndarray[double] cubound,
double risk_aversion=1.0):
self.cobj = new MVOptimizer(expected_return,
self.cobj = new MVOptimizer(expected_return,
cov_matrix.flatten(order='C'),
cov_matrix.flatten(order='C'),
lbound,
lbound,
ubound,
ubound,
cons_matrix.flatten(order='C'),
clbound,
cubound,
risk_aversion)
risk_aversion)
def __del__(self):
def __del__(self):
...
...
libs/include/pfopt/meanvariance.hpp
View file @
0ee8b1cb
...
@@ -22,6 +22,7 @@ namespace pfopt {
...
@@ -22,6 +22,7 @@ namespace pfopt {
double
riskAversion
=
1.
);
double
riskAversion
=
1.
);
bool
setBoundedConstraint
(
const
std
::
vector
<
double
>&
lb
,
const
std
::
vector
<
double
>&
ub
);
bool
setBoundedConstraint
(
const
std
::
vector
<
double
>&
lb
,
const
std
::
vector
<
double
>&
ub
);
bool
setLinearConstrains
(
const
std
::
vector
<
double
>&
consMatrix
,
const
std
::
vector
<
double
>&
clb
,
const
std
::
vector
<
double
>&
cub
);
virtual
bool
get_nlp_info
(
Index
&
n
,
Index
&
m
,
Index
&
nnz_jac_g
,
virtual
bool
get_nlp_info
(
Index
&
n
,
Index
&
m
,
Index
&
nnz_jac_g
,
Index
&
nnz_h_lag
,
IndexStyleEnum
&
index_style
);
Index
&
nnz_h_lag
,
IndexStyleEnum
&
index_style
);
...
@@ -44,11 +45,6 @@ namespace pfopt {
...
@@ -44,11 +45,6 @@ namespace pfopt {
Index
m
,
Index
nele_jac
,
Index
*
iRow
,
Index
*
jCol
,
Index
m
,
Index
nele_jac
,
Index
*
iRow
,
Index
*
jCol
,
Number
*
values
);
Number
*
values
);
virtual
bool
eval_h
(
Index
n
,
const
Number
*
x
,
bool
new_x
,
Number
obj_factor
,
Index
m
,
const
Number
*
lambda
,
bool
new_lambda
,
Index
nele_hess
,
Index
*
iRow
,
Index
*
jCol
,
Number
*
values
);
virtual
void
finalize_solution
(
SolverReturn
status
,
virtual
void
finalize_solution
(
SolverReturn
status
,
Index
n
,
const
Number
*
x
,
const
Number
*
z_L
,
const
Number
*
z_U
,
Index
n
,
const
Number
*
x
,
const
Number
*
z_L
,
const
Number
*
z_U
,
Index
m
,
const
Number
*
g
,
const
Number
*
lambda
,
Index
m
,
const
Number
*
g
,
const
Number
*
lambda
,
...
@@ -66,11 +62,19 @@ namespace pfopt {
...
@@ -66,11 +62,19 @@ namespace pfopt {
VectorXd
xReal_
;
VectorXd
xReal_
;
double
riskAversion_
;
double
riskAversion_
;
VectorXd
lb_
;
std
::
vector
<
double
>
lb_
;
VectorXd
ub_
;
std
::
vector
<
double
>
ub_
;
VectorXd
grad_f_
;
VectorXd
grad_f_
;
double
feval_
;
double
feval_
;
std
::
vector
<
double
>
x_
;
std
::
vector
<
double
>
x_
;
std
::
vector
<
Index
>
iRow_
;
std
::
vector
<
Index
>
jCol_
;
std
::
vector
<
double
>
g_grad_values_
;
std
::
vector
<
double
>
consMatrix_
;
std
::
vector
<
double
>
clb_
;
std
::
vector
<
double
>
cub_
;
Index
m_
;
};
};
}
}
#endif
#endif
libs/include/pfopt/mvoptimizer.hpp
View file @
0ee8b1cb
...
@@ -11,7 +11,10 @@ namespace pfopt {
...
@@ -11,7 +11,10 @@ namespace pfopt {
const
std
::
vector
<
double
>
&
varMatrix
,
const
std
::
vector
<
double
>
&
varMatrix
,
const
std
::
vector
<
double
>
&
lbound
,
const
std
::
vector
<
double
>
&
lbound
,
const
std
::
vector
<
double
>
&
ubound
,
const
std
::
vector
<
double
>
&
ubound
,
double
riskAversion
);
const
std
::
vector
<
double
>
&
consMatrix
=
std
::
vector
<
double
>
(),
const
std
::
vector
<
double
>
&
clb
=
std
::
vector
<
double
>
(),
const
std
::
vector
<
double
>
&
cub
=
std
::
vector
<
double
>
(),
double
riskAversion
=
1.
);
std
::
vector
<
double
>
xValue
()
const
{
return
mvImpl_
->
xValue
();
}
std
::
vector
<
double
>
xValue
()
const
{
return
mvImpl_
->
xValue
();
}
double
feval
()
const
{
return
mvImpl_
->
feval
();
}
double
feval
()
const
{
return
mvImpl_
->
feval
();
}
...
...
libs/lib/windows/pfopt.lib
View file @
0ee8b1cb
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment