如何在约束下以图形方式定义参数值?
我试图弄清楚是否可以实现以下 Mathematica 接口。
我想在 Mathematica 中创建一个界面,用户可以在受约束的情况下以图形方式和交互方式定义任意数量的数值参数。
问题中的参数是数字权重[0,1]
,每个权重都与相应的标准相关联,并且限制为总和为一。显然,这个约束导致了与每个标准相关的权重的权衡,我想通过沿着下面的线绘制一个交互式图(不幸的是,在 Excel 中制作),以图形方式使这种权衡变得明显:
在这个例子中,有 6 个标准,但我想将其概括为任意数字(例如 2 到 7 之间)。
该界面的工作原理是沿着相应的轴拖动每个多边形顶点(对应于特定的权重),并让其他顶点均匀调整,使它们的总和始终为 1。
然后返回数值以用于后续计算。
我环顾四周,似乎找不到有同样问题的人(搜索查询的定义可能并不简单)。
我在 Mathematica 的示例中发现的最接近的东西是定位器窗格的以下应用,其中允许在正方形上移动 3 个点并返回它们的位置:
DynamicModule[{pt = {{1, 1} /2, {-1, 1}/2, {1, -1}/2}}, {LocatorPane[ 动态[pt],图形[{灰色,磁盘[]}]],动态[pt]}]
I'm trying to figure out whether it's possible to implement the following Mathematica interface.
I would like to create an interface in Mathematica whereby the user would be able to define graphically and interactively an arbitrary number of numerical parameters, subject to a constraint.
The parameters in questions are numerical weights [0,1]
, each associated to a corresponding criterion and constrained to summing to one. Obvously, this constraint induces a trade-off to the weights that can be associated to each criterion and I wanted to make such trade-off evident graphically, by having an interactive plot along the line of what follows (made in Excel, unfortunately):
In this example, there are 6 criteria, but I would like to generalize that to an arbitrary number (between 2 and 7, for instance).
The interface would work by dragging each of the polygon vertices (corresponding to a specific weight) along the corresponding axis, and having the others adjust uniformely so that they always sum to 1.
The numerical values would then be returned to be used in subsequent computations.
I have looked around and do not seem to be able to find someone who had the same problem (the definition of the search queries is non-trivial, probably).
The closest thing I've found among Mathematica's examples is the following application of the locator pane, where 3 points are allowed to be moved on a square and their position is returned:
DynamicModule[{pt = {{1, 1}/2, {-1, 1}/2, {1, -1}/2}}, {LocatorPane[
Dynamic[pt], Graphics[{Gray, Disk[]}]], Dynamic[pt]}]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许是这样的:
Perhaps something like this:
也许像这样的
屏幕截图:
Maybe something like this
Screenshot: