Results 1 to 6 of 6

Thread: Nonlnear optimization in Qt

  1. #1
    Join Date
    Mar 2010
    Posts
    77
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Nonlnear optimization in Qt

    Hello!
    Introduction:
    I'm new here and pretty much a newbie when it comes to both Qt and C++ in general. Qt Creator however seems very structured and a good way to build a GUI application with limited experience.

    My problem:
    Now to the reason I'm posting. I want to build an application that gets some raw data from an external source, make a nonlinear optimization calculation and plots out the result as a mark in a linediagram. My goal is that it should do this at least 10times/second.
    The plotting diagram will look something like the one in this video.
    YouTube-clip

    I have made the whole optimization-function in GNU Octave (Matlab-like environment) .m-script and was hoping that it would be easy to call from a C++ program. However it seems harder than I thought. it may only work under Linux and then maybe it won't be able to communicate with Qt?
    I 'm not sure what I'm doing so if someone could take a glance at the link below and verify whether or not this kind of code is possible in the Qt-Creator IDE I would be very grateful!
    OctaveWiki about calling m-files from C++

    If it is not possible/very hard, is there any nice tools that might be suitable for nonlinear optimization that play nice with Qt?

    Have a fantastic day!
    /Tottish

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Nonlnear optimization in Qt

    What exactly do you mean by the octave program "communicating" with Qt?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Nonlnear optimization in Qt

    Whatever works for C++ works for Qt too. Qt IS C++. You write C++ code and you use the Qt libraries, that's all there is to it. A quick glance on that link you posted tells me that calling an octave function in an m-file from C++ means only including the octave headers and using the functions they provide. There is nothing Linux specific about this, so why wouldn't it work on Windows? Plus there is always cygwin for Linux sort of needs. Is it so hard to implement your optimization algorithm in C++ though? You might want to check out Qwt btw.

  4. The following user says thank you to Cruz for this useful post:

    Tottish (31st March 2010)

  5. #4
    Join Date
    Mar 2010
    Posts
    77
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Nonlnear optimization in Qt

    Ooops! I thought I was getting an Email when this thread was updated, now I see I have to fix that in thread tools... sorry for the late answer.

    "Whatever works for C++ works for Qt too."
    Thank you for that clarification. I wasn't sure that it was that simple. Of course I haven't missed that Qt is a C++ environment but I wasn't sure about the compilers being used and if what works with one compiler necessarily does it with another. Again, thank you!

    "so why wouldn't it work on Windows? Plus there is always cygwin for Linux sort of needs."
    I don't know. All the info I found about it was in a Linux environment so it got me wondering. I fooled around a bit with cygwin too but never got it to work properly. Now I've got an Ubuntu machine running where I can follow the few examples I find step by step.

    "Is it so hard to implement your optimization algorithm in C++ though?"
    I'm not sure but since I already have the octave script I figured I might as well use it since it took a while to write. When I run it in octave it's fast enough so I hope it won't be much slower to call from C++. Should I expect any extra delay?

    "You might want to check out Qwt btw."
    Already did and rest assured that's the one for my ploting! =)


    OK, so now I just need to get the example from the wiki I linked to to work and go from there, I suppose.
    Can't get it to work at all but I guess I should post this in the noob forum since this most probably is a very basic problem. The reason I posted this here is that I figured the other noobs probably wasn't into nonlinear optimization. =)

    Anyway, Thank you very much! Especially for "Whatever works for C++ works for Qt too.". Now this is possible.
    Good afternoon!
    /Tottish

  6. #5
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Nonlnear optimization in Qt

    Definitely this should work. Also good to leverage your Octave script. There shouldn't be much overhead calling it from C++. Many people think their algorithm would speed up if implemented in C++ (from Matlab/Octave), but often the reverse is true. Matlab at least has some incredibly well optimized routines, that will be very hard to beat. Post an update if you can't get it to work, but it does look fairly straightforward. You will need the include path set so it can find the octave header, and then likely the link path as well so it can find the octave library (docs should tell you where that is).

  7. #6
    Join Date
    Mar 2010
    Posts
    77
    Thanks
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Nonlnear optimization in Qt

    Hey!
    That's great to hear!
    As I said I'm very much a noob so I started a thread in my proper element. =)
    noob-forum-thread
    Check it out if you've got the time to help me out on cracking this nut!

    Cheers!
    /Tottish

    Edit: Scroll down to last post for sourcecode

Similar Threads

  1. g++ optimization
    By Krish_ng in forum Qt Programming
    Replies: 6
    Last Post: 31st August 2012, 09:01
  2. QT optimization
    By shiranraviv in forum Qt Programming
    Replies: 3
    Last Post: 9th February 2010, 18:57
  3. QTextEdit optimization
    By kib2 in forum Qt Programming
    Replies: 12
    Last Post: 6th November 2007, 22:28
  4. Application optimization - Where to begin?
    By Tux-Slack in forum General Programming
    Replies: 2
    Last Post: 19th October 2007, 01:38
  5. Qt g++ optimization
    By Krish_ng in forum Qt Programming
    Replies: 8
    Last Post: 2nd August 2007, 08:20

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.