Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
studieren666
nlopt
提交
812fb556
N
nlopt
项目概览
studieren666
/
nlopt
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nlopt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
812fb556
编写于
4月 04, 2020
作者:
J
Julien Schueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SWIG: Fix get_initial_step wrapping
Closes #319
上级
a10f7bc2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
14 addition
and
4 deletion
+14
-4
doc/docs/NLopt_Python_Reference.md
doc/docs/NLopt_Python_Reference.md
+1
-1
src/swig/nlopt.i
src/swig/nlopt.i
+4
-0
test/t_guile.scm
test/t_guile.scm
+5
-1
test/t_python.py
test/t_python.py
+4
-2
未找到文件。
doc/docs/NLopt_Python_Reference.md
浏览文件 @
812fb556
...
...
@@ -340,7 +340,7 @@ Just as in the C API, you can [get and set the initial step sizes](NLopt_Referen
```
opt.set_initial_step(dx)
opt.get_initial_step(x)
dx =
opt.get_initial_step(x)
```
...
...
src/swig/nlopt.i
浏览文件 @
812fb556
...
...
@@ -17,6 +17,10 @@ namespace std {
%
template
(
nlopt_doublevector
)
vector
<
double
>
;
}
;
// dont use the in-place version of get_initial_step
%
ignore
nlopt
::
opt
::
get_initial_step
;
%
rename
(
get_initial_step
)
nlopt
::
opt
::
get_initial_step_
;
// prepend "nlopt_" in Guile to substitute for namespace
#
if
defined
(
SWIGGUILE
)
%
rename
(
nlopt_opt
)
nlopt
::
opt
;
...
...
test/t_guile.scm
浏览文件 @
812fb556
...
...
@@ -25,7 +25,8 @@
(
myconstraint
x
grad
-1
1
))
1
e-8
)
(
nlopt-opt-set-xtol-rel
opt
1
e-4
)
(
define
x
(
nlopt-opt-optimize
opt
(
vector
1.234
5.678
)))
(
define
x0
(
vector
1.234
5.678
))
(
define
x
(
nlopt-opt-optimize
opt
x0
))
(
define
minf
(
nlopt-opt-last-optimum-value
opt
))
(
define
result
(
nlopt-opt-last-optimize-result
opt
))
(
display
"x="
)
...
...
@@ -34,3 +35,6 @@
(
display
"minf="
)
(
display
minf
)
(
newline
)
(
define
ini_step
(
nlopt-opt-get-initial-step
opt
x0
))
(
display
"initial step"
)
(
display
ini_step
)
test/t_python.py
浏览文件 @
812fb556
...
...
@@ -23,9 +23,11 @@ opt.set_min_objective(myfunc)
opt
.
add_inequality_constraint
(
lambda
x
,
grad
:
myconstraint
(
x
,
grad
,
2
,
0
),
1e-8
)
opt
.
add_inequality_constraint
(
lambda
x
,
grad
:
myconstraint
(
x
,
grad
,
-
1
,
1
),
1e-8
)
opt
.
set_xtol_rel
(
1e-4
)
x
=
opt
.
optimize
([
1.234
,
5.678
])
x0
=
[
1.234
,
5.678
]
x
=
opt
.
optimize
(
x0
)
minf
=
opt
.
last_optimum_value
()
print
(
'optimum at '
,
x
[
0
],
x
[
1
]
)
print
(
'optimum at '
,
x
)
print
(
'minimum value = '
,
minf
)
print
(
'result code = '
,
opt
.
last_optimize_result
())
print
(
'nevals = '
,
opt
.
get_numevals
())
print
(
'initial step ='
,
opt
.
get_initial_step
(
x0
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录