Using Microsoft Solver Foundation to solve a linear programming task requiring thousands of data points - linear-programming

Using Microsoft Solver Foundation,I am trying to solve a linear program of the form Ax <= b where A is a matrix containing thousands of data points.
I know that I can new up a Model object and then use the AddConstraint method to add constraints in equation form. However putting those equations together where each contains thousands of variables is just not possible. I looked at the Model Class and can not find a way to just give it the matrix and other info.
How can I do this?
Thanks!

You can make A a parameter and bind data to it. Warning: Microsoft Solver Foundation has been discontinued a while ago, so you are advised to consider an alternative modeling system.

Related

How to add attributes in combination of object detection using YOLO?

I'm new to computer vision and I'm wondering how to deal with the following problem.
I'm using YOLO for real time objet detection task. However I'm dealing with a dataset that gives me also few attributes such has weather, temperature etc...
(I'm obviously able to acces to those informations in real time, to use them in real life).
My data has some big differences depending of the weather, temperature etc... that's why it's useful to have access to those informations.
So is there any way to learn on both image dataset associated to a context ? I'm looking for something that is YOLO compatible.
If a such thing isn't compatible/doesn't exists, I guess I'll just do different versions of the trained YOLO on specifics datasets associated to different context. Each specific version will be actived only for specific weather and temperature.
Thank you in advance for any kind of help/informations.
You will need to build you custom model that combines visual features with tabular data. This could look something like:
vis_feats = nn.Linear(512, 1) # visual features
tab_feats = nn.Linear(4, 1) # tab features
x = torch.cat((x, tab), dim=1) # x goes into your prediction layer

infeasible row in Cplex C++

I have a small question; I am solving MIP Model , coded on C++ and solving by Cplex solver. I remember that when I test the model with relatively smaller instances , it was giving me "infeasibility row …."; Now ,I test the same model on a large size instance and I get the infeasibility and it does not tell me which row causes infeasibility. How can I find the which parameter or constraint causes infeasibility ? While the larger instance is tested, the presolve is performed, may it cause the infeasibility? I googled about conflict refiner but could not find a small and clear example explaining how to invoke it ? I will be very happy, if you have any suggestions or ideas
Thank you
Another way to find where the infeasibility comes is to export your model as an LP file or similar, then try to solve it with the standalone cplex. It helps if you name your variables and constraints sensibly. Then you have all the interactive tools in cplex to help you find where the issues are.
in C++ you should have a look at FeasOpt
In the documentation see
CPLEX > User's Manual for CPLEX > Infeasibility and unboundedness
If you model in OPL you could call the relaxation from concert C++ APIs

How to output the final tableau of simplex method in docplex?

Is there a way to output the final tableau in python with docplex library? If not, is there a work around?
I want to use dual simplex method to solve linear programming problem with newly added constraints. So, I would need to access the final tableau to decide which variable to exit the basis, without having to re-solve the problem from scratch.
This sort of low level interaction cannot be done at the docplex level. In order to do this you can use Model.get_cplex() to get a reference to the underlying engine object. With this you can then get additional information. You can find the reference documentation for this class here. You probably want to look at the solution, solution.basis, solution.advanced properties. This should give you all the information you need.
Note that the engine works with an index oriented model in which every variable or constraint is just a number. You can convert docplex variable objects by using Model.get_var_by_index().
I also wonder whether you may want drop docplex and instead directly use the CPLEX Python API. You can find documentation of this here.

Classification with machine learning and a small database

I want to create a valve detection and classification like this video : https://www.youtube.com/watch?v=VY92fqmSdfA
to detect the positions Open and close and intermediate of the valve.
I have done some research and I have found some methods to resolve this problem, but i have some conditions to respect to resolve this problem :
Condition 1 : Use machine learning in the application, I can't use simple methods like Template matching,...
Condition 2 : Use a small database (Minimum 10 images by classe, maximum 40 images by classe)
Condition 3 : detect the position of the valve if the camera position changes, so I can't use only colors to detect the valve handle.
I want to use HOG (Histogram oriented gradient) + SVM/ANN but HOG needs a lot of images to train SVM/ANN.
I dont know if I can resolve this problem respecting this conditions?
As we know, the most important thing that ML approaches need to work properly is data. So, I'd say your 1st and 2nd conditions are conflicting with each other. In addition, your 3rd condition is adding more complexity in the problem. You can solve it including more data from different angles and illumination conditions. But again, it's conflicting with condition 2.
Even so, if you'd like to follow the ML path, I'd recommend you to use a pre-trained model, a strong data augmentation and, maybe, an ensemble of models to help increase the detection. As the problem is not that hard, it should work.

Generate sequence of realized Cash flows from an IRS under a given scenario using QuantLib

I am new to quantlib, but I have relatively good understanding of C++. To put my question in some sort of context, I can inform you that I am actually trying to implement the portfolio CVA calculation method proposed by Giovanni Cesari (see link below) for a simple portfolio consisting of one interest rate swap (as a starting point).
I working with the Cheyette (quasi-Gaussian) interest rate model. The model has been implemented as a "new" stochastic process class and the simulated paths stored/generated as a multipath class.
However, as Cesari's method is based on LS-Monte Carlo, I need to write a code that can generate the resulting cash flow sequence from an interest rate swap under each scenario. I do not know if there is some efficient way to do this in quantlib, but I have a feeling that there is. I guess one should be able let the scenarios generated, populate Quantlib quotes which are linked to an instance of the quantlib term structures class. Hopefully I can use this together with the swap class in order to obtain the realized cash flows (basically the floating leg, as the fixed leg is deterministic) from the swap.
Any idea of how this can be done will be highly appreciated!
Link to Cesari's presentation (see page 21 to 26): http://sfi.epfl.ch/files/content/sites/sfi/files/shared/Swissquote%20Conference%202010/Cesari_talk.pdf