Is it possible to use Microsoft Visual Studio to build an UI for a CPLEX Optimization Model? - optimization

I'm currently building a timetable model on CPLEX O.S. My question is: is it possible to connect it to Microsoft Visual Studio in order to create an UI to let the user enter the initial data and parameters? Or maybe let Excel be the data input interface and then have a V.S built interface to load that file and begin the optimization problem? I would like to make it as easier as possible to optimize a timetable using the model I'm creating. I've been searching for it and found something called Concert Technology, not sure if this is what I need, still learning about it.

Yes, this is absolutely possible. If you're going to be using Visual Studio, the easiest option is probably to create a GUI application using .NET. Then, you can consume the CPLEX .NET API from within your application. Another option would be to use C++, but that would probably be considerably more complex. There's really no difference between calling CPLEX from a GUI application versus calling CPLEX from a console application. Usually you would add some logic to a button click event handler that would build the model in CPLEX, solve it, and gather the solution information. Take a look at the CPLEX User's Manual, CPLEX .NET Reference Manual, CPLEX C++ Reference Manual, and the many examples that are included with CPLEX when you install the software.

Absolutely, as Alex and rkersh already said. It is much much simpler than people expect to just write your application as you want it to be in C# or C++ (or any of the other supported languages). Then just use the CPLEX Concert API calls into the CPLEX library to build and solve your model and retrieve the answers. It won't make any difference to the performance of your model whichever language you use. Using the CPLEX API means that it is just like any other library. CPLEX is just software like any other.

there are many options:
You can write everything in C++ or C# with the CPLEX Concert API https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/GettingStarted/topics/tutorials/Cplusplus/cpp_synopsis.html
You may call OPL from C++ or C# with API https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.ide.help/OPL_Studio/usroplinterfaces/topics/opl_interf_intro_cpp.html
You may try VSTO : https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.6.3/ilog.odms.ide.help/OPL_Studio/usroplinterfaces/topics/opl_interfaces_work_integrateExcel.html
You may call OPL from Excel

Related

How integrate a linear programming solver like CPLEX in VB.NET?

I want to solve a linear programming model which is build through VB.NET. In this context I have following questions,
a) How to call a CPLEX or any such solver (Coin-OR) through VB.NET?
(While doing so I do not want CPLEX window to be opened. i.e. It should solve it in the background.)
b) How to transfer the LP model to CPLEX? (Again I want to stay away from opening a new window and then write the model to CPLEX)
VB.NET understanding: Intermediate
Thanks
Microsoft Solver Foundation provides a plugin for CPLEX, and there are samples that shows both how to invoke the CPLEX plug-in and how to call MSF from VB.NET. You can download the standard MSF library from here.
CPLEX can be used in VB.NET through the CPLEX/Concert .NET API which is a standard API supplied with the solver and is pretty straightforward to use. There is a good documentation available including this example and this tutorial. Examples are in C# but should give you the idea how to use the API in any .NET language.
You could also use MS Solver Foundation but it incurs additional costs and the product is discontinued.

VB6 Parser/Lexer/Scripter

I've got a game in VB6 and it works great and all, but I have been toying with the idea of creating a scripting engine. Ii'm thinking I'd like VB6 to read in flat text script files for me and then lex/parse/execute them.
I have good programming experience, and I've built a simple C compiler, as well as a LOGO emulator before.
My question is:
Are there any tools that I can use, like Lexx/Yakk/Bison to help me? How should I approach this problem in regards to lexing, parsing, and feeding the commands back to VB6 so I can handle them? Is this idea a BAD IDEA in the sense that there are too many obstacles in the way (For example, building minesweeper in assembly, though not impossible, is very difficult, and a bad idea.)?
Use the Microsoft® Windows® Script Control because it is easy to integrate into existing VB6 applications. The control supports VBScript, JScript, or any other "Active Script" implementation.
I have used the Windows Script Control in four projects and it works extremely well. Very easy to integrate. I wish Microsoft would have given us a replacement in .NET, and made it as easy to use. (I understand the control is not needed in .NET, but having the ability to simply create an object that handles everything is nice.)
Windows Script Control
The Microsoft® Windows® Script Control
is an ActiveX® control that provides
developers with an easy way to make
their applications scriptable. This,
in turn, enables users to extend
application functionality through
scripts, much as they do with macros
today.
INFO: Where to Obtain the Script Control at http://support.microsoft.com/kb/184739. Includes links to other howto support articles.
Chapter 13: Adding Scripting Support to Your Application at http://msdn.microsoft.com/en-us/library/aa227413(VS.60).aspx
Designing a Calculator at http://msdn.microsoft.com/en-us/library/aa227421(VS.60).aspx
How To Use Script Control Modules and Procedures Collections, Inserted from http://support.microsoft.com/kb/184745
How To Use the AddObject Method of the Script Control, Inserted from http://support.microsoft.com/kb/185697
SAMPLE: SCRIPTEX.EXE Uses the ScriptControl with Visual Basic, Inserted from http://support.microsoft.com/kb/189484
Windows Script Control can be downloaded at http://www.microsoft.com/downloads/details.aspx?familyid=d7e31492-2595-49e6-8c02-1426fec693ac&displaylang=en. (Supported Operating Systems: Windows 2000; Windows 98 Second Edition; Windows ME; Windows NT; Windows Server 2003; Windows XP)
MSDN Search of "MSScriptControl.ScriptControlClass" at http://social.msdn.microsoft.com/Search/en-US?query=%22MSScriptControl.ScriptControlClass%22&ac=8
MSDN Search of "Windows Script Control" at http://social.msdn.microsoft.com/Search/en-US?query=%22Windows+Script+Control%22&ac=8
MSDN Search of "MSSCRIPT" at http://social.msdn.microsoft.com/Search/en-US?query=MSSCRIPT&ac=8
Unless you're doing it for your own instruction, you may want to try using Lua: VB6 - Lua Integration
If you're willing to use VBScript rather than VB6 you might be able to just use the MSScriptControl to run the commands rather than creating your own. Here's an article discussing using it from a .Net app, though it's an ActiveX control so should give you quite a bit of flexibility.
The control can be downloaded from here.
I've actually seen some quite reasonable implementations of compilers/interpreters in VB6[1] - It's not the language I would choose (few functional features, insufficent static type system), but with experience, you can outweigh these drawbacks and be quite productive - So why not.
You can use the GOLD parser generator that supports VB6 as a start.
[1]: Somewhere on PSC or in this download repository I think ...
Note that there is the MSScriptControl too.
There also appears to be an additonal alternative for VB6:
SadScript is an variant of VB6 most prominently used for VB6 as an scripting engine in MMORPGS .
See here for more : What is sadscript? Can I use it in vb.net? Why hasn't anyone I have asked heard of it?

Active X Development: VC++ or VB or Other technologies

We are in the process of creating active-x controls used within our application.
Since Microsoft stopped supporting classic Visual Basic, is it wise to use Visual Basic to develop the Active X control or the latest VC++/ATL/MFC libraries provide more feature where we can create controls faster by leaving Visual Basic flexibility?
We will not be able to use .NET/VB.NET/C# since the application is supposed to work inside containers and containers may not support latest .NET runtime.
Any other language is best fit for Active X control development other than VB and VC++?
I, personally, would recommend using Delphi for this. It is still actively developed, and has the control you get with C++, but a rapid development environment more like VB.NET.
#nobugz: If you are really interested what is ActiveX in Delphi, look at docwiki. Normally it is 100% source code (yours + VCL, VCL is also available as sources) with autogenerated COM wrappers. So all potential security problems are also in source code. If you find a security problem in VCL, please send a bug report to Quality Central.
Here is a good example on how to create ActiveX Controls with C# .NET
http://www.codeproject.com/KB/cs/CreateActiveXDotNet.aspx
By all means VB6 is the best language. After reading your question I feel that you are a VB6 developer. If you know VB6 and use it then why hesitate using it for producing ActiveX controls.
I program in Delphi as well as VB6 along with VB.NET and C# but creating ActiveX controls is the easiest in VB6 compares to all other development tools.
If you are hell bent on not using VB and if you are looking for an alternative then try out PowerBasic (commercial - very costly) or PureBasic (commercial but affordable) Get it from here or better still MinGW (a GNU C++ compiler).
I have to say that VB6 with a good book like Developing COM/ActiveX Components with VB6: A Guide to the Perplexed you will be up and running faster.

VBx Language, What is this?

In Ironpython site exists references to a language called VBx using DLR. But i can't find any reference to this in google. Where is it?
Edit: Is a Implement of Visual Basic 6.0 in DLR? if yes is so cool. Is more expected for people using VB6 yet and can't migrate because big frameworks.
From this mailing list post:
VBx was an implementation of Visual Basic on the DLR. It was first meant
to be in Silverlight, but the VB team decided they'd rather put VB.NET in
Silverlight rather than build a new implementation up from scratch. So, VBx
is on hold.
Apparently it's an implementation of VB in the DLR:
http://www.mail-archive.com/users#lists.ironpython.com/msg05933.html
Straight from the mouth of Paul Vick (long time VB architect)
What is VBx?
VBx was one of the four language implementations that were originally driving the design of the DLR, the other three being IronPython (from which the DLR was extracted in the first place), IronRuby and Managed JavaScript.
VBx was intended to be a dynamic version of Visual Basic.NET or a .NET version of Visual Basic 6, whichever way you want to look at it. It was primarily intended as a testbed for the flexibility of the DLR, secondarily as a testbed for a more dynamic version of VB.NET and tertiarily (is that a word?) as a scripting language for Silverlight. It has fulfilled its primary goal and the designers of VB.NET decided that they want to pursue goals two and three within the existing VB.NET language, rather than producing yet another slightly different incompatible version of VB. (You already have VB.NET, VB, VBA and VBScript.)
Managed JavaScript was also abandoned, the team was folded into the IE team and is responsible for the ECMAScript 5 engine in IE 9.

Can JScript.NET be used to script a .NET application?

Since MS appears to have killed Managed JavaScript in the latest DLR for both server-side (ASP.NET Futures) and client-side (Silverlight), has anyone successfully used non-obsolete APIs to allow scripting of their application objects with JScript.NET and/or can explain how to do so? A Mono/JScript solution might also be acceptable, if it is stable and meets the requriements below.
We are interested in upgrading off of a script host which uses the Microsoft JScript engine and ActiveScript APIs to something with more performance and easier extensibility. We have over 16,000 server-side scripts weighing in at over 42MB of source, so rewriting into another scripting language is out of the question.
Our specific requirements are:
Noteably better performance than the Microsoft JScript (ActiveScript) engine
Better runtime performance and/or
Retention of pre-parsed or compiled scripts (don't reparse on every run)
Lower or equal memory consumption
Full ECMA-262 ECMAScript compatibility
a little porting can be tolerated
Injection of custom objects into the script namespace
.NET objects (not a hard requirement)
COM objects or COM objects wrapped in .NET
Instantiation of COM objects from Script
à la "new ActiveXObject(progid)"
Low priority given the preceeding
Include files
Pre-loading of "helper scripts" into a script execution context
An "include" function or statement (easy to create, given the above)
Support for code at global-scope
Execution of code the global scope
Retention of values initialized at global scope
Extraction of values from the global scope
Injection and replacement of values at the global scope
Calling of script-defined functions
with parameters
and with access to the previously initialized global scope
Source-level debugging
Commercial or Open Source Support
Non-obsolete APIs
I answered a similar question here. Have a look at IronJS, an implementation of JavaScript in F# running on the DLR.
Sooner or later, I imagine someone will write a DLR Javascript. I know that's not very convenient for you right now, but maybe you could start the project. I suspect it would have a better cost/benefit analysis to using JScript.NET.
If moving away from .NET and Microsoft is ok for you then you should try Mozilla's Rhino. It is an open-source implementation of JavaScript written entirely in Java. Alot of modern server side js libraries target this platform.
I have used CSScript.net as it will allow you to run C# as a scripting platform. From the site:
CS-Script combines the power and
richness of C# and FCL with the
flexibility of a scripting system.
CS-Script can be useful for system and
network administrators, developers and
testers. For any one who needs an
automation for solving variety of
programming tasks.
CS Script satisfies all the conditions that you laid out. I have used it in production as a substitute for Boo it has performed really well. You can see it in action here.
The use of Com interop means you are limited to an MS solution Java and Opensource want as little as possible to do with it.
I dont see any solution that supports all your requirements either you ditch all the COM/.NET stuff and go Java (Rhino) /Linux/Open source or you question the use of Javascript as your server language even in the Linux world we use PHP/Python/Ruby more on the server if we cant run Java. Your not going to see big performance gains with Java script as the language is the main barrier.
I wouldnt count on people writing a new DLR as server Java script is dying fast.
Considering you want performance ,what about F# , Microsoft will keep the Jscript engine supported for at least 5 years giving you time to create new stuff in F# while you slowly migrate the code.
Have you seen ROScript?
http://www.remobjects.com/script.aspx
Supports both PascalScript and ECMAScript (Javascript) syntax
The Jurrassic-Engine is alive and kicking.
From their codeplex site:
Supports all ECMAScript 3 and ECMAScript 5 functionality, including ES5 strict mode
Well tested - passes over five thousand unit tests (with over thirty thousand asserts)
Simple yet powerful API
Compiles JavaScript into .NET bytecode (CIL); not an interpreter
Deployed as a single .NET assembly (no native code)
Basic support for integrated debugging within Visual Studio
Uses light-weight code generation, so generated code is fully garbage collected
Tested on .NET 3.5, .NET 4 and Silverlight