I am solving an Integer program model with SCIP and I need to store the objective function value. I was wondering how I can get the objective function value after solving the IP model? can someone help me?
You can use SCIPgetPrimalbound() to get the best solution value.
Also, in the interactive shell the column "primalbound" will show the current best solution value and after the optimization process stops the primlalbound is also stated.
(Note, you might want to check whether a solution was found.)
If your problem is infeasible it 10^20 (SCIPs infinity value) is printed.
(If you want to see the objective function value and the solution values of each variable, you can enter display solution in the interactive shell, which will show all non-zeros solution values and the objective function value.)
See also http://scip.zib.de/doc/html/SHELL.php .
Hi does anybody know if is possible to utilise formulas containing complex numbers within basic programming. Part of the formula im trying to implement is i(e^2-e^2-2), e represents exponential and i the imaginary number. Any help appreciated.
Add a reference to the System.Numerics library to your project (Go to MyProject->References->Add->Assemblies->Search the list for System.Numerics). You can also import the namespace in your source by using Imports System.Numerics.
In this library you can find functions to compute complex numbers.
You define a complex number for example with the line
Dim MyComplex as New Complex(Realpart, ImaginaryPart)
To compute the exponential you would use
Dim Exped as Complex = Complex.Exp(MyComplex)
and so on. There are functions for most operations and the complex numbers support general operators like +, -, *, / as well.
For your specific problem you would just use
Dim result as New Complex(0, Math.Exp(2)-Math.Exp(2)-2)
This works because i*x is a complex number with a real part of zero and an imaginary part of x. I'm not judging how much sense your definition makes :-)
I'm modeling some financial products and each product has his own pricing formula.
In the application I would like to allow the end-user create his own product with the formula. And this formula can be used by my application to price the product.
Something like :
Formula as string = "f(x) = x * 2"
Dim Result as double = call(Formula, 1)
I know this is possible in Matlab :
f="#(x)(x*2)";
Result = feval(f,1);
I wrote a class in Matlab that implements this feature and integrated it in VB.Net project, but every function takes 4700 times the execution of the same function directly written in VB.Net which is not affordable regarding the business need.
Is that possible in .Net ?
You can look into MEF, so your end users would provide DLL modules in a certain format (see the link I mentioned), which would later be discovered in your program and executed at any given time.
Or use a math parser:
VB.Net- Evaluating Mathematical Expression in a String
Evaluate mathematical expression from a string using VB
But I feel that approach #1 would be more flexible.
I'm trying to figure out if there's a way in mathematica where I can solve for particular variables when given other variables and a set of equations. Essentially there are 6 variables, and I'm given 3 of them and have to calculate the others using these equations-
Variables-
B,Qs,f0,R,c,L
Equations-
f0=1/(2*Pi*Sqrt[L*c])
Qs=(w*L)/R
w=2*Pi*f0
B=f0/Qs
We are given the values of any 3 of those variables and have to figure out the rest using those values.
I was thinking perhaps using Eliminate but I'm not sure exactly how that would be structured as I've only used it previously with set variables that don't change and a single output.
When using the Solve function with Mathematica, you can specify for what variables you want Solve to specify the solutions. Note that Solve may not be able to find expressions in terms of these variables (if the equations you give it are contradictory or insufficient) or for all values as some functions have no inverse or only partial inverses.
Your question looks a lot like homework in Electromagnetics, but here is an example with your original problem. You will have to adapt these ideas to give to Solve the set of variables you are looking for. Also remember to use == to specify equality testing. A simple = is for immediate assignment to a variable.
Solve[{f0 == 1/(2*Pi*Sqrt[L*c]), Qs == (w*L)/R, w == 2*Pi*f0, B == f0/Qs}, {f0, B, c}]
{{f0->w/(2 [Pi]), B->w/(2 [Pi] Qs), c->L/(Qs^2 R^2)}}
In algebra if I make the statement x + y = 3, the variables I used will hold the values either 2 and 1 or 1 and 2. I know that assignment in programming is not the same thing, but I got to wondering. If I wanted to represent the value of, say, a quantumly weird particle, I would want my variable to have two values at the same time and to have it resolve into one or the other later. Or maybe I'm just dreaming?
Is it possible to say something like i = 3 or 2;?
This is one of the features planned for Perl 6 (junctions), with syntax that should look like my $a = 1|2|3;
If ever implemented, it would work intuitively, like $a==1 being true at the same time as $a==2. Also, for example, $a+1 would give you a value of 2|3|4.
This feature is actually available in Perl5 as well through Perl6::Junction and Quantum::Superpositions modules, but without the syntax sugar (through 'functions' all and any).
At least for comparison (b < any(1,2,3)) it was also available in Microsoft Cω experimental language, however it was not documented anywhere (I just tried it when I was looking at Cω and it just worked).
You can't do this with native types, but there's nothing stopping you from creating a variable object (presuming you are using an OO language) which has a range of values or even a probability density function rather than an actual value.
You will also need to define all the mathematical operators between your variables and your variables and native scalars. Same goes for the equality and assignment operators.
numpy arrays do something similar for vectors and matrices.
That's also the kind of thing you can do in Prolog. You define rules that constraint your variables and then let Prolog resolve them ...
It takes some time to get used to it, but it is wonderful for certain problems once you know how to use it ...
Damien Conways Quantum::Superpositions might do what you want,
https://metacpan.org/pod/Quantum::Superpositions
You might need your crack-pipe however.
What you're asking seems to be how to implement a Fuzzy Logic system. These have been around for some time and you can undoubtedly pick up a library for the common programming languages quite easily.
You could use a struct and handle the operations manualy. Otherwise, no a variable only has 1 value at a time.
A variable is nothing more than an address into memory. That means a variable describes exactly one place in memory (length depending on the type). So as long as we have no "quantum memory" (and we dont have it, and it doesnt look like we will have it in near future), the answer is a NO.
If you want to program and to modell this behaviour, your way would be to use a an array (with length equal to the number of max. multiple values). With this comes the increased runtime, hence the computations must be done on each of the values (e.g. x+y, must compute with 2 different values x1+y1, x2+y2, x1+y2 and x2+y1).
In Perl , you can .
If you use Scalar::Util , you can have a var take 2 values . One if it's used in string context , and another if it's used in a numerical context .