只是我或Cplex Concert API可以使用一些改进吗?

编程入门 行业动态 更新时间:2024-10-07 10:24:58
本文介绍了只是我或Cplex Concert API可以使用一些改进吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 附录:我认识到这个帖子似乎是以一种ran the的形式出现的,但是如果你能纠正任何误会,澄清一切,还是更好一点:帮助我解决我的问题与迭代器问题,我会很感激!我正在使用cplex 9(我知道这不是最新的,这不在我手中)。

只是我或CPLEX Concert API可以使用一些改进?说这个很有意思的话会在我目前的意见中表现出来,因为它似乎违反了我曾经遇到过的高质量C ++ API设计的所有惯例。

注意事项:

  • const setter方法
  • operator []返回参考句柄对象而不是引用
    • operator [] const返回不是const的引用句柄,导致潜在错误。
  • 没有数组迭代器(即使迭代器对于并行编程并不好,在我看来仍然可以使用不太关键的代码)
  • 极端开发者对STL用户的敌意,希望混合两者(或者如果不是STL,至少代码本身已经是STL兼容的,像Boost)。
    • 示例:在数组类中不是一个typedef,甚至(绝对最低)绝对最小)value_type。

我做了一个数组包装器,很简单。我做过的迭代器包装器,不是那么多。由于前两点,迭代器(当前)会导致编译时不应该的代码!我还在试图找到一个方法(我使用boost.iterator_facade)。

不要误会我,我明白权衡需要在设计API时要做。我相当清楚,API旨在简化手册(隐藏与我想象的用户的语言相关的注意事项)。然而,在这样做的同时,虽然可能简化了C ++ API的设计,但是它使我的代码写入更加复杂和耗时,以弥补我目前认为是设计错误。

在罗马,做罗马人!

我很乐意听到他们关于这些观点的设计决策的理由。 >

编辑:我已经设法让我的Iterator类工作,在处理中消除了与cplex对象中的迭代器相关的使用方面的许多角色可用性和正确性缺陷以一些性能为代价(克隆可解压缩文件,从const_iterator返回之前)。离开(我相信)只剩下第一个显着的缺陷,如果在cplex api中每个受影响的类型都没有额外的间接层次,就无法纠正。不用担心,我只需要小心呼叫的频率取消引用IloExtractable派生类型的const_iterators。

解决方案

不是这样会帮助你很多,但是当我切换时我不敢相信改进从CPLEX 9到12,它出来使用,因为12是免费的学术用途。

Addendum: I realize this post appears to take the form of a rant, but if you could correct any misunderstandings I have, clarify anything, or better yet: help me solve my problem with the iterator issue, I'd be very grateful! I'm currently using cplex 9 (I know it's not the latest, it's out of my hands).

Is it just me or could the CPLEX Concert API use some improvement? Saying that it leaves much to be desired would be putting it kindly in my current opinion, as it seems to violate just about every established practice for quality C++ API design that I've ever come across.

Notables:

  • const setter methods
  • operator[] returning reference handle objects instead of references
    • operator[] const returns reference handles that aren't const, leading to potential errors.
  • no array iterators (even though iterators aren't great for parallel programming, it should still be available for use by less critical code in my opinion)
  • extreme developer-hostility for users of the STL who wish to mix the two (or if not the STL, at least code that is itself already STL-compatible, like Boost).
    • example: not a single typedef in the array classes, not even (at a bare and absolute minimum) value_type.

I made an array wrapper, that was easy. An iterator wrapper I've made, not so much. Because of the first two points, the iterator (currently) results in code that compiles when it shouldn't! I'm still trying to find a way around it (I'm using boost.iterator_facade).

Don't get me wrong, I understand that trade-offs need to be made when designing an API. It's fairly clear to me that the API was designed to simplify the manuals (hiding language-dependent considerations from the user I imagine). In doing so however, while it may have simplified the designing of the C++ API, it has made my code-writing more complex and time-consuming to make up for what I currently deem to be design errors.

When in Rome, do as the romans!

I would LOVE to hear the rationale for their design decisions concerning these points.

Edit: I've managed to get my Iterator class to work, in the processing eliminating as many of the corner-case usability and correctness flaws with respect to usage through iterators in cplex's object-passing design as I could, at the cost of some performance (cloning extractables before returning them from a const_iterator). leaving (I believe) only the first notable flaw remaining which can't be corrected without an extra layer of indirection around every affected type in the cplex api.. no thanks, I'll just have to be careful of the frequency of calls when dereferencing const_iterators of IloExtractable-derived types.

解决方案

Not that this will help you much but I could not believe the improvements when I switched from CPLEX 9 to 12, it worked out for use since 12 is free for academic use.

更多推荐

只是我或Cplex Concert API可以使用一些改进吗?

本文发布于:2023-11-02 06:20:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551603.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可以使用   Cplex   Concert   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!