0

I am trying to run the following code, but there is an error in dvar float+

using CP;
int rows=3;
int columns=3;
range para=1..rows*columns;
float model1[para]=...;
dvar float+ model0[para];
maximize 
sum(p in para) model0[p]*(lg(model0[p]/model1[p]));
  subject to{
    c1:
    sum(p in para)
    model0[p]==3.0;    
    }

1 Answer 1

0

Decision variables with CPOptimizer cannot be float.

As can be seen in the example floatexpr.mod you can use a float dexpr in order to use decimal values computed out of a integer decision variables.

In your case:

using CP;

execute
{
cp.param.timelimit=10;
}

int scale=1000;
int rows=3;
int columns=3;
range para=1..rows*columns;
float model1[p in para]=p/10;

dvar int+ scalemodel0[para];
dexpr  float model0[p in para]=scalemodel0[p]/scale;
maximize 
sum(p in para) model0[p]*(lg(model0[p]/model1[p]));
  subject to{
    c1:
    sum(p in para)
    model0[p]==3.0;    
    } 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.