tillrohrmann edited a comment on issue #9760: [FLINK-13982][runtime] Implement 
memory calculation logics
URL: https://github.com/apache/flink/pull/9760#issuecomment-537483004
 
 
   One way to solve the problem could be
   
   ```
   final int numVariables = 8;
   final double[] c = new double[numVariables];
   Arrays.fill(c, 1.0);
   
   LinearObjectiveFunction f = new LinearObjectiveFunction(c, 0);
   Collection<LinearConstraint> constraints = new ArrayList<>();
   
   // JVM_overhead, jvm_metaspace, framework, task_heap, task_off_heap, 
shuffle, managed_memory, total process memory
   final double[] overallMemory = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0};
   final double[] jvmOverhead = {1.0, 0, 0, 0, 0, 0, 0, 0};
   final double[] jvmMetaspace = {0, 1.0, 0, 0, 0, 0, 0, 0};
   final double[] framework = {0, 0, 1.0, 0, 0, 0, 0, 0};
   final double[] taskOffHeap = {0, 0, 0, 0, 1.0, 0, 0, 0};
   final double minOverhead = 10;
   final double maxOverhead = 100;
   final double[] shuffle = {0, 0, 0, 0, 0, 1.0, 0, 0};
   final double minShuffle = 10;
   final double maxShuffle = 100;
   final double overheadFraction = 0.1;
   final double[] jvmOverheadRelationship = {-1.0, overheadFraction, 
overheadFraction, overheadFraction, overheadFraction, overheadFraction, 
overheadFraction, 0};
   final double shuffleFraction = 0.2;
   final double[] shuffleRelationship = {0, 0, shuffleFraction, 
shuffleFraction, shuffleFraction, -1, overheadFraction, 0};
   final double jvmMetaspaceValue = 192;
   final double frameworkValue = 192;
   final double taskOffHeapValue = 0;
   constraints.add(new LinearConstraint(overallMemory, Relationship.EQ, 0));
   constraints.add(new LinearConstraint(jvmOverhead, Relationship.GEQ, 
minOverhead));
   constraints.add(new LinearConstraint(jvmOverhead, Relationship.LEQ, 
maxOverhead));
   constraints.add(new LinearConstraint(shuffle, Relationship.GEQ, minShuffle));
   constraints.add(new LinearConstraint(shuffle, Relationship.LEQ, maxShuffle));
   constraints.add(new LinearConstraint(jvmOverheadRelationship, 
Relationship.EQ, 0));
   constraints.add(new LinearConstraint(shuffleRelationship, Relationship.EQ, 
0));
   constraints.add(new LinearConstraint(jvmMetaspace, Relationship.EQ, 
jvmMetaspaceValue));
   constraints.add(new LinearConstraint(framework, Relationship.EQ, 
frameworkValue));
   constraints.add(new LinearConstraint(taskOffHeap, Relationship.EQ, 
taskOffHeapValue));
   
   SimplexSolver solver = new SimplexSolver();
   PointValuePair optSolution = solver.optimize(
        new MaxIter(100),
        f,
        new LinearConstraintSet(constraints),
        GoalType.MAXIMIZE,
        new NonNegativeConstraint(true));
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to