"Overflow occurred, please use oplrun -profile ".This error message appears in C-PLEX. How to get rid of it? - runtime-error

After incorporating the power balance constraint, the overflow occurred. I have also tried using opl run.But it is of no use.
minimize 0.7*sum(i in nbus)(sum(j in tavail)sum(k in nport)((pt[i][j]*1000000-pl[i][j]1000000-pevch[j][k]+pevdis[j][k])+sum(k in nport)(pevdis[j][k]-pevch[j][k])))- 0.15(sum (j in tavail)(sum (k in nport)(c[j]*pevdis[j][k])))
+0.15* (sum (j in tavail)sum (k in nport)(c[j]*pevch[j][k]));
subject to
{
//constraint for discharging
forall(i in nbus,j in tavail,k in nport)
{ct1:if(c[j]==5 && 0.7<soc[k][j]<0.9)
{pevdis[j][k]==(0.9-soc[k][j])*100000;
}
//else
else
{pevdis[j][k]==0;
}}
//constraint for charging
forall(i in nbus, j in tavail, k in nport)
{ct4: if(c[j]==2.5 && soc[k][j]<=0.7 )
{pevch[j][k]==(0.7-soc[k][j])*100000;
}
else
{pevch[j][k]==0;}
}
forall(i in nbus, j in tavail, k in nport,l in nbus)
{//power balance
{ p[j]==v[j][i](sum(l in nbus)(v[j][l](G[i][l]*deltacos[i][l][j]+B[i][l]*deltasin[i][l][j])));
p[j]*100000000+ pg[i][j]-pl[i][j]-pevch[j][k]+pevdis[j][k]==0;
}
}
}

You should try what I suggested at
It is showing "opl run is not responding. Please rerun the configuration". Why is this error displayed in C-PLEX? How to fix this error?
Plus since you have many "pevch[j][k]==0; " you may try to use an array that is not indexed by the full Euclidian product but by the indexes that make sense
See Exploiting sparsity in the CPLEX documentation
Discusses how to exploit the sparsity of large-scale problems, beyond
the classical transportation problem exposed in the transp1.mod
sample.

Related

Create functions in R

I'm fairly new to R and I have not been working with functions in R before.
I want to write a program/algorithm (using R) that calculates the square root of a given positive number.
Would anyone mind take the time to give me an example of how this can be achieved?
Thanks a lot in advance!
UPDATE
posNum_to_squaRtNum <- function(posNum) {
if (posNum <= 0)
print("Due to mathmatical principles you have to input a positive number")
else
squaRtNum <- sqrt(posNum)
return(squaRtNum)
}
When I insert a negative number in the function, the output is my print PLUS the error: "Error in posNum_to_squaRtNum(-1) : object 'squaRtNum' not found." It should not go on to the else statement, if the if statement is fulfilled right?
You should wrap your if conditions in brackets:
posNum_to_squaRtNum <- function(posNum) {
if (posNum <= 0) {
print("Due to mathmatical principles you have to input a positive number")
} else {
squaRtNum <- sqrt(posNum)
return(squaRtNum)
}
}

Finding peaks and valleys in each column, I'm not understanding this problem

So, to be clear, I don't need help solving this problem, as I know I have the knowledge to do it. The problem is, my English is not good enough to understand technical language, so I don't know exactly what I'm supposed to do.
I've the following excel file:
And I need to find the ''peaks and valleys'' of each column, and graph them.
I know how to use Matplotlib to graph, what I don't understand is what the problem reffers to with ''peaks and valleys''.
The result should be looking something like this:
So I'm guessing what ''peaks and valleys'' mean is the lowest and highest value of each column? If this is the case, the high value in Open column would be 24.6875, and the low would be 20.375?
By peaks and valleys it means maxima and minima so find either where the derivative of your function is equal to zero (and curvature != 0) or else where the data reaches a high (low) point then goes down (up) again
Function to count Valleys in Javascript
function countingValleys(n, s) {
let valleyCounter = 0;
let cLevel = 0;
let prevLevel =0;
for (let i =0; i<s.length; i++){
prevLevel = cLevel;
if(s[i] === "U"){
cLevel++;
}else{
cLevel--;
}
if(prevLevel === 0 && cLevel <0){
valleyCounter++;
}
}
return valleyCounter;
}

Using audio_play_sound() in a if statement GameMaker

I am trying to use the command:
audio_play_sound()
I am trying to insert it into this piece of code, so that when the player jumps, a sound plays.
if (key_jump) && (jumps > 0)
{
jumps -=1;
vsp = -jumpspeed;
}
Code that causes problem:
if (key_jump) && (jumps > 0)
{
jumps -=1;
vsp = -jumpspeed;
audio_play_sound(snd_jump)
}
Simply inserting the line into the if statement does not work, and gives the error WRONG NUMBER OF ARGUMENTS IN FUNCTION. This is rather confusing, perhaps I am using the wrong command? Thanks in advance
The problem is stated in the error, you're providing the wrong number of arguments to the audo_play_sound function.
from the docs
audio_play_sound(index, priority, loop);
As the person above states your answer is audio_play_sound(snd_jump, 1, false).

Deduplication in R Studio

this is my first R Code, and it is a very simple deduplication, but it is working so slowly I can't believe it! My question is: Is it normal that it is working so slowly or is my code just bad?
Here it is:
file1=c(read.delim("file.txt", header=TRUE))
dedupes<-0
i<-1
n<-1
while (i<=100) {
while (n<=100) {
if (file1$email[i]==file1$email[n] && i!=n) {
#Remember amount of deduces
dedupes=dedupes+1
#Show dedupes
print(file1$email[i]) }
n<-n+1
}
n<-1
i<-i+1
}
#Show amount of dedupes
cat("There are ", dedupes/2, " deduces")
Many thanks in advance,
Saitam
Imbricated loops are well known to be slow in R. You need to vectorize your calculus or use existing optimized functions such as in the suggestion of BondedDust

how to subtract two vectors in OpenBUGS

I am having a very hard time trying to subtract two vectors in my OpenBUGS model. The last line of the code below keeps giving the error "expected right parenthesis error":
model {
for ( i in 1:N) {
for(j in 1:q) {
vv[i,j] ~ dnorm(vz[i,j],tau.eta[j])
}
vz[i,1:q] ~ dmnorm(media.z[i,], K.delta[,])
for(j in 1:q) {
mean.z[i,j] <- inprod(K[i,] , vbeta[j,])
}
K[i,1] <- 1.0
for(j in 1:N) {
K[i,j+1] <- sum(ve[,i] - ve[,j])
}
}
If I change that line to K[i,j+1] <- sum(ve[,i]) - sum(ve[,j]), then the model works fine, but that is not what I want to do. I would like to subtract element-wise.
I searched SO for OpenBUGS, but there are only a few unrelated topics:
OpenBUGS - Variable is not defined
OpenBUGS: missing value in Bernoulli distribution
In Stats Stack Exchange there is this post which is close, but I still could not make how to implement this in my model:
https://stats.stackexchange.com/questions/20653/vector-multiplication-in-bugs-and-jags/20739#20739
I understand I have to write a for loop, but this thing is sure giving me a big headache. :)
I tried changing that line to:
for(k in 1:p) { temp [k] <- ve[k,i] - ve[k,j] }
K[i,j+1] <- sum(temp[])
where 'p' is the number of rows in each 've'. Now I keep getting the error "multiple definitions of node temp[1]".
I could definitely use some help. It will be much appreciated.
Best regards to all and thanks in advance!
PS: I wanted to add the tag "OpenBUGS" to this question but unfortunately I couldn't because it would be a new tag and I do not have enough reputation. I added "winbugs" instead.
The "multiple definitions" error is because temp[k] is redefined over and over again within a loop over i and another loop over j - you can only define it once. To get around that, use i and j subscripts like
for(k in 1:p) { temp[k,i,j] <- ve[k,i] - ve[k,j] }
K[i,j+1] <- sum(temp[,i,j])
Though if that compiles and runs, I'd check the results to make sure that's exactly what you want mathematically.

Resources