GLOP - Google OR Tools - choose simplex method - c#

I am using the default linear solver in GLOP (which I believe is dual-simplex) and getting ABNORMAL result.
I'd like to use normal simplex instead (as this post describes - https://github.com/google/or-tools/issues/1868) but I don't know how to change this setting. How do I change the solver? (Using C# by the way)

Laurent gives the correct steps above. Here is the practical code to create these parameters and pass to solver (if anyone is interested):
var Params = new Google.OrTools.LinearSolver.MPSolverParameters();
Params.SetIntegerParam(MPSolverParameters.IntegerParam.LP_ALGORITHM, (int) MPSolverParameters.LpAlgorithmValues.PRIMAL);
Solver.ResultStatus solved = solver.Solve(Params);

You need to change the parameters of the solver.
The class is here: http://google.github.io/or-tools/dotnet/classGoogle_1_1OrTools_1_1LinearSolver_1_1MPSolverParameters.html
You need to change the integer parameter http://google.github.io/or-tools/dotnet/classGoogle_1_1OrTools_1_1LinearSolver_1_1MPSolverParameters.html#a3b8427a9f4368fd831af8f8c61fb823c
The parameter to change is http://google.github.io/or-tools/dotnet/classGoogle_1_1OrTools_1_1LinearSolver_1_1MPSolverParameters.html#a7319655592ea63d50ef2a6645e309784
the value to assign is http://google.github.io/or-tools/dotnet/classGoogle_1_1OrTools_1_1LinearSolver_1_1MPSolverParameters.html#a79b59c0c868544afdaa05d89c8f8541f

As per the current documentation (see the last row of the table here), it actually seems that the default mode is primal simplex, so that is what one would have if they did not set anything. You'd have to explicitly set parameters to make it work with dual simplex.

Related

Find Critical Chi Square Value using MathNet.Numerics

So I want to get Critical Chi-Square Value using Significance level and Degrees of Freedom. I tried using MathNet.Numerics but couldn't find which method to use to get the Critical Chi-Square Value
This was the documentation I'm referring, any help on redirecting me to correct documentation would help.
How I calculate the value in Excel is by using the formula =CHISQ.INV.RT(A2,B2)
The function you require is InvCDF(), it is used as follows:
MathNet.Numerics.Distributions.ChiSquared.InvCDF(degreesOfFreedom, probability);
I could finally solve this problem, so I want to share how I solved it.
I used the MathNet library, and to use the same function of Excel you are providing you have to keep in mind a few things: in this library it does not exist =CHISQ.INV.RT itself, instead, in C#, you need to use InvCDF (the equivalent of =CHISQ.INV in Excel) but instead of using a probability parameter like 0.05, you have to use the opposite part of the interval (0, 1), so that parameter should be 0.95.
The logic of this is in the description of the functions in Excel.
"CHISQ.INV" description says "Returns the inverse of the left-tailed probability of the chi-squared distribution", this one is the equivalent of ChiSquared.InvCDF (C#).
"CHISQ.INV.RT" description says "Returns the inverse of the right-tailed probability of the chi-squared distribution", this one DOES NOT exist in the MathNet library.
Example:
In Excel you write
=CHISQ.INV.RT(0.05, 9)
In C# you write
ChiSquared.InvCDF(9, 0.95);
In both cases the answer will be 16.9189776
Note that the order of the parameters are switched.
I hope I could help with this.

Calling NvAPI_GPU_SetEDID on Nvidia card

How do you call this method on Nvidia GPU:
NVAPI_INTERFACE NvAPI_GPU_SetEDID (
NvPhysicalGpuHandle hPhysicalGpu,
NvU32 displayOutputId,
NV_EDID * pEDID
)
Src: http://docs.nvidia.com/gameworks/content/gameworkslibrary/coresdk/nvapi/group__gpu.html#ga6a41b31dd9743120213435d985f8fbcf
I need to execute the above command to remove all EDID set on all DisplayOutputs on our new Quadro Graphics Cards. Based on the API documentation, I tried searching for NvPhysicalGpuHandle and came across this project/library:
https://github.com/openhardwaremonitor/openhardwaremonitor/blob/master/Hardware/Nvidia/NVAPI.cs
This does not have the method I need NvAPI_GPU_SetEDID
I am not hardware programmer, I just need to be able to call this one command. any ideas? Can this be achieved using nvapi.dll/nvapi64.dll via pinvoke or something?
I personally didn't test this, but you can try the library and see if it can set EDID information without any problem, if it fails, please open an issue.
https://github.com/falahati/NvAPIWrapper
Here is how you should do it,
First, you need to find the right DisplayDevice or GPUOutput that you want to write EDID information to. There are multiple ways to do so.
Get a list of all PhysicalGPUs in the system using the NvAPIWrapper.GPU.PhysicalGPU.GetPhysicalGPUs() static method, then select the PhysicalGPU you desire based on your logic. After finding the right PhysicalGPU, use the NvAPIWrapper.GPU.PhysicalGPU.GetDisplayDevices() method to get a list of all connected DisplayDevices to that GPU and store the right one in a variable.
Instead of searching for connected DisplayDevices, you can also go for the GPUOutputs. Just like before, you first need to find the right PhysicalGPU and then you can get a list of all GPUOutputs using the NvAPIWrapper.GPU.PhysicalGPU.ActiveOutputs property and store the right GPUOutput in a variable.
Another way to find the right DisplayDevice is to go for a list of all Displays. To do so, you need to use the NvAPIWrapper.Display.Display.GetDisplays() static method. This returns an array of Displays. Then using the NvAPIWrapper.Display.Display.DisplayDevice property, you can get the corresponding DisplayDevice of a Display.
After finding the right DisplayDevice or GPUOutput, you should use the NvAPIWrapper.GPU.PhysicalGPU.WriteEDIDData() method. This method allows you to write EDID data stored in a byte array to the DisplayDevice or the GPUOutput you selected before.
Note: Make sure to capture NVIDIAApiException and check for the NVIDIAApiException.Status property in case something went wrong.

Z3 in C#, Only getting 1 result

I am using z3 in visual studio and I want to do a simple check with the following
x > 3
After I run my code, I only get one result back in my model. Why do I only get one result back and how would I do model completion in C#?
Z3 is a satisfiability solver (the S in SMT), i.e., it checks whether there is 1 assignment that satisfies the formula. It can compute sets of solutions in some special cases and if the problems are set up the right way, but without further details I can't tell whether any of this would apply to your problem.
Of course, after getting one satisfying assignment you can add a new constraint that forces the assignment you just got is excluded and then get a new assignment.

How to get Test variable through custom code in HP UFT - ApiTest

I want to set value to the Test Variable using Custom Code.
Can you tell me how to do it as i am not able to access the variable from code.
I need to access the User Variable URL in my custom code and set the value.
Please help me if you know how to do it using Custom Code.
Thanks,
Madhan
Based on your question:
1. Click on File menu and then Settings, it will open Properties pane.
2. Click on "+" to add user variable and give a name.
3. In your custom code, type below code:
string s = "https://www.google.com/";
this.Context.TestProfile.SetVariableValue("NameOfYourVariable",s);
To retrieve the value of given variable:
string ss = this.Context.TestProfile.GetVariableValue("NameOfYourVariable");
CodeActivity5.Report("Variable is : ", ss); //(This line will print your variable value)
answer provided here is valid when the need is to set string values. The "SetVariableValue" method takes two "String" type parameters. This limits the ability to set Int32 type variables. Obviously, C# throws an error when trying to set an integer value.
Now, an integer value is particularly useful while setting values for loop iterations. I am not sure whether this is a limitation of the tool or whether my lack of knowledge. So, to work around this, i used the output property of custom code activity. To do this, create a custom code activity and create an output property of the desired type, say Int. Now, assign a value to this output property using the line:
this.ActivityName.Output.property name = property value
This is available in UFT help and can be useful while trying to pass values other than string between different activities in a flow.

Why does element.getAttribute("style") ignore everything after the colon ":" character? Returning part of the value only

Basically, I have my DOM objects set up and am calling the .getAttribute method on an IMG element that is defined as below:
<IMG style="WIDTH: 134px; HEIGHT: 75px;" src="...">
Assuming hElement is the object reference to above element, when I call the following:
MsgBox hElement.getAttribute("style")
I get the following returned: "WIDTH" only, ie: part including and after the : character is ignored. To add to this, if I do a hElement.getAttribute("width") on the IMG element, it returns the actual width as "134" even though I don't explicitely have a width="..." attribute defined. So, basically, I am asking, how can I ensure I get back things as they are written, and not as they are reconstructed and stored by IE, as that is what it seems to be doing with the inferred WIDTH attribute. Also, not sure why it is ignoring everything including and after the : character right next to the WIDTH - how can I make this work properly?
Odd thing is, if I do the following, it shows everything as it should be:
hElement.outerHTML
The style attribute's value is shown as defined above. If I have to parse .outerHTML in order to get correct readings, that is just going to be depressing - I'm really disappointed in MS's half baked efforts. If you're looking for something extra to read, feel free to refer to another issue I noted about attributes returning odd behaviour when using capitals and when not (solved through a hack).
I'm using VB6, but it is all just the same, mshtml.dll, I gather, I am using IHTMLElement to define the hElement, not sure if I should be using something else but I think IHTMLElement is good for IE6+...?
UPDATE:
If I declare the hElement as IHTMLElement5 or IHTMLElement6 then it WORKS AS EXPECTED. If I use any of the following, it doesn't work: IHTMLElement, IHTMLElement2, IHTMLElement3 and IHTMLElement4. Since it only goes up to 6, only 5 & 6 work. It seems as though these are added later for newer versions of IE, and although you don't see the .getAttribute object in intellisense in 2 and above, you can still use it for some reason (not sure if its based on what IE version is installed). Does anyone know what version of IE IHTMLElement5 and IHTMLElement6 stands for? How can I get consistent behaviour for IE6+ as I don't have control on what versions are installed on the clients. If I use IHTMLElement5 or IHTMLElement6 does this mean it will not work on IE6 clients?
More:
Turns out IHTMLElement5 is for IE8+ and IHTMLElement6 is for IE9+ - any ideas or recommendations on how to get consistent behaviour for IE6+? Thanks.
UPDATE2: I have added a new question, which spawns from this question, it can be found here for those interested:
What happens when using IHTMLElement5/6 (for IE8/9) in IE6/7? Does it divert to IHTMLElement behaviour?
You might wanna take a look at this http://robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/
SO in your case you should try using the cssText property which will return a string consisting of all the css properties
hElement.style.cssText
Flags are not supported anymore? http://msdn.microsoft.com/en-us/library/ms536429%28v=vs.85%29.aspx
However, this works:
styleContent=hElement.style.cssText;
It seems, that getAttribute('style') returns an object instead of the value of the attribute, since the code below works too.
styleContent=hElement.getAttribute('style').cssText;

Categories